All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4.9 v2] x86/pti/efi: broken conversion from efi to kernel page table
@ 2018-01-15 16:44 Pavel Tatashin
  2018-01-15 17:49 ` Patch "x86/pti/efi: broken conversion from efi to kernel page table" has been added to the 4.9-stable tree gregkh
  2018-01-15 17:49 ` [PATCH 4.9 v2] x86/pti/efi: broken conversion from efi to kernel page table Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Pavel Tatashin @ 2018-01-15 16:44 UTC (permalink / raw)
  To: steven.sistare, linux-kernel, tglx, mingo, hpa, x86, gregkh,
	jkosina, hughd, dave.hansen, luto, stable

The page table order must be increased for EFI table in order to avoid a
bug where NMI tries to change the page table to kernel page table, while
efi page table is active.

For more disccussion about this bug, see this thread:
http://lkml.iu.edu/hypermail/linux/kernel/1801.1/00951.html

Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
---
 arch/x86/include/asm/pgalloc.h | 11 +++++++++++
 arch/x86/mm/pgtable.c          |  7 -------
 arch/x86/platform/efi/efi_64.c |  2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)

Changelog:
	v1 - v2: Fixed compiling warning

diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
index b6d425999f99..1178a51b77f3 100644
--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -27,6 +27,17 @@ static inline void paravirt_release_pud(unsigned long pfn) {}
  */
 extern gfp_t __userpte_alloc_gfp;
 
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+/*
+ * Instead of one PGD, we acquire two PGDs.  Being order-1, it is
+ * both 8k in size and 8k-aligned.  That lets us just flip bit 12
+ * in a pointer to swap between the two 4k halves.
+ */
+#define PGD_ALLOCATION_ORDER 1
+#else
+#define PGD_ALLOCATION_ORDER 0
+#endif
+
 /*
  * Allocate and free page tables.
  */
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 5aaec8effc5f..209b9465e97a 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -345,13 +345,6 @@ static inline void _pgd_free(pgd_t *pgd)
 }
 #else
 
-/*
- * Instead of one pgd, Kaiser acquires two pgds.  Being order-1, it is
- * both 8k in size and 8k-aligned.  That lets us just flip bit 12
- * in a pointer to swap between the two 4k halves.
- */
-#define PGD_ALLOCATION_ORDER	kaiser_enabled
-
 static inline pgd_t *_pgd_alloc(void)
 {
 	return (pgd_t *)__get_free_pages(PGALLOC_GFP, PGD_ALLOCATION_ORDER);
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 2f25a363068c..dcb2d9d185a2 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -142,7 +142,7 @@ int __init efi_alloc_page_tables(void)
 		return 0;
 
 	gfp_mask = GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO;
-	efi_pgd = (pgd_t *)__get_free_page(gfp_mask);
+	efi_pgd = (pgd_t *)__get_free_pages(gfp_mask, PGD_ALLOCATION_ORDER);
 	if (!efi_pgd)
 		return -ENOMEM;
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Patch "x86/pti/efi: broken conversion from efi to kernel page table" has been added to the 4.9-stable tree
  2018-01-15 16:44 [PATCH 4.9 v2] x86/pti/efi: broken conversion from efi to kernel page table Pavel Tatashin
@ 2018-01-15 17:49 ` gregkh
  2018-01-15 17:49 ` [PATCH 4.9 v2] x86/pti/efi: broken conversion from efi to kernel page table Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2018-01-15 17:49 UTC (permalink / raw)
  To: pasha.tatashin, gregkh, jkosina, steven.sistare; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    x86/pti/efi: broken conversion from efi to kernel page table

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-pti-efi-broken-conversion-from-efi-to-kernel-page-table.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From pasha.tatashin@oracle.com  Mon Jan 15 18:48:49 2018
From: Pavel Tatashin <pasha.tatashin@oracle.com>
Date: Mon, 15 Jan 2018 11:44:14 -0500
Subject: x86/pti/efi: broken conversion from efi to kernel page table
To: steven.sistare@oracle.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, gregkh@linuxfoundation.org, jkosina@suse.cz, hughd@google.com, dave.hansen@linux.intel.com, luto@kernel.org, stable@vger.kernel.org
Message-ID: <20180115164414.19778-1-pasha.tatashin@oracle.com>

From: Pavel Tatashin <pasha.tatashin@oracle.com>

The page table order must be increased for EFI table in order to avoid a
bug where NMI tries to change the page table to kernel page table, while
efi page table is active.

For more disccussion about this bug, see this thread:
http://lkml.iu.edu/hypermail/linux/kernel/1801.1/00951.html

Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/include/asm/pgalloc.h |   11 +++++++++++
 arch/x86/mm/pgtable.c          |    7 -------
 arch/x86/platform/efi/efi_64.c |    2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)

