mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 20:22:46 +00:00
add hypercall hc_sos_offline_cpu support
SOS boot with all physicall cpus, before running UOS, it should free CPU resource by offline not used cpus - first do standard cpu offline flow - then call hcall_sos_offline_cpu hypercall to release cpu resource really Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
589c72382a
commit
2dca23c7c9
@ -38,6 +38,9 @@ int vmcall_vmexit_handler(struct vcpu *vcpu)
|
||||
|
||||
/* Dispatch the hypercall handler */
|
||||
switch (hypcall_id) {
|
||||
case HC_SOS_OFFLINE_CPU:
|
||||
ret = hcall_sos_offline_cpu(vm, param1);
|
||||
break;
|
||||
case HC_GET_API_VERSION:
|
||||
#ifdef CONFIG_VM0_DESC
|
||||
/* vm0 will call HC_GET_API_VERSION as first hypercall, fixup
|
||||
|
@ -25,6 +25,30 @@ bool is_hypercall_from_ring0(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t hcall_sos_offline_cpu(struct vm *vm, uint64_t lapicid)
|
||||
{
|
||||
struct vcpu *vcpu;
|
||||
int i;
|
||||
|
||||
if (!is_vm0(vm))
|
||||
return -1;
|
||||
|
||||
pr_info("sos offline cpu with lapicid %lld", lapicid);
|
||||
|
||||
foreach_vcpu(i, vm, vcpu) {
|
||||
if (vlapic_get_apicid(vcpu->arch_vcpu.vlapic) == lapicid) {
|
||||
/* should not offline BSP */
|
||||
if (vcpu->vcpu_id == 0)
|
||||
return -1;
|
||||
pause_vcpu(vcpu, VCPU_ZOMBIE);
|
||||
reset_vcpu(vcpu);
|
||||
destroy_vcpu(vcpu);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t hcall_get_api_version(struct vm *vm, uint64_t param)
|
||||
{
|
||||
struct hc_api_version version;
|
||||
|
@ -24,6 +24,18 @@ bool is_hypercall_from_ring0(void);
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief offline vcpu from SOS
|
||||
*
|
||||
* The function offline specific vcpu from SOS.
|
||||
*
|
||||
* @param vm Pointer to VM data structure
|
||||
* @param lapicid lapic id of the vcpu which wants to offline
|
||||
*
|
||||
* @return 0 on success, non-zero on error.
|
||||
*/
|
||||
int32_t hcall_sos_offline_cpu(struct vm *vm, uint64_t lapicid);
|
||||
|
||||
/**
|
||||
* @brief Get hypervisor api version
|
||||
*
|
||||
|
@ -26,6 +26,7 @@
|
||||
/* general */
|
||||
#define HC_ID_GEN_BASE 0x0UL
|
||||
#define HC_GET_API_VERSION _HC_ID(HC_ID, HC_ID_GEN_BASE + 0x00UL)
|
||||
#define HC_SOS_OFFLINE_CPU _HC_ID(HC_ID, HC_ID_GEN_BASE + 0x01UL)
|
||||
|
||||
/* VM management */
|
||||
#define HC_ID_VM_BASE 0x10UL
|
||||
|
Loading…
Reference in New Issue
Block a user