Skip to content

Commit 09a6356

Browse files
lifeixacrnsi
authored andcommitted
hv: vm_manage: minor fix about triple_fault_shutdown_vm
The current implement will trigger shutdown vm request on the BSP VCPU on the VM, not the VCPU will trap out because triple fault. However, if the BSP VCPU on the VM is handling another IO emulation, it may overwrite the triple fault IO request on the vhm_request_buffer in function acrn_insert_request. The atomic operation of get_vhm_req_state can't guarantee the vhm_request_buffer will not access by another IO request if it is not running on the corresponding VCPU. So it should trigger triple fault shutdown VM IO request on the VCPU which trap out because of triple fault exception. Besides, rt_vm_pm1a_io_write will do the right thing which we shouldn't do it in triple_fault_shutdown_vm. Tracked-On: #1842 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent ebf5c5e commit 09a6356

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

hypervisor/acpi_parser/acpi_ext.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <logmsg.h>
3535
#include <host_pm.h>
3636
#include <acrn_common.h>
37+
#include <vcpu.h>
3738
#include <vm_reset.h>
3839

3940
/* Per ACPI spec:

hypervisor/arch/x86/guest/vm_reset.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,13 @@ struct acpi_reset_reg *get_host_reset_reg_data(void)
3232
/**
3333
* @pre vm != NULL
3434
*/
35-
void triple_fault_shutdown_vm(struct acrn_vm *vm)
35+
void triple_fault_shutdown_vm(struct acrn_vcpu *vcpu)
3636
{
37-
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
37+
struct acrn_vm *vm = vcpu->vm;
3838

3939
if (is_postlaunched_vm(vm)) {
4040
struct io_request *io_req = &vcpu->req;
4141

42-
/*
43-
* Hypervisor sets VM_POWERING_OFF to authenticate that the reboot request is
44-
* actually from the guest itself, not from external entities. (for example acrn-dm)
45-
*/
46-
if (is_rt_vm(vm)) {
47-
vm->state = VM_POWERING_OFF;
48-
}
49-
5042
/* Device model emulates PM1A for post-launched VMs */
5143
io_req->io_type = REQ_PORTIO;
5244
io_req->reqs.pio.direction = REQUEST_WRITE;
@@ -258,9 +250,6 @@ void register_reset_port_handler(struct acrn_vm *vm)
258250
void shutdown_vm_from_idle(uint16_t pcpu_id)
259251
{
260252
struct acrn_vm *vm = get_vm_from_vmid(per_cpu(shutdown_vm_id, pcpu_id));
261-
const struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
262253

263-
if (vcpu->pcpu_id == pcpu_id) {
264-
(void)shutdown_vm(vm);
265-
}
254+
(void)shutdown_vm(vm);
266255
}

hypervisor/arch/x86/guest/vmexit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static int32_t triple_fault_vmexit_handler(struct acrn_vcpu *vcpu)
255255
{
256256
pr_fatal("VM%d: triple fault @ guest RIP 0x%016llx, exit qualification: 0x%016llx",
257257
vcpu->vm->vm_id, exec_vmread(VMX_GUEST_RIP), exec_vmread(VMX_EXIT_QUALIFICATION));
258-
triple_fault_shutdown_vm(vcpu->vm);
258+
triple_fault_shutdown_vm(vcpu);
259259

260260
return 0;
261261
}

hypervisor/include/arch/x86/guest/vm_reset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct acpi_reset_reg {
1616

1717
void register_reset_port_handler(struct acrn_vm *vm);
1818
void shutdown_vm_from_idle(uint16_t pcpu_id);
19-
void triple_fault_shutdown_vm(struct acrn_vm *vm);
19+
void triple_fault_shutdown_vm(struct acrn_vcpu *vcpu);
2020
struct acpi_reset_reg *get_host_reset_reg_data(void);
2121

2222
#endif /* VM_RESET_H_ */

0 commit comments

Comments
 (0)