Skip to content

Commit ec199d9

Browse files
jsun26intelEddie Dong
authored andcommitted
HV: add get_sos_vm api
This patch creates a new get_sos_vm() api to replace get_vm_from_vmid(0U) because VM 0 might not be SOS VM now; Tracked-On: #2291 Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent f3014a3 commit ec199d9

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

hypervisor/arch/x86/guest/vm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ struct acrn_vm *get_vm_from_vmid(uint16_t vm_id)
7373
return &vm_array[vm_id];
7474
}
7575

76+
/* return a pointer to the virtual machine structure of SOS VM */
77+
struct acrn_vm *get_sos_vm(void)
78+
{
79+
return sos_vm_ptr;
80+
}
81+
7682
/**
7783
* @pre vm_config != NULL
7884
*/

hypervisor/common/io_req.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ static void fire_vhm_interrupt(void)
1515
* use vLAPIC to inject vector to SOS vcpu 0 if vlapic is enabled
1616
* otherwise, send IPI hardcoded to BOOT_CPU_ID
1717
*/
18-
struct acrn_vm *vm0;
18+
struct acrn_vm *sos_vm;
1919
struct acrn_vcpu *vcpu;
2020

21-
vm0 = get_vm_from_vmid(0U);
21+
sos_vm = get_sos_vm();
22+
if (sos_vm != NULL) {
23+
vcpu = vcpu_from_vid(sos_vm, BOOT_CPU_ID);
2224

23-
vcpu = vcpu_from_vid(vm0, 0U);
24-
25-
vlapic_set_intr(vcpu, acrn_vhm_vector, LAPIC_TRIG_EDGE);
25+
vlapic_set_intr(vcpu, acrn_vhm_vector, LAPIC_TRIG_EDGE);
26+
}
2627
}
2728

2829
#if defined(HV_DEBUG)

hypervisor/debug/vuart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ struct acrn_vuart *vuart_console_active(void)
376376

377377
vm = get_vm_from_vmid(vuart_vmid);
378378
#else
379-
struct acrn_vm *vm = get_vm_from_vmid(0U);
379+
struct acrn_vm *vm = get_sos_vm();
380380
#endif
381381

382382
if (vm != NULL) {

hypervisor/dm/vpci/sharing_mode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void vpci_reset_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf,
228228
} else {
229229
/* Return this PCI device to SOS */
230230
if (vdev->vpci->vm == target_vm) {
231-
vm = get_vm_from_vmid(0U);
231+
vm = get_sos_vm();
232232

233233
if (vm != NULL) {
234234
vdev->vpci = &vm->vpci;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ extern struct acrn_vm_config vm_configs[];
314314
bool is_sos_vm(const struct acrn_vm *vm);
315315
uint16_t find_free_vm_id(void);
316316
struct acrn_vm *get_vm_from_vmid(uint16_t vm_id);
317+
struct acrn_vm *get_sos_vm(void);
317318

318319
#ifdef CONFIG_PARTITION_MODE
319320
struct vm_config_arraies {

0 commit comments

Comments
 (0)