[PATCH v2 42/58] i386/tdx: register the fd read callback with the main loop to read the quote data

2023-08-18 Thread Xiaoyao Li
the server returns. Set the io channel non-blocking and register the socket fd with the main loop. Move the read operation into the callback. When the fd is readable, inovke the callback to handle the quote data. Signed-off-by: Chenyi Qiang Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c

[PATCH v2 52/58] hw/i386: add eoi_intercept_unsupported member to X86MachineState

2023-08-18 Thread Xiaoyao Li
. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- hw/i386/x86.c | 1 + include/hw/i386/x86.h | 1 + target/i386/kvm/tdx.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index a0c9f4d646e2..567384484244 100644 --- a/hw/i386/x86.c +++ b/hw/i386

[PATCH v2 58/58] docs: Add TDX documentation

2023-08-18 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 since v1: - Add prerequisite of private gmem; - update example command to launch TD; Changes since RFC v4: - add the restriction that kernel-irqchip must be

[PATCH v2 48/58] i386/tdx: Disable SMM for TDX VMs

2023-08-18 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 | 8 1 file

[PATCH v2 57/58] i386/tdx: Don't get/put guest state for TDX VMs

2023-08-18 Thread Xiaoyao Li
Sean Christopherson Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/kvm.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index d542351983cd..1422c79aca40 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/

[PATCH v2 45/58] i386/tdx: Limit the range size for MapGPA

2023-08-18 Thread Xiaoyao Li
igned-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 0c43c1f7759f..ced55be506d1 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -994,12 +9

[PATCH v2 40/58] i386/tdx: handle TDG.VP.VMCALL

2023-08-18 Thread Xiaoyao Li
: Xiaoyao Li --- target/i386/kvm/kvm.c | 9 ++ target/i386/kvm/tdx-stub.c | 4 +++ target/i386/kvm/tdx.c | 61 ++ target/i386/kvm/tdx.h | 6 4 files changed, 80 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index

[PATCH v2 51/58] i386/tdx: LMCE is not supported for TDX

2023-08-18 Thread Xiaoyao Li
LMCE is not supported TDX since KVM doesn't provide emulation for MSR_IA32_FEAT_CTL. Signed-off-by: Xiaoyao Li --- target/i386/kvm/kvm-cpu.c | 5 + 1 file changed, 5 insertions(+) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 7237378a7d4e..bec8b5f918e7 1

[PATCH v2 41/58] i386/tdx: handle TDG.VP.VMCALL

2023-08-18 Thread Xiaoyao Li
mmand line example: qemu-system-x86_64 \ -object 'tdx-guest,id=tdx0,quote-generation-service=localhost:1234' \ -machine confidential-guest-support=tdx0 Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- qapi/qom.json | 5 +- target/i386/kvm/tdx.c | 380 +

[PATCH v2 37/58] i386/tdx: register TDVF as private memory

2023-08-18 Thread Xiaoyao Li
From: Chao Peng Allocate private gmem memory for BIOS if it's TD VM. Signed-off-by: Chao Peng Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li --- hw/i386/x86.c | 9 - target/i386/kvm/tdx.c | 17 + target/i386/kvm/tdx.h | 2 ++ 3 files change

[PATCH v2 54/58] i386/tdx: Don't synchronize guest tsc for TDs

2023-08-18 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 v2 46/58] i386/tdx: Handle TDG.VP.VMCALL

2023-08-18 Thread Xiaoyao Li
Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 40 1 file changed, 40 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index ced55be506d1..f111b46dac92 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c

[PATCH v2 49/58] i386/tdx: Disable PIC for TDX VMs

2023-08-18 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 f9d03ab0f461..23ecd84a9e21 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i38

[PATCH v2 39/58] i386/tdx: Finalize TDX VM

2023-08-18 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 | 7 +++ 1 file changed, 7 insertions(+) diff --git a/target/i386/kvm/td

[PATCH v2 38/58] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu

2023-08-18 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 v2 53/58] hw/i386: add option to forcibly report edge trigger in acpi tables

2023-08-18 Thread Xiaoyao Li
From: Isaku Yamahata When level trigger isn't supported on x86 platform, forcibly report edge trigger in acpi tables. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- hw/i386/acpi-build.c | 99 --- hw/i386

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

