From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750978AbdK3HcH (ORCPT ); Thu, 30 Nov 2017 02:32:07 -0500 Received: from mga11.intel.com ([192.55.52.93]:4480 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750761AbdK3HcG (ORCPT ); Thu, 30 Nov 2017 02:32:06 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,340,1508828400"; d="scan'208";a="7897838" Date: Thu, 30 Nov 2017 10:31:31 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Cyrill Gorcunov , Andi Kleen , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 0/4] x86: 5-level related changes into decompression code Message-ID: <20171130073130.afualycggltkvl6s@black.fi.intel.com> References: <20171110220645.59944-1-kirill.shutemov@linux.intel.com> <20171129154908.6y4st6xc7hbsey2v@pd.tnic> <20171129161349.d7ksuhwhdamloty6@node.shutemov.name> <20171129170831.2iqpop2u534mgrbc@node.shutemov.name> <20171129174851.jk2ai37uumxve6sg@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171129174851.jk2ai37uumxve6sg@pd.tnic> User-Agent: NeoMutt/20170714-126-deb55f (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 29, 2017 at 05:48:51PM +0000, Borislav Petkov wrote: > On Wed, Nov 29, 2017 at 08:08:31PM +0300, Kirill A. Shutemov wrote: > > We're really early in the boot -- startup_64 in decompression code -- and > > I don't know a way print a message there. Is there a way? > > > > no_longmode handled by just hanging the machine. Is it enough for no_la57 > > case too? > > Patch pls. The patch below on top of patch 2/4 from this patch would do the trick. Please give it a shot. >>From 95b5489d1f4ea03c6226d13eb6797825234489d6 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 30 Nov 2017 10:23:53 +0300 Subject: [PATCH] x86/boot/compressed/64: Print error if 5-level paging is not supported We cannot proceed booting if the machine doesn't support the paging mode kernel was compiled for. Getting error the usual way -- via validate_cpu() -- is not going to work. We need to enable appropriate paging mode before that, otherwise kernel would triple-fault during KASLR setup. This code will go away once we get support for boot-time switching between paging modes. Signed-off-by: Kirill A. Shutemov --- arch/x86/boot/compressed/misc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index b50c42455e25..5205e848dc33 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -40,6 +40,8 @@ /* Functions used by the included decompressor code below. */ void *memmove(void *dest, const void *src, size_t n); +int l5_paging_required(void); + /* * This is set up by the setup-routine at boot-time */ @@ -362,6 +364,13 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, console_init(); debug_putstr("early console in extract_kernel\n"); + if (IS_ENABLED(CONFIG_X86_5LEVEL) && !l5_paging_required()) { + error("The kernel is compiled with 5-level paging enabled, " + "but the CPU doesn't support la57\n" + "Unable to boot - please use " + "a kernel appropriate for your CPU.\n"); + } + free_mem_ptr = heap; /* Heap */ free_mem_end_ptr = heap + BOOT_HEAP_SIZE; -- Kirill A. Shutemov