Re: [PATCH v2] target/i386: Fix model number of Zhaoxin YongFeng vCPU template

2025-04-13 Thread Xiaoyao Li
On 4/11/2025 3:42 PM, Ewan Hai wrote: On 4/11/25 11:22 AM, Zhao Liu wrote: On Thu, Apr 10, 2025 at 10:07:15PM +0800, Ewan Hai wrote: Date: Thu, 10 Apr 2025 22:07:15 +0800 From: Ewan Hai Subject: Re: [PATCH v2] target/i386: Fix model number of Zhaoxin YongFeng   vCPU template On 4/10/25 8

Re: [PATCH v8 14/55] i386/tdx: Set APIC bus rate to match with what TDX module enforces

2025-04-10 Thread Xiaoyao Li
On 4/2/2025 7:56 PM, Daniel P. Berrangé wrote: On Tue, Apr 01, 2025 at 09:01:24AM -0400, Xiaoyao Li wrote: TDX advertises core crystal clock with cpuid[0x15] as 25MHz for TD guests and it's unchangeable from VMM. As a result, TDX guest reads the APIC timer as the same frequency, 25MHz.

Re: [PATCH v4 02/13] memory: Change memory_region_set_ram_discard_manager() to return the result

2025-04-10 Thread Xiaoyao Li
On 4/7/2025 3:49 PM, Chenyi Qiang wrote: Modify memory_region_set_ram_discard_manager() to return false if a RamDiscardManager is already set in the MemoryRegion. It doesn't return false, but -EBUSY. The caller must handle this failure, such as having virtio-mem undo its actions and fail the

Re: [PATCH v8 38/55] i386/tdx: Set and check kernel_irqchip mode for TDX

2025-04-10 Thread Xiaoyao Li
On 4/2/2025 6:41 PM, Daniel P. Berrangé wrote: On Tue, Apr 01, 2025 at 09:01:48AM -0400, Xiaoyao Li wrote: KVM mandates kernel_irqchip to be split mode. Set it to split mode automatically when users don't provide an explicit value, otherwise check it to be the split mode. Suggested-by: D

Re: [PATCH v8 08/55] i386/tdx: Initialize TDX before creating TD vcpus

2025-04-10 Thread Xiaoyao Li
On 4/2/2025 7:41 PM, Daniel P. Berrangé wrote: On Tue, Apr 01, 2025 at 09:01:18AM -0400, Xiaoyao Li wrote: Invoke KVM_TDX_INIT_VM in kvm_arch_pre_create_vcpu() that KVM_TDX_INIT_VM configures global TD configurations, e.g. the canonical CPUID config, and must be executed prior to creating vCPUs

Re: [PATCH v8 55/55] docs: Add TDX documentation

2025-04-09 Thread Xiaoyao Li
On 4/2/2025 6:50 PM, Daniel P. Berrangé wrote: CC libvirt / Jiri, for confirmation about whether the CPUID restrictions listed below will have any possible impact on libvirt CPUID handling... On Tue, Apr 01, 2025 at 09:02:05AM -0400, Xiaoyao Li wrote: Add docs/system/i386/tdx.rst for TDX

Re: [PATCH v8 17/55] i386/tdvf: Introduce function to parse TDVF metadata

2025-04-08 Thread Xiaoyao Li
On 4/2/2025 8:08 PM, Daniel P. Berrangé wrote: On Tue, Apr 01, 2025 at 09:01:27AM -0400, Xiaoyao Li wrote: From: Isaku Yamahata TDX VM needs to boot with its specialized firmware, Trusted Domain Virtual Firmware (TDVF). QEMU needs to parse TDVF and map it in TD guest memory prior to running

Re: [PATCH v8 12/55] i386/tdx: Validate TD attributes

2025-04-08 Thread Xiaoyao Li
On 4/2/2025 7:47 PM, Daniel P. Berrangé wrote: On Tue, Apr 01, 2025 at 09:01:22AM -0400, Xiaoyao Li wrote: Validate TD attributes with tdx_caps that only supported bits are allowed by KVM. Besides, sanity check the attribute bits that have not been supported by QEMU yet. e.g., debug bit, it

Re: [PATCH v8 55/55] docs: Add TDX documentation

2025-04-07 Thread Xiaoyao Li
On 4/2/2025 6:50 PM, Daniel P. Berrangé wrote: CC libvirt / Jiri, for confirmation about whether the CPUID restrictions listed below will have any possible impact on libvirt CPUID handling... On Tue, Apr 01, 2025 at 09:02:05AM -0400, Xiaoyao Li wrote: Add docs/system/i386/tdx.rst for TDX

Re: [PATCH v8 13/55] i386/tdx: Support user configurable mrconfigid/mrowner/mrownerconfig

2025-04-07 Thread Xiaoyao Li
On 4/2/2025 7:51 PM, Daniel P. Berrangé wrote: On Tue, Apr 01, 2025 at 09:01:23AM -0400, Xiaoyao Li wrote: From: Isaku Yamahata Three sha384 hash values, mrconfigid, mrowner and mrownerconfig, of a TD can be provided for TDX attestation. Detailed meaning of them can be found: https

Re: [PATCH v5 49/65] i386/tdx: handle TDG.VP.VMCALL

2025-04-07 Thread Xiaoyao Li
On 4/3/2025 4:10 PM, Daniel P. Berrangé wrote: On Thu, Apr 03, 2025 at 03:28:43PM +0800, Xiaoyao Li wrote: On 4/2/2025 11:49 PM, Daniel P. Berrangé wrote: On Wed, Apr 02, 2025 at 11:26:11PM +0800, Xiaoyao Li wrote: I guess the raw mode was introduced due to the design was changed to let

