HV: add hypercall interface of get vcpu state data

We can use this interface for VHM to pass per-cpu power state data
to guest per its request.

For now the vcpu power state is per-vm, this could be changed if
per-cpu power state support is required in the future.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
This commit is contained in:
Victor Sun
2018-04-05 17:57:09 +08:00
committed by Jack Ren
parent 0e2b9fc7fa
commit 1d0d4d3185
5 changed files with 97 additions and 0 deletions

View File

@@ -333,6 +333,17 @@ int64_t hcall_setup_sbuf(struct vm *vm, uint64_t param);
*
* @return 0 on success, non-zero on error.
*/
int64_t hcall_get_cpu_pm_state(struct vm *vm, uint64_t cmd, uint64_t param);
/**
* @brief Get VCPU Power state.
*
* @param VCPU power state data
*
* @return 0 on success, non-zero on error.
*/
int64_t hcall_world_switch(struct vcpu *vcpu);
/**

View File

@@ -301,6 +301,26 @@ struct cpu_px_data {
uint64_t status; /* success indicator */
} __attribute__((aligned(8)));
/**
* @brief Info PM command from DM/VHM.
*
* The command would specify request type(i.e. get px count or data) for
* specific VM and specific VCPU with specific state number.like P(n).
*/
#define PMCMD_VMID_MASK 0xff000000
#define PMCMD_VCPUID_MASK 0x00ff0000
#define PMCMD_STATE_NUM_MASK 0x0000ff00
#define PMCMD_TYPE_MASK 0x000000ff
#define PMCMD_VMID_SHIFT 24
#define PMCMD_VCPUID_SHIFT 16
#define PMCMD_STATE_NUM_SHIFT 8
enum pm_cmd_type {
PMCMD_GET_PX_CNT,
PMCMD_GET_PX_DATA,
};
/**
* @}
*/

View File

@@ -99,6 +99,10 @@
#define HC_WORLD_SWITCH _HC_ID(HC_ID, HC_ID_TRUSTY_BASE + 0x01)
#define HC_GET_SEC_INFO _HC_ID(HC_ID, HC_ID_TRUSTY_BASE + 0x02)
/* Power management */
#define HC_ID_PM_BASE 0x80UL
#define HC_PM_GET_CPU_STATE _HC_ID(HC_ID, HC_ID_PM_BASE + 0x00)
#define ACRN_DOM0_VMID (0UL)
#define ACRN_INVALID_VMID (-1)
#define ACRN_INVALID_HPA (-1UL)