RE: [PATCH v1 8/8] aspeed: Add an AST2700 eval board

2024-02-28 Thread Jamin Lin
> -Original Message- > From: Jamin Lin > Sent: Thursday, February 29, 2024 3:53 PM > To: Jamin Lin ; c...@kaod.org; > peter.mayd...@linaro.org; and...@codeconstruct.com.au; j...@jms.id.au; > qemu-...@nongnu.org; qemu-devel@nongnu.org > Cc: Troy Lee ; Yunlin Tang > > Subject: RE: [PATCH v1

RE: [PATCH v1 8/8] aspeed: Add an AST2700 eval board

2024-02-28 Thread Jamin Lin
> -Original Message- > From: Jamin Lin > Sent: Thursday, February 29, 2024 3:43 PM > To: c...@kaod.org; peter.mayd...@linaro.org; and...@codeconstruct.com.au; > j...@jms.id.au; qemu-...@nongnu.org; qemu-devel@nongnu.org > Cc: Troy Lee ; Jamin Lin > ; Yunlin Tang > Subject: [PATCH v1 8/8]

Re: [PATCH 05/19] smbios: get rid of smbios_smp_sockets global

2024-02-28 Thread Ani Sinha
> On 27-Feb-2024, at 21:17, Igor Mammedov wrote: > > it makes smbios_validate_table() independent from > smbios_smp_sockets global, which in turn lets > smbios_get_tables() avoid using not related legacy code. > Good cleanup! > Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha > --- >

[PATCH v1 1/8] aspeed/wdt: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 wdt controller is similiar to AST2600's wdt, but the AST2700 has 8 watchdogs, and they each have a 0x80 of registers. Introduce ast2700 object class and increse the number of regs(offset) of ast2700 model. Signed-off-by: Troy Lee Signed-off-by: Jamin Lin --- hw/watchdog/wdt_aspeed.c

[PATCH v1 2/8] aspeed/sli: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 SLI engine is designed to accelerate the throughput between cross-die connections. It have CPU_SLI at CPU die and IO_SLI at IO die. Introduce new ast2700_sli and ast2700_sliio class with instance_init and realize handlers. Signed-off-by: Troy Lee Signed-off-by: Jamin Lin --- hw/misc/as

[PATCH v1 5/8] aspeed/scu: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 have two SCU controllers which are SCU and SCUIO. Both SCU and SCUIO registers are not compatible previous SOCs , introduces new registers and adds ast2700 scu, sucio class init handler. The pclk divider selection of SCUIO is defined in SCUIO280[20:18] and the pclk divider selection of SCU

[PATCH v1 6/8] aspeed/intc: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 interrupt controller(INTC) provides hardware interrupt interfaces to interrupt of processors PSP, SSP and TSP. In INTC, each interrupt of INT 128 to INT136 combines 32 interrupts. Introduce a new aspeed_intc class with instance_init and realize handlers. QEMU supports ARM Generic Interrup

[PATCH v1 2/8] aspeed/sli: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 SLI engine is designed to accelerate the throughput between cross-die connections. It have CPU_SLI at CPU die and IO_SLI at IO die. Introduce new ast2700_sli and ast2700_sliio class with instance_init and realize handlers. Signed-off-by: Troy Lee Signed-off-by: Jamin Lin --- hw/misc/as

[PATCH v1 7/8] aspeed/soc: Add AST2700 support

2024-02-28 Thread Jamin Lin via
Initial definitions for a simple machine using an AST2700 SOC (Cortex-a35 CPU). AST2700 SOC and its interrupt controller are too complex to handle in the common Aspeed SoC framework. We introduce a new ast2700 class with instance_init and realize handlers. AST2700 is a 64 bits quad core cpus and

[PATCH v1 0/8] Add AST2700 support

2024-02-28 Thread Jamin Lin via
Changes from v1: The patch series supports WDT, SDMC, SMC, SCU, SLI and INTC for AST2700 SoC. Test steps: 1. Download openbmc image for AST2700 from https://github.com/AspeedTech-BMC/openbmc/releases/tag/v09.00 https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.00/ ast2700-de

[PATCH v1 3/8] aspeed/sdmc: Add AST2700 support

2024-02-28 Thread Jamin Lin via
The SDRAM memory controller(DRAMC) controls the access to external DDR4 and DDR5 SDRAM and power up to DDR4 and DDR5 PHY. The DRAM memory controller of AST2700 is not backward compatible to previous chips such AST2600, AST2500 and AST2400. Max memory is now 8GiB on the AST2700. Introduce new aspe

Re: [PATCH v2 06/21] migration: Add Error** argument to .save_setup() handler

2024-02-28 Thread Vladimir Sementsov-Ogievskiy
On 29.02.24 09:32, Markus Armbruster wrote: Cédric Le Goater writes: The purpose is to record a potential error in the migration stream if qemu_savevm_state_setup() fails. Most of the current .save_setup() handlers can be modified to use the Error argument instead of managing their own and cal

Re: [PATCH v9 18/21] hw/i386/pc: Support smp.modules for x86 PC machine

2024-02-28 Thread Zhao Liu
Hi Babu, > > DEF("smp", HAS_ARG, QEMU_OPTION_smp, > > "-smp > > [[cpus=]n][,maxcpus=maxcpus][,drawers=drawers][,books=books][,sockets=sockets]\n" Here the "drawers" and "books" are listed... > > -" > > [,dies=dies][,clusters=clusters][,cores=cores][,threads=threads]\n"

Re: ISO C90 compilation error

2024-02-28 Thread Thomas Huth
On 29/02/2024 08.03, Paz Offer wrote: Hi, I am trying to build my code with QEMU and getting compilation error according to the /ISO C90 /standard:   const size_t buf_size = 31;   char buffer[buf_size + 1];   error: ISO C90 forbids array ‘buffer’ whose size can’t be evaluated [-

Re: [PATCH v5 06/12] tests/plugin/mem: migrate to new per_vcpu API

2024-02-28 Thread Pierrick Bouvier
On 2/29/24 11:08 AM, Alex Bennée wrote: Pierrick Bouvier writes: On 2/29/24 2:08 AM, Alex Bennée wrote: Luc Michel writes: Hi Pierrick, My bad. Other plugins enable only inline when both are supplied, so I missed this here. I added an explicit error when user enable callback and inl

Re: [PATCH v5 06/12] tests/plugin/mem: migrate to new per_vcpu API

2024-02-28 Thread Alex Bennée
Pierrick Bouvier writes: > On 2/29/24 2:08 AM, Alex Bennée wrote: >> Luc Michel writes: >> >>> Hi Pierrick, >>> >> > > My bad. Other plugins enable only inline when both are supplied, so I > missed this here. > I added an explicit error when user enable callback and inline at the > same time

ISO C90 compilation error

2024-02-28 Thread Paz Offer
Hi, I am trying to build my code with QEMU and getting compilation error according to the ISO C90 standard:   const size_t buf_size = 31;   char buffer[buf_size + 1];   error: ISO C90 forbids array ‘buffer’ whose size can’t be evaluated [-Werror=vla] I noticed that the code builds

Re: [RFC 6/8] i386/cpu: Update cache topology with machine's configuration

2024-02-28 Thread Zhao Liu
Hi JeeHeng, > > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > > index d7cb0f1e49b4..4b5c551fe7f0 100644 > > --- a/target/i386/cpu.c > > +++ b/target/i386/cpu.c > > @@ -7582,6 +7582,27 @@ static void x86_cpu_realizefn(DeviceState *dev, > > Error **errp) > > > > #ifndef CONFIG_USER_ONLY >

[PATCH v1 6/8] aspeed/intc: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 interrupt controller(INTC) provides hardware interrupt interfaces to interrupt of processors PSP, SSP and TSP. In INTC, each interrupt of INT 128 to INT136 combines 32 interrupts. Introduce a new aspeed_intc class with instance_init and realize handlers. QEMU supports ARM Generic Interrup

[PATCH v1 5/8] aspeed/scu: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 have two SCU controllers which are SCU and SCUIO. Both SCU and SCUIO registers are not compatible previous SOCs , introduces new registers and adds ast2700 scu, sucio class init handler. The pclk divider selection of SCUIO is defined in SCUIO280[20:18] and the pclk divider selection of SCU

[PATCH v1 2/8] aspeed/sli: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 SLI engine is designed to accelerate the throughput between cross-die connections. It have CPU_SLI at CPU die and IO_SLI at IO die. Introduce new ast2700_sli and ast2700_sliio class with instance_init and realize handlers. Signed-off-by: Troy Lee Signed-off-by: Jamin Lin --- hw/misc/as

[PATCH v1 4/8] aspeed/smc: Add AST2700 support

2024-02-28 Thread Jamin Lin via
AST2700 fmc/spi controller's address decoding unit is 64KB and only bits [31:16] are used for decoding. Introduce seg_to_reg and reg_to_seg handlers for ast2700 fmc/spi controller. In addition, adds ast2700 fmc, spi0, spi1, and spi2 class init handler. AST2700 support the maximum dram size is 8GiB

[PATCH v5 39/65] i386/tdx: Skip BIOS shadowing setup

2024-02-28 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 in v1: - update co

[PATCH v5 40/65] i386/tdx: Don't initialize pc.rom for TDX VMs

2024-02-28 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 tdx_in

[PATCH v5 52/65] i386/tdx: Wire TDX_REPORT_FATAL_ERROR with GuestPanic facility

2024-02-28 Thread Xiaoyao Li
Integrate TDX's TDX_REPORT_FATAL_ERROR into QEMU GuestPanic facility Originated-from: Isaku Yamahata Signed-off-by: Xiaoyao Li --- Changes in v5: - mention additional error information in gpa when it presents; - refine the documentation; (Markus) Changes in v4: - refine the documentation; (Mark

[PATCH v5 32/65] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM

2024-02-28 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 --- t

Re: [RFC 4/8] hw/core: Add cache topology options in -smp

2024-02-28 Thread Zhao Liu
Hi JeeHeng, > > diff --git a/hw/core/machine.c b/hw/core/machine.c > > index 426f71770a84..cb5173927b0d 100644 > > --- a/hw/core/machine.c > > +++ b/hw/core/machine.c > > @@ -886,6 +886,10 @@ static void machine_get_smp(Object *obj, Visitor *v, > > const char *name, > > .has_cores = true

[PATCH v5 65/65] docs: Add TDX documentation

2024-02-28 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 v5: - Add TD attestation section and update the QEMU parameter; Changes since v1: - Add prerequisite of private gmem; - update example command to launch TD; Ch

[PATCH v5 28/65] i386/tdx: Disable pmu for TD guest

2024-02-28 Thread Xiaoyao Li
Current KVM doesn't support PMU for TD guest. It returns error if TD is created with PMU bit being set in attributes. Disable PMU for TD guest on QEMU side. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i

[PATCH v5 34/65] kvm/tdx: Ignore memory conversion to shared of unassigned region

2024-02-28 Thread Xiaoyao Li
From: Isaku Yamahata TDX requires vMMIO region to be shared. For KVM, MMIO region is the region which kvm memslot isn't assigned to (except in-kernel emulation). qemu has the memory region for vMMIO at each device level. While OVMF issues MapGPA(to-shared) conservatively on 32bit PCI MMIO regio

[PATCH v5 29/65] i386/tdx: Validate TD attributes

2024-02-28 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 Ac

[PATCH v5 35/65] memory: Introduce memory_region_init_ram_guest_memfd()

2024-02-28 Thread Xiaoyao Li
Introduce memory_region_init_ram_guest_memfd() to allocate private guset memfd on the MemoryRegion initialization. It's for the use case of TDVF, which must be private on TDX case. Signed-off-by: Xiaoyao Li --- Changes in v5: - drop memory_region_set_default_private() because this function is d

[PATCH v5 06/65] kvm: Introduce support for memory_attributes

2024-02-28 Thread Xiaoyao Li
Introduce the helper functions to set the attributes of a range of memory to private or shared. This is necessary to notify KVM the private/shared attribute of each gpa range. KVM needs the information to decide the GPA needs to be mapped at hva-based shared memory or guest_memfd based private mem

[PATCH v5 30/65] i386/tdx: Support user configurable mrconfigid/mrowner/mrownerconfig

2024-02-28 Thread Xiaoyao Li
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://lore.kernel.org/qemu-devel/31d6dbc1-f453-4cef-ab08-4813f4e0f...@intel.com/ Allow user to specify those values via pro

[PATCH v5 51/65] i386/tdx: Handle TDG.VP.VMCALL

2024-02-28 Thread Xiaoyao Li
TD guest can use TDG.VP.VMCALL to request termination with error message encoded in GPRs. Parse and print the error message, and terminate the TD guest in the handler. Signed-off-by: Xiaoyao Li --- target/i386/kvm/tdx.c | 39 +++ target/i386/kvm/tdx.h | 1 +

[PATCH v5 59/65] hw/i386: add eoi_intercept_unsupported member to X86MachineState

2024-02-28 Thread Xiaoyao Li
Add a new bool member, eoi_intercept_unsupported, to X86MachineState with default value false. Set true for TDX VM. Inability to intercept eoi causes impossibility to emulate level triggered interrupt to be re-injected when level is still kept active. which affects interrupt controller emulation.

[PATCH v3 0/1] Optimize Code

2024-02-28 Thread Dehan Meng
v2 -> v3 - Remove this declaration and make the function 'hexToIPAddress' as static. - Define 'IFNAMSIZ' from kernel instead of a hardcode - Remove 'GUEST_NETWORK_ROUTE_TYPE_LINUX' - Set flags 'has_xxx' for checking if a field exists or has a value set v1 -> v2 - Replace snprintf() to g_strdup_pri

[PATCH v5 18/65] i386/tdx: Make Intel-PT unsupported for TD guest

2024-02-28 Thread Xiaoyao Li
Due to the fact that Intel-PT virtualization support has been broken in QEMU since Sapphire Rapids generation[1], below warning is triggered when luanching TD guest: warning: host doesn't support requested feature: CPUID.07H:EBX.intel-pt [bit 25] Before Intel-pt is fixed in QEMU, just make Int

[PATCH v5 17/65] i386/tdx: Adjust the supported CPUID based on TDX restrictions

2024-02-28 Thread Xiaoyao Li
According to Chapter "CPUID Virtualization" in TDX module spec, CPUID bits of TD can be classified into 6 types: 1 | As configured | configurable by VMM, independent of native value; --

[PATCH v5 22/65] i386/kvm: Move architectural CPUID leaf generation to separate helper

2024-02-28 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 v3 1/1] qga/linux: Add new api 'guest-network-get-route'

2024-02-28 Thread Dehan Meng
The Route information of the Linux VM needs to be used by administrators and users when debugging network problems and troubleshooting. Signed-off-by: Dehan Meng --- qga/commands-posix.c | 81 qga/commands-win32.c | 6 qga/qapi-schema.json | 80

[PATCH v5 53/65] pci-host/q35: Move PAM initialization above SMRAM initialization

2024-02-28 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 ins

[PATCH v5 50/65] i386/tdx: handle TDG.VP.VMCALL hypercall

2024-02-28 Thread Xiaoyao Li
From: Isaku Yamahata MapGPA is a hypercall to convert GPA from/to private GPA to/from shared GPA. As the conversion function is already implemented as kvm_convert_memory, wire it to TDX hypercall exit. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- accel/kvm/kvm-all.c | 2 +-

[PATCH v5 55/65] i386/tdx: Disable SMM for TDX VMs

2024-02-28 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 changed, 8 insert

[PATCH v5 47/65] i386/tdx: Finalize TDX VM

2024-02-28 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/tdx.c b/targ

[PATCH v5 37/65] i386/tdvf: Introduce function to parse TDVF metadata

2024-02-28 Thread Xiaoyao Li
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 the TDX VM. A TDVF Metadata in TDVF image describes the structure of firmware. QEMU refers to it to setup memor

[PATCH v5 19/65] i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by tdx_caps.cpuid_config[]

2024-02-28 Thread Xiaoyao Li
tdx_cpuid_lookup[].tdx_fixed0/1 is QEMU maintained data which reflects TDX restrictions regrading what bits are fixed by TDX module. It's retrieved from TDX spec and static. However, TDX may evolve and change some fixed fields to configurable in the future. Update tdx_cpuid.lookup[].tdx_fixed0/1 f

[PATCH v5 63/65] i386/tdx: Skip kvm_put_apicbase() for TDs

2024-02-28 Thread Xiaoyao Li
KVM doesn't allow wirting to MSR_IA32_APICBASE for TDs. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/kvm.c | 5 + 1 file changed, 5 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index d23f94b77257..31aed1c9aae0 100644 --- a/target/i386/kv

[PATCH v5 24/65] i386/tdx: Initialize TDX before creating TD vcpus

2024-02-28 Thread Xiaoyao Li
Invoke KVM_TDX_INIT in kvm_arch_pre_create_vcpu() that KVM_TDX_INIT configures global TD configurations, e.g. the canonical CPUID config, and must be executed prior to creating vCPUs. Use kvm_x86_arch_cpuid() to setup the CPUID settings for TDX VM. Note, this doesn't address the fact that QEMU ma

[PATCH v5 46/65] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu

2024-02-28 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/kv

[PATCH v4] virtio-pci: correctly set virtio pci queue mem multiplier

2024-02-28 Thread Srujana Challa
Currently, virtio_pci_queue_mem_mult function always returns 4K when VIRTIO_PCI_FLAG_PAGE_PER_VQ is set. But this won't work for vhost vdpa when host has page size other than 4K. This patch introduces a new property(page-per-vdpa-vq) for vdpa use case to fix the same. Signed-off-by: Srujana Challa

[PATCH v5 33/65] kvm/tdx: Don't complain when converting vMMIO region to shared

2024-02-28 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 | 19 --- 1 file changed, 1

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

2024-02-28 Thread Xiaoyao Li
From: Isaku Yamahata Add property "quote-generation-socket" to tdx-guest, which is a property of type SocketAddress to specify Quote Generation Service(QGS). On request of GetQuote, it connects to the QGS socket, read request data from shared guest memory, send the request data to the QGS, and s

[PATCH v5 62/65] i386/tdx: Only configure MSR_IA32_UCODE_REV in kvm_init_msrs() for TDs

2024-02-28 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 Hoff

[PATCH v5 64/65] i386/tdx: Don't get/put guest state for TDX VMs

2024-02-28 Thread Xiaoyao Li
From: Sean Christopherson Don't get/put state of TDX VMs since accessing/mutating guest state of production TDs is not supported. Note, it will be allowed for a debug TD. Corresponding support will be introduced when debug TD support is implemented in the future. Signed-off-by: Sean Christopher

[PATCH v5 44/65] i386/tdx: Setup the TD HOB list

2024-02-28 Thread Xiaoyao Li
The TD HOB list is used to pass the information from VMM to TDVF. The TD HOB must include PHIT HOB and Resource Descriptor HOB. More details can be found in TDVF specification and PI specification. Build the TD HOB in TDX's machine_init_done callback. Co-developed-by: Isaku Yamahata Signed-off-b

[PATCH v5 61/65] i386/tdx: Don't synchronize guest tsc for TDs

2024-02-28 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 Hoffmann

[PATCH v5 41/65] i386/tdx: Track mem_ptr for each firmware entry of TDVF

2024-02-28 Thread Xiaoyao Li
For each TDVF sections, QEMU needs to copy the content to guest private memory via KVM API (KVM_TDX_INIT_MEM_REGION). Introduce a field @mem_ptr for TdxFirmwareEntry to track the memory pointer of each TDVF sections. So that QEMU can add/copy them to guest private memory later. TDVF sections can

[PATCH v5 60/65] hw/i386: add option to forcibly report edge trigger in acpi tables

2024-02-28 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/acpi-commo

[PATCH v5 56/65] i386/tdx: Disable PIC for TDX VMs

2024-02-28 Thread Xiaoyao Li
Legacy PIC (8259) cannot be supported for TDX VMs since TDX module doesn't allow directly interrupt injection. Using posted interrupts for the PIC is not a viable option as the guest BIOS/kernel will not do EOI for PIC IRQs, i.e. will leave the vIRR bit set. Hence disable PIC for TDX VMs and erro

[PATCH v5 57/65] i386/tdx: Don't allow system reset for TDX VMs

2024-02-28 Thread Xiaoyao Li
TDX CPU state is protected and thus vcpu state cann't be reset by VMM. Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 2748086231d5..b1b0384b0c5c 1

[PATCH v5 43/65] headers: Add definitions from UEFI spec for volumes, resources, etc...

2024-02-28 Thread Xiaoyao Li
Add UEFI definitions for literals, enums, structs, GUIDs, etc... that will be used by TDX to build the UEFI Hand-Off Block (HOB) that is passed to the Trusted Domain Virtual Firmware (TDVF). All values come from the UEFI specification [1], PI spec [2] and TDVF design guide[3]. [1] UEFI Specificat

[PATCH v5 45/65] i386/tdx: Populate TDVF private memory via KVM_MEMORY_MAPPING

2024-02-28 Thread Xiaoyao Li
From: Isaku Yamahata TDVF firmware (CODE and VARS) needs to be copied to TD's private memory, as well as TD HOB and TEMP memory. If the TDVF section has TDVF_SECTION_ATTRIBUTES_MR_EXTEND set in the flag, calling KVM_TDX_EXTEND_MEMORY to extend the measurement. After populating the TDVF memory,

[PATCH v5 31/65] i386/tdx: Implement user specified tsc frequency

2024-02-28 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 Li Acked-by

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

2024-02-28 Thread Xiaoyao Li
From: Isaku Yamahata For SetupEventNotifyInterrupt, record interrupt vector and the apic id of the vcpu that received this TDVMCALL. Later it can inject interrupt with given vector to the specific vcpu that received SetupEventNotifyInterrupt. Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoya

[PATCH v5 42/65] i386/tdx: Track RAM entries for TDX VM

2024-02-28 Thread Xiaoyao Li
The RAM of TDX VM can be classified into two types: - TDX_RAM_UNACCEPTED: default type of TDX memory, which needs to be accepted by TDX guest before it can be used and will be all-zeros after being accepted. - TDX_RAM_ADDED: the RAM that is ADD'ed to TD guest before running, and can be

[PATCH v5 58/65] i386/tdx: LMCE is not supported for TDX

2024-02-28 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 9c791b7b0520..8c618869533c 100644 ---

[PATCH v5 54/65] q35: Introduce smm_ranges property for q35-pci-host

2024-02-28 Thread Xiaoyao Li
From: Isaku Yamahata Add a q35 property to check whether or not SMM ranges, e.g. SMRAM, TSEG, etc... exist for the target platform. TDX doesn't support SMM and doesn't play nice with QEMU modifying related guest memory ranges. Signed-off-by: Isaku Yamahata Co-developed-by: Sean Christopherson

[PATCH v5 36/65] i386/tdx: load TDVF for TD guest

2024-02-28 Thread Xiaoyao Li
From: Chao Peng TDVF(OVMF) needs to run at private memory for TD guest. TDX cannot support pflash device since it doesn't support read-only private memory. Thus load TDVF(OVMF) with -bios option for TDs. Use memory_region_init_ram_guest_memfd() to allocate the MemoryRegion for TDVF because it ne

[PATCH v5 27/65] i386/tdx: Wire CPU features up with attributes of TD guest

2024-02-28 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 | 13 + 1 file changed, 13 insertions(+) diff --git

[PATCH v5 04/65] trace/kvm: Split address space and slot id in trace_kvm_set_user_memory()

2024-02-28 Thread Xiaoyao Li
The upper 16 bits of kvm_userspace_memory_region::slot are address space id. Parse it separately in trace_kvm_set_user_memory(). Signed-off-by: Xiaoyao Li --- accel/kvm/kvm-all.c| 5 +++-- accel/kvm/trace-events | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/accel/kvm

[PATCH v5 10/65] kvm/memory: Make memory type private by default if it has guest memfd backend

2024-02-28 Thread Xiaoyao Li
KVM side leaves the memory to shared by default, while may incur the overhead of paging conversion on the first visit of each page. Because the expectation is that page is likely to private for the VMs that require private memory (has guest memfd). Explicitly set the memory to private when memory

[PATCH v5 20/65] i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookup

2024-02-28 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 | 3 --- targ

[PATCH v5 14/65] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context

2024-02-28 Thread Xiaoyao Li
Implement TDX specific ConfidentialGuestSupportClass::kvm_init() callback, tdx_kvm_init(). Set ms->require_guest_memfd to true to require private guest memfd allocation for any memory backend. More TDX specific initialization will be added later. Signed-off-by: Xiaoyao Li --- Changes in v5: -

[PATCH v5 21/65] i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookup

2024-02-28 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 --- Changes in v4: - reverse the meaning of tdx_caps->attr_fixed0, because value 0 of bit

[PATCH v5 03/65] HostMem: Add mechanism to opt in kvm guest memfd via MachineState

2024-02-28 Thread Xiaoyao Li
Add a new member "guest_memfd" to memory backends. When it's set to true, it enables RAM_GUEST_MEMFD in ram_flags, thus private kvm guest_memfd will be allocated during RAMBlock allocation. Memory backend's @guest_memfd is wired with @require_guest_memfd field of MachineState. It avoid looking up

[PATCH v5 16/65] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object

2024-02-28 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 --- changes in v3: - replace

[PATCH v5 38/65] i386/tdx: Parse TDVF metadata for TDX VM

2024-02-28 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 v5 23/65] kvm: Introduce kvm_arch_pre_create_vcpu()

2024-02-28 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 --- Changes in v3: - pass @errp to kvm_arch_pre_create_vcpu(); (Per Da

[PATCH v5 26/65] i386/tdx: Make sept_ve_disable set by default

2024-02-28 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 v5 25/65] i386/tdx: Add property sept-ve-disable for tdx-guest object

2024-02-28 Thread Xiaoyao Li
Bit 28 of TD attribute, named SEPT_VE_DISABLE. When set to 1, it disables EPT violation conversion to #VE on guest TD access of PENDING pages. Some guest OS (e.g., Linux TD guest) may require this bit as 1. Otherwise refuse to boot. Add sept-ve-disable property for tdx-guest object, for user to c

[PATCH v5 15/65] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES

2024-02-28 Thread Xiaoyao Li
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's setting later. Since there is no interface reporting how many cpuid configs contains in KVM_TDX_CAPABILITIES, Q

[PATCH v5 09/65] trace/kvm: Add trace for page convertion between shared and private

2024-02-28 Thread Xiaoyao Li
From: Isaku Yamahata Signed-off-by: Isaku Yamahata Signed-off-by: Xiaoyao Li --- accel/kvm/kvm-all.c| 2 ++ accel/kvm/trace-events | 1 + 2 files changed, 3 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 87e4275932a7..fe2eb3f06902 100644 --- a/accel/kvm/kvm-all

[PATCH v5 13/65] target/i386: Implement mc->kvm_type() to get VM type

2024-02-28 Thread Xiaoyao Li
TDX VM requires VM type KVM_X86_TDX_VM to be passed to kvm_ioctl(KVM_CREATE_VM). Hence implement mc->kvm_type() for i386 architecture. If tdx-guest object is specified to confidential-guest-support, like, qemu -machine ...,confidential-guest-support=tdx0 \ -object tdx-guest,id=tdx0,...

[PATCH v5 05/65] kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot

2024-02-28 Thread Xiaoyao Li
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 backend'ed both by hva-based shared memory and guest memfd based private memory. Signed-off-by: Chao Peng Co-developed-by: Xiaoyao Li Signed-off-by

[PATCH v5 08/65] kvm: handle KVM_EXIT_MEMORY_FAULT

2024-02-28 Thread Xiaoyao Li
From: Chao Peng When geeting KVM_EXIT_MEMORY_FAULT exit, it indicates userspace needs to do the memory conversion on the RAMBlock to turn the memory into desired attribute, i.e., private/shared. Currently only KVM_MEMORY_EXIT_FLAG_PRIVATE in flags is valid when KVM_EXIT_MEMORY_FAULT happens. No

[PATCH v5 12/65] i386: Introduce tdx-guest object

2024-02-28 Thread Xiaoyao Li
Introduce tdx-guest object which inherits CONFIDENTIAL_GUEST_SUPPORT, and will be used to create TDX VMs (TDs) by qemu -machine ...,confidential-guest-support=tdx0 \ -object tdx-guest,id=tdx0 So far, it has no QAPI member/properety decleared and only one internal member 'attributes'

[PATCH v5 11/65] *** HACK *** linux-headers: Update headers to pull in TDX API changes

2024-02-28 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 | 86 +

[PATCH v5 07/65] physmem: Introduce ram_block_discard_guest_memfd_range()

2024-02-28 Thread Xiaoyao Li
When memory page is converted from private to shared, the original private memory is back'ed by guest_memfd. Introduce ram_block_discard_guest_memfd_range() for discarding memory in guest_memfd. Originally-from: Isaku Yamahata Codeveloped-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Reviewed-by: Da

[PATCH v5 01/65] linux-headers: Update to Linux v6.8-rc5

2024-02-28 Thread Xiaoyao Li
Guest memfd support in QEMU requires corresponding KVM guest memfd APIs, which lands in Linux from v6.8-rc1. Signed-off-by: Xiaoyao Li --- include/standard-headers/drm/drm_fourcc.h | 10 +- include/standard-headers/linux/ethtool.h | 41 +++-- .../standard-headers/linux/virtio_config.h

[PATCH v5 02/65] RAMBlock: Add support of KVM private guest memfd

2024-02-28 Thread Xiaoyao Li
Add KVM guest_memfd support to RAMBlock so both normal hva based memory and kvm guest memfd based private memory can be associated in one RAMBlock. Introduce new flag RAM_GUEST_MEMFD. When it's set, it calls KVM ioctl to create private guest_memfd during RAMBlock setup. Allocating a new RAM_GUEST

[PATCH v5 00/65] QEMU Guest memfd + QEMU TDX support

2024-02-28 Thread Xiaoyao Li
This v5 series matches with latest KVM v19 series: https://lore.kernel.org/all/cover.1708933498.git.isaku.yamah...@intel.com/ This series is also available in github: https://github.com/intel/qemu-tdx/tree/tdx-qemu-upstream-v5 It's based on one series that refacotrs cgs specific KVM functions: ht

Re: [PATCH v2 06/21] migration: Add Error** argument to .save_setup() handler

2024-02-28 Thread Markus Armbruster
Cédric Le Goater writes: > The purpose is to record a potential error in the migration stream if > qemu_savevm_state_setup() fails. Most of the current .save_setup() > handlers can be modified to use the Error argument instead of managing > their own and calling locally error_report(). The follow

Re: [PATCH 4/4] replay: simple auto-snapshot mode for record

2024-02-28 Thread Nicholas Piggin
On Wed Feb 28, 2024 at 3:07 PM AEST, Pavel Dovgalyuk wrote: > On 26.02.2024 10:36, Nicholas Piggin wrote: > > On Fri Aug 18, 2023 at 2:36 PM AEST, Pavel Dovgalyuk wrote: > >> On 14.08.2023 19:31, Nicholas Piggin wrote: > >>> record makes an initial snapshot when the machine is created, to enable >

Re: [PATCH 0/4] plugins/execlog: add data address match and address range support

2024-02-28 Thread Pierrick Bouvier
Hi Sven, thanks for your series. Yesterday, series for new API to access registers from plugins was merged. As part of it, execlog plugin was extended to support this [1]. This conflict with the changes presented here. Could you please rebase this series on top of master? Thanks, Pierrick [1

Re: [PATCH V2] migration: export fewer options

2024-02-28 Thread Markus Armbruster
Steven Sistare writes: > Just a reminder, after our further discussion in the V1 thread, > this patch is still what I propose, no updates needed. > > Markus, I think Peter is looking for your blessing on the new > file name: include/migration/client-options.h. Not my preference, but no objectio

[PATCH 3/4] ppc/pef: switch to use confidential_guest_kvm_init/reset()

2024-02-28 Thread Xiaoyao Li
Use the unified interface to call confidential guest related kvm_init() and kvm_reset(), to avoid exposing pef specific functions. remove perf.h since it is now blank.. Signed-off-by: Xiaoyao Li --- Changes from rfc v1: - check machine->cgs not NULL before callling confidential_guest_kvm_ini

Re: [External] Re: [PATCH v3 6/7] migration/multifd: Add zero pages and zero bytes counter to migration status interface.

2024-02-28 Thread Markus Armbruster
Hao Xiang writes: > On Wed, Feb 28, 2024 at 1:52 AM Markus Armbruster wrote: >> >> Hao Xiang writes: >> >> > This change extends the MigrationStatus interface to track zero pages >> > and zero bytes counter. >> > >> > Signed-off-by: Hao Xiang >> >> [...] >> >> > diff --git a/qapi/migration.jso

[PATCH 4/4] s390: Switch to use confidential_guest_kvm_init()

2024-02-28 Thread Xiaoyao Li
Use unified confidential_guest_kvm_init(), to avoid exposing specific functions. Signed-off-by: Xiaoyao Li --- Changes from rfc v1: - check machine->cgs not NULL before calling confidential_guest_kvm_init(); --- hw/s390x/s390-virtio-ccw.c | 5 - target/s390x/kvm/pv.c | 8 ta

[PATCH 1/4] confidential guest support: Add kvm_init() and kvm_reset() in class

2024-02-28 Thread Xiaoyao Li
Different confidential VMs in different architectures all have the same needs to do their specific initialization (and maybe resetting) stuffs with KVM. Currently each of them exposes individual *_kvm_init() functions and let machine code or kvm code to call it. To make it more object oriented, ad

  1   2   3   4   5   6   >