Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752822AbbKES5K (ORCPT ); Thu, 5 Nov 2015 13:57:10 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:18175 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750739AbbKES5J (ORCPT ); Thu, 5 Nov 2015 13:57:09 -0500 From: Boris Ostrovsky To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux@eikelenboom.it, xen-devel@lists.xen.org, boris.ostrovsky@oracle.com Subject: [PATCH] x86/mm: Skip the hypervisor range when walking PGD Date: Thu, 5 Nov 2015 13:56:35 -0500 Message-Id: <1446749795-27764-1-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.9.3 X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1937 Lines: 49 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 alsways been a problem, with commit e1a58320a38d ("x86/mm: Warn on W^X mappings") ptdump_walk_pgd_level_core() can now be called during boot, causing a PV Xen guest to crash. Reported-by: Sander Eikelenboom Signed-off-by: Boris Ostrovsky --- arch/x86/mm/dump_pagetables.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 1bf417e..756c921 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -362,8 +362,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, bool checkwx) { #ifdef CONFIG_X86_64 +/* ffff800000000000 - ffff87ffffffffff is reserved for hypervisor */ +#define is_hypervisor_range(idx) (paravirt_enabled() && \ + (((idx) >= pgd_index(__PAGE_OFFSET) - 16) && \ + ((idx) < pgd_index(__PAGE_OFFSET)))) pgd_t *start = (pgd_t *) &init_level4_pgt; #else +#define is_hypervisor_range(idx) 0 pgd_t *start = swapper_pg_dir; #endif pgprotval_t prot; @@ -381,7 +386,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, for (i = 0; i < PTRS_PER_PGD; i++) { st.current_address = normalize_addr(i * PGD_LEVEL_MULT); - if (!pgd_none(*start)) { + if (!pgd_none(*start) && !is_hypervisor_range(i)) { if (pgd_large(*start) || !pgd_present(*start)) { prot = pgd_flags(*start); note_page(m, &st, __pgprot(prot), 1); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/