Skip to content

Commit 7694386

Browse files
lyan3wenlingz
authored andcommitted
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>
1 parent d18fd5f commit 7694386

File tree

8 files changed

+25
-16
lines changed

8 files changed

+25
-16
lines changed

hypervisor/arch/x86/configs/vm_config.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ static bool check_vm_uuid_collision(uint16_t vm_id)
8888
return ret;
8989
}
9090

91+
static bool check_vm_clos_config(uint16_t vm_id)
92+
{
93+
uint16_t i;
94+
bool ret = true;
95+
struct acrn_vm_config *vm_config = get_vm_config(vm_id);
96+
97+
for (i = 0U; i < vm_config->vcpu_num; i++) {
98+
if (vm_config->clos[i] >= platform_clos_num) {
99+
pr_err("vm%u: vcpu%u clos(%u) exceed the max clos(%u).",
100+
vm_id, i, vm_config->clos[i], platform_clos_num);
101+
ret = false;
102+
break;
103+
}
104+
}
105+
return ret;
106+
}
107+
91108
/**
92109
* @pre vm_config != NULL
93110
*/
@@ -184,11 +201,8 @@ bool sanitize_vm_config(void)
184201
break;
185202
}
186203

187-
if (ret &&
188-
is_platform_rdt_capable() &&
189-
(vm_config->clos >= platform_clos_num)) {
190-
pr_err("%s set wrong CLOS. Please set below %d\n", __func__, platform_clos_num);
191-
ret = false;
204+
if (ret && is_platform_rdt_capable()) {
205+
ret = check_vm_clos_config(vm_id);
192206
}
193207

194208
if (ret &&

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ static void intercept_x2apic_msrs(uint8_t *msr_bitmap_arg, uint32_t mode)
292292
static void init_msr_area(struct acrn_vcpu *vcpu)
293293
{
294294
struct acrn_vm_config *cfg = get_vm_config(vcpu->vm->vm_id);
295+
uint16_t vcpu_clos = cfg->clos[vcpu->vcpu_id];
295296

296297
vcpu->arch.msr_area.count = 0U;
297298

@@ -302,14 +303,14 @@ static void init_msr_area(struct acrn_vcpu *vcpu)
302303
vcpu->arch.msr_area.count++;
303304

304305
/* only load/restore MSR IA32_PQR_ASSOC when hv and guest have differnt settings */
305-
if (is_platform_rdt_capable() && (cfg->clos != hv_clos)) {
306+
if (is_platform_rdt_capable() && (vcpu_clos != hv_clos)) {
306307
vcpu->arch.msr_area.guest[MSR_AREA_IA32_PQR_ASSOC].msr_index = MSR_IA32_PQR_ASSOC;
307-
vcpu->arch.msr_area.guest[MSR_AREA_IA32_PQR_ASSOC].value = clos2pqr_msr(cfg->clos);
308+
vcpu->arch.msr_area.guest[MSR_AREA_IA32_PQR_ASSOC].value = clos2pqr_msr(vcpu_clos);
308309
vcpu->arch.msr_area.host[MSR_AREA_IA32_PQR_ASSOC].msr_index = MSR_IA32_PQR_ASSOC;
309310
vcpu->arch.msr_area.host[MSR_AREA_IA32_PQR_ASSOC].value = clos2pqr_msr(hv_clos);
310311
vcpu->arch.msr_area.count++;
311312
pr_acrnlog("switch clos for VM %u vcpu_id %u, host 0x%x, guest 0x%x",
312-
vcpu->vm->vm_id, vcpu->vcpu_id, hv_clos, cfg->clos);
313+
vcpu->vm->vm_id, vcpu->vcpu_id, hv_clos, vcpu_clos);
313314
}
314315
}
315316

hypervisor/include/arch/x86/vm_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ struct acrn_vm_config {
129129
uint16_t pci_dev_num; /* indicate how many PCI devices in VM */
130130
struct acrn_vm_pci_dev_config *pci_devs; /* point to PCI devices BDF list */
131131
struct acrn_vm_os_config os_config; /* OS information the VM */
132-
uint16_t clos; /* Class of Service, effective only if CONFIG_CAT_ENABLED
132+
uint16_t clos[MAX_VCPUS_PER_VM]; /* Class of Service, effective only if CONFIG_RDT_ENABLED
133133
* is defined on CAT capable platforms
134134
*/
135135

hypervisor/scenarios/hybrid/vm_configurations.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1717
.guest_flags = 0UL,
1818
.vcpu_num = 1U,
1919
.vcpu_affinity = VM0_CONFIG_VCPU_AFFINITY,
20-
.clos = 0U,
2120
.severity = SEVERITY_SAFETY_VM,
2221
.memory = {
2322
.start_hpa = VM0_CONFIG_MEM_START_HPA,
@@ -52,7 +51,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
5251
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
5352

5453
.guest_flags = 0UL,
55-
.clos = 0U,
5654
.severity = SEVERITY_SOS,
5755
.memory = {
5856
.start_hpa = 0UL,

hypervisor/scenarios/industry/vm_configurations.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1616
0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U},
1717
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
1818
.guest_flags = 0UL,
19-
.clos = 0U,
2019
.severity = SEVERITY_SOS,
20+
.clos = { 0U },
2121
.memory = {
2222
.start_hpa = 0UL,
2323
.size = CONFIG_SOS_RAM_SIZE,

hypervisor/scenarios/logical_partition/vm_configurations.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1919
/* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */
2020
.vcpu_num = 2U,
2121
.vcpu_affinity = VM0_CONFIG_VCPU_AFFINITY,
22-
.clos = 0U,
2322
.memory = {
2423
.start_hpa = VM0_CONFIG_MEM_START_HPA,
2524
.size = VM0_CONFIG_MEM_SIZE,
@@ -59,7 +58,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
5958
.vcpu_num = 2U,
6059
.vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY,
6160
.guest_flags = (GUEST_FLAG_RT | GUEST_FLAG_LAPIC_PASSTHROUGH),
62-
.clos = 0U,
6361
.memory = {
6462
.start_hpa = VM1_CONFIG_MEM_START_HPA,
6563
.size = VM1_CONFIG_MEM_SIZE,

hypervisor/scenarios/sdc/vm_configurations.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1818

1919
/* Allow SOS to reboot the host since there is supposed to be the highest severity guest */
2020
.guest_flags = 0UL,
21-
.clos = 0U,
2221
.severity = SEVERITY_SOS,
2322
.memory = {
2423
.start_hpa = 0UL,

hypervisor/scenarios/sdc2/vm_configurations.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1818

1919
/* Allow SOS to reboot the host since there is supposed to be the highest severity guest */
2020
.guest_flags = 0UL,
21-
.clos = 0U,
2221
.severity = SEVERITY_SOS,
2322
.memory = {
2423
.start_hpa = 0UL,

0 commit comments

Comments
 (0)