2023-08-18 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 v2 20/58] i386/tdx: Allows mrconfigid/mrowner/mrownerconfig for TDX_INIT_VM

2023-08-18 Thread Xiaoyao Li
onfig=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- TODO: - community requests to use base64 encoding if no special reason --- qapi/qom.json | 11 ++- target/i386/kvm/tdx.c

[PATCH v2 29/58] i386/tdx: Skip BIOS shadowing setup

2023-08-18 Thread Xiaoyao Li
TDX doesn't support map different GPAs to same private memory. Thus, aliasing top 128KB of BIOS as isa-bios is not supported. On the other hand, TDX guest cannot go to real mode, it can work fine without isa-bios. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- Changes from R

[PATCH v2 31/58] i386/tdx: Track mem_ptr for each firmware entry of TDVF

2023-08-18 Thread Xiaoyao Li
do the stuff. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- hw/i386/tdvf.c | 1 + include/hw/i386/tdvf.h | 7 +++ target/i386/kvm/tdx.c | 31 +++ 3 files changed, 39 insertions(+) diff --git a/hw/i386/tdvf.c b/hw/i386/tdvf.c index ff51f40088f0

[PATCH v2 05/58] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context

2023-08-18 Thread Xiaoyao Li
Introduce tdx_kvm_init() and invoke it in kvm_confidential_guest_init() if it's a TDX VM. More initialization will be added later. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/kvm.c | 15 ++- target/i386/kvm/meson.build | 2 +- target/i386/kv

[PATCH v2 23/58] i386/tdx: Make memory type private by default

2023-08-18 Thread Xiaoyao Li
iolation Originated-from: Isaku Yamahata Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index 8a2491ed03c2..775110f8bd02 100644 --- a/target/i386/kvm/tdx.c +++ b/target/

[PATCH v2 36/58] memory: Introduce memory_region_init_ram_gmem()

2023-08-18 Thread Xiaoyao Li
Introduce memory_region_init_ram_gmem() to allocate private gmem on the MemoryRegion initialization. It's for the usercase of TDVF, which must be private on TDX case. Signed-off-by: Xiaoyao Li --- include/exec/memory.h | 6 + softmmu/memory.c

[PATCH v2 24/58] i386/tdx: Create kvm gmem for TD

2023-08-18 Thread Xiaoyao Li
From: Isaku Yamahata Allocate private gmem for TD guest, if the MemoryRegion is memory backend and has private property on. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 27 +-- 1 file changed, 25 insertions(+), 2 deletions

[PATCH v2 18/58] i386/tdx: Validate TD attributes

2023-08-18 Thread Xiaoyao Li
Validate TD attributes with tdx_caps that fixed-0 bits must be zero and fixed-1 bits must be set. 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

[PATCH v2 33/58] headers: Add definitions from UEFI spec for volumes, resources, etc...

2023-08-18 Thread Xiaoyao Li
, EFI_RESOURCE_MEMORY_UNACCEPTED will be added in future UEFI spec. [1] https://software.intel.com/content/dam/develop/external/us/en/documents/tdx-virtual-firmware-design-guide-rev-1.pdf Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- include/standard-headers/uefi/uefi.h | 198 +++ 1 file

[PATCH v2 30/58] i386/tdx: Don't initialize pc.rom for TDX VMs

2023-08-18 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 v2 34/58] i386/tdx: Setup the TD HOB list

2023-08-18 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 from RFC v4: - drop the code of adding mmio resources since OVMF prepares all the MMIO hob itself. --- hw/i386/meson.build

[PATCH v2 35/58] i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION

2023-08-18 Thread Xiaoyao Li
From: Isaku Yamahata TDVF firmware (CODE and VARS) needs to be added/copied to TD's private memory via KVM_TDX_INIT_MEM_REGION, as well as TD HOB and TEMP memory. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- Changes from RFC v4: - rename var

[PATCH v2 25/58] kvm/tdx: Don't complain when converting vMMIO region to shared

2023-08-18 Thread Xiaoyao Li
From: Isaku Yamahata Because vMMIO region needs to be shared region, guest TD may explicitly convert such region from private to shared. Don't complain such conversion. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- accel/kvm/kvm-all.c | 20 ++-- 1 file ch

[PATCH v2 32/58] i386/tdx: Track RAM entries for TDX VM

2023-08-18 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 from RFC v4: - simplify the algorithm of tdx_accept