Re: [PULL 2/8] migration: ram block cpr blockers

2025-04-05 Thread Xiaoyao Li
On 3/27/2025 8:27 PM, Steven Sistare wrote: On 3/26/2025 5:34 PM, Michael Roth wrote: On Wed, Mar 26, 2025 at 05:13:50PM -0300, Fabiano Rosas wrote: Michael Roth writes: Quoting Tom Lendacky (2025-03-26 14:21:31) On 3/26/25 13:46, Tom Lendacky wrote: On 3/7/25 12:15, Fabiano Rosas wrote:

Re: [PATCH v5 49/65] i386/tdx: handle TDG.VP.VMCALL

2025-04-05 Thread Xiaoyao Li
On 4/2/2025 11:49 PM, Daniel P. Berrangé wrote: On Wed, Apr 02, 2025 at 11:26:11PM +0800, Xiaoyao Li wrote: Sorry for the late response. KVM part of TDX attestation support is submitting again. QEMU part will follow and we need to settle dowm this topic before QEMU patches submission. On 10/4

[PATCH v8 05/55] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES

2025-04-05 Thread Xiaoyao Li
ITIES, QEMU chooses to try starting with a known number and abort when it exceeds KVM_MAX_CPUID_ENTRIES. Besides, introduce the interfaces to invoke TDX "ioctls" at VCPU scope in preparation. Signed-off-by: Xiaoyao Li --- Changes in v7: - refine and unifiy the error handling; (Daniel)

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

2025-04-05 Thread Xiaoyao Li
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 Acked-by: Gerd Hoffmann

[PATCH v8 55/55] docs: Add TDX documentation

2025-04-05 Thread Xiaoyao Li
Add docs/system/i386/tdx.rst for TDX support, and add tdx in confidential-guest-support.rst Signed-off-by: Xiaoyao Li --- Changes in v6: - Add more information of "Feature configuration" - Mark TD Attestation as future work because KVM now drops the support of it. Changes in v5:

[PATCH v8 39/55] i386/tdx: Don't synchronize guest tsc for TDs

2025-04-05 Thread Xiaoyao Li
From: Isaku Yamahata TSC of TDs is not accessible and KVM doesn't allow access of MSR_IA32_TSC for TDs. To avoid the assert() in kvm_get_tsc, make kvm_synchronize_all_tsc() noop for TDs, Signed-off-by: Isaku Yamahata Reviewed-by: Connor Kuehl Signed-off-by: Xiaoyao Li Acked-by: Gerd Hof

[PATCH v8 16/55] i386/tdx: load TDVF for TD guest

2025-04-04 Thread Xiaoyao Li
se it needs to be located at private memory. Also store the MemoryRegion pointer of TDVF since the shared ramblock of it can be discared after it gets copied to private ramblock. Signed-off-by: Chao Peng Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li --- hw/i386/x86-common.c

[PATCH v8 01/55] *** HACK *** linux-headers: Update headers to pull in TDX API changes

2025-04-04 Thread Xiaoyao Li
Pull in recent TDX updates, which are not backwards compatible. It's just to make this series runnable. It will be updated by script scripts/update-linux-headers.sh once TDX support is upstreamed in linux kernel Signed-off-by: Xiaoyao Li --- linux-headers/asm-x86/kvm.h

[PATCH v8 42/55] cpu: Don't set vcpu_dirty when guest_state_protected

2025-04-04 Thread Xiaoyao Li
QEMU calls kvm_arch_put_registers() when vcpu_dirty is true in kvm_vcpu_exec(). However, for confidential guest, like TDX, putting registers is disallowed due to guest state is protected. Only set vcpu_dirty to true with guest state is not protected when creating the vcpu. Signed-off-by: Xiaoyao

Re: [PATCH v5 49/65] i386/tdx: handle TDG.VP.VMCALL

2025-04-02 Thread Xiaoyao Li
Sorry for the late response. KVM part of TDX attestation support is submitting again. QEMU part will follow and we need to settle dowm this topic before QEMU patches submission. On 10/4/2024 2:08 AM, Daniel P. Berrangé wrote: On Thu, Feb 29, 2024 at 01:37:10AM -0500, Xiaoyao Li wrote: From

Re: [PATCH v8 05/55] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES

2025-04-02 Thread Xiaoyao Li
On 4/2/2025 7:00 PM, Daniel P. Berrangé wrote: On Tue, Apr 01, 2025 at 09:01:15AM -0400, Xiaoyao Li wrote: KVM provides TDX capabilities via sub command KVM_TDX_CAPABILITIES of IOCTL(KVM_MEMORY_ENCRYPT_OP). Get the capabilities when initializing TDX context. It will be used to validate user&#

[PATCH v8 28/55] i386/tdx: Handle KVM_SYSTEM_EVENT_TDX_FATAL

2025-04-01 Thread Xiaoyao Li
TD guest can use TDG.VP.VMCALL to request termination. KVM translates such request into KVM_EXIT_SYSTEM_EVENT with type of KVM_SYSTEM_EVENT_TDX_FATAL. Add hanlder for such exit. Parse and print the error message, and terminate the TD guest in the handler. Signed-off-by: Xiaoyao Li --- Changes

