Skip to content

Commit 9a56024

Browse files
jsun26intellijinxia
authored andcommitted
HV: load host pm S state data while create vm0
The pm S state data is from host ACPI info and needed for S3/S5 implementation. Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 88e1c49 commit 9a56024

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

hypervisor/arch/x86/guest/pm.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,21 @@ void vm_setup_cpu_state(struct vm *vm)
103103
vm_setup_cpu_cx(vm);
104104
init_cx_port(vm);
105105
}
106+
107+
/* This function is for power management Sx state implementation,
108+
* VM need to load the Sx state data to implement S3/S5.
109+
*/
110+
int vm_load_pm_s_state(struct vm *vm)
111+
{
112+
if ((boot_cpu_data.x86 == host_acpi_info.x86_family)
113+
&& (boot_cpu_data.x86_model == host_acpi_info.x86_model)) {
114+
vm->pm.sx_state_data = (struct pm_s_state_data *)
115+
&host_acpi_info.pm_s_state;
116+
pr_info("System S3/S5 is supported.");
117+
return 0;
118+
} else {
119+
vm->pm.sx_state_data = NULL;
120+
pr_err("System S3/S5 is NOT supported.");
121+
return -1;
122+
}
123+
}

hypervisor/arch/x86/guest/vm.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,13 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
141141

142142
vm_setup_cpu_state(vm);
143143

144-
/* Create virtual uart */
145-
if (is_vm0(vm))
146-
vm->vuart = vuart_init(vm);
144+
if (is_vm0(vm)) {
145+
/* Load pm S state data */
146+
vm_load_pm_s_state(vm);
147147

148+
/* Create virtual uart */
149+
vm->vuart = vuart_init(vm);
150+
}
148151
vm->vpic = vpic_init(vm);
149152

150153
/* vpic wire_mode default is INTR */

hypervisor/bsp/include/bsp_extern.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/* EXTERNAL VARIABLES */
2424
/**********************************/
2525
extern struct vm_description vm0_desc;
26+
extern const struct acpi_info host_acpi_info;
2627

2728
/* BSP Interfaces */
2829
void init_bsp(void);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define PM_H
99

1010
void vm_setup_cpu_state(struct vm *vm);
11+
int vm_load_pm_s_state(struct vm *vm);
1112
int validate_pstate(struct vm *vm, uint64_t perf_ctl);
1213
struct cpu_cx_data* get_target_cx(struct vm *vm, uint8_t cn);
1314

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct vm_pm_info {
6363
struct cpu_px_data px_data[MAX_PSTATE];
6464
uint8_t cx_cnt; /* count of all Cx entries */
6565
struct cpu_cx_data cx_data[MAX_CSTATE];
66+
struct pm_s_state_data *sx_state_data; /* data for S3/S5 implementation */
6667
};
6768

6869
/* VM guest types */

0 commit comments

Comments
 (0)