mbox series

[v6,0/3] amd/msr: implement MSR_VIRT_SPEC_CTRL for HVM guests

Message ID 20220517153127.40276-1-roger.pau@citrix.com (mailing list archive)
Headers show
Series amd/msr: implement MSR_VIRT_SPEC_CTRL for HVM guests | expand

Message

Roger Pau Monné May 17, 2022, 3:31 p.m. UTC
Hello,

The following series implements support for MSR_VIRT_SPEC_CTRL
(VIRT_SSBD) on different AMD CPU families.

Note that the support is added backwards, starting with the newer CPUs
that support MSR_SPEC_CTRL and moving to the older ones either using
MSR_VIRT_SPEC_CTRL or the SSBD bit in LS_CFG.

Xen is still free to use it's own SSBD setting, as the selection is
context switched on vm{entry,exit}.

On Zen2 and later, SPEC_CTRL.SSBD should exist and should be used in
preference to VIRT_SPEC_CTRL.SSBD.  However, for migration
compatibility, Xen offers VIRT_SSBD to guests (in the max cpuid policy,
not default) implemented in terms of SPEC_CTRL.SSBD.

On Fam15h thru Zen1, Xen exposes VIRT_SSBD to guests by default to
abstract away the model and/or hypervisor specific differences in
MSR_LS_CFG/MSR_VIRT_SPEC_CTRL.

So the implementation of VIRT_SSBD exposed to HVM guests will use one of
the following underlying mechanisms, in the preference order listed
below:

 * SPEC_CTRL.SSBD: patch 1
 * VIRT_SPEC_CTRL.SSBD: patch 2.
 * Non-architectural way using LS_CFG: patch 3.

NB: patch 3 introduces some logic in GIF=0 context, such logic has been
kept to a minimum due to the special context it's running on.

Roger Pau Monne (3):
  amd/msr: implement VIRT_SPEC_CTRL for HVM guests on top of SPEC_CTRL
  amd/msr: allow passthrough of VIRT_SPEC_CTRL for HVM guests
  amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD

 CHANGELOG.md                                |   3 +
 xen/arch/x86/cpu/amd.c                      | 121 +++++++++++++++++---
 xen/arch/x86/cpuid.c                        |  21 ++++
 xen/arch/x86/hvm/hvm.c                      |   1 +
 xen/arch/x86/hvm/svm/entry.S                |   8 ++
 xen/arch/x86/hvm/svm/svm.c                  |  39 +++++++
 xen/arch/x86/include/asm/amd.h              |   4 +
 xen/arch/x86/include/asm/cpufeatures.h      |   1 +
 xen/arch/x86/include/asm/msr.h              |  14 +++
 xen/arch/x86/msr.c                          |  26 +++++
 xen/arch/x86/spec_ctrl.c                    |  12 +-
 xen/include/public/arch-x86/cpufeatureset.h |   2 +-
 12 files changed, 233 insertions(+), 19 deletions(-)

Comments

Jan Beulich May 18, 2022, 9:45 a.m. UTC | #1
On 17.05.2022 17:31, Roger Pau Monne wrote:
> Hello,
> 
> The following series implements support for MSR_VIRT_SPEC_CTRL
> (VIRT_SSBD) on different AMD CPU families.
> 
> Note that the support is added backwards, starting with the newer CPUs
> that support MSR_SPEC_CTRL and moving to the older ones either using
> MSR_VIRT_SPEC_CTRL or the SSBD bit in LS_CFG.
> 
> Xen is still free to use it's own SSBD setting, as the selection is
> context switched on vm{entry,exit}.
> 
> On Zen2 and later, SPEC_CTRL.SSBD should exist and should be used in
> preference to VIRT_SPEC_CTRL.SSBD.  However, for migration
> compatibility, Xen offers VIRT_SSBD to guests (in the max cpuid policy,
> not default) implemented in terms of SPEC_CTRL.SSBD.
> 
> On Fam15h thru Zen1, Xen exposes VIRT_SSBD to guests by default to
> abstract away the model and/or hypervisor specific differences in
> MSR_LS_CFG/MSR_VIRT_SPEC_CTRL.
> 
> So the implementation of VIRT_SSBD exposed to HVM guests will use one of
> the following underlying mechanisms, in the preference order listed
> below:
> 
>  * SPEC_CTRL.SSBD: patch 1
>  * VIRT_SPEC_CTRL.SSBD: patch 2.
>  * Non-architectural way using LS_CFG: patch 3.
> 
> NB: patch 3 introduces some logic in GIF=0 context, such logic has been
> kept to a minimum due to the special context it's running on.
> 
> Roger Pau Monne (3):
>   amd/msr: implement VIRT_SPEC_CTRL for HVM guests on top of SPEC_CTRL
>   amd/msr: allow passthrough of VIRT_SPEC_CTRL for HVM guests
>   amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD

FTAOD, while besides a missing ack for ...

>  CHANGELOG.md                                |   3 +

... this addition the series would now look to be ready to go in,
I'd like to have some form of confirmation by you, Andrew, that
you now view this as meeting the comments you gave on an earlier
version.

Jan
Henry Wang May 18, 2022, 9:51 a.m. UTC | #2
Hi Jan, Roger and Andrew,

> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> 
> On 17.05.2022 17:31, Roger Pau Monne wrote:
> > Hello,
> >
> > The following series implements support for MSR_VIRT_SPEC_CTRL
> > (VIRT_SSBD) on different AMD CPU families.
> >
> > Note that the support is added backwards, starting with the newer CPUs
> > that support MSR_SPEC_CTRL and moving to the older ones either using
> > MSR_VIRT_SPEC_CTRL or the SSBD bit in LS_CFG.
> >
> > Xen is still free to use it's own SSBD setting, as the selection is
> > context switched on vm{entry,exit}.
> >
> > On Zen2 and later, SPEC_CTRL.SSBD should exist and should be used in
> > preference to VIRT_SPEC_CTRL.SSBD.  However, for migration
> > compatibility, Xen offers VIRT_SSBD to guests (in the max cpuid policy,
> > not default) implemented in terms of SPEC_CTRL.SSBD.
> >
> > On Fam15h thru Zen1, Xen exposes VIRT_SSBD to guests by default to
> > abstract away the model and/or hypervisor specific differences in
> > MSR_LS_CFG/MSR_VIRT_SPEC_CTRL.
> >
> > So the implementation of VIRT_SSBD exposed to HVM guests will use one
> of
> > the following underlying mechanisms, in the preference order listed
> > below:
> >
> >  * SPEC_CTRL.SSBD: patch 1
> >  * VIRT_SPEC_CTRL.SSBD: patch 2.
> >  * Non-architectural way using LS_CFG: patch 3.
> >
> > NB: patch 3 introduces some logic in GIF=0 context, such logic has been
> > kept to a minimum due to the special context it's running on.
> >
> > Roger Pau Monne (3):
> >   amd/msr: implement VIRT_SPEC_CTRL for HVM guests on top of
> SPEC_CTRL
> >   amd/msr: allow passthrough of VIRT_SPEC_CTRL for HVM guests
> >   amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD
> 
> FTAOD, while besides a missing ack for ...
> 
> >  CHANGELOG.md                                |   3 +
> 
> ... this addition the series would now look to be ready to go in,
> I'd like to have some form of confirmation by you, Andrew, that
> you now view this as meeting the comments you gave on an earlier
> version.

Not completely sure if I am proper to do that but for the CHANGELOG.md
change:

Acked-by: Henry Wang <Henry.Wang@arm.com>

Kind regards,
Henry

> 
> Jan
Jan Beulich May 18, 2022, 10:09 a.m. UTC | #3
On 18.05.2022 11:51, Henry Wang wrote:
>> -----Original Message-----
>> From: Jan Beulich <jbeulich@suse.com>
>>
>> On 17.05.2022 17:31, Roger Pau Monne wrote:
>>> Roger Pau Monne (3):
>>>   amd/msr: implement VIRT_SPEC_CTRL for HVM guests on top of
>> SPEC_CTRL
>>>   amd/msr: allow passthrough of VIRT_SPEC_CTRL for HVM guests
>>>   amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD
>>
>> FTAOD, while besides a missing ack for ...
>>
>>>  CHANGELOG.md                                |   3 +
>>
>> ... this addition the series would now look to be ready to go in,
>> I'd like to have some form of confirmation by you, Andrew, that
>> you now view this as meeting the comments you gave on an earlier
>> version.
> 
> Not completely sure if I am proper to do that but for the CHANGELOG.md
> change:

Well, no-one except you actually can ack changes to this file, as per
./MAINTAINERS.

> Acked-by: Henry Wang <Henry.Wang@arm.com>

Thanks.

Jan
Henry Wang May 18, 2022, 10:22 a.m. UTC | #4
Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> 
> On 18.05.2022 11:51, Henry Wang wrote:
> >> -----Original Message-----
> >> From: Jan Beulich <jbeulich@suse.com>
> >>
> >> On 17.05.2022 17:31, Roger Pau Monne wrote:
> >>> Roger Pau Monne (3):
> >>>   amd/msr: implement VIRT_SPEC_CTRL for HVM guests on top of
> >> SPEC_CTRL
> >>>   amd/msr: allow passthrough of VIRT_SPEC_CTRL for HVM guests
> >>>   amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy
> SSBD
> >>
> >> FTAOD, while besides a missing ack for ...
> >>
> >>>  CHANGELOG.md                                |   3 +
> >>
> >> ... this addition the series would now look to be ready to go in,
> >> I'd like to have some form of confirmation by you, Andrew, that
> >> you now view this as meeting the comments you gave on an earlier
> >> version.
> >
> > Not completely sure if I am proper to do that but for the CHANGELOG.md
> > change:
> 
> Well, no-one except you actually can ack changes to this file, as per
> ./MAINTAINERS.

Thanks for confirming and sending the reminder to help me to understand
that I should ack the changes in CHANGELOG.md for this series, I will keep
the information in mind and I guess I am gradually acquiring experiences :)

Kind regards,
Henry

> 
> > Acked-by: Henry Wang <Henry.Wang@arm.com>
> 
> Thanks.
> 
> Jan
Jan Beulich July 7, 2022, 4:14 p.m. UTC | #5
On 17.05.2022 17:31, Roger Pau Monne wrote:
> Roger Pau Monne (3):
>   amd/msr: implement VIRT_SPEC_CTRL for HVM guests on top of SPEC_CTRL
>   amd/msr: allow passthrough of VIRT_SPEC_CTRL for HVM guests
>   amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD

While, somewhat different from Jürgen's series, here the delay is more
voluntary (in that I had told Roger that I'd prefer to commit this only
with your (perhaps informal) agreement, I think we also can't wait much
longer. I'm willing to give it until the end of next week, so I guess
I'd move forward with committing early the week after, unless I hear
substantial arguments against doing so (at which point the two of us
would likely need to decide who's going to pick up this work while
Roger is away).

Once again thanks for your understanding,
Jan