[PATCH v8 45/55] i386/tdx: Add TDX fixed1 bits to supported CPUIDs

2025-04-01 Thread Xiaoyao Li
tdx_supported_cpuid. Besides, set all the fixed1 bits to the initial set of KVM's support since KVM might not report them as supported. Signed-off-by: Xiaoyao Li --- target/i386/cpu.h | 2 + target/i386/kvm/kvm_i386.h | 7 ++ target/i386/kvm/tdx.c

[PATCH v8 49/55] i386/tdx: Define supported KVM features for TDX

2025-04-01 Thread Xiaoyao Li
For TDX, only limited KVM PV features are supported. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 20 1 file changed, 20 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index e07cd9a1ee15..7382b53fcc51 100644 --- a/target/i386/kvm/tdx.c

[PATCH v8 36/55] i386/tdx: Disable SMM for TDX VMs

2025-04-01 Thread Xiaoyao Li
TDX doesn't support SMM and VMM cannot emulate SMM for TDX VMs because VMM cannot manipulate TDX VM's memory. Disable SMM for TDX VMs and error out if user requests to enable SMM. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/tdx.c | 9 + 1 file

[PATCH v8 11/55] i386/tdx: Wire CPU features up with attributes of TD guest

2025-04-01 Thread Xiaoyao Li
existing configuration interfaces of 'cpu' for TD's attributes. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- 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 592fb9cbbf0b..1202b2111ba8 1

[PATCH for 10.1 v8 00/55] QEMU TDX support

2025-04-01 Thread Xiaoyao Li
ON i386/tdx: Don't synchronize guest tsc for TDs Xiaoyao Li (49): *** HACK *** linux-headers: Update headers to pull in TDX API changes i386: Introduce tdx-guest object i386/tdx: Implement tdx_kvm_type() for TDX i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context i386/

[PATCH v8 31/55] i386/cpu: introduce x86_confidential_guest_cpu_instance_init()

2025-04-01 Thread Xiaoyao Li
To allow execute confidential guest specific cpu init operations. Signed-off-by: Xiaoyao Li --- Changes in v6: - new patch; --- target/i386/confidential-guest.h | 11 +++ target/i386/cpu.c| 10 ++ 2 files changed, 21 insertions(+) diff --git a/target/i386

[PATCH v8 04/55] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context

2025-04-01 Thread Xiaoyao Li
Implement TDX specific ConfidentialGuestSupportClass::kvm_init() callback, tdx_kvm_init(). Mark guest state is proctected for TDX VM. More TDX specific initialization will be added later. Signed-off-by: Xiaoyao Li --- Changes in v6: - remove Acked-by from Gerd since the patch changed due to

[PATCH v8 08/55] i386/tdx: Initialize TDX before creating TD vcpus

2025-04-01 Thread Xiaoyao Li
that QEMU may change the CPUID configuration when creating vCPUs, i.e. punts on refactoring QEMU to provide a stable CPUID config prior to kvm_arch_init(). Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann Acked-by: Markus Armbruster --- Changes in v8: - Drop the code that initializes cpu->k

[PATCH v8 38/55] i386/tdx: Set and check kernel_irqchip mode for TDX

2025-04-01 Thread Xiaoyao Li
KVM mandates kernel_irqchip to be split mode. Set it to split mode automatically when users don't provide an explicit value, otherwise check it to be the split mode. Suggested-by: Daniel P. Berrangé Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 8 1 file changed, 8 inser

[PATCH v8 15/55] i386/tdx: Implement user specified tsc frequency

2025-04-01 Thread Xiaoyao Li
Reuse "-cpu,tsc-frequency=" to get user wanted tsc frequency and call VM scope VM_SET_TSC_KHZ to set the tsc frequency of TD before KVM_TDX_INIT_VM. Besides, sanity check the tsc frequency to be in the legal range and legal granularity (required by TDX module). Signed-off-by: Xiaoyao

[PATCH v8 13/55] i386/tdx: Support user configurable mrconfigid/mrowner/mrownerconfig

2025-04-01 Thread Xiaoyao Li
=ASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83v Signed-off-by: Isaku Yamahata Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li --- Changes in v8: - it gets squashed into previous patch in v7. So split it out in v8; Changes in v6: - refine the doc comment of QAPI properties; Changes in v5

[PATCH v8 27/55] i386/tdx: Enable user exit on KVM_HC_MAP_GPA_RANGE

2025-04-01 Thread Xiaoyao Li
KVM translates TDG.VP.VMCALL to KVM_HC_MAP_GPA_RANGE, and QEMU needs to enable user exit on KVM_HC_MAP_GPA_RANGE in order to handle the memory conversion requested by TD guest. Signed-off-by: Xiaoyao Li --- changes in v6: - new patch; --- target/i386/kvm/tdx.c | 7 +++ 1 file changed, 7

[PATCH v8 44/55] i386/tdx: Implement adjust_cpuid_features() for TDX

2025-04-01 Thread Xiaoyao Li
e the CPUID bits related to QEMU's feature word. Only mask the CPUID leafs which are feature word leaf. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 18 ++ target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 2 +- target/i386/kvm/kvm_i386.h | 1 + t

[PATCH v8 23/55] i386/tdx: Setup the TD HOB list

2025-04-01 Thread Xiaoyao Li
d-off-by: Isaku Yamahata Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- Changes in v7: - use SPDX tag for license info; - clean up the included headers; Changes in v1: - drop the code of adding mmio resources

[PATCH v8 29/55] i386/tdx: Wire TDX_REPORT_FATAL_ERROR with GuestPanic facility

