public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"Rick Edgecombe" <rick.p.edgecombe@intel.com>,
	"Francesco Lavra" <francescolavra.fl@gmail.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [PATCH v7 51/52] i386/tdx: Validate phys_bits against host value
Date: Sun, 2 Feb 2025 22:39:07 +0800	[thread overview]
Message-ID: <774945ce-04e2-42d5-83fc-97ad08647101@intel.com> (raw)
In-Reply-To: <CABgObfb5ruVO2sxLCbZobiaqX-3h9Q+UKOZnp_hhxfJA=T-OJA@mail.gmail.com>

On 2/1/2025 2:27 AM, Paolo Bonzini wrote:
> On Fri, Jan 24, 2025 at 2:40 PM Xiaoyao Li <xiaoyao.li@intel.com> wrote:
>>
>> For TDX guest, the phys_bits is not configurable and can only be
>> host/native value.
>>
>> Validate phys_bits inside tdx_check_features().
> 
> Hi Xiaoyao,
> 
> to avoid
> 
> qemu-kvm: TDX requires guest CPU physical bits (48) to match host CPU
> physical bits (52)
> 
> I need options like
> 
> -cpu host,phys-bits=52,guest-phys-bits=52,host-phys-bits-limit=52,-kvm-asyncpf-int
> 
> to start a TDX guest, is that intentional?

"-cpu host" should be sufficient and should not hit the error.

why did you get "guest CPU physical bits (48)"?

