Skip to content

Commit 842cef9

Browse files
jbeulichIngo Molnar
authored andcommitted
x86/mm: Fix {pmd,pud}_{set,clear}_flags()
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> Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/5A8AF1BB02000078001A91C3@prv-mh.provo.novell.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent ced5d0b commit 842cef9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

arch/x86/include/asm/pgtable.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,14 @@ static inline pmd_t pmd_set_flags(pmd_t pmd, pmdval_t set)
350350
{
351351
pmdval_t v = native_pmd_val(pmd);
352352

353-
return __pmd(v | set);
353+
return native_make_pmd(v | set);
354354
}
355355

356356
static inline pmd_t pmd_clear_flags(pmd_t pmd, pmdval_t clear)
357357
{
358358
pmdval_t v = native_pmd_val(pmd);
359359

360-
return __pmd(v & ~clear);
360+
return native_make_pmd(v & ~clear);
361361
}
362362

363363
static inline pmd_t pmd_mkold(pmd_t pmd)
@@ -409,14 +409,14 @@ static inline pud_t pud_set_flags(pud_t pud, pudval_t set)
409409
{
410410
pudval_t v = native_pud_val(pud);
411411

412-
return __pud(v | set);
412+
return native_make_pud(v | set);
413413
}
414414

415415
static inline pud_t pud_clear_flags(pud_t pud, pudval_t clear)
416416
{
417417
pudval_t v = native_pud_val(pud);
418418

419-
return __pud(v & ~clear);
419+
return native_make_pud(v & ~clear);
420420
}
421421

422422
static inline pud_t pud_mkold(pud_t pud)

arch/x86/include/asm/pgtable_types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ static inline pudval_t native_pud_val(pud_t pud)
323323
#else
324324
#include <asm-generic/pgtable-nopud.h>
325325

326+
static inline pud_t native_make_pud(pudval_t val)
327+
{
328+
return (pud_t) { .p4d.pgd = native_make_pgd(val) };
329+
}
330+
326331
static inline pudval_t native_pud_val(pud_t pud)
327332
{
328333
return native_pgd_val(pud.p4d.pgd);
@@ -344,6 +349,11 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
344349
#else
345350
#include <asm-generic/pgtable-nopmd.h>
346351

352+
static inline pmd_t native_make_pmd(pmdval_t val)
353+
{
354+
return (pmd_t) { .pud.p4d.pgd = native_make_pgd(val) };
355+
}
356+
347357
static inline pmdval_t native_pmd_val(pmd_t pmd)
348358
{
349359
return native_pgd_val(pmd.pud.p4d.pgd);

0 commit comments

Comments
 (0)