[PATCH v2] i386/cpu: Drop the check of phys_bits in host_cpu_realizefn()

2024-09-29 Thread Xiaoyao Li
efn(). Opportunistically adjust cpu->phys_bits directly in host_cpu_adjust_phys_bits(), which matches more with the function name. Signed-off-by: Xiaoyao Li Reviewed-by: Igor Mammedov Reviewed-by: Zhao Liu --- Changes in v2: - make host_cpu_adjust_phys_bits() return void and adjust cpu->phys_bits

[PATCH 0/9] Misc patches for x86 CPUID

2024-08-14 Thread Xiaoyao Li
development and testing. However, they issues they aim to address are not TDX specific and the patches are not TDX specific. Xiaoyao Li (9): i386/cpu: Don't construct a all-zero entry for CPUID[0xD 0x3f] i386/cpu: Enable fdp-excptn-only and zero-fcs-fds i386/cpu: Add support for bits in

[PATCH 4/9] i386/cpu: Construct valid CPUID leaf 5 iff CPUID_EXT_MONITOR

2024-08-14 Thread Xiaoyao Li
When CPUID_EXT_MONITOR is not set, it means no support of MONITOR/MWAIT leaf, i.e., CPUID leaf 5. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 03376ccf3e75

[PATCH 6/9] i386/cpu: Set topology info in 0x80000008.ECX only for AMD CPUs

2024-08-14 Thread Xiaoyao Li
The whole ECX of CPUID 0x8008 is reserved for Intel. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5bee84333089..7a4835289760 100644 --- a/target/i386/cpu.c +++ b/target/i386

[PATCH 9/9] i386/cpu: Make invtsc migratable when user sets tsc-khz explicitly

2024-08-14 Thread Xiaoyao Li
When user sets tsc-frequency explicitly, the invtsc feature is actually migratable because the tsc-frequency is supposed to be fixed during the migration. See commit d99569d9d856 ("kvm: Allow invtsc migration if tsc-khz is set explicitly") for referrence. Signed-off-by: Xiaoyao Li -

[PATCH 1/9] i386/cpu: Don't construct a all-zero entry for CPUID[0xD 0x3f]

2024-08-14 Thread Xiaoyao Li
Currently, QEMU always constructs a all-zero CPUID entry for CPUID[0xD 0x3f]. It's meaningless to construct such a leaf as the end of leaf 0xD. Rework the logic of how subleaves of 0xD are constructed to get rid of such all-zero value of subleaf 0x3f. Signed-off-by: Xiaoyao Li --- target

[PATCH 5/9] i386/cpu: Construct CPUID 2 as stateful iff times > 1

2024-08-14 Thread Xiaoyao Li
When times == 1, the CPUID leaf 2 is not stateful. Signed-off-by: Xiaoyao Li --- target/i386/kvm/kvm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index c168ff5691df..6618259f265c 100644 --- a/target/i386/kvm/kvm.c

[PATCH 8/9] i386/cpu: Drop AMD alias bits in FEAT_8000_0001_EDX for non-AMD guests

2024-08-14 Thread Xiaoyao Li
The AMD alias bits are reserved for Intel. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 5 + 1 file changed, 5 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fed805e04aeb..85ce405ece80 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6118,6 +6118,11

[PATCH 7/9] i386/cpu: Suppress CPUID values not defined by Intel

2024-08-14 Thread Xiaoyao Li
. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 7a4835289760..fed805e04aeb 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6863,12 +6863,16 @@ void cpu_x86_cpuid

[PATCH 3/9] i386/cpu: Add support for bits in CPUID.7_2.EDX

2024-08-14 Thread Xiaoyao Li
KVM started to report the support of bit 0-5 since commit eefe5e668209 ("Advertise CPUID.(EAX=7,ECX=2):EDX[5:0] to userspace") Allow them to be exposed to guest in QEMU. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) di

[PATCH 2/9] i386/cpu: Enable fdp-excptn-only and zero-fcs-fds

2024-08-14 Thread Xiaoyao Li
. Also define the bit field MACROs so that named cpu models can add it as well in the future. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 4 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 85ef7452c04e

Re: [PATCH v2] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f

2024-08-13 Thread Xiaoyao Li
On 8/13/2024 10:51 PM, Xiaoyao Li wrote: On 8/13/2024 5:27 PM, Igor Mammedov wrote: On Mon, 12 Aug 2024 23:31:45 -0400 Xiaoyao Li wrote: Currently, QEMU exposes CPUID 0x1f to guest only when necessary, i.e., when topology level that cannot be enumerated by leaf 0xB, e.g., die or module level

Re: [PATCH v2] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f

2024-08-13 Thread Xiaoyao Li
On 8/13/2024 5:27 PM, Igor Mammedov wrote: On Mon, 12 Aug 2024 23:31:45 -0400 Xiaoyao Li wrote: Currently, QEMU exposes CPUID 0x1f to guest only when necessary, i.e., when topology level that cannot be enumerated by leaf 0xB, e.g., die or module level, are configured for the guest, e.g., -smp

[PATCH v2] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f