Changelog:
	v1 - v2: Fixed compiling warning

--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -27,6 +27,17 @@ static inline void paravirt_release_pud(
  */
 extern gfp_t __userpte_alloc_gfp;
 
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+/*
+ * Instead of one PGD, we acquire two PGDs.  Being order-1, it is
+ * both 8k in size and 8k-aligned.  That lets us just flip bit 12
+ * in a pointer to swap between the two 4k halves.
+ */
+#define PGD_ALLOCATION_ORDER 1
+#else
+#define PGD_ALLOCATION_ORDER 0
+#endif
+
 /*
  * Allocate and free page tables.
  */
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -345,13 +345,6 @@ static inline void _pgd_free(pgd_t *pgd)
 }
 #else
 
-/*
- * Instead of one pgd, Kaiser acquires two pgds.  Being order-1, it is
- * both 8k in size and 8k-aligned.  That lets us just flip bit 12
- * in a pointer to swap between the two 4k halves.
- */
-#define PGD_ALLOCATION_ORDER	kaiser_enabled
-
 static inline pgd_t *_pgd_alloc(void)
 {
 	return (pgd_t *)__get_free_pages(PGALLOC_GFP, PGD_ALLOCATION_ORDER);
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -142,7 +142,7 @@ int __init efi_alloc_page_tables(void)
 		return 0;
 
 	gfp_mask = GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO;
-	efi_pgd = (pgd_t *)__get_free_page(gfp_mask);
+	efi_pgd = (pgd_t *)__get_free_pages(gfp_mask, PGD_ALLOCATION_ORDER);
 	if (!efi_pgd)
 		return -ENOMEM;
 


Patches currently in stable-queue which might be from pasha.tatashin@oracle.com are

queue-4.9/x86-pti-efi-broken-conversion-from-efi-to-kernel-page-table.patch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4.9 v2] x86/pti/efi: broken conversion from efi to kernel page table
  2018-01-15 16:44 [PATCH 4.9 v2] x86/pti/efi: broken conversion from efi to kernel page table Pavel Tatashin
  2018-01-15 17:49 ` Patch "x86/pti/efi: broken conversion from efi to kernel page table" has been added to the 4.9-stable tree gregkh
@ 2018-01-15 17:49 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-01-15 17:49 UTC (permalink / raw)
  To: Pavel Tatashin
  Cc: steven.sistare, linux-kernel, tglx, mingo, hpa, x86, jkosina,
	hughd, dave.hansen, luto, stable

On Mon, Jan 15, 2018 at 11:44:14AM -0500, Pavel Tatashin wrote:
> The page table order must be increased for EFI table in order to avoid a
> bug where NMI tries to change the page table to kernel page table, while
> efi page table is active.
> 
> For more disccussion about this bug, see this thread:
> http://lkml.iu.edu/hypermail/linux/kernel/1801.1/00951.html
> 
> Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
> Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
> Acked-by: Jiri Kosina <jkosina@suse.cz>
> ---
>  arch/x86/include/asm/pgalloc.h | 11 +++++++++++
>  arch/x86/mm/pgtable.c          |  7 -------
>  arch/x86/platform/efi/efi_64.c |  2 +-
>  3 files changed, 12 insertions(+), 8 deletions(-)
> 
> Changelog:
> 	v1 - v2: Fixed compiling warning

Many thanks for this, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-15 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 16:44 [PATCH 4.9 v2] x86/pti/efi: broken conversion from efi to kernel page table Pavel Tatashin
2018-01-15 17:49 ` Patch "x86/pti/efi: broken conversion from efi to kernel page table" has been added to the 4.9-stable tree gregkh
2018-01-15 17:49 ` [PATCH 4.9 v2] x86/pti/efi: broken conversion from efi to kernel page table Greg KH

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.