diff mbox

[38/39] x86/mm/pti: Add Warning when booting on a PCID capable CPU

Message ID 1531308586-29340-39-git-send-email-joro@8bytes.org (mailing list archive)
State New, archived
Headers show

Commit Message

Joerg Roedel July 11, 2018, 11:29 a.m. UTC
From: Joerg Roedel <jroedel@suse.de>

Warn the user in case the performance can be significantly
improved by switching to a 64-bit kernel.

Suggested-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 arch/x86/mm/pti.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Andy Lutomirski July 13, 2018, 6:59 p.m. UTC | #1
On Wed, Jul 11, 2018 at 4:29 AM, Joerg Roedel <joro@8bytes.org> wrote:
> From: Joerg Roedel <jroedel@suse.de>
>
> Warn the user in case the performance can be significantly
> improved by switching to a 64-bit kernel.

...

> +#ifdef CONFIG_X86_32
> +       if (boot_cpu_has(X86_FEATURE_PCID)) {

I'm a bit confused. Wouldn't the setup_clear_cpu_cap() call in
early_identify_cpu() prevent this from working?

Boris, do we have a straightforward way to ask "does the CPU advertise
this feature in CPUID regardless of whether we have it enabled right
now"?

--Andy
Joerg Roedel July 14, 2018, 5:08 a.m. UTC | #2
On Fri, Jul 13, 2018 at 11:59:44AM -0700, Andy Lutomirski wrote:
> On Wed, Jul 11, 2018 at 4:29 AM, Joerg Roedel <joro@8bytes.org> wrote:
> > From: Joerg Roedel <jroedel@suse.de>
> >
> > Warn the user in case the performance can be significantly
> > improved by switching to a 64-bit kernel.
> 
> ...
> 
> > +#ifdef CONFIG_X86_32
> > +       if (boot_cpu_has(X86_FEATURE_PCID)) {
> 
> I'm a bit confused. Wouldn't the setup_clear_cpu_cap() call in
> early_identify_cpu() prevent this from working?

Right you are, I don't have a PCID capable system at hand for testing,
so I didn't catch this...

> Boris, do we have a straightforward way to ask "does the CPU advertise
> this feature in CPUID regardless of whether we have it enabled right
> now"?

I guess we need to call cpuid again.


Regards,

	Joerg
diff mbox

Patch

diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index b879ccd..e20283fa 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -517,6 +517,22 @@  void __init pti_init(void)
 
 	pr_info("enabled\n");
 
+#ifdef CONFIG_X86_32
+	if (boot_cpu_has(X86_FEATURE_PCID)) {
+		/* Use printk to work around pr_fmt() */
+		printk(KERN_WARNING "\n");
+		printk(KERN_WARNING "************************************************************\n");
+		printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!  **\n");
+		printk(KERN_WARNING "**                                                        **\n");
+		printk(KERN_WARNING "** You are using 32-bit PTI on a 64-bit PCID-capable CPU. **\n");
+		printk(KERN_WARNING "** Your performance will increase dramatically if you     **\n");
+		printk(KERN_WARNING "** switch to a 64-bit kernel!                             **\n");
+		printk(KERN_WARNING "**                                                        **\n");
+		printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!  **\n");
+		printk(KERN_WARNING "************************************************************\n");
+	}
+#endif
+
 	pti_clone_user_shared();
 
 	/* Undo all global bits from the init pagetables in head_64.S: */