2025-04-01 Thread Xiaoyao Li
Integrate TDX's TDX_REPORT_FATAL_ERROR into QEMU GuestPanic facility Originated-from: Isaku Yamahata Signed-off-by: Xiaoyao Li Acked-by: Markus Armbruster --- Changes in v8: - use g_strdup() for copy string; - use the new data ABI of KVM_SYSTEM_EVENT_TDX_FATAL to grab gpa info; Changes

[PATCH v8 47/55] i386/tdx: Add supported CPUID bits relates to XFAM

2025-04-01 Thread Xiaoyao Li
. Besides, incorporate the supported_xfam into the supported CPUID leaf of 0xD. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 12 --- target/i386/cpu.h | 16 ++ target/i386/kvm/tdx.c | 73 +++ 3 files changed, 89 insertions(+), 12

[PATCH v8 41/55] i386/apic: Skip kvm_apic_put() for TDX

2025-04-01 Thread Xiaoyao Li
onfidential guest through guest_state_protected. [*] https://lore.kernel.org/all/z3w4ku4jq0crt...@google.com/ Signed-off-by: Xiaoyao Li --- Changes in v8: - Fix the coding style; (Francesco) --- hw/i386/kvm/apic.c | 5 + 1 file changed, 5 insertions(+) diff --git a/hw/i386/kvm/apic.c b/hw/i386

[PATCH v8 26/55] i386/tdx: Finalize TDX VM

2025-04-01 Thread Xiaoyao Li
Invoke KVM_TDX_FINALIZE_VM to finalize the TD's measurement and make the TD vCPUs runnable once machine initialization is complete. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/tdx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/kvm/tdx.c b/t

[PATCH v8 50/55] i386/cgs: Introduce x86_confidential_guest_check_features()

2025-04-01 Thread Xiaoyao Li
To do cgs specific feature checking. Note the feature checking in x86_cpu_filter_features() is valid for non-cgs VMs. For cgs VMs like TDX, what features can be supported has more restrictions. Signed-off-by: Xiaoyao Li --- target/i386/confidential-guest.h | 13 + target/i386/kvm

[PATCH v8 40/55] i386/tdx: Only configure MSR_IA32_UCODE_REV in kvm_init_msrs() for TDs

2025-04-01 Thread Xiaoyao Li
For TDs, only MSR_IA32_UCODE_REV in kvm_init_msrs() can be configured by VMM, while the features enumerated/controlled by other MSRs except MSR_IA32_UCODE_REV in kvm_init_msrs() are not under control of VMM. Only configure MSR_IA32_UCODE_REV for TDs. Signed-off-by: Xiaoyao Li Acked-by: Gerd

[PATCH v8 53/55] i386/tdx: Make invtsc default on

2025-04-01 Thread Xiaoyao Li
Because it's fixed1 bit that enforced by TDX module. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index cd8e96d476b8..8f075ba5a4de 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i38

[PATCH v8 48/55] i386/tdx: Add XFD to supported bit of TDX

2025-04-01 Thread Xiaoyao Li
Just mark XFD as always supported for TDX. This simple solution relies on the fact KVM will report XFD as 0 when it's not supported by the hardware. Signed-off-by: Xiaoyao Li --- target/i386/cpu.h | 1 + target/i386/kvm/tdx.c | 5 + 2 files changed, 6 insertions(+) diff --git a/t

[PATCH v8 34/55] i386/tdx: Force exposing CPUID 0x1f

2025-04-01 Thread Xiaoyao Li
TDX uses CPUID 0x1f to configure TD guest's CPU topology. So set enable_cpuid_0x1f for TDs. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 4 1 file changed, 4 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 49e748af3949..b0616eb3d371 100644

[PATCH v8 43/55] i386/cgs: Rename *mask_cpuid_features() to *adjust_cpuid_features()

2025-04-01 Thread Xiaoyao Li
Because for TDX case, there are also fixed-1 bits that enfored by TDX module. Signed-off-by: Xiaoyao Li --- target/i386/confidential-guest.h | 20 ++-- target/i386/kvm/kvm.c| 2 +- target/i386/sev.c| 4 ++-- 3 files changed, 13 insertions(+), 13

[PATCH v8 51/55] i386/tdx: Fetch and validate CPUID of TD guest

2025-04-01 Thread Xiaoyao Li
s enforced enabled. - If cpu->enforced_cpuid is not set, prints the warning message of both 1) and 2) and tweak QEMU's configuration. - If cpu->enforced_cpuid is set, quit if any case of 1) or 2). Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 33 ++- targe

[PATCH v8 25/55] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu

2025-04-01 Thread Xiaoyao Li
TDX vcpu needs to be initialized by SEAMCALL(TDH.VP.INIT) and KVM provides vcpu level IOCTL KVM_TDX_INIT_VCPU for it. KVM_TDX_INIT_VCPU needs the address of the HOB as input. Invoke it for each vcpu after HOB list is created. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386

[PATCH v8 54/55] i386/tdx: Validate phys_bits against host value

2025-04-01 Thread Xiaoyao Li
For TDX guest, the phys_bits is not configurable and can only be host/native value. Validate phys_bits inside tdx_check_features(). Signed-off-by: Xiaoyao Li --- target/i386/host-cpu.c | 2 +- target/i386/host-cpu.h | 1 + target/i386/kvm/tdx.c | 8 3 files changed, 10 insertions

[PATCH v8 06/55] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object