[PATCH v2 27/58] i386/tdvf: Introduce function to parse TDVF metadata

2023-08-18 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 v2 13/58] kvm: Introduce kvm_arch_pre_create_vcpu()

2023-08-18 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. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- accel/kvm/kvm-all.c | 12 include/sysemu/kvm.h

[PATCH v2 28/58] i386/tdx: Parse TDVF metadata for TDX VM

2023-08-18 Thread Xiaoyao Li
TDX cannot support pflash device since it doesn't support read-only memslot and doesn't support emulation. Load TDVF(OVMF) with -bios option for TDs. When boot a TD, besides load TDVF to the address below 4G, it needs parse TDVF metadata. Signed-off-by: Xiaoyao Li Acked-by: Ger

[PATCH v2 17/58] i386/tdx: Wire CPU features up with attributes of TD guest

2023-08-18 Thread Xiaoyao Li
For QEMU VMs, PKS is configured via CPUID_7_0_ECX_PKS and PMU is configured by x86cpu->enable_pmu. Reuse the existing configuration interface for TDX VMs. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/tdx.c | 14 +- 1 file changed, 13 insertions(+)

[PATCH v2 08/58] i386/tdx: Adjust the supported CPUID based on TDX restrictions

2023-08-18 Thread Xiaoyao Li
urable bits (it covers the other part of type #1); - fix the ones in vmm_fixup; - filter the one has valid .supported field; (Calculated type is ignored since it's determined at runtime). Co-developed-by: Chenyi Qiang Signed-off-by: Chenyi Qiang Signed-off-by: Xiaoyao Li --- target/i3

[PATCH v2 04/58] target/i386: Introduce kvm_confidential_guest_init()

2023-08-18 Thread Xiaoyao Li
Introduce a separate function kvm_confidential_guest_init() for SEV (and future TDX). Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/kvm.c | 11 ++- target/i386/sev.c | 1 - target/i386/sev.h | 2 ++ 3 files changed, 12 insertions(+), 2 deletions

[PATCH v2 26/58] kvm/tdx: Ignore memory conversion to shared of unassigned region

2023-08-18 Thread Xiaoyao Li
MMIO. Ignore memory conversion request of non-assigned region to shared and return success. Otherwise OVMF is confused and panics there. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- accel/kvm/kvm-all.c | 12 1 file changed, 12 insertions(+) diff --git a/accel/kvm/k

[PATCH v2 22/58] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM

2023-08-18 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 v2 21/58] i386/tdx: Implement user specified tsc frequency

2023-08-18 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 v2 19/58] qom: implement property helper for sha384

2023-08-18 Thread Xiaoyao Li
From: Isaku Yamahata Implement property_add_sha384() which converts hex string <-> uint8_t[48] It will be used for TDX which uses sha384 for measurement. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- include/qom/object.h | 17 ++ qom/object.c

[PATCH v2 12/58] i386/kvm: Move architectural CPUID leaf generation to separate helper

2023-08-18 Thread Xiaoyao Li
From: Sean Christopherson Move the architectural (for lack of a better term) CPUID leaf generation to a separate helper so that the generation code can be reused by TDX, which needs to generate a canonical VM-scoped configuration. Signed-off-by: Sean Christopherson Signed-off-by: Xiaoyao Li

[PATCH v2 15/58] i386/tdx: Add property sept-ve-disable for tdx-guest object

2023-08-18 Thread Xiaoyao Li
configure this bit. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- 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 2ca7ce7c0da5..cc08b9a98df9 100644

[PATCH v2 06/58] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES

2023-08-18 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 different scope (KVM, VM and VCPU) in preparation. Signed-off-by: Xiaoyao Li --- changes from v1: - Make the error mes

[PATCH v2 16/58] i386/tdx: Make sept_ve_disable set by default

2023-08-18 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 --- target/i386/kvm/tdx.c | 2 +- 1 file

[PATCH v2 09/58] i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by tdx_caps.cpuid_config[]

2023-08-18 Thread Xiaoyao Li
ds by removing the bits that reported from TDX module as configurable. This can adapt with the updated TDX (module) automatically. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i38

[PATCH v2 14/58] i386/tdx: Initialize TDX before creating TD vcpus

2023-08-18 Thread Xiaoyao Li
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 --- accel/kvm/kvm-all.c| 9 +++- target/i386/kvm/kvm.c | 8 +++ target

