All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot for Kirill A. Shutemov" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
	tglx@linutronix.de, akpm@linux-foundation.org, hpa@zytor.com,
	kirill.shutemov@linux.intel.com, bp@alien8.de,
	peterz@infradead.org, jpoimboe@redhat.com, dave.hansen@intel.com,
	arnd@arndb.de, matt@codeblueprint.co.uk, luto@kernel.org,
	mingo@kernel.org, brgerst@gmail.com, mhocko@suse.com,
	dvlasenk@redhat.com, luto@amacapital.net
Subject: [tip:x86/mm] x86/efi: Add 5-level paging support
Date: Mon, 27 Mar 2017 03:23:28 -0700	[thread overview]
Message-ID: <tip-e981316f560482c001dede7f5b29259bde0b8afb@git.kernel.org> (raw)
In-Reply-To: <20170317185515.8636-3-kirill.shutemov@linux.intel.com>

Commit-ID:  e981316f560482c001dede7f5b29259bde0b8afb
Gitweb:     http://git.kernel.org/tip/e981316f560482c001dede7f5b29259bde0b8afb
Author:     Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
AuthorDate: Fri, 17 Mar 2017 21:55:11 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 27 Mar 2017 08:56:25 +0200

x86/efi: Add 5-level paging support

Allocate additional page table level and ajdust efi_sync_low_kernel_mappings()
to work with additional page table level.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.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: Michal Hocko <mhocko@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-arch@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/20170317185515.8636-3-kirill.shutemov@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/efi/efi_64.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 8544dae..eb64e5b 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -135,6 +135,7 @@ static pgd_t *efi_pgd;
 int __init efi_alloc_page_tables(void)
 {
 	pgd_t *pgd;
+	p4d_t *p4d;
 	pud_t *pud;
 	gfp_t gfp_mask;
 
@@ -147,15 +148,20 @@ int __init efi_alloc_page_tables(void)
 		return -ENOMEM;
 
 	pgd = efi_pgd + pgd_index(EFI_VA_END);
+	p4d = p4d_alloc(&init_mm, pgd, EFI_VA_END);
+	if (!p4d) {
+		free_page((unsigned long)efi_pgd);
+		return -ENOMEM;
+	}
 
-	pud = pud_alloc_one(NULL, 0);
+	pud = pud_alloc(&init_mm, p4d, EFI_VA_END);
 	if (!pud) {
+		if (CONFIG_PGTABLE_LEVELS > 4)
+			free_page((unsigned long) pgd_page_vaddr(*pgd));
 		free_page((unsigned long)efi_pgd);
 		return -ENOMEM;
 	}
 
-	pgd_populate(NULL, pgd, pud);
-
 	return 0;
 }
 
@@ -191,26 +197,36 @@ void efi_sync_low_kernel_mappings(void)
 	memcpy(pgd_efi, pgd_k, sizeof(pgd_t) * num_entries);
 
 	/*
+	 * As with PGDs, we share all P4D entries apart from the one entry
+	 * that covers the EFI runtime mapping space.
+	 */
+	BUILD_BUG_ON(p4d_index(EFI_VA_END) != p4d_index(MODULES_END));
+	BUILD_BUG_ON((EFI_VA_START & P4D_MASK) != (EFI_VA_END & P4D_MASK));
+
+	pgd_efi = efi_pgd + pgd_index(EFI_VA_END);
+	pgd_k = pgd_offset_k(EFI_VA_END);
+	p4d_efi = p4d_offset(pgd_efi, 0);
+	p4d_k = p4d_offset(pgd_k, 0);
+
+	num_entries = p4d_index(EFI_VA_END);
+	memcpy(p4d_efi, p4d_k, sizeof(p4d_t) * num_entries);
+
+	/*
 	 * We share all the PUD entries apart from those that map the
 	 * EFI regions. Copy around them.
 	 */
 	BUILD_BUG_ON((EFI_VA_START & ~PUD_MASK) != 0);
 	BUILD_BUG_ON((EFI_VA_END & ~PUD_MASK) != 0);
 