2025-04-01 Thread Xiaoyao Li
It will need special handling for TDX VMs all around the QEMU. Introduce is_tdx_vm() helper to query if it's a TDX VM. Cache tdx_guest object thus no need to cast from ms->cgs every time. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann Reviewed-by: Isaku Yamahata --- chang

[PATCH v8 18/55] i386/tdx: Parse TDVF metadata for TDX VM

2025-04-01 Thread Xiaoyao Li
After TDVF is loaded to bios MemoryRegion, it needs parse TDVF metadata. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- hw/i386/pc_sysfw.c | 7 +++ target/i386/kvm/tdx-stub.c | 5 + target/i386/kvm/tdx.c | 5 + target/i386/kvm/tdx.h | 3 +++ 4 files changed

[PATCH v8 03/55] i386/tdx: Implement tdx_kvm_type() for TDX

2025-04-01 Thread Xiaoyao Li
TDX VM requires VM type to be KVM_X86_TDX_VM. Implement tdx_kvm_type() as X86ConfidentialGuestClass->kvm_type. Signed-off-by: Xiaoyao Li --- Changes in v6: - new added patch; --- target/i386/kvm/kvm.c | 1 + target/i386/kvm/tdx.c | 12 2 files changed, 13 insertions(+) d

[PATCH v8 37/55] i386/tdx: Disable PIC for TDX VMs

2025-04-01 Thread Xiaoyao Li
s and error out if user wants PIC. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/tdx.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 0eefd058f7a2..0d30506c2021 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i38

[PATCH v8 24/55] i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION

2025-04-01 Thread Xiaoyao Li
After populating the TDVF memory, the original image located in shared ramblock can be discarded. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- Changes in v6: - switch back to use KVM_TDX_INIT_MEM_REGION according to KVM's change; --- target/i386/kvm/

[PATCH v8 10/55] i386/tdx: Make sept_ve_disable set by default

2025-04-01 Thread Xiaoyao Li
From: Isaku Yamahata For TDX KVM use case, Linux guest is the most major one. It requires sept_ve_disable set. Make it default for the main use case. For other use case, it can be enabled/disabled via qemu command line. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- target

[PATCH v8 52/55] i386/tdx: Don't treat SYSCALL as unavailable

2025-04-01 Thread Xiaoyao Li
Signed-off-by: Xiaoyao Li --- Changes in v7: - fix CPUID_EXT2_SYSCALL by adding it to actual; --- 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 58797470ba7e..cd8e96d476b8 100644 --- a/target/i386/kvm

[PATCH v8 33/55] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f

2025-04-01 Thread Xiaoyao Li
est. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 9 + target/i386/kvm/kvm.c | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5c69d1489365..f219961b62cd 100644 --- a/target/i386/cpu.c ++

[PATCH v8 07/55] kvm: Introduce kvm_arch_pre_create_vcpu()

2025-04-01 Thread Xiaoyao Li
Introduce kvm_arch_pre_create_vcpu(), to perform arch-dependent work prior to create any vcpu. This is for i386 TDX because it needs call TDX_INIT_VM before creating any vcpu. The specific implemnet of i386 will be added in the future patch. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann

[PATCH v8 46/55] i386/tdx: Add supported CPUID bits related to TD Attributes

2025-04-01 Thread Xiaoyao Li
For TDX, some CPUID feature bit is configured via TD attributes. They are not covered by tdx_caps.cpuid (which only contians the configurable bits), but they are actually supported when the related attributre bit is supported. Signed-off-by: Xiaoyao Li --- target/i386/cpu.h | 4 +++ target

[PATCH v8 30/55] kvm: Check KVM_CAP_MAX_VCPUS at vm level

2025-04-01 Thread Xiaoyao Li
KVM with TDX support starts to report different KVM_CAP_MAX_VCPUS per different VM types. So switch to check the KVM_CAP_MAX_VCPUS at vm level. KVM still returns the global KVM_CAP_MAX_VCPUS when the KVM is old that doesn't report different value at vm level. Signed-off-by: Xiaoy

[PATCH v8 21/55] i386/tdx: Track RAM entries for TDX VM

2025-04-01 Thread Xiaoyao Li
;ed before TD runs and no need to be accepted runtime. The TdxRamEntries[] are later used to setup the memory TD resource HOB that passes memory info from QEMU to TDVF. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- Changes in v3: - use enum TdxRamType in struct TdxRamEntry; (Isaku)

[PATCH v8 32/55] i386/tdx: implement tdx_cpu_instance_init()

2025-04-01 Thread Xiaoyao Li
Currently, pmu is not supported for TDX by KVM. Signed-off-by: Xiaoyao Li --- chanegs in v6: - new patch; --- target/i386/kvm/tdx.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 282cdbd775c5..49e748af3949 100644 --- a/target/i386

[PATCH v8 20/55] i386/tdx: Track mem_ptr for each firmware entry of TDVF

2025-04-01 Thread Xiaoyao Li
do the stuff. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- Changes in v8: - Remove the duplicated header include; - Add error handling for qemu_ram_mmap() failure; --- hw/i386/tdvf.c | 1 + include/hw/i386/tdvf.h | 7 +++ target/i386/kvm/tdx.c | 37

[PATCH v8 17/55] i386/tdvf: Introduce function to parse TDVF metadata

2025-04-01 Thread Xiaoyao Li
offset of TDX metadata to the end of firmware file. Select X86_FW_OVMF when TDX is enable to leverage existing functions to parse and search OVMF's GUID-ed structures. Signed-off-by: Isaku Yamahata Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- Changes

