[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 11/52] i386/tdx: Wire CPU features up with attributes of TD gu
From: |
Xiaoyao Li |
Subject: |
[PATCH v7 11/52] i386/tdx: Wire CPU features up with attributes of TD guest |
Date: |
Fri, 24 Jan 2025 08:20:07 -0500 |
For QEMU VMs,
- PKS is configured via CPUID_7_0_ECX_PKS, e.g., -cpu xxx,+pks and
- PMU is configured by x86cpu->enable_pmu, e.g., -cpu xxx,pmu=on
While the bit 30 (PKS) and bit 63 (PERFMON) of TD's attributes are also
used to configure the PKS and PERFMON/PMU of TD, reuse the existing
configuration interfaces of 'cpu' for TD's attributes.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
target/i386/kvm/tdx.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index dcb19a18e405..653942d83bcb 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -19,6 +19,8 @@
#include "tdx.h"
#define TDX_TD_ATTRIBUTES_SEPT_VE_DISABLE BIT_ULL(28)
+#define TDX_TD_ATTRIBUTES_PKS BIT_ULL(30)
+#define TDX_TD_ATTRIBUTES_PERFMON BIT_ULL(63)
static TdxGuest *tdx_guest;
@@ -151,6 +153,15 @@ static int tdx_kvm_type(X86ConfidentialGuest *cg)
return KVM_X86_TDX_VM;
}
+static void setup_td_guest_attributes(X86CPU *x86cpu)
+{
+ CPUX86State *env = &x86cpu->env;
+
+ tdx_guest->attributes |= (env->features[FEAT_7_0_ECX] & CPUID_7_0_ECX_PKS)
?
+ TDX_TD_ATTRIBUTES_PKS : 0;
+ tdx_guest->attributes |= x86cpu->enable_pmu ? TDX_TD_ATTRIBUTES_PERFMON :
0;
+}
+
static int setup_td_xfam(X86CPU *x86cpu, Error **errp)
{
CPUX86State *env = &x86cpu->env;
@@ -214,6 +225,8 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)
init_vm = g_malloc0(sizeof(struct kvm_tdx_init_vm) +
sizeof(struct kvm_cpuid_entry2) *
KVM_MAX_CPUID_ENTRIES);
+ setup_td_guest_attributes(x86cpu);
+
r = setup_td_xfam(x86cpu, errp);
if (r) {
return r;
--
2.34.1
- [PATCH v7 01/52] *** HACK *** linux-headers: Update headers to pull in TDX API changes, (continued)
- [PATCH v7 01/52] *** HACK *** linux-headers: Update headers to pull in TDX API changes, Xiaoyao Li, 2025/01/24
- [PATCH v7 02/52] i386: Introduce tdx-guest object, Xiaoyao Li, 2025/01/24
- [PATCH v7 05/52] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES, Xiaoyao Li, 2025/01/24
- [PATCH v7 06/52] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object, Xiaoyao Li, 2025/01/24
- [PATCH v7 03/52] i386/tdx: Implement tdx_kvm_type() for TDX, Xiaoyao Li, 2025/01/24
- [PATCH v7 04/52] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context, Xiaoyao Li, 2025/01/24
- [PATCH v7 07/52] kvm: Introduce kvm_arch_pre_create_vcpu(), Xiaoyao Li, 2025/01/24
- [PATCH v7 09/52] i386/tdx: Add property sept-ve-disable for tdx-guest object, Xiaoyao Li, 2025/01/24
- [PATCH v7 08/52] i386/tdx: Initialize TDX before creating TD vcpus, Xiaoyao Li, 2025/01/24
- [PATCH v7 10/52] i386/tdx: Make sept_ve_disable set by default, Xiaoyao Li, 2025/01/24
- [PATCH v7 11/52] i386/tdx: Wire CPU features up with attributes of TD guest,
Xiaoyao Li <=
- [PATCH v7 12/52] i386/tdx: Validate TD attributes, Xiaoyao Li, 2025/01/24
- [PATCH v7 13/52] i386/tdx: Set APIC bus rate to match with what TDX module enforces, Xiaoyao Li, 2025/01/24
- [PATCH v7 14/52] i386/tdx: Implement user specified tsc frequency, Xiaoyao Li, 2025/01/24
- [PATCH v7 15/52] i386/tdx: load TDVF for TD guest, Xiaoyao Li, 2025/01/24
- [PATCH v7 16/52] i386/tdvf: Introduce function to parse TDVF metadata, Xiaoyao Li, 2025/01/24
- [PATCH v7 17/52] i386/tdx: Parse TDVF metadata for TDX VM, Xiaoyao Li, 2025/01/24
- [PATCH v7 18/52] i386/tdx: Don't initialize pc.rom for TDX VMs, Xiaoyao Li, 2025/01/24
- [PATCH v7 19/52] i386/tdx: Track mem_ptr for each firmware entry of TDVF, Xiaoyao Li, 2025/01/24
- [PATCH v7 20/52] i386/tdx: Track RAM entries for TDX VM, Xiaoyao Li, 2025/01/24
- [PATCH v7 21/52] headers: Add definitions from UEFI spec for volumes, resources, etc..., Xiaoyao Li, 2025/01/24