* [PATCH] x86/mm: Introduce 'no5vl kernel parameter
@ 2018-05-02 16:10 Kirill A. Shutemov
2018-05-02 19:39 ` kbuild test robot
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Kirill A. Shutemov @ 2018-05-02 16:10 UTC (permalink / raw)
To: Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin
Cc: Dave Hansen, Larry Woodman, linux-kernel, Kirill A. Shutemov
The kernel parameter allows to force kernel to use 4-level paging even
if hardware and kernel support 5-level paging.
The option may be useful to workaround regressions related to 5-level
paging.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
Documentation/admin-guide/kernel-parameters.txt | 3 +++
arch/x86/boot/compressed/cmdline.c | 2 +-
arch/x86/boot/compressed/head_64.S | 1 +
arch/x86/boot/compressed/pgtable_64.c | 12 ++++++++++--
arch/x86/kernel/cpu/common.c | 4 ++++
arch/x86/kernel/head64.c | 10 ++++++----
6 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 11fc28ecdb6d..364a33c1534d 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2600,6 +2600,9 @@
emulation library even if a 387 maths coprocessor
is present.
+ no5lvl [X86-64] Disable 5-level paging mode. Forces
+ kernel to use 4-level paging instead.
+
no_console_suspend
[HW] Never suspend the console
Disable suspending of consoles during suspend and
diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
index 0cb325734cfb..af6cda0b7900 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "misc.h"
-#if CONFIG_EARLY_PRINTK || CONFIG_RANDOMIZE_BASE
+#if CONFIG_EARLY_PRINTK || CONFIG_RANDOMIZE_BASE || CONFIG_X86_5LEVEL
static unsigned long fs;
static inline void set_fs(unsigned long seg)
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index c433c21703e6..6490697f1133 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -346,6 +346,7 @@ ENTRY(startup_64)
* this function call.
*/
pushq %rsi
+ movq %rsi, %rdi /* real mode address */
call paging_prepare
popq %rsi
diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
index 3a0578f54550..7230c9cc5bc0 100644
--- a/arch/x86/boot/compressed/pgtable_64.c
+++ b/arch/x86/boot/compressed/pgtable_64.c
@@ -37,16 +37,23 @@ extern char *top_pgtable;
*/
unsigned long *trampoline_32bit __section(.data);
-struct paging_config paging_prepare(void)
+extern struct boot_params *boot_params;
+int cmdline_find_option_bool(const char *option);
+
+struct paging_config paging_prepare(void *rmode)
{
struct paging_config paging_config = {};
unsigned long bios_start, ebda_start;
+ /* Initialize boot_params. Required for cmdline_find_option_bool(). */
+ boot_params = rmode;
+
/*
* Check if LA57 is desired and supported.
*
- * There are two parts to the check:
+ * There are several parts to the check:
* - if the kernel supports 5-level paging: CONFIG_X86_5LEVEL=y
+ * - if user asked to disable 5-level paging: no5lvl in cmdline
* - if the machine supports 5-level paging:
* + CPUID leaf 7 is supported
* + the leaf has the feature bit set
@@ -54,6 +61,7 @@ struct paging_config paging_prepare(void)
* That's substitute for boot_cpu_has() in early boot code.
*/
if (IS_ENABLED(CONFIG_X86_5LEVEL) &&
+ !cmdline_find_option_bool("no5lvl") &&
native_cpuid_eax(0) >= 7 &&
(native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31)))) {
paging_config.l5_required = 1;
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 8a5b185735e1..8da50947e053 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1004,6 +1004,10 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
*/
setup_clear_cpu_cap(X86_FEATURE_PCID);
#endif
+
+ /* Clear the 5-level paging feature if user asked for 'no5lvl' */
+ if (!__pgtable_l5_enabled)
+ setup_clear_cpu_cap(X86_FEATURE_LA57);
}
void __init early_cpu_init(void)
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 0c408f8c4ed4..8ca65d35b93a 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -82,10 +82,12 @@ static unsigned int __head *fixup_int(void *ptr, unsigned long physaddr)
static bool __head check_la57_support(unsigned long physaddr)
{
- if (native_cpuid_eax(0) < 7)
- return false;
-
- if (!(native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31))))
+ /*
+ * 5-level paging is detected and enabled on kernel decomression
+ * stage. Back off if 5-level paging mode has not yet enabled by
+ * this point.
+ */
+ if (!(native_read_cr4() & X86_CR4_LA57))
return false;
*fixup_int(&pgtable_l5_enabled, physaddr) = 1;
--
2.17.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] x86/mm: Introduce 'no5vl kernel parameter
2018-05-02 16:10 [PATCH] x86/mm: Introduce 'no5vl kernel parameter Kirill A. Shutemov
@ 2018-05-02 19:39 ` kbuild test robot
2018-05-02 19:42 ` kbuild test robot
2018-05-06 17:33 ` Pavel Machek
2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2018-05-02 19:39 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: kbuild-all, Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin,
Dave Hansen, Larry Woodman, linux-kernel, Kirill A. Shutemov
[-- Attachment #1: Type: text/plain, Size: 1457 bytes --]
Hi Kirill,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v4.17-rc3 next-20180502]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kirill-A-Shutemov/x86-mm-Introduce-no5vl-kernel-parameter/20180503-030855
config: i386-randconfig-x014-201817 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
arch/x86/kernel/cpu/common.c: In function 'early_identify_cpu':
>> arch/x86/kernel/cpu/common.c:1009:7: error: '__pgtable_l5_enabled' undeclared (first use in this function); did you mean 'pgtable_l5_enabled'?
if (!__pgtable_l5_enabled)
^~~~~~~~~~~~~~~~~~~~
pgtable_l5_enabled
arch/x86/kernel/cpu/common.c:1009:7: note: each undeclared identifier is reported only once for each function it appears in
vim +1009 arch/x86/kernel/cpu/common.c
1007
1008 /* Clear the 5-level paging feature if user asked for 'no5lvl' */
> 1009 if (!__pgtable_l5_enabled)
1010 setup_clear_cpu_cap(X86_FEATURE_LA57);
1011 }
1012
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28533 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] x86/mm: Introduce 'no5vl kernel parameter
2018-05-02 16:10 [PATCH] x86/mm: Introduce 'no5vl kernel parameter Kirill A. Shutemov
2018-05-02 19:39 ` kbuild test robot
@ 2018-05-02 19:42 ` kbuild test robot
2018-05-06 17:33 ` Pavel Machek
2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2018-05-02 19:42 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: kbuild-all, Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin,
Dave Hansen, Larry Woodman, linux-kernel, Kirill A. Shutemov
[-- Attachment #1: Type: text/plain, Size: 2408 bytes --]
Hi Kirill,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tip/auto-latest]
[also build test WARNING on v4.17-rc3 next-20180502]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kirill-A-Shutemov/x86-mm-Introduce-no5vl-kernel-parameter/20180503-030855
config: i386-randconfig-x019-201817 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
In file included from include/linux/kernel.h:10:0,
from include/linux/list.h:9,
from include/linux/preempt.h:11,
from include/linux/spinlock.h:51,
from include/linux/mmzone.h:8,
from include/linux/bootmem.h:8,
from arch/x86/kernel/cpu/common.c:1:
arch/x86/kernel/cpu/common.c: In function 'early_identify_cpu':
arch/x86/kernel/cpu/common.c:1009:7: error: '__pgtable_l5_enabled' undeclared (first use in this function); did you mean 'pgtable_l5_enabled'?
if (!__pgtable_l5_enabled)
^
include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> arch/x86/kernel/cpu/common.c:1009:2: note: in expansion of macro 'if'
if (!__pgtable_l5_enabled)
^~
arch/x86/kernel/cpu/common.c:1009:7: note: each undeclared identifier is reported only once for each function it appears in
if (!__pgtable_l5_enabled)
^
include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> arch/x86/kernel/cpu/common.c:1009:2: note: in expansion of macro 'if'
if (!__pgtable_l5_enabled)
^~
vim +/if +1009 arch/x86/kernel/cpu/common.c
1007
1008 /* Clear the 5-level paging feature if user asked for 'no5lvl' */
> 1009 if (!__pgtable_l5_enabled)
1010 setup_clear_cpu_cap(X86_FEATURE_LA57);
1011 }
1012
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26188 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] x86/mm: Introduce 'no5vl kernel parameter
2018-05-02 16:10 [PATCH] x86/mm: Introduce 'no5vl kernel parameter Kirill A. Shutemov
2018-05-02 19:39 ` kbuild test robot
2018-05-02 19:42 ` kbuild test robot
@ 2018-05-06 17:33 ` Pavel Machek
2018-05-07 10:47 ` Kirill A. Shutemov
2 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2018-05-06 17:33 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin, Dave Hansen,
Larry Woodman, linux-kernel
On Wed 2018-05-02 19:10:27, Kirill A. Shutemov wrote:
> The kernel parameter allows to force kernel to use 4-level paging even
> if hardware and kernel support 5-level paging.
>
> The option may be useful to workaround regressions related to 5-level
> paging.
There's typo in subject.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/mm: Introduce 'no5vl kernel parameter
2018-05-06 17:33 ` Pavel Machek
@ 2018-05-07 10:47 ` Kirill A. Shutemov
0 siblings, 0 replies; 5+ messages in thread
From: Kirill A. Shutemov @ 2018-05-07 10:47 UTC (permalink / raw)
To: Pavel Machek
Cc: Kirill A. Shutemov, Ingo Molnar, x86, Thomas Gleixner,
H. Peter Anvin, Dave Hansen, Larry Woodman, linux-kernel
On Sun, May 06, 2018 at 07:33:52PM +0200, Pavel Machek wrote:
> On Wed 2018-05-02 19:10:27, Kirill A. Shutemov wrote:
> > The kernel parameter allows to force kernel to use 4-level paging even
> > if hardware and kernel support 5-level paging.
> >
> > The option may be useful to workaround regressions related to 5-level
> > paging.
>
> There's typo in subject.
Fixed in v2.
--
Kirill A. Shutemov
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-07 10:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-02 16:10 [PATCH] x86/mm: Introduce 'no5vl kernel parameter Kirill A. Shutemov
2018-05-02 19:39 ` kbuild test robot
2018-05-02 19:42 ` kbuild test robot
2018-05-06 17:33 ` Pavel Machek
2018-05-07 10:47 ` 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