From 9a56024b4946340e9dfece7b133e99dcbfad5ec8 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Fri, 8 Jun 2018 09:28:48 +0800 Subject: [PATCH] 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 Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/pm.c | 18 ++++++++++++++++++ hypervisor/arch/x86/guest/vm.c | 9 ++++++--- hypervisor/bsp/include/bsp_extern.h | 1 + hypervisor/include/arch/x86/guest/pm.h | 1 + hypervisor/include/arch/x86/guest/vm.h | 1 + 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/hypervisor/arch/x86/guest/pm.c b/hypervisor/arch/x86/guest/pm.c index 00532f670..8dd4bbe32 100644 --- a/hypervisor/arch/x86/guest/pm.c +++ b/hypervisor/arch/x86/guest/pm.c @@ -103,3 +103,21 @@ void vm_setup_cpu_state(struct vm *vm) vm_setup_cpu_cx(vm); init_cx_port(vm); } + +/* This function is for power management Sx state implementation, + * VM need to load the Sx state data to implement S3/S5. + */ +int vm_load_pm_s_state(struct vm *vm) +{ + if ((boot_cpu_data.x86 == host_acpi_info.x86_family) + && (boot_cpu_data.x86_model == host_acpi_info.x86_model)) { + vm->pm.sx_state_data = (struct pm_s_state_data *) + &host_acpi_info.pm_s_state; + pr_info("System S3/S5 is supported."); + return 0; + } else { + vm->pm.sx_state_data = NULL; + pr_err("System S3/S5 is NOT supported."); + return -1; + } +} diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 1a95ad122..36f062a5c 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -141,10 +141,13 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm) vm_setup_cpu_state(vm); - /* Create virtual uart */ - if (is_vm0(vm)) - vm->vuart = vuart_init(vm); + if (is_vm0(vm)) { + /* Load pm S state data */ + vm_load_pm_s_state(vm); + /* Create virtual uart */ + vm->vuart = vuart_init(vm); + } vm->vpic = vpic_init(vm); /* vpic wire_mode default is INTR */ diff --git a/hypervisor/bsp/include/bsp_extern.h b/hypervisor/bsp/include/bsp_extern.h index 306e631bb..e78c592f9 100644 --- a/hypervisor/bsp/include/bsp_extern.h +++ b/hypervisor/bsp/include/bsp_extern.h @@ -23,6 +23,7 @@ /* EXTERNAL VARIABLES */ /**********************************/ extern struct vm_description vm0_desc; +extern const struct acpi_info host_acpi_info; /* BSP Interfaces */ void init_bsp(void); diff --git a/hypervisor/include/arch/x86/guest/pm.h b/hypervisor/include/arch/x86/guest/pm.h index c3841af9e..9ba9f47bc 100644 --- a/hypervisor/include/arch/x86/guest/pm.h +++ b/hypervisor/include/arch/x86/guest/pm.h @@ -8,6 +8,7 @@ #define PM_H void vm_setup_cpu_state(struct vm *vm); +int vm_load_pm_s_state(struct vm *vm); int validate_pstate(struct vm *vm, uint64_t perf_ctl); struct cpu_cx_data* get_target_cx(struct vm *vm, uint8_t cn); diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index ca4b7da40..abb200e8b 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -63,6 +63,7 @@ struct vm_pm_info { struct cpu_px_data px_data[MAX_PSTATE]; uint8_t cx_cnt; /* count of all Cx entries */ struct cpu_cx_data cx_data[MAX_CSTATE]; + struct pm_s_state_data *sx_state_data; /* data for S3/S5 implementation */ }; /* VM guest types */