linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mm: Avoid paravirtualization calls in native_set_p4d()
@ 2018-02-28 15:00 Kirill A. Shutemov
  2018-03-02 12:16 ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2018-02-28 15:00 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin
  Cc: Fengguang Wu, linux-kernel, Kirill A. Shutemov

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().

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
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(-)

diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 81dda8d1d0bd..163e01a0631d 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -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)
-- 
2.16.1

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

* Re: [PATCH] x86/mm: Avoid paravirtualization calls in native_set_p4d()
  2018-02-28 15:00 [PATCH] x86/mm: Avoid paravirtualization calls in native_set_p4d() Kirill A. Shutemov
@ 2018-03-02 12:16 ` Thomas Gleixner
  2018-03-05  8:16   ` [PATCH] x86/mm: Do not use paravirtualized " Kirill A. Shutemov
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2018-03-02 12:16 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Ingo Molnar, x86, H. Peter Anvin, Fengguang Wu, linux-kernel

On Wed, 28 Feb 2018, Kirill A. Shutemov wrote:

> 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".

> 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

> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> 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(-)
> 
> diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
> index 81dda8d1d0bd..163e01a0631d 100644
> --- a/arch/x86/include/asm/pgtable_64.h
> +++ b/arch/x86/include/asm/pgtable_64.h
> @@ -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)
> -- 
> 2.16.1
> 
> 

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

* [PATCH] x86/mm: Do not use paravirtualized calls in native_set_p4d()
  2018-03-02 12:16 ` Thomas Gleixner
@ 2018-03-05  8:16   ` Kirill A. Shutemov
  2018-03-12 12:16     ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2018-03-05  8:16 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin
  Cc: Fengguang Wu, linux-kernel, Kirill A. Shutemov

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().

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
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(-)

diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index af0cb0d2b7d2..877bc27718ae 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -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)
-- 
2.16.1

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

* [tip:x86/mm] x86/mm: Do not use paravirtualized calls in native_set_p4d()
  2018-03-05  8:16   ` [PATCH] x86/mm: Do not use paravirtualized " Kirill A. Shutemov
@ 2018-03-12 12:16     ` tip-bot for Kirill A. Shutemov
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Kirill A. Shutemov @ 2018-03-12 12:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, bp, dvlasenk, tglx, mingo, peterz, jpoimboe, linux-kernel,
	torvalds, luto, brgerst, kirill.shutemov, fengguang.wu

Commit-ID:  a5b162b2ecb013ed517ab5ce90079117ada743f4
Gitweb:     https://git.kernel.org/tip/a5b162b2ecb013ed517ab5ce90079117ada743f4
Author:     Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
AuthorDate: Mon, 5 Mar 2018 11:16:41 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
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().

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.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: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 91f606a8fa68 ("x86/mm: Replace compile-time checks for 5-level paging with runtime-time checks")
Link: http://lkml.kernel.org/r/20180305081641.4290-1-kirill.shutemov@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/pgtable_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 81dda8d1d0bd..163e01a0631d 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -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)

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

end of thread, other threads:[~2018-03-12 12:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28 15:00 [PATCH] x86/mm: Avoid paravirtualization calls in native_set_p4d() Kirill A. Shutemov
2018-03-02 12:16 ` Thomas Gleixner
2018-03-05  8:16   ` [PATCH] x86/mm: Do not use paravirtualized " Kirill A. Shutemov
2018-03-12 12:16     ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).