[tip:x86/urgent] x86/boot/compressed/64: Set EFER.LME=1 in 32-bit trampoline before returning to long mode
Commit-ID: b677dfae5aa197afc5191755a76a8727ffca538a Gitweb: https://git.kernel.org/tip/b677dfae5aa197afc5191755a76a8727ffca538a Author: Wei Huang AuthorDate: Thu, 3 Jan 2019 23:44:11 -0600 Committer: Thomas Gleixner CommitDate: Tue, 29 Jan 2019 21:58:59 +0100 x86/boot/compressed/64: Set EFER.LME=1 in 32-bit trampoline before returning to long mode In some old AMD KVM implementation, guest's EFER.LME bit is cleared by KVM when the hypervsior detects that the guest sets CR0.PG to 0. This causes the guest OS to reboot when it tries to return from 32-bit trampoline code because the CPU is in incorrect state: CR4.PAE=1, CR0.PG=1, CS.L=1, but EFER.LME=0. As a precaution, set EFER.LME=1 as part of long mode activation procedure. This extra step won't cause any harm when Linux is booted on a bare-metal machine. Signed-off-by: Wei Huang Signed-off-by: Thomas Gleixner Acked-by: Kirill A. Shutemov Cc: b...@alien8.de Cc: h...@zytor.com Link: https://lkml.kernel.org/r/20190104054411.12489-1-...@redhat.com --- arch/x86/boot/compressed/head_64.S | 8 arch/x86/boot/compressed/pgtable.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 64037895b085..f105ae8651c9 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -600,6 +600,14 @@ ENTRY(trampoline_32bit_src) lealTRAMPOLINE_32BIT_PGTABLE_OFFSET(%ecx), %eax movl%eax, %cr3 3: + /* Set EFER.LME=1 as a precaution in case hypervsior pulls the rug */ + pushl %ecx + movl$MSR_EFER, %ecx + rdmsr + btsl$_EFER_LME, %eax + wrmsr + popl%ecx + /* Enable PAE and LA57 (if required) paging modes */ movl$X86_CR4_PAE, %eax cmpl$0, %edx diff --git a/arch/x86/boot/compressed/pgtable.h b/arch/x86/boot/compressed/pgtable.h index 91f75638f6e6..6ff7e81b5628 100644 --- a/arch/x86/boot/compressed/pgtable.h +++ b/arch/x86/boot/compressed/pgtable.h @@ -6,7 +6,7 @@ #define TRAMPOLINE_32BIT_PGTABLE_OFFSET0 #define TRAMPOLINE_32BIT_CODE_OFFSET PAGE_SIZE -#define TRAMPOLINE_32BIT_CODE_SIZE 0x60 +#define TRAMPOLINE_32BIT_CODE_SIZE 0x70 #define TRAMPOLINE_32BIT_STACK_END TRAMPOLINE_32BIT_SIZE
[tip:perf/core] perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment
Commit-ID: cc6cd47e7395bc05c5077009808b820633eb3f18 Gitweb: http://git.kernel.org/tip/cc6cd47e7395bc05c5077009808b820633eb3f18 Author: Wei Huang AuthorDate: Wed, 24 Sep 2014 22:55:14 -0500 Committer: Ingo Molnar CommitDate: Fri, 3 Oct 2014 06:04:41 +0200 perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment PMU checking can fail due to various reasons. On native machine, this is mostly caused by faulty hardware and it is reasonable to use KERN_ERR in reporting. However, when kernel is running on virtualized environment, this checking can fail if virtual PMU is not supported (e.g. KVM on AMD host). It is annoying to see an error message on splash screen, even though we know such failure is benign on virtualized environment. This patch checks if the kernel is running in a virtualized environment. If so, it will use KERN_INFO in reporting, which reduces the syslog priority of them. This patch was tested successfully on KVM. Signed-off-by: Wei Huang Signed-off-by: Peter Zijlstra (Intel) Cc: Arnaldo Carvalho de Melo Link: http://lkml.kernel.org/r/1411617314-24659-1-git-send-email-...@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/perf_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 918d75f..16c7302 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -243,7 +243,8 @@ static bool check_hw_exists(void) msr_fail: printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n"); - printk(KERN_ERR "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new); + printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR + "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new); return false; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment
Commit-ID: cc6cd47e7395bc05c5077009808b820633eb3f18 Gitweb: http://git.kernel.org/tip/cc6cd47e7395bc05c5077009808b820633eb3f18 Author: Wei Huang w...@redhat.com AuthorDate: Wed, 24 Sep 2014 22:55:14 -0500 Committer: Ingo Molnar mi...@kernel.org CommitDate: Fri, 3 Oct 2014 06:04:41 +0200 perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment PMU checking can fail due to various reasons. On native machine, this is mostly caused by faulty hardware and it is reasonable to use KERN_ERR in reporting. However, when kernel is running on virtualized environment, this checking can fail if virtual PMU is not supported (e.g. KVM on AMD host). It is annoying to see an error message on splash screen, even though we know such failure is benign on virtualized environment. This patch checks if the kernel is running in a virtualized environment. If so, it will use KERN_INFO in reporting, which reduces the syslog priority of them. This patch was tested successfully on KVM. Signed-off-by: Wei Huang w...@redhat.com Signed-off-by: Peter Zijlstra (Intel) pet...@infradead.org Cc: Arnaldo Carvalho de Melo a...@kernel.org Link: http://lkml.kernel.org/r/1411617314-24659-1-git-send-email-...@redhat.com Signed-off-by: Ingo Molnar mi...@kernel.org --- arch/x86/kernel/cpu/perf_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 918d75f..16c7302 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -243,7 +243,8 @@ static bool check_hw_exists(void) msr_fail: printk(KERN_CONT Broken PMU hardware detected, using software events only.\n); - printk(KERN_ERR Failed to access perfctr msr (MSR %x is %Lx)\n, reg, val_new); + printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR + Failed to access perfctr msr (MSR %x is %Lx)\n, reg, val_new); return false; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/