[PATCH v8 19/55] i386/tdx: Don't initialize pc.rom for TDX VMs

2025-04-01 Thread Xiaoyao Li
For TDX, the address below 1MB are entirely general RAM. No need to initialize pc.rom memory region for TDs. Signed-off-by: Xiaoyao Li --- This is more as a workaround of the issue that for q35 machine type, the real memslot update (which requires memslot deletion )for pc.rom happens after

[PATCH v8 02/55] i386: Introduce tdx-guest object

2025-04-01 Thread Xiaoyao Li
ibutes directly. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann Acked-by: Markus Armbruster --- Changes in v7: - update QAPI version to 10.0; - update to use SPDX tags for license info; - update copyright to 2025; Chanegs in v6: - Make tdx-guest inherits X86_CONFIDENTIAL_GU

[PATCH v8 22/55] headers: Add definitions from UEFI spec for volumes, resources, etc...

2025-04-01 Thread Xiaoyao Li
.pdf Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- Changes in v7: - use SPDX tag; --- include/standard-headers/uefi/uefi.h | 187 +++ 1 file changed, 187 insertions(+) create mode 100644 include/standard-headers/uefi/uefi.h diff --git a/include/standard-headers

[PATCH v8 14/55] i386/tdx: Set APIC bus rate to match with what TDX module enforces

2025-04-01 Thread Xiaoyao Li
licitly to ensure KVM provide correct emulated APIC timer for TD guest. Signed-off-by: Xiaoyao Li --- Changes in v6: - new patch; --- target/i386/kvm/tdx.c | 13 + target/i386/kvm/tdx.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/t

[PATCH v8 09/55] i386/tdx: Add property sept-ve-disable for tdx-guest object

2025-04-01 Thread Xiaoyao Li
configure this bit. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann Acked-by: Markus Armbruster --- Changes in v4: - collect Acked-by from Markus Changes in v3: - update the comment of property @sept-ve-disable to make it more descriptive and use new format. (Daniel and Markus) --- qapi

[PATCH v8 12/55] i386/tdx: Validate TD attributes

2025-04-01 Thread Xiaoyao Li
Validate TD attributes with tdx_caps that only supported bits are allowed by KVM. Besides, sanity check the attribute bits that have not been supported by QEMU yet. e.g., debug bit, it will be allowed in the future when debug TD support lands in QEMU. Signed-off-by: Xiaoyao Li Acked-by: Gerd

Re: [PATCH v7 52/52] docs: Add TDX documentation

2025-03-25 Thread Xiaoyao Li
On 3/26/2025 11:36 AM, Xiaoyao Li wrote: On 3/26/2025 2:46 AM, Daniel P. Berrangé wrote: On Fri, Jan 24, 2025 at 08:20:48AM -0500, Xiaoyao Li wrote: Add docs/system/i386/tdx.rst for TDX support, and add tdx in confidential-guest-support.rst Signed-off-by: Xiaoyao Li --- ---   docs/system

Re: [PATCH v7 52/52] docs: Add TDX documentation

2025-03-25 Thread Xiaoyao Li
On 3/26/2025 2:46 AM, Daniel P. Berrangé wrote: On Fri, Jan 24, 2025 at 08:20:48AM -0500, Xiaoyao Li wrote: Add docs/system/i386/tdx.rst for TDX support, and add tdx in confidential-guest-support.rst Signed-off-by: Xiaoyao Li --- --- docs/system/confidential-guest-support.rst | 1

Re: [PATCH v2 03/10] [DO NOT MERGE] kvm: Introduce kvm_arch_pre_create_vcpu()

2025-03-07 Thread Xiaoyao Li
On 3/7/2025 3:52 PM, Zhao Liu wrote: I didn't know if I would need to wait until this patch is merged into mainline QEMU. That's why I didn't add my signed-off. No problem if Xiaoyao is okay with it (copyright of patches need to honor the original author & signed-off). IMO, if your series is ac

Re: [PATCH 0/2] i386: Adjust CPUID_EXT_PDCM based on enable_pmu at realization

2025-03-06 Thread Xiaoyao Li
On 3/7/2025 12:22 AM, Zhao Liu wrote: Hi Xiaoyao, First, it's not a good practice that values in env->features[] cannot be directly used for guest CPUID in void cpu_x86_cpuid(), but require further adjustment there. env->features[] are supposed to be finalized at cpu realization, so that after

Re: [PATCH v2 01/10] target/i386: disable PerfMonV2 when PERFCORE unavailable

2025-03-04 Thread Xiaoyao Li
On 3/5/2025 6:53 AM, dongli.zh...@oracle.com wrote: Hi Xiaoyao, On 3/4/25 6:40 AM, Xiaoyao Li wrote: On 3/3/2025 6:00 AM, Dongli Zhang wrote: When the PERFCORE is disabled with "-cpu host,-perfctr-core", it is reflected in in guest dmesg. [    0.285136] Performance Events: AMD

Re: [PATCH v2 04/10] target/i386/kvm: set KVM_PMU_CAP_DISABLE if "-pmu" is configured

2025-03-04 Thread Xiaoyao Li
On 3/5/2025 9:22 AM, Sean Christopherson wrote: On Tue, Mar 04, 2025, Xiaoyao Li wrote: On 3/3/2025 6:00 AM, Dongli Zhang wrote: Although AMD PERFCORE and PerfMonV2 are removed when "-pmu" is configured, there is no way to fully disable KVM AMD PMU virtualization. Neither "-cpu