2024-08-12 Thread Xiaoyao Li
e_cpuid_0x1f and x86_has_extended_topo() to check if it needs to enable cpuid leaf 0x1f for the guest. [1] https://lore.kernel.org/qemu-devel/20240724075226.212882-1-manish.mis...@nutanix.com/ Signed-off-by: Xiaoyao Li --- changes in v2: - Add more details in commit message; - introduce a separate function x8

Re: [PATCH] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f

2024-08-12 Thread Xiaoyao Li
On 8/8/2024 10:46 PM, Zhao Liu wrote: On Thu, Aug 08, 2024 at 09:59:07PM +0800, Xiaoyao Li wrote: Date: Thu, 8 Aug 2024 21:59:07 +0800 From: Xiaoyao Li Subject: Re: [PATCH] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f On 8/8/2024 6:09 PM, Zhao Liu wrote: Hi Xiaoyao

Re: [PATCH] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f

2024-08-08 Thread Xiaoyao Li
On 8/8/2024 5:29 PM, Igor Mammedov wrote: On Fri, 2 Aug 2024 03:24:26 -0400 Xiaoyao Li wrote: Currently, QEMU exposes CPUID 0x1f to guest only when necessary, i.e., when topology level that cannot be enumerated by leaf 0xB, e.g., die or module level, are configured for the guest. above

Re: [PATCH] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f

2024-08-08 Thread Xiaoyao Li
On 8/8/2024 6:09 PM, Zhao Liu wrote: Hi Xiaoyao, Patch is generally fine for me. Just a few nits: On Fri, Aug 02, 2024 at 03:24:26AM -0400, Xiaoyao Li wrote: diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index dff49fce1154..b63bce2f4c82 100644 --- a/include/hw/i386

Re: [PATCH v1] target/i386: Always set leaf 0x1f

2024-08-02 Thread Xiaoyao Li
On 8/2/2024 12:46 AM, Manish wrote: On 01/08/24 8:41 pm, Xiaoyao Li wrote: !---|  CAUTION: External Email |---! On 8/1/2024 6:25 PM, Igor Mammedov wrote: On Thu, 1

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

2024-08-02 Thread Xiaoyao Li
eaf 0x1f is v2 extended topology enumration leaf. [1] https://lore.kernel.org/qemu-devel/21ca5c19-677b-4fac-84d4-72413577f...@nutanix.com/ Signed-off-by: Xiaoyao Li --- include/hw/i386/topology.h | 9 - target/i386/cpu.c | 18 -- target/i386/cpu.h |

Re: [PATCH v1] target/i386: Always set leaf 0x1f

2024-08-01 Thread Xiaoyao Li
On 8/1/2024 6:25 PM, Igor Mammedov wrote: On Thu, 1 Aug 2024 15:36:10 +0530 Manish wrote: On 31/07/24 9:01 pm, Xiaoyao Li wrote: !---|  CAUTION: External Email

Re: [PATCH v1] target/i386: Always set leaf 0x1f

2024-07-31 Thread Xiaoyao Li
On 7/31/2024 4:49 PM, John Levon wrote: On Wed, Jul 31, 2024 at 03:02:15PM +0800, Xiaoyao Li wrote: Windows does not expect 0x1f to be present for any CPU model. But if it is exposed to the guest, it expects non-zero values. Please fix Windows! A ticket has been filed with MSFT, we are

Re: [PATCH v1] target/i386: Always set leaf 0x1f

2024-07-31 Thread Xiaoyao Li
On 7/24/2024 6:29 PM, Manish wrote: Thanks Igor On 24/07/24 2:30 pm, Igor Mammedov wrote: !---|    CAUTION: External Email |---! On Wed, 24 Jul 2024 07:52:26 + "

Re: [PATCH] target/i386: Always set leaf 0x1f

