Skip to content

Commit

Permalink
hv: vm_reset: simulate RESET_CONTROL(0xCF9) register
Browse files Browse the repository at this point in the history
Add reset_control in acrn_vm. Use this reset_control to simulate
RESET_CONTROL(0xCF9) register in hypervisor.

Tracked-On: projectacrn#8724
Signed-off-by: Yuan Lu <yuan.y.lu@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
  • Loading branch information
yison committed Sep 9, 2024
1 parent 4845ec3 commit de6ac87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions hypervisor/arch/x86/guest/vm_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,18 @@ static bool handle_reset_reg_read(struct acrn_vcpu *vcpu, __unused uint16_t addr
__unused size_t bytes)
{
bool ret = true;
struct acrn_vm *vm = vcpu->vm;

if (is_postlaunched_vm(vcpu->vm)) {
if (is_postlaunched_vm(vm)) {
/* re-inject to DM */
ret = false;
} else {
/*
* - reset control register 0xcf9: hide this from guests for now.
* - FADT reset register: the read behavior is not defined in spec, keep it simple to return all '1'.
* - FADT reset register: the read behavior is not defined in spec,
* return simulated vm->reset_control.
*/
vcpu->req.reqs.pio_request.value = ~0U;
vcpu->req.reqs.pio_request.value = vm->reset_control;
}

return ret;
Expand Down Expand Up @@ -168,6 +170,9 @@ static bool handle_kb_read(struct acrn_vcpu *vcpu, uint16_t addr, size_t bytes)
*/
static bool handle_cf9_write(struct acrn_vcpu *vcpu, __unused uint16_t addr, size_t bytes, uint32_t val)
{
struct acrn_vm *vm = vcpu->vm;

vm->reset_control = val & 0xeU;
return handle_common_reset_reg_write(vcpu,
((bytes == 1U) && ((val & 0x4U) == 0x4U) && ((val & 0xaU) != 0U)),
((val & 0x8U) == 0U));
Expand Down
1 change: 1 addition & 0 deletions hypervisor/include/arch/x86/asm/guest/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ struct acrn_vm {
struct acrn_vrtc vrtc;

uint64_t intr_inject_delay_delta; /* delay of intr injection */
uint32_t reset_control;
} __aligned(PAGE_SIZE);

/*
Expand Down

0 comments on commit de6ac87

Please sign in to comment.