Skip to contentSkip to conversation

x86/mm: Avoid paravirtualization calls in native_set_p4d()

PATCH In review Kirill A. Shutemov 3 participants 4 messages Feb 28, 2018 – Mar 12, 2018 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: Avoid paravirtualization calls in native_set_p4d()

p4d_val() and pgd_val() are paravirtualized and we should avoid using them in native_set_p4d().

Let's replace them with native_p4d_val() and native_pgd_val().

Fixes 91f606a8fa68 ("x86/mm: Replace compile-time checks for 5-level paging with runtime-time checks")
---
 arch/x86/include/asm/pgtable_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/pgtable_64.h +2 -2
index 81dda8d1d0bd..163e01a0631d 100644
@@ -224,9 +224,9 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
 		return;
 	}
 
-	pgd = native_make_pgd(p4d_val(p4d));
+	pgd = native_make_pgd(native_p4d_val(p4d));
 	pgd = pti_set_user_pgd((pgd_t *)p4dp, pgd);
-	*p4dp = native_make_p4d(pgd_val(pgd));
+	*p4dp = native_make_p4d(native_pgd_val(pgd));
 }
 
 static inline void native_p4d_clear(p4d_t *p4d)
Signature · 1 line
2.16.1
#1 lore raw
Quoted 2 lines · Kirill A. Shutemov

p4d_val() and pgd_val() are paravirtualized and we should avoid using them in native_set_p4d().

I'm really unhappy with your changelogs.

... and we should avoid ....

Should is not strong enough as it leaves the option to not do it.

Aside of that you fail (again) to explain the WHY. Something like this:

native_set_p4d() uses p4d_val() and pgd_val() to do ".....". Both functions are paravirtualized which is wrong because it brings paravirtualization into the native implementation resulting in "$problem".

Quoted 1 line

Let's replace them with native_p4d_val() and native_pgd_val().

Let's? Just say:

Replace them with native_p4d_val() and native_pgd_val().

Documentation/process/... explains it really well change logs have to be written in imperative mood.

Thanks,

tglx

Quoted 27 lines
Fixes 91f606a8fa68 ("x86/mm: Replace compile-time checks for 5-level paging with runtime-time checks")
---
 arch/x86/include/asm/pgtable_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/pgtable_64.h +2 -2
index 81dda8d1d0bd..163e01a0631d 100644
@@ -224,9 +224,9 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
 		return;
 	}
 
-	pgd = native_make_pgd(p4d_val(p4d));
+	pgd = native_make_pgd(native_p4d_val(p4d));
 	pgd = pti_set_user_pgd((pgd_t *)p4dp, pgd);
-	*p4dp = native_make_p4d(pgd_val(pgd));
+	*p4dp = native_make_p4d(native_pgd_val(pgd));
 }
 
 static inline void native_p4d_clear(p4d_t *p4d)
Signature · 1 line
2.16.1
#2 lore raw

PATCH 1/1 x86/mm: Do not use paravirtualized calls in native_set_p4d()

In 4-level paging mode, native_set_p4d() updates entry in the top-level page table. With PTI, update to top-level kernel page table requires update to userspace copy of the table using pti_set_user_pgd().

native_set_p4d() uses p4d_val() and pgd_val() to convert types between p4d_t and pgd_t.

p4d_val() and pgd_val() are paravirtualized and we must not use them in native helpers. They cause boot failure in paravirtualized environments.

Replace p4d_val() and pgd_val() with native_p4d_val() and native_pgd_val() in native_set_p4d().

Fixes 91f606a8fa68 ("x86/mm: Replace compile-time checks for 5-level paging with runtime-time checks")
---
 arch/x86/include/asm/pgtable_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/pgtable_64.h +2 -2
index af0cb0d2b7d2..877bc27718ae 100644
@@ -225,9 +225,9 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
 		return;
 	}
 
-	pgd = native_make_pgd(p4d_val(p4d));
+	pgd = native_make_pgd(native_p4d_val(p4d));
 	pgd = pti_set_user_pgd((pgd_t *)p4dp, pgd);
-	*p4dp = native_make_p4d(pgd_val(pgd));
+	*p4dp = native_make_p4d(native_pgd_val(pgd));
 }
 
 static inline void native_p4d_clear(p4d_t *p4d)
Signature · 1 line
2.16.1
#3 lore raw

[tip:x86/mm] x86/mm: Do not use paravirtualized calls in native_set_p4d()

x86/mm: Do not use paravirtualized calls in native_set_p4d()
Commit-ID:  a5b162b2ecb013ed517ab5ce90079117ada743f4
Gitweb:     https://git.kernel.org/tip/a5b162b2ecb013ed517ab5ce90079117ada743f4
Author:     Kirill A. Shutemov <[email protected]>
AuthorDate: Mon, 5 Mar 2018 11:16:41 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 12 Mar 2018 10:30:48 +0100

x86/mm: Do not use paravirtualized calls in native_set_p4d()

In 4-level paging mode, native_set_p4d() updates the entry in the top-level page table. With PTI, update to the top-level kernel page table requires update to the userspace copy of the table as well, using pti_set_user_pgd().

native_set_p4d() uses p4d_val() and pgd_val() to convert types between p4d_t and pgd_t.

p4d_val() and pgd_val() are paravirtualized and we must not use them in native helpers, as they crash the boot in paravirtualized environments.

Replace p4d_val() and pgd_val() with native_p4d_val() and native_pgd_val() in native_set_p4d().

Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Fixes 91f606a8fa68 ("x86/mm: Replace compile-time checks for 5-level paging with runtime-time checks")
---
 arch/x86/include/asm/pgtable_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/pgtable_64.h +2 -2
index 81dda8d1d0bd..163e01a0631d 100644
@@ -224,9 +224,9 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
 		return;
 	}
 
-	pgd = native_make_pgd(p4d_val(p4d));
+	pgd = native_make_pgd(native_p4d_val(p4d));
 	pgd = pti_set_user_pgd((pgd_t *)p4dp, pgd);
-	*p4dp = native_make_p4d(pgd_val(pgd));
+	*p4dp = native_make_p4d(native_pgd_val(pgd));
 }
 
 static inline void native_p4d_clear(p4d_t *p4d)