HV: CAT: support cache allocation for each vcpu

This commit allows hypervisor to allocate cache to vcpu by assigning different clos
to vcpus of a same VM.
For example, we could allocate different cache to housekeeping core and real-time core
of an RTVM in order to isolate the interference of housekeeping core via cache hierarchy.

Tracked-On: #4566
Signed-off-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Chen, Zide <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yan, Like
2020-03-24 15:30:08 +08:00
committed by wenlingz
parent fcd9a1ca73
commit 2997c4b570
8 changed files with 25 additions and 16 deletions

View File

@@ -96,6 +96,23 @@ static bool check_vm_uuid_collision(uint16_t vm_id)
return ret;
}
static bool check_vm_clos_config(uint16_t vm_id)
{
uint16_t i;
bool ret = true;
struct acrn_vm_config *vm_config = get_vm_config(vm_id);
for (i = 0U; i < vm_config->vcpu_num; i++) {
if (vm_config->clos[i] >= platform_clos_num) {
pr_err("vm%u: vcpu%u clos(%u) exceed the max clos(%u).",
vm_id, i, vm_config->clos[i], platform_clos_num);
ret = false;
break;
}
}
return ret;
}
/**
* @pre vm_config != NULL
*/
@@ -192,11 +209,8 @@ bool sanitize_vm_config(void)
break;
}
if (ret &&
is_platform_rdt_capable() &&
(vm_config->clos >= platform_clos_num)) {
pr_err("%s set wrong CLOS. Please set below %d\n", __func__, platform_clos_num);
ret = false;
if (ret && is_platform_rdt_capable()) {
ret = check_vm_clos_config(vm_id);
}
if (ret &&

View File

@@ -292,6 +292,7 @@ static void intercept_x2apic_msrs(uint8_t *msr_bitmap_arg, uint32_t mode)
static void init_msr_area(struct acrn_vcpu *vcpu)
{
struct acrn_vm_config *cfg = get_vm_config(vcpu->vm->vm_id);
uint16_t vcpu_clos = cfg->clos[vcpu->vcpu_id];
vcpu->arch.msr_area.count = 0U;
@@ -302,14 +303,14 @@ static void init_msr_area(struct acrn_vcpu *vcpu)
vcpu->arch.msr_area.count++;
/* only load/restore MSR IA32_PQR_ASSOC when hv and guest have differnt settings */
if (is_platform_rdt_capable() && (cfg->clos != hv_clos)) {
if (is_platform_rdt_capable() && (vcpu_clos != hv_clos)) {
vcpu->arch.msr_area.guest[MSR_AREA_IA32_PQR_ASSOC].msr_index = MSR_IA32_PQR_ASSOC;
vcpu->arch.msr_area.guest[MSR_AREA_IA32_PQR_ASSOC].value = clos2pqr_msr(cfg->clos);
vcpu->arch.msr_area.guest[MSR_AREA_IA32_PQR_ASSOC].value = clos2pqr_msr(vcpu_clos);
vcpu->arch.msr_area.host[MSR_AREA_IA32_PQR_ASSOC].msr_index = MSR_IA32_PQR_ASSOC;
vcpu->arch.msr_area.host[MSR_AREA_IA32_PQR_ASSOC].value = clos2pqr_msr(hv_clos);
vcpu->arch.msr_area.count++;
pr_acrnlog("switch clos for VM %u vcpu_id %u, host 0x%x, guest 0x%x",
vcpu->vm->vm_id, vcpu->vcpu_id, hv_clos, cfg->clos);
vcpu->vm->vm_id, vcpu->vcpu_id, hv_clos, vcpu_clos);
}
}