Re: [PATCH v2 01/10] target/i386: disable PerfMonV2 when PERFCORE unavailable

2025-03-04 Thread Xiaoyao Li
= 0x0 Disable PerfMonV2 in CPUID when PERFCORE is disabled. Suggested-by: Zhao Liu Though I have above confusion of the description, the change itself looks good to me. So Reviewed-by: Xiaoyao Li Fixes: 209b0ac12074 ("target/i386: Add PerfMonV2 feature bit") Signed-off-by: Do

Re: [PATCH v2 04/10] target/i386/kvm: set KVM_PMU_CAP_DISABLE if "-pmu" is configured

2025-03-04 Thread Xiaoyao Li
Anyway, since QEMU can achieve its goal with KVM_PMU_CAP_DISABLE with current KVM, I'm fine with it. I have one nit below, otherwise Reviewed-by: Xiaoyao Li As a result, the following message still appears in the VM dmesg: [0.263615] Performance Events: AMD PMU driver. How

Re: [PATCH v2 02/10] target/i386: disable PERFCORE when "-pmu" is configured

2025-03-03 Thread Xiaoyao Li
On 3/4/2025 2:45 AM, dongli.zh...@oracle.com wrote: Hi Xiaoyao, On 3/2/25 5:59 PM, Xiaoyao Li wrote: On 3/3/2025 6:00 AM, Dongli Zhang wrote: Currently, AMD PMU support isn't determined based on CPUID, that is, the "-pmu" option does not fully disable KVM AMD PMU virtualizatio

[PATCH 1/2] i386/cpu: Move adjustment of CPUID_EXT_PDCM before feature_dependencies[] check

2025-03-03 Thread Xiaoyao Li
There is one entry relates to CPUID_EXT_PDCM in feature_dependencies[]. So it needs to get correct value of CPUID_EXT_PDCM before using feature_dependencies[] to apply dependencies. Besides, it also ensures CPUID_EXT_PDCM value is tracked in env->features[FEAT_1_ECX]. Signed-off-by: Xiaoyao

[PATCH 0/2] i386: Adjust CPUID_EXT_PDCM based on enable_pmu at realization

2025-03-03 Thread Xiaoyao Li
they request pdcm explicitly while PMU disabled. Xiaoyao Li (2): i386/cpu: Move adjustment of CPUID_EXT_PDCM before feature_dependencies[] check i386/cpu: Warn about why CPUID_EXT_PDCM is not available target/i386/cpu.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.34.1

[PATCH 2/2] i386/cpu: Warn about why CPUID_EXT_PDCM is not available

2025-03-03 Thread Xiaoyao Li
When user requests PDCM explicitly via "+pdcm" without PMU enabled, emit a warning to inform the user. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2bf6495140a0..2aa2bab12100 10

Re: [PATCH v7 38/52] i386/apic: Skip kvm_apic_put() for TDX

2025-03-02 Thread Xiaoyao Li
On 2/28/2025 12:57 AM, Francesco Lavra wrote: On Fri, 2025-01-24 at 08:20 -0500, Xiaoyao Li wrote: KVM neithers allow writing to MSR_IA32_APICBASE for TDs, nor allow for KVM_SET_LAPIC[*]. Note, KVM_GET_LAPIC is also disallowed for TDX. It is called in the path   do_kvm_cpu_synchronize_state

Re: [PATCH v7 28/52] i386/tdx: Wire TDX_REPORT_FATAL_ERROR with GuestPanic facility

