From 4e552b0785400fd5659aa1a1480fb362e16065bd Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Fri, 9 Aug 2024 18:05:59 +0800 Subject: [PATCH] hv: allow guest with the highest severity to read RESET_CONTROL Guest VM, such as Linux, may read RESET_CONTROL(0xCF9) register before writing to, in this case, ACRN should not always return dummy value. Tracked-On: #8688 Signed-off-by: Yonghua Huang Reviewed-by: Junjie Mao --- hypervisor/arch/x86/guest/vm_reset.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hypervisor/arch/x86/guest/vm_reset.c b/hypervisor/arch/x86/guest/vm_reset.c index 344af3760..8f7e1f701 100644 --- a/hypervisor/arch/x86/guest/vm_reset.c +++ b/hypervisor/arch/x86/guest/vm_reset.c @@ -74,12 +74,16 @@ static bool handle_reset_reg_read(struct acrn_vcpu *vcpu, __unused uint16_t addr { bool ret = true; - if (is_postlaunched_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)) { /* re-inject to DM */ ret = false; } else { /* - * - reset control register 0xcf9: hide this from guests for now. + * - 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;