All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v9 04/10] x86/cpu-policy: re-arrange no-VMX logic
Date: Wed, 8 Apr 2026 08:09:02 +0200	[thread overview]
Message-ID: <a46d6578-e622-48c5-ab0f-34a88dfd2bec@suse.com> (raw)
In-Reply-To: <48df7b1b-5d07-4eeb-8028-6a90c12a6e2a@citrix.com>

On 07.04.2026 23:58, Andrew Cooper wrote:
> On 24/11/2025 2:59 pm, Jan Beulich wrote:
>> --- a/xen/arch/x86/cpu-policy.c
>> +++ b/xen/arch/x86/cpu-policy.c
>> @@ -812,19 +812,20 @@ static void __init calculate_hvm_max_pol
>>          if ( !cpu_has_vmx_xsaves )
>>              __clear_bit(X86_FEATURE_XSAVES, fs);
>>      }
>> +    else
>> +    {
>> +        /*
>> +         * Xen doesn't use PKS, so the guest support for it has opted to not use
>> +         * the VMCS load/save controls for efficiency reasons.  This depends on
>> +         * the exact vmentry/exit behaviour, so don't expose PKS in other
>> +         * situations until someone has cross-checked the behaviour for safety.
>> +         */
>> +        __clear_bit(X86_FEATURE_PKS, fs);
>> +    }
>>  
>>      if ( !cpu_has_vmx_msrlist )
>>          __clear_bit(X86_FEATURE_MSRLIST, fs);
>>  
>> -    /*
>> -     * Xen doesn't use PKS, so the guest support for it has opted to not use
>> -     * the VMCS load/save controls for efficiency reasons.  This depends on
>> -     * the exact vmentry/exit behaviour, so don't expose PKS in other
>> -     * situations until someone has cross-checked the behaviour for safety.
>> -     */
>> -    if ( !cpu_has_vmx )
>> -        __clear_bit(X86_FEATURE_PKS, fs);
>> -
>>      /* 
>>       * Make adjustments to possible (nested) virtualization features exposed
>>       * to the guest
>>
> 
> These clauses aren't logically doing the same thing.  So while the
> compiler can merge them, I don't think it's a good idea to do so at a
> source level.
> 
> The "if ( vmx ) " block we can just see the end of is for features which
> need to cross-check extra VMX capabilities.  Each of RDTSCP, INVPCID and
> XSAVES are #UD unless explicitly enabled.  MPX is the odd-one out,
> checking the load/save capabilities.
> 
> I suspect this list is incomplete.  These cross-checks shouldn't fail on
> real hardware, where the VMX capabilities should match the native
> features, but nested virt is rife with enumeration bugs here.
> 
> The second "if ( !vmx )" clause is different.  This is really "I wired
> up PKS based on how Intel works, and if AMD ever gains it it will
> definitely need context switching changes to work".  This is in lieu of
> having dedicated Intel/AMD annotations for features.

Right, and this is what I'm using the new "else" body for later in the
series.

> The MSRLIST addition from the prior patch is arguably misplaced, except
> it's trying to cover both of the aspects.

Why is it misplaced? Where else would you want it to go? The VMX aspect,
as you say, is included in cpu_has_vmx_msrlist, so it doesn't need
separate checking for VMX.

> AMD are making no obvious moves to add PKS, and I expect MSRLIST is even
> lower down their priority list.
> 
> Overall, we need checks here for every guest-visible feature which:
> * has VMCS/VMCB controls which are enumerated separately
> * needs new context switching considerations

Which in this series are USER-MSR and MSR-IMM. Hence this prereq change,
to simplify the additions there.

> Maybe the "if ( !vmx )" shouldn't really be written this way.  I'm open
> to suggestions, but making it an else block isn't a solution.

Well in this situation I guess it's you to make suggestions. I have made
mine by way of this submission.

Jan


  reply	other threads:[~2026-04-08  6:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24 14:56 [PATCH v9 10/10] x86emul: misc additions Jan Beulich
2025-11-24 14:57 ` [PATCH v9 01/10] x86emul: support LKGS Jan Beulich
2025-11-24 14:58 ` [PATCH v9 02/10] x86emul+VMX: support {RD,WR}MSRLIST Jan Beulich
2025-11-24 14:58 ` [PATCH v9 03/10] x86emul: support USER_MSR instructions Jan Beulich
2025-11-24 14:59 ` [PATCH v9 04/10] x86/cpu-policy: re-arrange no-VMX logic Jan Beulich
2026-04-07 21:58   ` Andrew Cooper
2026-04-08  6:09     ` Jan Beulich [this message]
2025-11-24 15:00 ` [PATCH v9 05/10] VMX: support USER-MSR Jan Beulich
2025-11-24 15:00 ` [PATCH v9 06/10] x86emul: support MSR_IMM instructions Jan Beulich
2025-11-24 15:00 ` [PATCH v9 07/10] VMX: support MSR-IMM Jan Beulich
2025-11-26 18:50   ` Andrew Cooper
2025-11-27  8:18     ` Jan Beulich
2025-11-24 15:01 ` [PATCH v9 08/10] x86emul: support non-SIMD MOVRS Jan Beulich
2025-11-24 15:01 ` [PATCH v9 09/10] x86: use / "support" UDB Jan Beulich
2025-12-05 12:01   ` Andrew Cooper
2025-12-05 12:40     ` Andrew Cooper
2025-12-05 13:13       ` Jan Beulich
2025-12-05 13:15         ` Andrew Cooper
2025-12-05 13:15       ` Jan Beulich
2025-12-05 13:35         ` Andrew Cooper
2025-12-05 13:09     ` Jan Beulich
2025-11-24 15:02 ` [PATCH v9 10/10] x86emul: support AVX512-BMM Jan Beulich
2025-12-05 12:33   ` Andrew Cooper
2025-12-05 12:47     ` Jan Beulich
2026-04-07 15:11       ` Andrew Cooper
2025-11-24 15:03 ` [PATCH v9 00/10] x86emul: misc additions Jan Beulich

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=a46d6578-e622-48c5-ab0f-34a88dfd2bec@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.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.