mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>, Laura Abbott <labbott@redhat.com>,
	X86 ML <x86@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	stable <stable@vger.kernel.org>
Subject: Re: Yet another KPTI regression with 4.14.x series in a VM
Date: Sat, 13 Jan 2018 14:14:14 +0000	[thread overview]
Message-ID: <1515852854.22302.574.camel@infradead.org> (raw)
In-Reply-To: <20180113131010.GJ3397@worktop>

[-- Attachment #1: Type: text/plain, Size: 2504 bytes --]

On Sat, 2018-01-13 at 14:10 +0100, Peter Zijlstra wrote:
> On Sat, Jan 13, 2018 at 12:30:11PM +0000, David Woodhouse wrote:
> > 
> > On Sat, 2018-01-13 at 13:08 +0100, Peter Zijlstra wrote:
> > > 
> > > 
> > >         ALTERNATIVE "orq $(PTI_SWITCH_PGTABLE_MASK), \scratch_reg",
> > >                     "orq $(PTI_SWITCH_MASK), \scratch_reg", X86_FEATURE_PCID
> > > 
> > > Is not wanting to compile though; probably that whole alternative vs
> > > macro thing again :/
> > Welcome to my world. Try
> > 
> >  ALTERNATIVE __stringify(orq $(PTI_SWITCH_PGTABLE_MASK), \scratch_reg), \
> >              __stringify(orq $(PTI_SWITCH_MASK), \scratch_reg), \
> >              X86_FEATURE_PCID
> Doesn't seem to work, gets literal __stringy() crud in the .s file.

--- a/arch/x86/entry/calling.h
+++ b/arch/x86/entry/calling.h
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/jump_label.h>
+#include <linux/stringify.h>
 #include <asm/unwind_hints.h>
 #include <asm/cpufeatures.h>
 #include <asm/page_types.h>
@@ -222,7 +223,10 @@ For 32-bit we have the following conventions - kernel is built with
 #define THIS_CPU_user_pcid_flush_mask   \
        PER_CPU_VAR(cpu_tlbstate) + TLB_STATE_user_pcid_flush_mask
 
-.macro SWITCH_TO_USER_CR3_NOSTACK scratch_reg:req scratch_reg2:req
+.macro SWITCH_TO_USER_CR3_NOSTACK scratch_reg:req scratch_reg2:req \
+                       pti_sw_mask=__stringify(PTI_SWITCH_MASK) \
+                       pti_sw_pgt_mask=PTI_SWITCH_PGTABLES_MASK
+
        ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_PTI
        mov     %cr3, \scratch_reg
 
@@ -247,7 +251,9 @@ For 32-bit we have the following conventions - kernel is built with
 
 .Lwrcr3_\@:
        /* Flip the PGD and ASID to the user version */
-       orq     $(PTI_SWITCH_MASK), \scratch_reg
+       ALTERNATIVE __stringify(orq $\pti_sw_pgt_mask, \scratch_reg),   \
+                   __stringify(orq $\pti_sw_mask, \scratch_reg),               \
+                   X86_FEATURE_PCID
        mov     \scratch_reg, %cr3
 .Lend_\@:
 .endm

Yeah you need to 'stringify' the first of the macro args (pti_sw_mask)
because its default value being in parens confuses the very primitive
.macro arg processing. The last arg is fine.

This shit makes my brain hurt.

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5213 bytes --]

  parent reply	other threads:[~2018-01-13 14:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 18:19 Laura Abbott
2018-01-12 18:51 ` Thomas Gleixner
2018-01-12 21:30   ` Laura Abbott
2018-01-12 21:51     ` Thomas Gleixner
2018-01-13  6:08       ` Andy Lutomirski
2018-01-13  6:33         ` Willy Tarreau
2018-01-13 20:01           ` Andy Lutomirski
2018-01-13 20:45             ` Thomas Gleixner
2018-01-13 20:52               ` Andy Lutomirski
2018-01-13 12:08         ` Peter Zijlstra
2018-01-13 12:30           ` David Woodhouse
2018-01-13 13:10             ` Peter Zijlstra
2018-01-13 13:39               ` David Woodhouse
2018-01-13 14:14               ` David Woodhouse [this message]
2018-01-13 12:50           ` Thomas Gleixner
2018-01-13 13:51             ` Borislav Petkov

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=1515852854.22302.574.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=bp@alien8.de \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®