x86/mm: Fix {pmd,pud}_{set,clear}_flags()
authorJan Beulich <JBeulich@suse.com>
Mon, 19 Feb 2018 14:48:11 +0000 (07:48 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 31 May 2018 23:30:17 +0000 (00:30 +0100)
commit 842cef9113c2120f74f645111ded1e020193d84c upstream.

Just like pte_{set,clear}_flags() their PMD and PUD counterparts should
not do any address translation. This was outright wrong under Xen
(causing a dead boot with no useful output on "suitable" systems), and
produced needlessly more complicated code (even if just slightly) when
paravirt was enabled.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/5A8AF1BB02000078001A91C3@prv-mh.provo.novell.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
[bwh: Backported to 3.2:
 - There aren't any pud_{set,clear}_flags() functions
 - There's no p4d level]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

index 859dc4a..daaf934 100644 (file)
@@ -254,14 +254,14 @@ static inline pmd_t pmd_set_flags(pmd_t pmd, pmdval_t set)
        pmdval_t v = native_pmd_val(pmd);
-       return __pmd(v | set);
+       return native_make_pmd(v | set);
 static inline pmd_t pmd_clear_flags(pmd_t pmd, pmdval_t clear)
        pmdval_t v = native_pmd_val(pmd);
-       return __pmd(v & ~clear);
+       return native_make_pmd(v & ~clear);
 static inline pmd_t pmd_mkold(pmd_t pmd)
index 34501e6..3c46723 100644 (file)
@@ -271,6 +271,11 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
 #include <asm-generic/pgtable-nopmd.h>
+static inline pmd_t native_make_pmd(pmdval_t val)
+       return (pmd_t) { .pud.pgd = native_make_pgd(val) };
 static inline pmdval_t native_pmd_val(pmd_t pmd)
        return native_pgd_val(pmd.pud.pgd);