From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Ingo Molnar <mingo@kernel.org>
Cc: lguest@lists.ozlabs.org,
Andrew Cooper <andrew.cooper3@citrix.com>,
x86@kernel.org, "Luis R. Rodriguez" <mcgrof@kernel.org>,
xen-devel@lists.xensource.com, Borislav Petkov <bp@alien8.de>,
david.vrabel@citrix.com, Andy Lutomirski <luto@kernel.org>
Subject: Re: [PATCH v2 1/2] x86/entry/32: Introduce and use X86_BUG_ESPFIX instead of paravirt_enabled
Date: Wed, 2 Mar 2016 01:15:54 +0100 [thread overview]
Message-ID: <20160302001554.GH25240@wotan.suse.de> (raw)
In-Reply-To: <56D5A095.4050102@oracle.com>
Ingo, your feedback appreciated at the end here, regarding quirks.
On Tue, Mar 01, 2016 at 09:00:53AM -0500, Boris Ostrovsky wrote:
> On 02/29/2016 06:50 PM, Andy Lutomirski wrote:
> >diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> >index 91ddae732a36..c6ef4da8e4f4 100644
> >--- a/arch/x86/kernel/cpu/common.c
> >+++ b/arch/x86/kernel/cpu/common.c
> >@@ -979,6 +979,31 @@ static void identify_cpu(struct cpuinfo_x86 *c)
Note: Andy's change is on identify_cpu() modification here at the end.
> > #ifdef CONFIG_NUMA
> > numa_add_cpu(smp_processor_id());
> > #endif
> >+
> >+ /*
> >+ * ESPFIX is a strange bug. All real CPUs have it. Paravirt
> >+ * systems that run Linux at CPL > 0 may or may not have the
> >+ * issue, but, even if they have the issue, there's absolutely
> >+ * nothing we can do about it because we can't use the real IRET
> >+ * instruction.
> >+ *
> >+ * NB: For the time being, only 32-bit kernels support
> >+ * X86_BUG_ESPFIX as such. 64-bit kernels directly choose
> >+ * whether to apply espfix using paravirt hooks. If any
> >+ * non-paravirt system ever shows up that does *not* have the
> >+ * ESPFIX issue, we can change this.
> >+ */
> >+#ifdef CONFIG_X86_32
> >+#ifdef CONFIG_PARAVIRT
> >+ do {
> >+ extern void native_iret(void);
> >+ if (pv_cpu_ops.iret == native_iret)
> >+ set_cpu_bug(c, X86_BUG_ESPFIX);
> >+ } while (0);
> >+#else
> >+ set_cpu_bug(c, X86_BUG_ESPFIX);
> >+#endif
> >+#endif
> > }
> > /*
>
> Alternatively, PV guests can clear X86_BUG_ESPFIX in their init
> code. E.g in .set_cpu_features op, just like we do for
> X86_BUG_SYSRET_SS_ATTRS
Andy's proposal works out of identify_cpu() and that covers both boot
processor and secondary CPUs. The summary is as follows, tracing back in
time from left to right.
--- identify_boot_cpu() --- check_bugs() --- start_kernel()
/
identify_cpu()<
\
--- identify_secondary_cpu() --- cpu_up() --- smp_init()
--- kernel_init_freeable() --- kernel_init()
--- rest_init() --- start_kernel()
set_cpu_features() is called from both: init_hypervisor_platform()
during setup_arch() and identify_cpu(). Since it'll be called on
check_bugs() already on identify_boot_cpu() though I think the
call from init_hypervisor_platform() seems redundant ?
We assume we just call:
setup_arch() --> init_hypervisor_platform() --> init_hypervisor(&boot_cpu_data)
But the above map on identify_cpu() also shows we call:
start_kernel --> check_bugs() --> identify_boot_cpu() -->
identify_cpu() --> init_hypervisor() --> set_cpu_features()
void init_hypervisor(struct cpuinfo_x86 *c)
{
if (x86_hyper && x86_hyper->set_cpu_features)
x86_hyper->set_cpu_features(c);
}
Anyway, since we're consolidating quirks, and since it turns out the other
quirks are being shifted away from paravirt_enabled() out into another struct
x86_platform_ops CPU specific quirk, I wonder why not just also replace this
set_cpu_features() thing as a struct x86_platform_ops quirk CPU callback.
> (although this may require adding struct
> hypervisor_x86 for lguests. Which I think they should have anyway).
lguest already uses x86_platform, and setting up a per CPU quirk would
be rather trivial.
CPU feature / CPU quirk...
I've stashed the other quirks into a x86_early_init_platform_quirks(),
this was to have all quirks handled in one place. We handle differences
with subarch there. vmware has no subarch though, and it uses its own
set_cpu_features(). We have a few options I can think of:
1) keep this on set_cpu_features() and modify lguest to add a struct hypervisor_x86
as boris suggests
2) move set_cpu_features() as a platform feature / quirk callback and
call it on identify_cpu()
3) Just identify each quirk on struct x86_platform, with a set of defaults
set. Then identify_cpu() enables a platform callback to override
defaults, and finally then a shared quirk call is issued to
set the different set_cpu_features() or clear them.
Perhaps there are others. 2) and 3) are similar but 3) ensures the platform
struct is extended / documented per quirk.
Luis
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-03-02 0:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-29 23:50 [PATCH v2 0/2] x86/entry/32: Get rid of paravirt_enabled in ESPFIX Andy Lutomirski
[not found] ` <cover.1456789731.git.luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-02-29 23:50 ` [PATCH v2 1/2] x86/entry/32: Introduce and use X86_BUG_ESPFIX instead of paravirt_enabled Andy Lutomirski
2016-03-01 14:00 ` Boris Ostrovsky
[not found] ` <56D5A095.4050102-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-03-01 15:44 ` Andy Lutomirski
2016-03-01 22:06 ` Luis R. Rodriguez
2016-03-02 0:15 ` Luis R. Rodriguez [this message]
[not found] ` <20160302001554.GH25240-B4tOwbsTzaBolqkO4TVVkw@public.gmane.org>
2016-03-03 0:33 ` Andy Lutomirski
2016-03-03 1:01 ` Luis R. Rodriguez
2016-03-01 23:11 ` Luis R. Rodriguez
[not found] ` <5cf8d92df1ad2965a2d8cdbb466af04da8dbbbc1.1456789731.git.luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-03-04 9:38 ` Borislav Petkov
2016-02-29 23:50 ` [PATCH v2 2/2] x86/asm-offsets: Remove PARAVIRT_enabled Andy Lutomirski
[not found] ` <b8adc42d21ea64d84589f8ee7540f8299df21577.1456789731.git.luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-03-04 9:38 ` Borislav Petkov
2016-03-01 22:45 ` [PATCH v2 0/2] x86/entry/32: Get rid of paravirt_enabled in ESPFIX Borislav Petkov
[not found] ` <20160301224512.GF22677-fF5Pk5pvG8Y@public.gmane.org>
2016-03-03 0:47 ` Andy Lutomirski
[not found] ` <CALCETrUcgHKYKn-K4EHF3mCOpuO3cW6Qnpa4k2ydKUAWVpQsSg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-03 10:18 ` Borislav Petkov
[not found] ` <20160303101807.GA24621-fF5Pk5pvG8Y@public.gmane.org>
2016-03-03 23:49 ` Andy Lutomirski
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=20160302001554.GH25240@wotan.suse.de \
--to=mcgrof@kernel.org \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=david.vrabel@citrix.com \
--cc=lguest@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xensource.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;
as well as URLs for NNTP newsgroup(s).