[PATCH v2 10/58] i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookup

2023-08-18 Thread Xiaoyao Li
KVM requires userspace to pass XFAM configuration via CPUID 0xD leaves. Convert tdx_caps->xfam_fixed0/1 into corresponding tdx_cpuid_lookup[].tdx_fixed0/1 field of CPUID 0xD leaves. Thus the requirement can be applied naturally. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c |

[PATCH v2 11/58] i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookup

2023-08-18 Thread Xiaoyao Li
Some bits in TD attributes have corresponding CPUID feature bits. Reflect the fixed0/1 restriction on TD attributes to their corresponding CPUID bits in tdx_cpuid_lookup[] as well. Signed-off-by: Xiaoyao Li --- target/i386/cpu-internal.h | 9 + target/i386/cpu.c | 9

[PATCH v2 03/58] target/i386: Parse TDX vm type

2023-08-18 Thread Xiaoyao Li
: Xiaoyao Li --- target/i386/kvm/kvm.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 62f237068a3a..77f4772afe6c 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -32,6 +32,7 @@ #include "s

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

2023-08-18 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 v2 07/58] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object

2023-08-18 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 --- target/i386/kvm/tdx.c | 13 +

[PATCH v2 02/58] i386: Introduce tdx-guest object

2023-08-18 Thread Xiaoyao Li
0 and not configurable so far. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- changes from RFC-V4 - make @attributes not user-settable --- configs/devices/i386-softmmu/default.mak | 1 + hw/i386/Kconfig | 5 +++ qapi/qom.json| 12 +++ t

[PATCH v2 00/58] TDX QEMU support

2023-08-18 Thread Xiaoyao Li
e helper i386/tdx: Don't get/put guest state for TDX VMs Xiaoyao Li (39): *** HACK *** linux-headers: Update headers to pull in TDX API changes i386: Introduce tdx-guest object target/i386: Parse TDX vm type target/i386: Introduce kvm_confidential_guest_init() i386/tdx: Implemen

Re: [PATCH 2/2] vhost: Add Error parameter to vhost_scsi_common_start()

2023-08-16 Thread Li Feng
> 2023年8月14日 下午8:11,Raphael Norwitz 写道: > > Thanks for the cleanup! A few comments. > >> On Aug 4, 2023, at 1:29 AM, Li Feng wrote: >> >> Add a Error parameter to report the real error, like vhost-user-blk. >> >> Signed-off-by: Li Feng >> -

Re: [PATCH 1/2] vhost-user: fix lost reconnect

