From dbc3ff39aae19677a540957ce58f78651132f91b Mon Sep 17 00:00:00 2001 From: Yuan Lu Date: Wed, 4 Sep 2024 14:04:07 +0800 Subject: [PATCH] hv: vm_reset: simulate RESET_CONTROL(0xCF9) register Add reset_control in acrn_vm. Use this reset_control to simulate RESET_CONTROL(0xCF9) register in hypervisor. Tracked-On: #8724 Signed-off-by: Yuan Lu Reviewed-by: Fei Li --- hypervisor/arch/x86/guest/vm_reset.c | 16 ++++++---------- hypervisor/include/arch/x86/asm/guest/vm.h | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hypervisor/arch/x86/guest/vm_reset.c b/hypervisor/arch/x86/guest/vm_reset.c index a15de301e..91e15b07c 100644 --- a/hypervisor/arch/x86/guest/vm_reset.c +++ b/hypervisor/arch/x86/guest/vm_reset.c @@ -73,20 +73,13 @@ 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 (get_highest_severity_vm(true) == vcpu->vm) { - /* Guest may read RESET_CONTROL register before cold reset or warm reset */ - vcpu->req.reqs.pio_request.value = pio_read8(0xcf9U); - - } else 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 whose severity is not the highest. - * - FADT reset register: the read behavior is not defined in spec, keep it simple to return all '1'. - */ - vcpu->req.reqs.pio_request.value = ~0U; + vcpu->req.reqs.pio_request.value = vm->reset_control; } return ret; @@ -172,6 +165,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)); diff --git a/hypervisor/include/arch/x86/asm/guest/vm.h b/hypervisor/include/arch/x86/asm/guest/vm.h index 7d2f16dad..5ba9d7434 100644 --- a/hypervisor/include/arch/x86/asm/guest/vm.h +++ b/hypervisor/include/arch/x86/asm/guest/vm.h @@ -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); /*