2024-07-23 Thread Xiaoyao Li
On 7/23/2024 10:26 PM, Zhao Liu wrote: (+Xiaoyao, whose TDX work may also be related with this.) I have a similar patch for TDX because TDX requires CPUID leaf 0x1f to configure topology as a must. (I haven't post to QEMU community yet. I'm not sure how people want to proceed, refine this p

[PATCH] i386/cpu: Drop the check of phys_bits in host_cpu_realizefn()

2024-07-04 Thread Xiaoyao Li
off-by: Xiaoyao Li --- target/i386/host-cpu.c | 12 +--- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/target/i386/host-cpu.c b/target/i386/host-cpu.c index 8b8bf5afeccf..b109c1a2221f 100644 --- a/target/i386/host-cpu.c +++ b/target/i386/host-cpu.c @@ -75,17 +75,7 @@ b

Re: [PATCH v4 20/31] i386/sev: Add support for SNP CPUID validation

2024-07-03 Thread Xiaoyao Li
On 7/4/2024 8:34 AM, Michael Roth wrote: On Tue, Jul 02, 2024 at 11:07:18AM +0800, Xiaoyao Li wrote: On 5/30/2024 7:16 PM, Pankaj Gupta wrote: From: Michael Roth SEV-SNP firmware allows a special guest page to be populated with a table of guest CPUID values so that they can be validated

Re: [PATCH 4/4] target/i386: Update CMPLegacy handling for Zhaoxin and VIA CPUs

2024-07-03 Thread Xiaoyao Li
On 7/4/2024 11:14 AM, Ewan Hai wrote: On 7/3/24 10:49, Xiaoyao Li wrote: On 6/25/2024 5:19 PM, EwanHai wrote: Zhaoxin and VIA CPUs handle the CMPLegacy bit in the same way as Intel CPUs. This patch simplifies the existing logic by using the IS_XXX_CPU macro and includes checks for Zhaoxin and

Re: [PATCH 4/4] target/i386: Update CMPLegacy handling for Zhaoxin and VIA CPUs

2024-07-03 Thread Xiaoyao Li
On 6/25/2024 5:19 PM, EwanHai wrote: Zhaoxin and VIA CPUs handle the CMPLegacy bit in the same way as Intel CPUs. This patch simplifies the existing logic by using the IS_XXX_CPU macro and includes checks for Zhaoxin and VIA vendors to align their behavior with Intel. Signed-off-by: EwanHai ---

Re: [PATCH v4 20/31] i386/sev: Add support for SNP CPUID validation

2024-07-01 Thread Xiaoyao Li
On 5/30/2024 7:16 PM, Pankaj Gupta wrote: From: Michael Roth SEV-SNP firmware allows a special guest page to be populated with a table of guest CPUID values so that they can be validated through firmware before being loaded into encrypted guest memory where they can be used in place of hypervis

Re: [PATCH 2/2] target/i386: drop AMD machine check bits from Intel CPUID

2024-06-28 Thread Xiaoyao Li
ust it based on vendor in kvm_arch_get_supported_cpuid() is better than in x86_cpu_get_supported_feature_word(). Otherwise kvm_arch_get_supported_cpuid() still returns "risky" value for Intel VMs. Suggested-by: Xiaoyao Li Cc: John Allen Signed-off-by: Paolo Bonzini --- target/i386/c

Re: [PATCH 1/2] target/i386: pass X86CPU to x86_cpu_get_supported_feature_word

2024-06-28 Thread Xiaoyao Li
D, and bits from AMD should be dropped when configuring the guest for an Intel model. Cc: Xiaoyao Li Cc: John Allen Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 3 +-- target/i386/cpu.c | 13 ++--- target/i386/kvm/kvm-cpu.c | 2 +- 3 files changed, 8 inserti

Re: [PATCH v5 25/65] i386/tdx: Add property sept-ve-disable for tdx-guest object

2024-06-26 Thread Xiaoyao Li
On 6/24/2024 11:01 PM, Daniel P. Berrangé wrote: On Fri, Jun 14, 2024 at 08:49:57AM +0100, Daniel P. Berrangé wrote: On Fri, Jun 14, 2024 at 09:04:33AM +0800, Xiaoyao Li wrote: On 6/13/2024 4:35 PM, Duan, Zhenzhong wrote: -Original Message- From: Li, Xiaoyao Subject: Re: [PATCH v5

Re: [PATCH v4 28/31] hw/i386: Add support for loading BIOS using guest_memfd

2024-06-14 Thread Xiaoyao Li
On 6/14/2024 4:48 PM, Gupta, Pankaj wrote: On 6/14/2024 10:34 AM, Xiaoyao Li wrote: On 5/30/2024 7:16 PM, Pankaj Gupta wrote: From: Michael Roth When guest_memfd is enabled, the BIOS is generally part of the initial encrypted guest image and will be accessed as private guest memory. Add the

Re: [PATCH v4 27/31] hw/i386/sev: Use guest_memfd for legacy ROMs

2024-06-14 Thread Xiaoyao Li
On 5/30/2024 7:16 PM, Pankaj Gupta wrote: From: Michael Roth Current SNP guest kernels will attempt to access these regions with with C-bit set, so guest_memfd is needed to handle that. Otherwise, kvm_convert_memory() will fail when the guest kernel tries to access it and QEMU attempts to call

Re: [PATCH v4 28/31] hw/i386: Add support for loading BIOS using guest_memfd

2024-06-14 Thread Xiaoyao Li
On 5/30/2024 7:16 PM, Pankaj Gupta wrote: From: Michael Roth When guest_memfd is enabled, the BIOS is generally part of the initial encrypted guest image and will be accessed as private guest memory. Add the necessary changes to set up the associated RAM region with a guest_memfd backend to all

Re: [PATCH v5 25/65] i386/tdx: Add property sept-ve-disable for tdx-guest object

2024-06-13 Thread Xiaoyao Li
libvirt TDX patches. On Thu, Feb 29, 2024 at 01:36:46AM -0500, Xiaoyao Li wrote: 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

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

2024-06-13 Thread Xiaoyao Li
On 6/13/2024 4:26 PM, Duan, Zhenzhong wrote: + * + * It also has side effect to enable unsupported bits, e.g., the + * bits of "fixed0" type while present natively. It's safe because + * the unsupported bits will be masked off by .fixed0 later. + */ +    *ret |= host_cpuid_reg

Re: [PULL 39/42] i386: Add support for SUCCOR feature

2024-06-13 Thread Xiaoyao Li
On 6/8/2024 4:34 PM, Paolo Bonzini wrote: From: John Allen Add cpuid bit definition for the SUCCOR feature. This cpuid bit is required to be exposed to guests to allow them to handle machine check exceptions on AMD hosts. v2: - Add "succor" feature word. - Add case to kvm_arch_get_s

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

2024-06-12 Thread Xiaoyao Li
On 5/31/2024 5:27 PM, Duan, Zhenzhong wrote: On 2/29/2024 2:36 PM, Xiaoyao Li wrote: 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 requ

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

2024-06-12 Thread Xiaoyao Li
On 5/31/2024 4:47 PM, Duan, Zhenzhong wrote: On 2/29/2024 2:36 PM, Xiaoyao Li wrote: According to Chapter "CPUID Virtualization" in TDX module spec, CPUID bits of TD can be classified into 6 types: 1 | As

Re: [PATCH v5 25/65] i386/tdx: Add property sept-ve-disable for tdx-guest object

2024-06-12 Thread Xiaoyao Li
On 6/6/2024 6:45 PM, Daniel P. Berrangé wrote: Copying Zhenzhong Duan as my point relates to the proposed libvirt TDX patches. On Thu, Feb 29, 2024 at 01:36:46AM -0500, Xiaoyao Li wrote: Bit 28 of TD attribute, named SEPT_VE_DISABLE. When set to 1, it disables EPT violation conversion to #VE

Re: [PATCH] i386/apic: Add hint on boot failure because of disabling x2APIC

2024-06-07 Thread Xiaoyao Li
On 6/7/2024 3:46 PM, Zhao Liu wrote: Hi Philippe, On Fri, Jun 07, 2024 at 08:17:36AM +0200, Philippe Mathieu-Daudé wrote: Date: Fri, 7 Jun 2024 08:17:36 +0200 From: Philippe Mathieu-Daudé Subject: Re: [PATCH] i386/apic: Add hint on boot failure because of disabling x2APIC On 6/6/24 16:08, Z

Re: [PATCH] target/i386: SEV: do not assume machine->cgs is SEV

2024-06-06 Thread Xiaoyao Li
On 6/6/2024 6:44 AM, Paolo Bonzini wrote: There can be other confidential computing classes that are not derived from sev-common. Avoid aborting when encountering them. I hit it today when rebasing TDX patches to latest QEMU master, which has the SEV-SNP series merged. (I didn't get time to r

Re: [PATCH V3 2/2] target/i386: Advertise MWAIT iff host supports

2024-06-04 Thread Xiaoyao Li
izefn(), and this patch merges host_cpu_enable_cpu_pm() into kvm_cpu_realizefn(). Fixes: f5cc5a5c1686 ("i386: split cpu accelerators from cpu.c, using AccelCPUClass") Fixes: 662175b91ff2 ("i386: reorder call to cpu_exec_realizefn") Signed-off-by: Zide Chen Reviewed-by: Xiaoyao Li --- V3:

Re: [PATCH v2] i386/cpu: fixup number of addressable IDs for processor cores in the physical package

2024-06-04 Thread Xiaoyao Li
On 6/4/2024 5:43 PM, Zhao Liu wrote: Hi Chuang, On Mon, Jun 03, 2024 at 04:36:41PM +0800, Chuang Xu wrote: Date: Mon, 3 Jun 2024 16:36:41 +0800 From: Chuang Xu Subject: [PATCH v2] i386/cpu: fixup number of addressable IDs for processor cores in the physical package X-Mailer: git-send-email

Re: [PATCH 2/2] tests: add testing of parameter=1 for SMP topology

2024-05-15 Thread Xiaoyao Li
On 5/13/2024 8:33 PM, Daniel P. Berrangé wrote: Validate that it is possible to pass 'parameter=1' for any SMP topology parameter, since unsupported parameters are implicitly considered to always have a value of 1. Signed-off-by: Daniel P. Berrangé --- tests/unit/test-smp-parse.c | 8

Re: [PATCH 6/6] target/i386/confidential-guest: Fix comment of x86_confidential_guest_kvm_type()

2024-04-26 Thread Xiaoyao Li
On 4/26/2024 6:07 PM, Zhao Liu wrote: Update the comment to match the X86ConfidentialGuestClass implementation. Suggested-by: Xiaoyao Li I think it should be "Reported-by" Signed-off-by: Zhao Liu --- target/i386/confidential-guest.h | 2 +- 1 file changed, 1 insertion(+),

Re: [PATCH for-9.1 0/7] target/i386/kvm: Cleanup the kvmclock feature name

2024-04-25 Thread Xiaoyao Li
On 4/25/2024 6:29 PM, Zhao Liu wrote: On Thu, Apr 25, 2024 at 04:40:10PM +0800, Xiaoyao Li wrote: Date: Thu, 25 Apr 2024 16:40:10 +0800 From: Xiaoyao Li Subject: Re: [PATCH for-9.1 0/7] target/i386/kvm: Cleanup the kvmclock feature name On 4/25/2024 3:17 PM, Zhao Liu wrote: Hi Xiaoyao, On

Re: [PATCH for-9.1 0/7] target/i386/kvm: Cleanup the kvmclock feature name

2024-04-25 Thread Xiaoyao Li
On 4/25/2024 3:17 PM, Zhao Liu wrote: Hi Xiaoyao, On Wed, Apr 24, 2024 at 11:57:11PM +0800, Xiaoyao Li wrote: Date: Wed, 24 Apr 2024 23:57:11 +0800 From: Xiaoyao Li Subject: Re: [PATCH for-9.1 0/7] target/i386/kvm: Cleanup the kvmclock feature name On 3/29/2024 6:19 PM, Zhao Liu wrote

Re: [PATCH for-9.1 0/7] target/i386/kvm: Cleanup the kvmclock feature name

2024-04-24 Thread Xiaoyao Li
On 3/29/2024 6:19 PM, Zhao Liu wrote: From: Zhao Liu Hi list, This series is based on Paolo's guest_phys_bits patchset [1]. Currently, the old and new kvmclocks have the same feature name "kvmclock" in FeatureWordInfo[FEAT_KVM]. When I tried to dig into the history of this unusual naming and

Re: [PATCH for-9.1 2/7] target/i386/kvm: Remove local MSR_KVM_WALL_CLOCK and MSR_KVM_SYSTEM_TIME definitions

2024-04-24 Thread Xiaoyao Li
On 3/29/2024 6:19 PM, Zhao Liu wrote: From: Zhao Liu These 2 MSRs have been already defined in the kvm_para header (standard-headers/asm-x86/kvm_para.h). Remove QEMU local definitions to avoid duplication. Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li --- target/i386/kvm/kvm.c | 3

Re: [PATCH for-9.1 1/7] target/i386/kvm: Add feature bit definitions for KVM CPUID

2024-04-24 Thread Xiaoyao Li
On 3/29/2024 6:19 PM, Zhao Liu wrote: From: Zhao Liu Add feature definiations for KVM_CPUID_FEATURES in CPUID ( CPUID[4000_0001].EAX and CPUID[4000_0001].EDX), to get rid of lots of offset calculations. Signed-off-by: Zhao Liu --- hw/i386/kvm/clock.c | 5 ++--- target/i386/cpu.h | 2

Re: [PULL 43/63] target/i386: Implement mc->kvm_type() to get VM type

2024-04-24 Thread Xiaoyao Li
On 4/23/2024 11:09 PM, Paolo Bonzini wrote: + +/** + * x86_confidential_guest_kvm_type: + * + * Calls #X86ConfidentialGuestClass.unplug callback of @plug_handler. the comment needs to be updated: Calls #X86ConfidentialGuestClass.kvm_type() callback + */ +static inline int x86_confidential_gu

Re: [PULL 25/63] i386/kvm: Move architectural CPUID leaf generation to separate helper

2024-04-23 Thread Xiaoyao Li
just a cleanup, so keep the function static. Signed-off-by: Sean Christopherson Signed-off-by: Xiaoyao Li Message-ID: <20240229063726.610065-23-xiaoyao...@intel.com> Reviewed-by: Xiaoyao Li Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c

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

2024-04-16 Thread Xiaoyao Li
On 4/16/2024 4:32 PM, Chenyi Qiang wrote: On 2/29/2024 2:36 PM, Xiaoyao Li wrote: 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/i38

Re: [PATCH v2] hw/i386/acpi: Set PCAT_COMPAT bit only when pic is not disabled

2024-04-03 Thread Xiaoyao Li
On 4/3/2024 11:12 PM, Igor Mammedov wrote: On Wed, 3 Apr 2024 10:59:53 -0400 Xiaoyao Li wrote: A value 1 of PCAT_COMPAT (bit 0) of MADT.Flags indicates that the system also has a PC-AT-compatible dual-8259 setup, i.e., the PIC. When PIC is not enabled (pic=off) for x86 machine, the

[PATCH v2] hw/i386/acpi: Set PCAT_COMPAT bit only when pic is not disabled

2024-04-03 Thread Xiaoyao Li
: Xiaoyao Li --- changes in v2: - Clarify more in commit message; --- hw/i386/acpi-common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 20f19269da40..0cc2919bb851 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c

Re: [PATCH] hw/i386/acpi: Set PCAT_COMPAT bit only when pic is not disabled

2024-04-02 Thread Xiaoyao Li
On 4/2/2024 10:31 PM, Michael S. Tsirkin wrote: On Tue, Apr 02, 2024 at 09:18:44PM +0800, Xiaoyao Li wrote: On 4/2/2024 6:02 PM, Michael S. Tsirkin wrote: On Tue, Apr 02, 2024 at 04:25:16AM -0400, Xiaoyao Li wrote: Set MADT.FLAGS[bit 0].PCAT_COMPAT based on x86ms->pic. Signed-off-by: Xiao

Re: [PATCH] hw/i386/acpi: Set PCAT_COMPAT bit only when pic is not disabled

2024-04-02 Thread Xiaoyao Li
On 4/2/2024 6:02 PM, Michael S. Tsirkin wrote: On Tue, Apr 02, 2024 at 04:25:16AM -0400, Xiaoyao Li wrote: Set MADT.FLAGS[bit 0].PCAT_COMPAT based on x86ms->pic. Signed-off-by: Xiaoyao Li Please include more info in the commit log: what is the behaviour you observe, why it is wrong,

[PATCH] hw/i386/acpi: Set PCAT_COMPAT bit only when pic is not disabled

2024-04-02 Thread Xiaoyao Li
Set MADT.FLAGS[bit 0].PCAT_COMPAT based on x86ms->pic. Signed-off-by: Xiaoyao Li --- hw/i386/acpi-common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 20f19269da40..0cc2919bb851 100644 --- a/hw/i386/acpi-commo

Re: [PATCH 26/26] i386/kvm: Move architectural CPUID leaf generation to separate helper

2024-04-01 Thread Xiaoyao Li
just a cleanup, so keep the function static. Signed-off-by: Sean Christopherson Signed-off-by: Xiaoyao Li Message-ID: <20240229063726.610065-23-xiaoyao...@intel.com> [Unify error reporting, rename function. - Paolo] Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c

Re: [PATCH v3 48/49] hw/i386/sev: Use guest_memfd for legacy ROMs

2024-03-27 Thread Xiaoyao Li
On 3/21/2024 2:12 AM, Isaku Yamahata wrote: On Wed, Mar 20, 2024 at 03:39:44AM -0500, Michael Roth wrote: TODO: make this SNP-specific if TDX disables legacy ROMs in general TDX disables pc.rom, not disable isa-bios. IIRC, TDX doesn't need pc pflash. Not TDX doesn't need pc pflash, but TDX

Re: [PATCH for-9.1 v5 2/3] target/i386: add guest-phys-bits cpu property

2024-03-26 Thread Xiaoyao Li
viewed-by: Xiaoyao Li --- v4->v5: - move here all non-KVM parts - add compat property and support for special value "-1" (accelerator defines value) target/i386/cpu.h | 1 + hw/i386/pc.c | 4 +++- target/i386/cpu.c | 22 ++ 3 files changed, 26 insert

Re: [PATCH 12/26] KVM: track whether guest state is encrypted

2024-03-26 Thread Xiaoyao Li
On 3/23/2024 2:11 AM, Paolo Bonzini wrote: So far, KVM has allowed KVM_GET/SET_* ioctls to execute even if the guest state is encrypted, in which case they do nothing. For the new API using VM types, instead, the ioctls will fail which is a safer and more robust approach. The new API will be th

Re: [PATCH 21/26] kvm/memory: Make memory type private by default if it has guest memfd backend

2024-03-26 Thread Xiaoyao Li
On 3/23/2024 2:11 AM, Paolo Bonzini wrote: From: Xiaoyao Li KVM side leaves the memory to shared by default, while may incur the /s/while/which/ fix typo from myself. overhead of paging conversion on the first visit of each page. Because the expectation is that page is likely to private

Re: [PATCH 25/26] kvm: handle KVM_EXIT_MEMORY_FAULT

2024-03-26 Thread Xiaoyao Li
original shared memory can be discarded via ram_block_discard_range(). Note, shared memory can be discarded only when it's not back'ed by hugetlb because hugetlb is supposed to be pre-allocated and no need for discarding. Signed-off-by: Chao Peng Co-developed-by: Xiaoyao Li Sig

Re: [PATCH 3/7] KVM: track whether guest state is encrypted

2024-03-22 Thread Xiaoyao Li
future in order to suppor migration). From that point, skip reading registers so that cpu->vcpu_dirty is never true: if it ever becomes true, kvm_arch_put_registers() will fail miserably. Signed-off-by: Paolo Bonzini Reviewed-by: Xiaoyao Li

Re: [PATCH 4/7] KVM: remove kvm_arch_cpu_check_are_resettable

2024-03-22 Thread Xiaoyao Li
Reviewed-by: Xiaoyao Li

Re: [PATCH 5/7] target/i386: introduce x86-confidential-guest

2024-03-22 Thread Xiaoyao Li
On 3/19/2024 9:59 PM, Paolo Bonzini wrote: Introduce a common superclass for x86 confidential guest implementations. It will extend ConfidentialGuestSupportClass with a method that provides the VM type to be passed to KVM_CREATE_VM. Signed-off-by: Paolo Bonzini Reviewed-by: Xiaoyao Li

Re: [PATCH 6/7] target/i386: Implement mc->kvm_type() to get VM type

2024-03-22 Thread Xiaoyao Li
On 3/19/2024 9:59 PM, Paolo Bonzini wrote: From: Xiaoyao Li KVM is introducing a new API to create confidential guests, which will be used by TDX and SEV-SNP but is also available for SEV and SEV-ES. The API uses the VM type argument to KVM_CREATE_VM to identify which confidential computing

Re: [PATCH RFC v3 00/49] Add AMD Secure Nested Paging (SEV-SNP) support

2024-03-20 Thread Xiaoyao Li
On 3/21/2024 1:08 AM, Paolo Bonzini wrote: On Wed, Mar 20, 2024 at 10:59 AM Paolo Bonzini wrote: I will now focus on reviewing patches 6-20. This way we can prepare a common tree for SEV_INIT2/SNP/TDX, for both vendors to build upon. Ok, the attachment is the delta that I have. The only majo

Re: [PATCH v5 08/65] kvm: handle KVM_EXIT_MEMORY_FAULT

2024-03-20 Thread Xiaoyao Li
On 3/19/2024 10:14 AM, Wang, Lei wrote: On 2/29/2024 14:36, Xiaoyao Li wrote: 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

Re: [PATCH v3 13/49] [FIXUP] "kvm: handle KVM_EXIT_MEMORY_FAULT": drop qemu_host_page_size

2024-03-20 Thread Xiaoyao Li
On 3/20/2024 4:39 PM, Michael Roth wrote: TODO: squash into "kvm: handle KVM_EXIT_MEMORY_FAULT" qemu_host_page_size has been superseded by qemu_real_host_page_size() in newer QEMU, so update the patch accordingly. I found it today as well when rebase to qemu v9.0.0-rc0. Fix it locally, will s

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

2024-03-20 Thread Xiaoyao Li
On 3/19/2024 10:03 AM, Wang, Lei wrote: On 2/29/2024 14:36, Xiaoyao Li wrote:> 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 dec

Re: [PATCH v3 11/49] physmem: Introduce ram_block_discard_guest_memfd_range()

2024-03-20 Thread Xiaoyao Li
On 3/20/2024 5:37 PM, David Hildenbrand wrote: On 20.03.24 09:39, Michael Roth wrote: From: 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 memo

Re: [PATCH v4 1/2] kvm: add support for guest physical bits

2024-03-19 Thread Xiaoyao Li
gt;host_phys_bits && cpu->host_phys_bits_limit && cpu->guest_phys_bits > cpu->host_phys_bits_limt) { } Simpler, we can guard with cpu->phys_bits like below, because cpu->host_phys_bits_limit is used to guard cpu->phys_bits in host_cpu_realizefn() if (cpu-

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

2024-03-19 Thread Xiaoyao Li
On 3/19/2024 11:08 PM, Pawan Gupta wrote: On Tue, Mar 19, 2024 at 12:22:08PM +0800, Xiaoyao Li wrote: On 3/13/2024 10:53 PM, Pawan Gupta wrote: Register File Data Sampling (RFDS) is a CPU side-channel vulnerability that may expose stale register value. CPUs that set RFDS_NO bit in MSR

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

2024-03-18 Thread Xiaoyao Li
On 3/13/2024 10:53 PM, Pawan Gupta wrote: Register File Data Sampling (RFDS) is a CPU side-channel vulnerability that may expose stale register value. CPUs that set RFDS_NO bit in MSR IA32_ARCH_CAPABILITIES indicate that they are not vulnerable to RFDS. Similarly, RFDS_CLEAR indicates that CPU is

Re: [PATCH 2/4] i386/sev: Switch to use confidential_guest_kvm_init()

2024-03-18 Thread Xiaoyao Li
On 3/19/2024 5:51 AM, Paolo Bonzini wrote: On Thu, Feb 29, 2024 at 7:01 AM Xiaoyao Li wrote: Use confidential_guest_kvm_init() instead of calling SEV specific sev_kvm_init(). As a bouns, it fits to future TDX when TDX implements its own confidential_guest_support and .kvm_init(). Move the

Re: [PATCH v3 2/3] kvm: add support for guest physical bits

2024-03-17 Thread Xiaoyao Li
On 3/13/2024 9:27 PM, Gerd Hoffmann wrote: Query kvm for supported guest physical address bits, in cpuid function 8008, eax[23:16]. Usually this is identical to host physical address bits. With NPT or EPT being used this might be restricted to 48 (max 4-level paging address space size) even

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

2024-03-15 Thread Xiaoyao Li
On 3/13/2024 11:31 PM, Daniel P. Berrangé wrote: On Tue, Mar 12, 2024 at 03:44:32PM +0800, Xiaoyao Li wrote: On 3/11/2024 5:27 PM, Daniel P. Berrangé wrote: On Thu, Feb 29, 2024 at 01:37:10AM -0500, Xiaoyao Li wrote: From: Isaku Yamahata Add property "quote-generation-socket" to

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

2024-03-12 Thread Xiaoyao Li
On 3/11/2024 5:27 PM, Daniel P. Berrangé wrote: On Thu, Feb 29, 2024 at 01:37:10AM -0500, Xiaoyao Li wrote: 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 Ge

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

2024-03-12 Thread Xiaoyao Li
On 3/11/2024 3:29 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 3/7/2024 9:51 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 2/29/2024 4:51 PM, Markus Armbruster wrote: Xiaoyao Li writes: Integrate TDX's TDX_REPORT_FATAL_ERROR into QEMU GuestPanic facility Originated

Re: [PATCH v9 06/21] i386/cpu: Use APIC ID info to encode cache topo in CPUID[4]

2024-03-11 Thread Xiaoyao Li
On 3/10/2024 9:38 PM, Zhao Liu wrote: Hi Xiaoyao, case 3: /* L3 cache info */ -die_offset = apicid_die_offset(&topo_info); if (cpu->enable_l3_cache) { +addressable_threads_width = apicid_die_offset(&topo_info); Please get r

Re: [PATCH v9 11/21] i386/cpu: Decouple CPUID[0x1F] subleaf with specific topology level

2024-03-11 Thread Xiaoyao Li
uot;module" level in 0x1F, decouple CPUID[0x1F] subleaf with specific topology level. Tested-by: Yongwei Ma Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li Besides, some nits below. --- Changes since v7: * Refactored the encode_topo_cpuid1f() to use traversal to search the enco

Re: [PATCH v9 09/21] i386/cpu: Introduce bitmap to cache available CPU topology levels

2024-03-10 Thread Xiaoyao Li
asier to detect without touching the topology details. This is also in preparation for the follow-up to decouple CPUID[0x1F] subleaf with specific topology level. Tested-by: Yongwei Ma Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li

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

2024-03-10 Thread Xiaoyao Li
On 3/7/2024 9:51 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 2/29/2024 4:51 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 v5: - me

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

2024-03-10 Thread Xiaoyao Li
On 3/7/2024 9:56 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 3/7/2024 4:39 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 2/29/2024 9:25 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 2/29/2024 4:37 PM, Markus Armbruster wrote: Xiaoyao Li writes: From: Isaku

Re: [PATCH v9 08/21] i386/cpu: Consolidate the use of topo_info in cpu_x86_cpuid()

2024-03-09 Thread Xiaoyao Li
On 2/27/2024 6:32 PM, Zhao Liu wrote: From: Zhao Liu In cpu_x86_cpuid(), there are many variables in representing the cpu topology, e.g., topo_info, cs->nr_cores and cs->nr_threads. Since the names of cs->nr_cores/cs->nr_threads does not accurately Again as in v7, please changes to "cs->nr_co

Re: [PATCH v9 07/21] i386/cpu: Use APIC ID info get NumSharingCache for CPUID[0x8000001D].EAX[bits 25:14]

2024-03-09 Thread Xiaoyao Li
ID to calculate this field. [1]: APM, vol.3, appendix.E.4.15 Function 8000_001Dh--Cache Topology Information Cc: Babu Moger Tested-by: Yongwei Ma Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li --- Changes since v7: * Moved this patch after CPUID[4]'s similar change ("i386

Re: [PATCH v9 06/21] i386/cpu: Use APIC ID info to encode cache topo in CPUID[4]

2024-03-09 Thread Xiaoyao Li
id_core_offset(&topo_info); And it is straightforward that it means the number of bits in x2APICID to encode different addressable cores. But it is not similar to addressable_threads_width, the semantic changes per different cache level. In fact, you want something like bi

Re: [PATCH v2 2/2] kvm: add support for guest physical bits

2024-03-07 Thread Xiaoyao Li
On 3/5/2024 6:52 PM, Gerd Hoffmann wrote: Query kvm for supported guest physical address bits, in cpuid function 8008, eax[23:16]. Usually this is identical to host physical address bits. With NPT or EPT being used this might be restricted to 48 (max 4-level paging address space size) even

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

2024-03-07 Thread Xiaoyao Li
On 2/29/2024 4:51 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 v5: - mention additional error information in gpa when it presents; - refin

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

2024-03-07 Thread Xiaoyao Li
On 2/29/2024 9:28 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 2/29/2024 4:40 PM, Markus Armbruster wrote: Xiaoyao Li writes: From: Isaku Yamahata Add property "quote-generation-socket" to tdx-guest, which is a property of type SocketAddress to specify Quote Generation S

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

2024-03-07 Thread Xiaoyao Li
On 3/7/2024 4:39 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 2/29/2024 9:25 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 2/29/2024 4:37 PM, Markus Armbruster wrote: Xiaoyao Li writes: From: Isaku Yamahata Three sha384 hash values, mrconfigid, mrowner and mrownerconfig

Re: [PATCH v5 08/65] kvm: handle KVM_EXIT_MEMORY_FAULT

2024-03-06 Thread Xiaoyao Li
On 3/5/2024 5:10 PM, Isaku Yamahata wrote: On Thu, Feb 29, 2024 at 01:36:29AM -0500, Xiaoyao Li wrote: 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

Re: [PATCH 1/1] kvm: add support for guest physical bits

2024-03-04 Thread Xiaoyao Li
On 3/4/2024 10:58 PM, Gerd Hoffmann wrote: On Mon, Mar 04, 2024 at 09:54:40AM +0800, Xiaoyao Li wrote: On 3/1/2024 6:17 PM, Gerd Hoffmann wrote: query kvm for supported guest physical address bits using KVM_CAP_VM_GPA_BITS. Expose the value to the guest via cpuid (leaf 0x8008, eax, bits

Re: [PATCH 1/1] kvm: add support for guest physical bits

2024-03-03 Thread Xiaoyao Li
On 3/1/2024 6:17 PM, Gerd Hoffmann wrote: query kvm for supported guest physical address bits using KVM_CAP_VM_GPA_BITS. Expose the value to the guest via cpuid (leaf 0x8008, eax, bits 16-23). Signed-off-by: Gerd Hoffmann --- target/i386/cpu.h | 1 + target/i386/cpu.c | 1 + ta

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

2024-02-29 Thread Xiaoyao Li
On 2/29/2024 9:25 PM, Markus Armbruster wrote: Xiaoyao Li writes: On 2/29/2024 4:37 PM, Markus Armbruster wrote: Xiaoyao Li writes: From: Isaku Yamahata Three sha384 hash values, mrconfigid, mrowner and mrownerconfig, of a TD can be provided for TDX attestation. Detailed meaning of them

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

2024-02-29 Thread Xiaoyao Li
On 2/29/2024 4:40 PM, Markus Armbruster wrote: Xiaoyao Li writes: 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 so

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

2024-02-29 Thread Xiaoyao Li
On 2/29/2024 4:37 PM, Markus Armbruster wrote: Xiaoyao Li writes: 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

  1   2   3   4   5   6   7   8   9   10   >