[PATCH v8 35/55] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM

Xiaoyao Li posted 55 patches 10 months, 2 weeks ago
[PATCH v8 35/55] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM
Posted by Xiaoyao Li 10 months, 2 weeks ago
TDX only supports readonly for shared memory but not for private memory.

In the view of QEMU, it has no idea whether a memslot is used as shared
memory of private. Thus just mark kvm_readonly_mem_enabled to false to
TDX VM for simplicity.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
 target/i386/kvm/tdx.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index b0616eb3d371..a816f57043f6 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -386,6 +386,15 @@ static int tdx_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
         return -EOPNOTSUPP;
     }
 
+    /*
+     * Set kvm_readonly_mem_allowed to false, because TDX only supports readonly
+     * memory for shared memory but not for private memory. Besides, whether a
+     * memslot is private or shared is not determined by QEMU.
+     *
+     * Thus, just mark readonly memory not supported for simplicity.
+     */
+    kvm_readonly_mem_allowed = false;
+
     qemu_add_machine_init_done_notifier(&tdx_machine_done_notify);
 
     tdx_guest = tdx;
-- 
2.34.1
Re: [PATCH v8 35/55] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM
Posted by Zhao Liu 9 months, 2 weeks ago
On Tue, Apr 01, 2025 at 09:01:45AM -0400, Xiaoyao Li wrote:
> Date: Tue,  1 Apr 2025 09:01:45 -0400
> From: Xiaoyao Li <xiaoyao.li@intel.com>
> Subject: [PATCH v8 35/55] i386/tdx: Set kvm_readonly_mem_enabled to false
>  for TDX VM
> X-Mailer: git-send-email 2.34.1
> 
> TDX only supports readonly for shared memory but not for private memory.
> 
> In the view of QEMU, it has no idea whether a memslot is used as shared
> memory of private. Thus just mark kvm_readonly_mem_enabled to false to
> TDX VM for simplicity.
> 
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  target/i386/kvm/tdx.c | 9 +++++++++
>  1 file changed, 9 insertions(+)

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>