> Thanks,
> 
> Paolo
> 
>> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
>> ---
>>   target/i386/host-cpu.c | 2 +-
>>   target/i386/host-cpu.h | 1 +
>>   target/i386/kvm/tdx.c  | 8 ++++++++
>>   3 files changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/target/i386/host-cpu.c b/target/i386/host-cpu.c
>> index 3e4e85e729c8..8a15af458b05 100644
>> --- a/target/i386/host-cpu.c
>> +++ b/target/i386/host-cpu.c
>> @@ -15,7 +15,7 @@
>>   #include "system/system.h"
>>
>>   /* Note: Only safe for use on x86(-64) hosts */
>> -static uint32_t host_cpu_phys_bits(void)
>> +uint32_t host_cpu_phys_bits(void)
>>   {
>>       uint32_t eax;
>>       uint32_t host_phys_bits;
>> diff --git a/target/i386/host-cpu.h b/target/i386/host-cpu.h
>> index 6a9bc918baa4..b97ec01c9bec 100644
>> --- a/target/i386/host-cpu.h
>> +++ b/target/i386/host-cpu.h
>> @@ -10,6 +10,7 @@
>>   #ifndef HOST_CPU_H
>>   #define HOST_CPU_H
>>
>> +uint32_t host_cpu_phys_bits(void);
>>   void host_cpu_instance_init(X86CPU *cpu);
>>   void host_cpu_max_instance_init(X86CPU *cpu);
>>   bool host_cpu_realizefn(CPUState *cs, Error **errp);
>> diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
>> index bb75eb06dad9..c906a76c4c0e 100644
>> --- a/target/i386/kvm/tdx.c
>> +++ b/target/i386/kvm/tdx.c
>> @@ -24,6 +24,7 @@
>>
>>   #include "cpu.h"
>>   #include "cpu-internal.h"
>> +#include "host-cpu.h"
>>   #include "hw/i386/e820_memory_layout.h"
>>   #include "hw/i386/x86.h"
>>   #include "hw/i386/tdvf.h"
>> @@ -838,6 +839,13 @@ static int tdx_check_features(X86ConfidentialGuest *cg, CPUState *cs)
>>           return -1;
>>       }
>>
>> +    if (cpu->phys_bits != host_cpu_phys_bits()) {
>> +        error_report("TDX requires guest CPU physical bits (%u) "
>> +                     "to match host CPU physical bits (%u)",
>> +                     cpu->phys_bits, host_cpu_phys_bits());
>> +        exit(1);
>> +    }
>> +
>>       return 0;
>>   }
>>
>> --
>> 2.34.1
>>
> 
> 


  reply	other threads:[~2025-02-02 14:39 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24 13:19 [PATCH v7 00/52] QEMU TDX support Xiaoyao Li
2025-01-24 13:19 ` [PATCH v7 01/52] *** HACK *** linux-headers: Update headers to pull in TDX API changes Xiaoyao Li
2025-01-24 13:19 ` [PATCH v7 02/52] i386: Introduce tdx-guest object Xiaoyao Li
2025-01-24 13:19 ` [PATCH v7 03/52] i386/tdx: Implement tdx_kvm_type() for TDX Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 04/52] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 05/52] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES Xiaoyao Li
2025-02-18 19:21   ` Francesco Lavra
2025-02-25  8:59     ` Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 06/52] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 07/52] kvm: Introduce kvm_arch_pre_create_vcpu() Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 08/52] i386/tdx: Initialize TDX before creating TD vcpus Xiaoyao Li
2025-02-19 10:14   ` Francesco Lavra
2025-02-25  9:55     ` Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 09/52] i386/tdx: Add property sept-ve-disable for tdx-guest object Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 10/52] i386/tdx: Make sept_ve_disable set by default Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 11/52] i386/tdx: Wire CPU features up with attributes of TD guest Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 12/52] i386/tdx: Validate TD attributes Xiaoyao Li
2025-02-05  9:06   ` Markus Armbruster
2025-02-05 10:29     ` Xiaoyao Li
2025-02-05 10:31   ` Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 13/52] i386/tdx: Set APIC bus rate to match with what TDX module enforces Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 14/52] i386/tdx: Implement user specified tsc frequency Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 15/52] i386/tdx: load TDVF for TD guest Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 16/52] i386/tdvf: Introduce function to parse TDVF metadata Xiaoyao Li
2025-02-19 10:58   ` Francesco Lavra
2025-02-25 11:59     ` Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 17/52] i386/tdx: Parse TDVF metadata for TDX VM Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 18/52] i386/tdx: Don't initialize pc.rom for TDX VMs Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 19/52] i386/tdx: Track mem_ptr for each firmware entry of TDVF Xiaoyao Li
2025-02-19 11:26   ` Francesco Lavra
2025-02-26  9:07     ` Xiaoyao Li
2025-02-19 18:40   ` Francesco Lavra
2025-02-26  9:08     ` Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 20/52] i386/tdx: Track RAM entries for TDX VM Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 21/52] headers: Add definitions from UEFI spec for volumes, resources, etc Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 22/52] i386/tdx: Setup the TD HOB list Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 23/52] i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 24/52] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 25/52] i386/tdx: Finalize TDX VM Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 26/52] i386/tdx: Enable user exit on KVM_HC_MAP_GPA_RANGE Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 27/52] i386/tdx: Handle KVM_SYSTEM_EVENT_TDX_FATAL Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 28/52] i386/tdx: Wire TDX_REPORT_FATAL_ERROR with GuestPanic facility Xiaoyao Li
2025-02-05  9:19   ` Markus Armbruster
2025-02-05 10:19     ` Xiaoyao Li
2025-02-27 16:30   ` Francesco Lavra
2025-03-03  2:36     ` Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 29/52] i386/cpu: introduce x86_confidential_guest_cpu_instance_init() Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 30/52] i386/tdx: implement tdx_cpu_instance_init() Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 31/52] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 32/52] i386/tdx: Force " Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 33/52] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 34/52] i386/tdx: Disable SMM for TDX VMs Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 35/52] i386/tdx: Disable PIC " Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 36/52] i386/tdx: Don't synchronize guest tsc for TDs Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 37/52] i386/tdx: Only configure MSR_IA32_UCODE_REV in kvm_init_msrs() " Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 38/52] i386/apic: Skip kvm_apic_put() for TDX Xiaoyao Li
2025-02-27 16:57   ` Francesco Lavra
2025-03-03  2:42     ` Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 39/52] cpu: Don't set vcpu_dirty when guest_state_protected Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 40/52] i386/cgs: Rename *mask_cpuid_features() to *adjust_cpuid_features() Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 41/52] i386/tdx: Implement adjust_cpuid_features() for TDX Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 42/52] i386/tdx: Apply TDX fixed0 and fixed1 information to supported CPUIDs Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 43/52] i386/tdx: Mask off CPUID bits by unsupported TD Attributes Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 44/52] i386/cpu: Move CPUID_XSTATE_XSS_MASK to header file and introduce CPUID_XSTATE_MASK Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 45/52] i386/tdx: Mask off CPUID bits by unsupported XFAM Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 46/52] i386/tdx: Mark the configurable bit not reported by KVM as unsupported Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 47/52] i386/cgs: Introduce x86_confidential_guest_check_features() Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 48/52] i386/tdx: Fetch and validate CPUID of TD guest Xiaoyao Li
2025-02-05  9:28   ` Markus Armbruster
2025-02-05 10:29     ` Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 49/52] i386/tdx: Don't treat SYSCALL as unavailable Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 50/52] i386/tdx: Make invtsc default on Xiaoyao Li
2025-01-24 13:20 ` [PATCH v7 51/52] i386/tdx: Validate phys_bits against host value Xiaoyao Li
2025-01-31 18:27   ` Paolo Bonzini
2025-02-02 14:39     ` Xiaoyao Li [this message]
2025-02-03 18:15       ` Paolo Bonzini
2025-01-24 13:20 ` [PATCH v7 52/52] docs: Add TDX documentation Xiaoyao Li
2025-03-25 18:46   ` Daniel P. Berrangé
2025-03-26  3:36     ` Xiaoyao Li
2025-03-26  6:48       ` Xiaoyao Li
2025-03-26  9:22       ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=774945ce-04e2-42d5-83fc-97ad08647101@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=chenhuacai@kernel.org \
    --cc=eblake@redhat.com \
    --cc=francescolavra.fl@gmail.com \
    --cc=imammedo@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox