Skip to content

Commit f4e342c

Browse files
bostrovsKAGA-KOKO
authored andcommitted
x86/mm: Skip the hypervisor range when walking PGD
The range between 0xffff800000000000 and 0xffff87ffffffffff is reserved for hypervisor and therefore we should not try to follow PGD's indexes corresponding to those addresses. While this has always been a problem, with the new W+X warning mechanism ptdump_walk_pgd_level_core() can now be called during boot, causing a PV Xen guest to crash. [ tglx: Replaced the macro with a readable inline ] Fixes: e1a5832 "x86/mm: Warn on W^X mappings" Reported-by: Sander Eikelenboom <linux@eikelenboom.it> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: xen-devel@lists.xen.org Link: http://lkml.kernel.org/r/1446749795-27764-1-git-send-email-boris.ostrovsky@oracle.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 3849e91 commit f4e342c

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

arch/x86/mm/dump_pagetables.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,21 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, pgd_t addr,
358358
#define pgd_none(a) pud_none(__pud(pgd_val(a)))
359359
#endif
360360

361+
#ifdef CONFIG_X86_64
362+
static inline bool is_hypervisor_range(int idx)
363+
{
364+
/*
365+
* ffff800000000000 - ffff87ffffffffff is reserved for
366+
* the hypervisor.
367+
*/
368+
return paravirt_enabled() &&
369+
(idx >= pgd_index(__PAGE_OFFSET) - 16) &&
370+
(idx < pgd_index(__PAGE_OFFSET));
371+
}
372+
#else
373+
static inline bool is_hypervisor_range(int idx) { return false; }
374+
#endif
375+
361376
static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
362377
bool checkwx)
363378
{
@@ -381,7 +396,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
381396

382397
for (i = 0; i < PTRS_PER_PGD; i++) {
383398
st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
384-
if (!pgd_none(*start)) {
399+
if (!pgd_none(*start) && !is_hypervisor_range(i)) {
385400
if (pgd_large(*start) || !pgd_present(*start)) {
386401
prot = pgd_flags(*start);
387402
note_page(m, &st, __pgprot(prot), 1);

0 commit comments

Comments
 (0)