Skip to content

Commit

Permalink
hv: allow guest with the highest severity to read RESET_CNT
Browse files Browse the repository at this point in the history
Guest VM, such as Linux, may read platform RESET_CNT(0xCF9)
register before writing to, in this case, ACRN should not always
return dummy value.

Tracked-On: projectacrn#8688
Signed-off-by: Yonghua Huang <[email protected]>
Reviewed-by: Junjie Mao <[email protected]>
  • Loading branch information
yonghuah committed Aug 9, 2024
1 parent 5c351be commit 2ade211
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hypervisor/arch/x86/guest/vm_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2ade211

Please sign in to comment.