x86/ldt: Define LDT_END_ADDR
authorJoerg Roedel <jroedel@suse.de>
Wed, 18 Jul 2018 09:41:11 +0000 (11:41 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 19 Jul 2018 23:11:47 +0000 (01:11 +0200)
It marks the end of the address-space range reserved for the LDT. The
LDT-code will use it when unmapping the LDT for user-space.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Pavel Machek <pavel@ucw.cz>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: linux-mm@kvack.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: David Laight <David.Laight@aculab.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Eduardo Valentin <eduval@amazon.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: aliguori@amazon.com
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: keescook@google.com
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Waiman Long <llong@redhat.com>
Cc: "David H . Gutteridge" <dhgutteridge@sympatico.ca>
Cc: joro@8bytes.org
Link: https://lkml.kernel.org/r/1531906876-13451-35-git-send-email-joro@8bytes.org
arch/x86/include/asm/pgtable_32_types.h
arch/x86/include/asm/pgtable_64_types.h
arch/x86/kernel/ldt.c

index 7297810747cfdd4be9e08587b2a47df664b89722..b0bc0fff5f1f9ed792c910cd92d7d93d3b38ccfb 100644 (file)
@@ -53,6 +53,8 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
 #define LDT_BASE_ADDR          \
        ((CPU_ENTRY_AREA_BASE - PAGE_SIZE) & PMD_MASK)
 
+#define LDT_END_ADDR           (LDT_BASE_ADDR + PMD_SIZE)
+
 #define PKMAP_BASE             \
        ((LDT_BASE_ADDR - PAGE_SIZE) & PMD_MASK)
 
index 066e0ab9ffab100d316c6ed52cdceec4ca3f2f9f..04edd2d58211a78e3261993bd8d0e088e3b4c4ef 100644 (file)
@@ -115,6 +115,7 @@ extern unsigned int ptrs_per_p4d;
 #define LDT_PGD_ENTRY_L5       -112UL
 #define LDT_PGD_ENTRY          (pgtable_l5_enabled() ? LDT_PGD_ENTRY_L5 : LDT_PGD_ENTRY_L4)
 #define LDT_BASE_ADDR          (LDT_PGD_ENTRY << PGDIR_SHIFT)
+#define LDT_END_ADDR           (LDT_BASE_ADDR + PGDIR_SIZE)
 
 #define __VMALLOC_BASE_L4      0xffffc90000000000UL
 #define __VMALLOC_BASE_L5      0xffa0000000000000UL
index c9b14020f4ddf433c5d96f6f4930a65340f214a2..e921b3d494d53c03aea051758a26e5796342f508 100644 (file)
@@ -206,7 +206,7 @@ static void free_ldt_pgtables(struct mm_struct *mm)
 #ifdef CONFIG_PAGE_TABLE_ISOLATION
        struct mmu_gather tlb;
        unsigned long start = LDT_BASE_ADDR;
-       unsigned long end = start + (1UL << PGDIR_SHIFT);
+       unsigned long end = LDT_END_ADDR;
 
        if (!static_cpu_has(X86_FEATURE_PTI))
                return;