-	pgd_efi = efi_pgd + pgd_index(EFI_VA_END);
-	p4d_efi = p4d_offset(pgd_efi, 0);
+	p4d_efi = p4d_offset(pgd_efi, EFI_VA_END);
+	p4d_k = p4d_offset(pgd_k, EFI_VA_END);
 	pud_efi = pud_offset(p4d_efi, 0);
-
-	pgd_k = pgd_offset_k(EFI_VA_END);
-	p4d_k = p4d_offset(pgd_k, 0);
 	pud_k = pud_offset(p4d_k, 0);
 
 	num_entries = pud_index(EFI_VA_END);
 	memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
 
-	p4d_efi = p4d_offset(pgd_efi, EFI_VA_START);
 	pud_efi = pud_offset(p4d_efi, EFI_VA_START);
-	p4d_k = p4d_offset(pgd_k, EFI_VA_START);
 	pud_k = pud_offset(p4d_k, EFI_VA_START);
 
 	num_entries = PTRS_PER_PUD - pud_index(EFI_VA_START);

  reply	other threads:[~2017-03-27 10:32 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17 18:55 [PATCH 0/6] x86: 5-level paging enabling for v4.12, Part 2 Kirill A. Shutemov
2017-03-17 18:55 ` Kirill A. Shutemov
2017-03-17 18:55 ` [PATCH 1/6] x86/kexec: Add 5-level paging support Kirill A. Shutemov
2017-03-17 18:55   ` Kirill A. Shutemov
2017-03-27 10:22   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2017-03-17 18:55 ` [PATCH 2/6] x86/efi: " Kirill A. Shutemov
2017-03-17 18:55   ` Kirill A. Shutemov
2017-03-27 10:23   ` tip-bot for Kirill A. Shutemov [this message]
2017-03-17 18:55 ` [PATCH 3/6] x86/mm/pat: " Kirill A. Shutemov
2017-03-17 18:55   ` Kirill A. Shutemov
2017-03-17 19:49   ` Thomas Gleixner
2017-03-17 19:49     ` Thomas Gleixner
2017-03-27 10:24   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2017-03-17 18:55 ` [PATCH 4/6] x86/kasan: Prepare clear_pgds() to switch to <asm-generic/pgtable-nop4d.h> Kirill A. Shutemov
2017-03-17 18:55   ` Kirill A. Shutemov
2017-03-20 16:21   ` Andrey Ryabinin
2017-03-20 16:21     ` Andrey Ryabinin
2017-03-20 16:21     ` Andrey Ryabinin
2017-03-22  7:31     ` Ingo Molnar
2017-03-22  7:31       ` Ingo Molnar
2017-03-24  9:07       ` Kirill A. Shutemov
2017-03-24  9:07         ` Kirill A. Shutemov
2017-03-24 10:58         ` Ingo Molnar
2017-03-24 10:58           ` Ingo Molnar
2017-03-27 10:24   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2017-03-17 18:55 ` [PATCH 5/6] x86/xen: Change __xen_pgd_walk() and xen_cleanmfnmap() to support p4d Kirill A. Shutemov
2017-03-17 18:55   ` Kirill A. Shutemov
2017-03-27  6:34   ` Ingo Molnar
2017-03-27  6:34     ` Ingo Molnar
2017-03-27 13:13     ` Kirill A. Shutemov
2017-03-27 13:13       ` Kirill A. Shutemov
2017-03-27 10:25   ` [tip:x86/mm] " tip-bot for Xiong Zhang
2017-03-17 18:55 ` [PATCH 6/6] x86: Convert the rest of the code to support p4d_t Kirill A. Shutemov
2017-03-17 18:55   ` Kirill A. Shutemov
2017-03-27 10:25   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2017-04-23 19:56     ` Dan Williams
2017-04-24 16:57       ` Kirill A. Shutemov
2017-04-24 18:42         ` Dan Williams
2017-04-25  0:57           ` Kirill A. Shutemov
2017-04-25  6:38             ` Ingo Molnar
2017-04-25  9:02               ` Kirill A. Shutemov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-e981316f560482c001dede7f5b29259bde0b8afb@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dave.hansen@intel.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.