[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 15/40] i386/tdx: Add property sept-ve-disable for tdx-guest ob
From: |
Xiaoyao Li |
Subject: |
[PATCH v1 15/40] i386/tdx: Add property sept-ve-disable for tdx-guest object |
Date: |
Tue, 2 Aug 2022 15:47:25 +0800 |
Bit 28, named SEPT_VE_DISABLE, disables EPT violation conversion to #VE
on guest TD access of PENDING pages when set to 1. Some guest OS (e.g.,
Linux TD guest) may require this bit set as 1. Otherwise refuse to boot.
Add sept-ve-disable property for tdx-guest object, for user to configure
this bit.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
qapi/qom.json | 4 +++-
target/i386/kvm/tdx.c | 24 ++++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/qapi/qom.json b/qapi/qom.json
index 38177848abc1..2a5486bfed3e 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -835,10 +835,12 @@
#
# Properties for tdx-guest objects.
#
+# @sept-ve-disable: bit 28 of TD attributes (default: 0)
+#
# Since: 7.2
##
{ 'struct': 'TdxGuestProperties',
- 'data': { }}
+ 'data': { '*sept-ve-disable': 'bool' } }
##
# @ObjectType:
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index ecb0205651bd..bf57f270ac9d 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -30,6 +30,8 @@
(1U << KVM_FEATURE_PV_SCHED_YIELD) | \
(1U << KVM_FEATURE_MSI_EXT_DEST_ID))
+#define TDX_TD_ATTRIBUTES_SEPT_VE_DISABLE BIT_ULL(28)
+
#define TDX_ATTRIBUTES_MAX_BITS 64
static FeatureMask tdx_attrs_ctrl_fields[TDX_ATTRIBUTES_MAX_BITS] = {
@@ -490,6 +492,24 @@ out:
return r;
}
+static bool tdx_guest_get_sept_ve_disable(Object *obj, Error **errp)
+{
+ TdxGuest *tdx = TDX_GUEST(obj);
+
+ return !!(tdx->attributes & TDX_TD_ATTRIBUTES_SEPT_VE_DISABLE);
+}
+
+static void tdx_guest_set_sept_ve_disable(Object *obj, bool value, Error
**errp)
+{
+ TdxGuest *tdx = TDX_GUEST(obj);
+
+ if (value) {
+ tdx->attributes |= TDX_TD_ATTRIBUTES_SEPT_VE_DISABLE;
+ } else {
+ tdx->attributes &= ~TDX_TD_ATTRIBUTES_SEPT_VE_DISABLE;
+ }
+}
+
/* tdx guest */
OBJECT_DEFINE_TYPE_WITH_INTERFACES(TdxGuest,
tdx_guest,
@@ -505,6 +525,10 @@ static void tdx_guest_init(Object *obj)
qemu_mutex_init(&tdx->lock);
tdx->attributes = 0;
+
+ object_property_add_bool(obj, "sept-ve-disable",
+ tdx_guest_get_sept_ve_disable,
+ tdx_guest_set_sept_ve_disable);
}
static void tdx_guest_finalize(Object *obj)
--
2.27.0
- Re: [PATCH v1 08/40] i386/tdx: Adjust the supported CPUID based on TDX restrictions, (continued)
- [PATCH v1 09/40] i386/tdx: Update tdx_fixed0/1 bits by tdx_caps.cpuid_config[], Xiaoyao Li, 2022/08/02
- [PATCH v1 12/40] i386/kvm: Move architectural CPUID leaf generation to separate helper, Xiaoyao Li, 2022/08/02
- [PATCH v1 10/40] i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookup, Xiaoyao Li, 2022/08/02
- [PATCH v1 11/40] i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookup, Xiaoyao Li, 2022/08/02
- [PATCH v1 13/40] KVM: Introduce kvm_arch_pre_create_vcpu(), Xiaoyao Li, 2022/08/02
- [PATCH v1 14/40] i386/tdx: Initialize TDX before creating TD vcpus, Xiaoyao Li, 2022/08/02
- [PATCH v1 15/40] i386/tdx: Add property sept-ve-disable for tdx-guest object,
Xiaoyao Li <=
- [PATCH v1 16/40] i386/tdx: Wire CPU features up with attributes of TD guest, Xiaoyao Li, 2022/08/02
- [PATCH v1 17/40] i386/tdx: Validate TD attributes, Xiaoyao Li, 2022/08/02
- [PATCH v1 18/40] i386/tdx: Implement user specified tsc frequency, Xiaoyao Li, 2022/08/02
- [PATCH v1 19/40] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM, Xiaoyao Li, 2022/08/02