2025-03-02 Thread Xiaoyao Li
On 2/28/2025 12:30 AM, Francesco Lavra wrote: On Fri, 2025-01-24 at 08:20 -0500, Xiaoyao Li wrote: diff --git a/system/runstate.c b/system/runstate.c index 272801d30769..c4244c8915c6 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -565,6 +565,60 @@ static void qemu_system_wakeup(void

Re: [PATCH v2 02/10] target/i386: disable PERFCORE when "-pmu" is configured

2025-03-02 Thread Xiaoyao Li
On 3/3/2025 6:00 AM, Dongli Zhang wrote: Currently, AMD PMU support isn't determined based on CPUID, that is, the "-pmu" option does not fully disable KVM AMD PMU virtualization. To minimize AMD PMU features, remove PERFCORE when "-pmu" is configured. To completely disable AMD PMU virtualizatio

Re: [PATCH 3/4] i386/cpu: Fix overflow of cache topology fields in CPUID.04H

2025-02-26 Thread Xiaoyao Li
the future, check and honor the maximum value for EAX[14:25] as well. In addition, for host-cache-info case, also apply the same checks and fixes. Signed-off-by: Qian Wen Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li --- Changes since original v4 [*]: * Rebase on addressable ID fixup

Re: [PATCH 2/4] i386/cpu: Fix cpu number overflow in CPUID.01H.EBX[23:16]

2025-02-26 Thread Xiaoyao Li
sue caused by overflow, limit the max value written to EBX[23:16] to 255 as the HW does. Cc: qemu-sta...@nongnu.org Signed-off-by: Qian Wen Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li --- Changes since original v4 [*]: * Rebase on addressable ID fixup. * Drop R/b tags since the c

Re: [PATCH v7 19/52] i386/tdx: Track mem_ptr for each firmware entry of TDVF

2025-02-26 Thread Xiaoyao Li
On 2/19/2025 7:26 PM, Francesco Lavra wrote: On Fri, 2025-01-24 at 08:20 -0500, Xiaoyao Li wrote: +static void tdx_finalize_vm(Notifier *notifier, void *unused) +{ +    TdxFirmware *tdvf = &tdx_guest->tdvf; +    TdxFirmwareEntry *entry; + +    for_each_tdx_fw_entry(tdvf

Re: [PATCH v7 19/52] i386/tdx: Track mem_ptr for each firmware entry of TDVF

2025-02-26 Thread Xiaoyao Li
On 2/20/2025 2:40 AM, Francesco Lavra wrote: On Fri, 2025-01-24 at 08:20 -0500, Xiaoyao Li wrote: diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 73f90b0a2217..8564b3ae905d 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -12,10 +12,14 @@  #include "

Re: [PATCH v7 16/52] i386/tdvf: Introduce function to parse TDVF metadata

2025-02-25 Thread Xiaoyao Li
On 2/19/2025 6:58 PM, Francesco Lavra wrote: On Fri, 2025-01-24 at 08:20 -0500, Xiaoyao Li wrote: +int tdvf_parse_metadata(TdxFirmware *fw, void *flash_ptr, int size) +{ +    g_autofree TdvfSectionEntry *sections = NULL; +    TdvfMetadata *metadata; +    ssize_t entries_size; +    int i

Re: [PATCH v7 08/52] i386/tdx: Initialize TDX before creating TD vcpus

2025-02-25 Thread Xiaoyao Li
On 2/19/2025 6:14 PM, Francesco Lavra wrote: On Fri, 2025-01-24 at 08:20 -0500, Xiaoyao Li wrote: diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 45867dbe0839..e35a9fbd687e 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -540,8 +540,15 @@ int kvm_init_vcpu(CPUState

Re: [PATCH v7 05/52] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES

2025-02-25 Thread Xiaoyao Li
On 2/19/2025 3:21 AM, Francesco Lavra wrote: On Fri, 24 Jan 2025 08:20:01 -0500, Xiaoyao Li wrote: diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 4ff94860815d..bd212abab865 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -10,17 +10,122 @@ */ #include

Re: [PATCH] physmem: replace assertion with error

2025-02-17 Thread Xiaoyao Li
6_64 -m 512 -nographic -object sev-snp-guest,reduced-phys-bits=48,id=sev0 \ -M q35,kernel-irqchip=split,confidential-guest-support=sev0 qemu-system-x86_64: ../system/physmem.c:1871: ram_block_add: Assertion `kvm_enabled()' failed. Cc: Xiaoyao Li Cc: qemu-sta...@nongnu.org Signed-o

Re: [PATCH v7 12/52] i386/tdx: Validate TD attributes

2025-02-05 Thread Xiaoyao Li
On 1/24/2025 9:20 PM, Xiaoyao Li wrote: Validate TD attributes with tdx_caps that only supported bits arer allowed by KVM. Besides, sanity check the attribute bits that have not been supported by QEMU yet. e.g., debug bit, it will be allowed in the future when debug TD support lands in QEMU

Re: [PATCH v7 48/52] i386/tdx: Fetch and validate CPUID of TD guest

2025-02-05 Thread Xiaoyao Li
On 2/5/2025 5:28 PM, Markus Armbruster wrote: Xiaoyao Li writes: Use KVM_TDX_GET_CPUID to get the CPUIDs that are managed and enfored by TDX module for TD guest. Check QEMU's configuration against the fetched data. Print wanring message when 1. a feature is not supported but request

Re: [PATCH v7 12/52] i386/tdx: Validate TD attributes

2025-02-05 Thread Xiaoyao Li
On 2/5/2025 5:06 PM, Markus Armbruster wrote: Xiaoyao Li writes: Validate TD attributes with tdx_caps that only supported bits arer allowed by KVM. Besides, sanity check the attribute bits that have not been supported by QEMU yet. e.g., debug bit, it will be allowed in the future when debug

Re: [PATCH v7 28/52] i386/tdx: Wire TDX_REPORT_FATAL_ERROR with GuestPanic facility

2025-02-05 Thread Xiaoyao Li
On 2/5/2025 5:19 PM, Markus Armbruster wrote: Xiaoyao Li writes: Integrate TDX's TDX_REPORT_FATAL_ERROR into QEMU GuestPanic facility Originated-from: Isaku Yamahata Signed-off-by: Xiaoyao Li --- Changes in v6: - change error_code of GuestPanicInformationTdx from uint64_t to uin

Re: [PATCH v7 51/52] i386/tdx: Validate phys_bits against host value

2025-02-02 Thread Xiaoyao Li
On 2/1/2025 2:27 AM, Paolo Bonzini wrote: On Fri, Jan 24, 2025 at 2:40 PM Xiaoyao Li wrote: For TDX guest, the phys_bits is not configurable and can only be host/native value. Validate phys_bits inside tdx_check_features(). Hi Xiaoyao, to avoid qemu-kvm: TDX requires guest CPU physical

[PATCH v7 44/52] i386/cpu: Move CPUID_XSTATE_XSS_MASK to header file and introduce CPUID_XSTATE_MASK

2025-01-24 Thread Xiaoyao Li
They will be used by TDX. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 3 --- target/i386/cpu.h | 5 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4088bf63c48f..f1330627adbb 100644 --- a/target/i386/cpu.c +++ b/target/i386

  1   2   3   4   5   6   7   8   9   10   >