From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, aep@kraud.cloud
Cc: qemu-devel@nongnu.org
Subject: Re: [PULL 16/16] target/i386/SEV: implement mask_cpuid_features
Date: Tue, 6 Aug 2024 12:42:24 +0100 [thread overview]
Message-ID: <ZrIMII0SUzfwoF_P@redhat.com> (raw)
In-Reply-To: <20240704095806.1780273-17-pbonzini@redhat.com>
On Thu, Jul 04, 2024 at 11:58:06AM +0200, Paolo Bonzini wrote:
> Drop features that are listed as "BitMask" in the PPR and currently
> not supported by AMD processors. The only ones that may become useful
> in the future are TSC deadline timer and x2APIC, everything else is
> not needed for SEV-SNP guests (e.g. VIRT_SSBD) or would require
> processor support (e.g. TSC_ADJUST).
>
> This allows running SEV-SNP guests with "-cpu host".
What CPU generation(s)/model(s) did you test this with ?
I've been talking to a libvirt user (CC'd) who has tried host CPU
passthrough with SNP, using QEMU git master from yesterday (which
has this patch present) and they are still getting failures.
They are using pc-q35-9.1 machine type and host CPU passthrough,
on a Milan 7003 host, and getting this validation failure
SEV-SNP: CPUID validation failed for function 0x80000021, index: 0x0, provided: eax:0x18000245, ebx: 0x00000000, ecx: 0x00000000, edx: 0x00000000, expected: eax:0x18000045, ebx: 0x00000000, ecx: 0x00000000, edx: 0x00000000
I don't see any 0x0000_0200 bit defined for EAX with
the function 0x8000_0021 in target/i386/cpu.c, so there's
nothing we can mask out on the CLI, nor in your
sev_snp_mask_cpuid_features function.
For that matter we've not defined the 0x1000_0000 or 0x0800_000
bits either, though SNP isn't complaining about those at least.
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 2f3dbe289f4..2ba5f517228 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -945,6 +945,38 @@ out:
> return ret;
> }
>
> +static uint32_t
> +sev_snp_mask_cpuid_features(X86ConfidentialGuest *cg, uint32_t feature, uint32_t index,
> + int reg, uint32_t value)
> +{
> + switch (feature) {
> + case 1:
> + if (reg == R_ECX) {
> + return value & ~CPUID_EXT_TSC_DEADLINE_TIMER;
> + }
> + break;
> + case 7:
> + if (index == 0 && reg == R_EBX) {
> + return value & ~CPUID_7_0_EBX_TSC_ADJUST;
> + }
> + if (index == 0 && reg == R_EDX) {
> + return value & ~(CPUID_7_0_EDX_SPEC_CTRL |
> + CPUID_7_0_EDX_STIBP |
> + CPUID_7_0_EDX_FLUSH_L1D |
> + CPUID_7_0_EDX_ARCH_CAPABILITIES |
> + CPUID_7_0_EDX_CORE_CAPABILITY |
> + CPUID_7_0_EDX_SPEC_CTRL_SSBD);
> + }
> + break;
> + case 0x80000008:
> + if (reg == R_EBX) {
> + return value & ~CPUID_8000_0008_EBX_VIRT_SSBD;
> + }
> + break;
> + }
> + return value;
> +}
> +
> static int
> sev_launch_update_data(SevCommonState *sev_common, hwaddr gpa,
> uint8_t *addr, size_t len)
> @@ -2315,6 +2347,7 @@ sev_snp_guest_class_init(ObjectClass *oc, void *data)
> klass->launch_finish = sev_snp_launch_finish;
> klass->launch_update_data = sev_snp_launch_update_data;
> klass->kvm_init = sev_snp_kvm_init;
> + x86_klass->mask_cpuid_features = sev_snp_mask_cpuid_features;
> x86_klass->kvm_type = sev_snp_kvm_type;
>
> object_class_property_add(oc, "policy", "uint64",
> --
> 2.45.2
>
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2024-08-06 11:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 9:57 [PULL 00/16] meson, i386 changes for 2024-07-04 Paolo Bonzini
2024-07-04 9:57 ` [PULL 01/16] meson: move shared_module() calls where modules are already walked Paolo Bonzini
2024-07-04 9:57 ` [PULL 02/16] meson: move block.syms dependency out of libblock Paolo Bonzini
2024-07-04 9:57 ` [PULL 03/16] meson: merge plugin_ldflags into emulator_link_args Paolo Bonzini
2024-07-04 9:57 ` [PULL 04/16] meson: Pass objects and dependencies to declare_dependency() Paolo Bonzini
2024-07-04 9:57 ` [PULL 05/16] Revert "meson: Propagate gnutls dependency" Paolo Bonzini
2024-07-04 9:57 ` [PULL 06/16] meson: Drop the .fa library suffix Paolo Bonzini
2024-07-04 9:57 ` [PULL 07/16] target/i386: pass X86CPU to x86_cpu_get_supported_feature_word Paolo Bonzini
2024-07-04 9:57 ` [PULL 08/16] target/i386: drop AMD machine check bits from Intel CPUID Paolo Bonzini
2024-07-04 9:57 ` [PULL 09/16] target/i386: SEV: fix formatting of CPUID mismatch message Paolo Bonzini
2024-07-04 9:58 ` [PULL 10/16] target/i386: do not include undefined bits in the AMD topoext leaf Paolo Bonzini
2024-07-04 9:58 ` [PULL 11/16] i386/sev: Fix error message in sev_get_capabilities() Paolo Bonzini
2024-07-04 9:58 ` [PULL 12/16] i386/sev: Fallback to the default SEV device if none provided " Paolo Bonzini
2024-07-04 9:58 ` [PULL 13/16] target/i386: add avx-vnni-int16 feature Paolo Bonzini
2024-07-04 9:58 ` [PULL 14/16] char-stdio: Restore blocking mode of stdout on exit Paolo Bonzini
2024-07-04 9:58 ` [PULL 15/16] target/i386: add support for masking CPUID features in confidential guests Paolo Bonzini
2024-07-04 9:58 ` [PULL 16/16] target/i386/SEV: implement mask_cpuid_features Paolo Bonzini
2024-08-06 11:42 ` Daniel P. Berrangé [this message]
2024-07-04 18:16 ` [PULL 00/16] meson, i386 changes for 2024-07-04 Richard Henderson
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=ZrIMII0SUzfwoF_P@redhat.com \
--to=berrange@redhat.com \
--cc=aep@kraud.cloud \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.