2023-08-16 Thread Li Feng
{ /* @started: is the vhost device started? */ bool started; bool log_enabled; +bool inited; uint64_t log_size; Error *migration_blocker; const VhostOps *vhost_ops; Thanks. > >> On Aug 4, 2023, at 1:29 AM, Li Feng wrote: >> >> When the vhost

Re: [PATCH v3 2/2] target/i386: Avoid overflow of the cache parameter enumerated by leaf 4

2023-08-16 Thread Xiaoyao Li
reports 0x3f when the intel processor has over 64 cores, limit the max value written to EBX[31:26] to 63, so max num_cores should be 64. Signed-off-by: Qian Wen Reviewed-by: Zhao Liu Reviewed-by: Xiaoyao Li --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

Re: [PATCH v3 1/2] target/i386: Avoid cpu number overflow in legacy topology

2023-08-16 Thread Xiaoyao Li
by overflow, limit the max value written to EBX[23:16] to 255 as the HW does. Signed-off-by: Qian Wen Reviewed-by: Zhao Liu Reviewed-by: Xiaoyao Li --- target/i386/cpu.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 97ad229

[PATCH v2] target/riscv: Update CSR bits name for svadu extension

2023-08-16 Thread Weiwei Li
The Svadu specification updated the name of the *envcfg bit from HADE to ADUE. Signed-off-by: Weiwei Li Signed-off-by: Junqiang Wang --- v2: * rename hade variable name to adue suggested by Daniel target/riscv/cpu.c| 4 ++-- target/riscv/cpu_bits.h | 8 target/riscv

Re: [PATCH v2 0/4] Add full zoned storage emulation to qcow2 driver

2023-08-16 Thread Sam Li
Klaus Jensen 于2023年8月16日周三 15:37写道: > > On Aug 14 16:57, Sam Li wrote: > > This patch series add a new extension - zoned format - to the > > qcow2 driver thereby allowing full zoned storage emulation on > > the qcow2 img file. Users can attach such a qcow2 file to the >

[RFC 4/5] hw/nvme: refactor zone append writes using block layer APIs

2023-08-16 Thread Sam Li
Signed-off-by: Sam Li --- block/block-backend.c | 8 ++ block/qcow2.c | 7 +- hw/nvme/ctrl.c| 195 ++ include/sysemu/block-backend-io.h | 1 + include/sysemu/dma.h | 3 + softmmu/dma-helpers.c

[RFC 5/5] hw/nvme: make ZDED persistent

2023-08-16 Thread Sam Li
attributes at the following eight bit of zoned bit of write pointers for each zone. The ZDED is stored as part of zoned metadata as write pointers. Signed-off-by: Sam Li --- block/qcow2.c| 44 +++- hw/nvme/ctrl.c | 6 + include

[RFC 3/5] hw/nvme: make the metadata of ZNS emulation persistent

2023-08-15 Thread Sam Li
zone state transition and manage zone resources. Signed-off-by: Sam Li --- block/block-backend.c | 15 + block/qcow2.c |3 + hw/nvme/ctrl.c| 1114 ++--- hw/nvme/ns.c | 77 +- hw/nvme/nvme.h

[RFC 2/5] qcow2: add zone device metadata with zd_extension

2023-08-15 Thread Sam Li
Zone descriptor data is host definied data that is associated with each zone. Add zone descriptor extensions to zonedmeta and blk_get_zone_extension to access zd_extensions. Signed-off-by: Sam Li --- block/block-backend.c | 15 ++ block/qcow2.c | 86

[RFC 1/5] hw/nvme: use blk_get_*() to access zone info in the block layer

2023-08-15 Thread Sam Li
The zone information is contained in the BlockLimits fileds. Add blk_get_*() functions to access the block layer and update zone info accessing in the NVMe device emulation. Signed-off-by: Sam Li --- block/block-backend.c | 56 block/qcow2.c

[RFC 0/5] Add persistence to NVMe ZNS emulation

2023-08-15 Thread Sam Li
command line of QEMU, use: -drive file=${znsimg},id=nvmezns0,format=qcow2,if=none \ -device nvme-ns,drive=nvmezns0,bus=nvme0,nsid=1,uuid=xxx \ Sam Li (5): hw/nvme: use blk_get_*() to access zone info in the block layer qcow2: add zone device metadata with zd_extension hw/nvme: make the

Re: [PATCH v2] target/i386: Export GDS_NO bit to guests

2023-08-14 Thread Xiaoyao Li
: https://lore.kernel.org/qemu-devel/camgffemg6tnq0n3+4ojagxc8j0oevy60khzekxcbs3lok9v...@mail.gmail.com/ Reported-by: Jack Wang Signed-off-by: Pawan Gupta Tested-by: Jack Wang Tested-by: Daniel Sneddon Reviewed-by: Xiaoyao Li --- v2: Added commit tags v1: https://lore.kernel.org/qemu-devel

[PATCH] target/riscv: Update CSR bits name for svadu extension

2023-08-14 Thread Weiwei Li
The Svadu specification updated the name of the *envcfg bit from HADE to ADUE. Signed-off-by: Weiwei Li Signed-off-by: Junqiang Wang --- target/riscv/cpu.c| 4 ++-- target/riscv/cpu_bits.h | 8 target/riscv/cpu_helper.c | 4 ++-- target/riscv/csr.c| 12

[PATCH v2 4/4] iotests: test the zoned format feature for qcow2 file

2023-08-14 Thread Sam Li
The zoned format feature can be tested by: $ tests/qemu-iotests/check zoned-qcow2 Signed-off-by: Sam Li --- tests/qemu-iotests/tests/zoned-qcow2 | 135 ++ tests/qemu-iotests/tests/zoned-qcow2.out | 140 +++ 2 files changed, 275 insertions(+) create

[PATCH v2 0/4] Add full zoned storage emulation to qcow2 driver

2023-08-14 Thread Sam Li
use bitwise or than addition * fix wp index overflow and locking * cleanups: comments, naming Sam Li (4): docs/qcow2: add the zoned format feature qcow2: add configurations for zoned format extension qcow2: add zoned emulation capability iotests: test the zoned format feature for qcow2 f

[PATCH v2 1/4] docs/qcow2: add the zoned format feature

2023-08-14 Thread Sam Li
a ZNS drive. Signed-off-by: Sam Li --- docs/system/qemu-block-drivers.rst.inc | 39 ++ 1 file changed, 39 insertions(+) diff --git a/docs/system/qemu-block-drivers.rst.inc b/docs/system/qemu-block-drivers.rst.inc index 105cb9679c..2c1620668f 100644 --- a/docs/system

[PATCH v2 3/4] qcow2: add zoned emulation capability

2023-08-14 Thread Sam Li
corresponding state changing. Zoned devices have a limit on zone resources, which puts constraints on write operations into zones. Signed-off-by: Sam Li --- block/qcow2.c | 676 - block/qcow2.h | 2 + docs/interop/qcow2.txt | 2 + 3

[PATCH v2 2/4] qcow2: add configurations for zoned format extension

2023-08-14 Thread Sam Li
=0 -o zoned_profile=zbc/zns Signed-off-by: Sam Li --- block/qcow2.c| 125 +++ block/qcow2.h| 21 ++ docs/interop/qcow2.txt | 24 ++ include/block/block-common.h | 5 ++ include/block/block_int-common.h

[PATCH] roms: Support compile the efi bios for loongarch

2023-08-10 Thread xianglai li
. Berrangé" Cc: Thomas Huth Cc: "Philippe Mathieu-Daudé" Cc: Gerd Hoffmann Cc: Xiaojuan Yang Cc: Song Gao Cc: Bibo Mao Signed-off-by: xianglai li --- .gitmodules| 3 +++ meson.build| 2 +- pc-bios/meson.build| 2 ++ roms/edk2-build.config | 14

Re: [PATCH v3 03/17] softmmu: Fix CPUSTATE.nr_cores' calculation

2023-08-07 Thread Xiaoyao Li
On 8/7/2023 6:00 PM, Zhao Liu wrote: Hi Xiaoyao, On Mon, Aug 07, 2023 at 04:43:32PM +0800, Xiaoyao Li wrote: Date: Mon, 7 Aug 2023 16:43:32 +0800 From: Xiaoyao Li Subject: Re: [PATCH v3 03/17] softmmu: Fix CPUSTATE.nr_cores' calculation On 8/7/2023 3:53 PM, Zhao Liu wrote: diff --

Re: [PATCH v3 03/17] softmmu: Fix CPUSTATE.nr_cores' calculation

2023-08-07 Thread Xiaoyao Li
On 8/7/2023 3:53 PM, Zhao Liu wrote: diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 97ad229d8ba3..50613cd04612 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6011,7 +6011,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, X86CPUTopoInfo topo_in

Re: [PATCH v3 05/17] i386/cpu: Use APIC ID offset to encode cache topo in CPUID[4]

2023-08-07 Thread Xiaoyao Li
On 8/1/2023 6:35 PM, Zhao Liu wrote: From: Zhao Liu Refer to the fixes of cache_info_passthrough ([1], [2]) and SDM, the CPUID.04H:EAX[bits 25:14] and CPUID.04H:EAX[bits 31:26] should use the nearest power-of-2 integer. I doubt it. Especially for [1]. SDM doesn't state it should be the neare

Re: [PATCH] target/i386: Avoid cpu number overflow in legacy topology

2023-08-07 Thread Xiaoyao Li
On 7/28/2023 4:01 PM, Qian Wen wrote: The legacy topology enumerated by CPUID.1.EBX[23:16] is defined in SDM Vol2: Bits 23-16: Maximum number of addressable IDs for logical processors in this physical package. To avoid data overflow, limit the max value written to EBX[23:16] to 255. It's bett

Re: [PATCH v3 03/17] softmmu: Fix CPUSTATE.nr_cores' calculation

2023-08-07 Thread Xiaoyao Li
On 8/1/2023 6:35 PM, Zhao Liu wrote: From: Zhuocheng Ding From CPUState.nr_cores' comment, it represents "number of cores within this CPU package". After 003f230e37d7 ("machine: Tweak the order of topology members in struct CpuTopology"), the meaning of smp.cores changed to "the number of cor

Re: [PATCH v3 01/17] i386: Fix comment style in topology.h

2023-08-06 Thread Xiaoyao Li
in Reviewed-by: Xiaoyao Li

Re: [PATCH v3 04/17] i386/cpu: Fix i/d-cache topology to core level for Intel CPU

2023-08-04 Thread Xiaoyao Li
lying on QEMU's default topology structure. Fixes: 7e3482f82480 ("i386: Helpers to encode cache information consistently") Suggested-by: Robert Hoo Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li --- Changes since v1: * Split this fix from the patch named "i386/cpu: F

[PATCH 0/2] Fix vhost reconnect issues

2023-08-03 Thread Li Feng
smartx.com/ Li Feng (2): vhost-user: fix lost reconnect vhost: Add Error parameter to vhost_scsi_common_start() hw/scsi/vhost-scsi-common.c | 17 ++--- hw/scsi/vhost-scsi.c | 5 +++-- hw/scsi/vhost-user-scsi.c | 14 -- hw/vi

[PATCH 2/2] vhost: Add Error parameter to vhost_scsi_common_start()

2023-08-03 Thread Li Feng
Add a Error parameter to report the real error, like vhost-user-blk. Signed-off-by: Li Feng --- hw/scsi/vhost-scsi-common.c | 17 ++--- hw/scsi/vhost-scsi.c | 5 +++-- hw/scsi/vhost-user-scsi.c | 14 -- include/hw/virtio/vhost-scsi

[PATCH 1/2] vhost-user: fix lost reconnect

2023-08-03 Thread Li Feng
user-blk/scsi. Fixes: 71e076a07d ("hw/virtio: generalise CHR_EVENT_CLOSED handling") Signed-off-by: Li Feng --- hw/virtio/vhost-user.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 8dcf049d42..697b403fe2 1006

Re: [RFC PATCH 05/19] kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot

2023-08-03 Thread Xiaoyao Li
On 8/2/2023 1:10 AM, Claudio Fontana wrote: On 7/31/23 18:21, Xiaoyao Li wrote: From: Chao Peng Switch to KVM_SET_USER_MEMORY_REGION2 when supported by KVM. With KVM_SET_USER_MEMORY_REGION2, QEMU can set up memory region that backen'ed both by hva-based shared memory and gmem fd

Re: [RFC PATCH 04/19] memory: Introduce memory_region_can_be_private()

2023-08-02 Thread Xiaoyao Li
On 8/2/2023 12:52 AM, Claudio Fontana wrote: On 8/1/23 18:48, Claudio Fontana wrote: On 7/31/23 18:21, Xiaoyao Li wrote: Signed-off-by: Xiaoyao Li --- include/exec/memory.h | 9 + softmmu/memory.c | 5 + 2 files changed, 14 insertions(+) diff --git a/include/exec

Re: [RFC PATCH 08/19] HostMem: Add private property to indicate to use kvm gmem

2023-08-02 Thread Xiaoyao Li
On 8/1/2023 10:57 PM, Daniel P. Berrangé wrote: On Mon, Jul 31, 2023 at 07:22:05PM +0200, Markus Armbruster wrote: Xiaoyao Li writes: From: Isaku Yamahata Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li [...] diff --git a/qapi/qom.json b/qapi/qom.json index 7f92ea43e8e1

Re: [RFC PATCH 08/19] HostMem: Add private property to indicate to use kvm gmem

2023-08-02 Thread Xiaoyao Li
On 8/2/2023 1:21 AM, David Hildenbrand wrote: On 31.07.23 18:21, Xiaoyao Li wrote: From: Isaku Yamahata Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li ---   backends/hostmem.c   | 18 ++   include/sysemu/hostmem.h |  2 +-   qapi/qom.json    |  4   3

Re: [RFC PATCH 08/19] HostMem: Add private property to indicate to use kvm gmem

2023-08-01 Thread Xiaoyao Li
On 8/1/2023 1:22 AM, Markus Armbruster wrote: Xiaoyao Li writes: From: Isaku Yamahata Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li [...] diff --git a/qapi/qom.json b/qapi/qom.json index 7f92ea43e8e1..e0b2044e3d20 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -605,6

Re: [RFC PATCH 00/19] QEMU gmem implemention

2023-07-31 Thread Xiaoyao Li
On 8/1/2023 1:10 AM, Isaku Yamahata wrote: On Mon, Jul 31, 2023 at 12:21:42PM -0400, Xiaoyao Li wrote: This is the first RFC version of enabling KVM gmem[1] as the backend for private memory of KVM_X86_PROTECTED_VM. It adds the support to create a specific KVM_X86_PROTECTED_VM type VM, and

Re: [RFC PATCH 00/19] QEMU gmem implemention

2023-07-31 Thread Xiaoyao Li
On 8/1/2023 12:51 AM, Daniel P. Berrangé wrote: On Mon, Jul 31, 2023 at 12:21:42PM -0400, Xiaoyao Li wrote: This is the first RFC version of enabling KVM gmem[1] as the backend for private memory of KVM_X86_PROTECTED_VM. It adds the support to create a specific KVM_X86_PROTECTED_VM type VM

[RFC PATCH 08/19] HostMem: Add private property to indicate to use kvm gmem

2023-07-31 Thread Xiaoyao Li
From: Isaku Yamahata Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- backends/hostmem.c | 18 ++ include/sysemu/hostmem.h | 2 +- qapi/qom.json| 4 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/backends/hostmem.c b/backends

[RFC PATCH 09/19] i386/kvm: Create gmem fd for KVM_X86_SW_PROTECTED_VM

2023-07-31 Thread Xiaoyao Li
Register a memory listener for KVM_X86_SW_PROVTED_VM. It creates gmem for the backend who sets the private property. Signed-off-by: Xiaoyao Li --- include/exec/memory.h | 1 + target/i386/kvm/kvm.c | 38 ++ 2 files changed, 39 insertions(+) diff --git a

[RFC PATCH 17/19] pci-host/q35: Move PAM initialization above SMRAM initialization

2023-07-31 Thread Xiaoyao Li
From: Isaku Yamahata In mch_realize(), process PAM initialization before SMRAM initialization so that later patch can skill all the SMRAM related with a single check. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- hw/pci-host/q35.c | 19 ++- 1 file changed, 10

[RFC PATCH 16/19] trace/kvm: Add trace for page convertion between shared and private

2023-07-31 Thread Xiaoyao Li
From: Isaku Yamahata Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- accel/kvm/kvm-all.c| 1 + accel/kvm/trace-events | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 72d50b923bf2..c9f3aab5e587 100644 --- a

[RFC PATCH 13/19] physmem: replace function name with __func__ in ram_block_discard_range()

2023-07-31 Thread Xiaoyao Li
Signed-off-by: Xiaoyao Li --- softmmu/physmem.c | 34 +++--- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 8f64128de0b5..05c981e5c18e 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -3430,16

[RFC PATCH 18/19] q35: Introduce smm_ranges property for q35-pci-host

2023-07-31 Thread Xiaoyao Li
stopherson Signed-off-by: Sean Christopherson Signed-off-by: Xiaoyao Li --- hw/i386/pc_q35.c | 3 ++- hw/pci-host/q35.c | 42 +++ include/hw/i386/pc.h | 1 + include/hw/pci-host/q35.h | 1 + 4 files changed, 33 insertions(+), 14

[RFC PATCH 15/19] kvm: handle KVM_EXIT_MEMORY_FAULT

2023-07-31 Thread Xiaoyao Li
only when the RAMBlock has gmem memory backend. Signed-off-by: Chao Peng Signed-off-by: Xiaoyao Li --- accel/kvm/kvm-all.c | 52 + 1 file changed, 52 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f9b5050b8885..72d50b923bf2

[RFC PATCH 14/19] physmem: Add ram_block_convert_range

2023-07-31 Thread Xiaoyao Li
From: Chao Peng This new routine adds support for memory conversion between shared/private memory for gmem fd based private ram_block. Signed-off-by: Chao Peng Signed-off-by: Xiaoyao Li --- include/exec/cpu-common.h | 2 ++ softmmu/physmem.c | 61

[RFC PATCH 07/19] target/i386: Implement mc->kvm_type() to get VM type

2023-07-31 Thread Xiaoyao Li
Implement mc->kvm_type() for i386 machines. It provides a way for user to create SW_PROTECTE_VM. Signed-off-by: Xiaoyao Li --- hw/i386/x86.c | 27 +++ include/hw/i386/x86.h | 4 target/i386/kvm/kvm.c |

<    5   6   7   8   9   10   11   12   13   14   >