Re: Yet another KPTI regression with 4.14.x series in a VM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]