[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/3] amd/msr: allow passthrough of VIRT_SPEC_CTRL for HVM guests
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Thu, 10 Mar 2022 17:41:19 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g1GROqNbzLR92M0X8QnrmNGlycl5GeJ7Kk749jNgCNk=; b=Hq/li9dLKPjcYpMaqjWGKC9vfvdbO3scYb3pQct+Vn3xMnabfwvdy9AK/10UWmCtCXzXEs4mMUsNCxHsfWY7sP7apZUjAXYklBdLDNucP4cqCrBQ18l55INwMf+KM2jk5yOqcpru2RNHSV67hytjlf7MYIazdcWhfiPyi3j7TIxOBfyzLGTEmZuyCwSCa7sa8sJaILjNZW8biyAPjQtYbvvD7Uv6AwiIuzRyGwBp0Qq/IvitWKX/ok47APj5RyXZ5eVgUzC+xrmELs4A54BJ9HiT0R4Ems3ifa7j6B0KGmnSsgUA1oBwhS7crDT6mIkZ7hKHE4MyBm0Ek+VKRyaTzw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aUI0BV7ORAph5E9GggMSUCDqHOCzlni7y9mDZINmyRRUe0n4+TGyV229ou6q/ZeLYporymByNeIMMSxKhgXbMtiwpQs3s9IrPVGGR1k8RrvDax3PqAR3C/Wb2u8Qopdc5Z8j1NQDMTL1q94n54BVa+AgSdFhJwJw4Nlhlcz8M3d2nfVFrOc2KSKlWo4JPxTndUrVFlqkdKU8H4Rn6SmEbKJ0ks7ui8vfSiPT6U72f43tI3uE9lqGaFv4uQouAkiUOPIQluEBk8+JQUZ38OQWvtTbzdGh7/dyUv6RiLgpgt8h+hS0QUjlmpZpQemeZkASctr0af19ygxnnYkr6Inugg==
- Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Thu, 10 Mar 2022 16:42:14 +0000
- Ironport-data: A9a23:4gEcjKBHTdByGxVW/zjjw5YqxClBgxIJ4kV8jS/XYbTApGwh0zxTx zZMXGCDPq6CYWbzfoxxPY7l8hxU7MWGm9VrQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E/raNANlFEkvU2ybuOU5NXsZ2YgHWeIdA970Ug5w7Vg2tYy6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhP6 s9g5Me8Tzw2ZLHghqcbfgcGMx9XaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguw5K8bmJsUHs2xIxjDFF/c2B5vERs0m4PcGgWto150TRJ4yY eIiNBF0MSuffSZoHQo0Cr45xNevol7WJmgwRFW9+vNsvjm7IBZK+KjgNp/Zd8KHQe1Rn12Ev STW8mLhGBYYOdeDjz2f/RqEmevnjS79HoUIG9WQ9PRnnVmSzWw7EwANWB2wpvzRt6Klc4sBc QpOoHNo9PVsshzwJjXgY/GmiECmpDNNANZWKPJg9C2Tiaz5/Vi5OEFRG1atd+canMMxQDUr0 HqAkNXoGSFjvdWpd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id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Mon, Feb 14, 2022 at 05:02:52PM +0100, Jan Beulich wrote:
> On 01.02.2022 17:46, Roger Pau Monne wrote:
> > --- a/xen/arch/x86/hvm/svm/entry.S
> > +++ b/xen/arch/x86/hvm/svm/entry.S
> > @@ -71,7 +71,9 @@ __UNLIKELY_END(nsvm_hap)
> > mov %al, CPUINFO_last_spec_ctrl(%rsp)
> > 1: /* No Spectre v1 concerns. Execution will hit VMRUN
> > imminently. */
> > .endm
> > - ALTERNATIVE "", svm_vmentry_spec_ctrl, X86_FEATURE_SC_MSR_HVM
> > + ALTERNATIVE_2 "", STR(call vmentry_virt_spec_ctrl), \
>
> I'm afraid this violates the "ret" part of the warning a few lines up,
> while ...
>
> > + X86_FEATURE_VIRT_SC_MSR_HVM, \
> > + svm_vmentry_spec_ctrl, X86_FEATURE_SC_MSR_HVM
> >
> > pop %r15
> > pop %r14
> > @@ -111,7 +113,9 @@ __UNLIKELY_END(nsvm_hap)
> > wrmsr
> > mov %al, CPUINFO_last_spec_ctrl(%rsp)
> > .endm
> > - ALTERNATIVE "", svm_vmexit_spec_ctrl, X86_FEATURE_SC_MSR_HVM
> > + ALTERNATIVE_2 "", STR(call vmexit_virt_spec_ctrl), \
>
> ... this violates ...
>
> > + X86_FEATURE_VIRT_SC_MSR_HVM, \
> > + svm_vmexit_spec_ctrl, X86_FEATURE_SC_MSR_HVM
> > /* WARNING! `ret`, `call *`, `jmp *` not safe before this point. */
>
> ... the "ret" part of this warning.
Hm, so while I could load VIRT_SPEC_CTRL easily from assembly, loading
of the legacy non-architectural setting of SSBD for Fam18h and earlier
it's likely not doable from assembly.
Since those helpers would only set SSBD, isn't it fine to execute a
`ret` after either having set or clear SSBD?
AFAICT the requirement would be to either have loaded SPEC_CTRL first
(if present) in the VM exit path, or to set SSBD before setting
SPEC_CTRL in the VM entry path.
> Furthermore, opposite to what the change to amd_init_ssbd() suggests,
> the ordering of the alternatives here means you prefer SPEC_CTRL over
> VIRT_SPEC_CTRL; see the comment near the top of _apply_alternatives().
> Unless I've missed logic guaranteeing that both of the keyed to
> features can't be active at the same time.
Xen itself will only use a single one (either SPEC_CTRL.SSBD or
VIRT_SPEC_CTRL.SSBD) in order to implement support on behalf of the
guest. amd_init_ssbd already prefer to use SPEC_CTRL.SSBD over
VIRT_SPEC_CTRL.SSBD when both are available, so we aim to do the same
here.
I think part of the confusion steams from using info->{last_spec_ctrl,
xen_spec_ctrl} even when SPEC_CTRL MSR is not used by Xen, I need to
clarify this somehow, maybe by not using those fields in the first
place.
Thanks, Roger.
|