Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp180277yba; Wed, 8 May 2019 18:38:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqsK+6N3NZHA36H2qf3bp1HJg/06yuBlTFDKy3o+wl2FhOZh8GbmlOUymxNtPjyng+yc5v X-Received: by 2002:a63:5110:: with SMTP id f16mr1911902pgb.107.1557365934170; Wed, 08 May 2019 18:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557365934; cv=none; d=google.com; s=arc-20160816; b=CekKB/cAuOrAd1lZ2JmC+HIxNxNYUnSDykRnDNSZQzLeOeCxsrKx8h1uubwkaKXU3x 1RkRTjMtSJL9iivSUQ8vwLwsVZCz233P77HfmHvXKTQMuGhcn03GuMT12udQ3R4VCwf1 ftLeC0OHbZ91zFSd1GwVuIYe+YLh/kKWbd25Y0Xt+tIla1+Ohla6HsqFak0b/hQ+i9YR Ix7EA6HfMUjJYzVcHKBLGFh+/E/CTz8ciM/9jvs7yAhMXbNXYDsznC++KppeHXCVJMFm /j0FVZOXFQT1ZAOb+7yLKuS6Xjlegrq3+YICc3oKFjtqiS7A+N5GuLgSJc74ZoTRW1GF 6BNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=4ZjwQbM+BXa/uRZH9nldNQjg7zVV+WL1mo9VSPvPpow=; b=OH/8v5fiLwG9PiGtJqejywloz+tFYOLM+hbvLwaATLAWtfn6Tub8Z+Byhdbk+opsq9 QCGZZFpnKqxxsWybL5IkAwyE3CdUYGtEjnUL8KdFKkp8oTO4zHHUjHU99QKIsfru89e3 w3V5vcr3qU8i2lhvleknt+47DFv23buK5HB6BcBLoLTyt9VZeya7mWMNpP+666STXLp5 Ve9wuMwjFbdSFEJxBpspQ03l1hC0eV4C81TIIzw1yAYbzxJAcO4hXyijSvTqpI3cfSZn XKajpcfztaMeOSM8iP4wz2kSWoAap1vYCir8xAbOjM2pCQau64c/y5V0bzjPr0bWdCt5 1foQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 39si755015pla.437.2019.05.08.18.38.24; Wed, 08 May 2019 18:38:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726513AbfEIBg6 (ORCPT + 99 others); Wed, 8 May 2019 21:36:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51080 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725778AbfEIBg6 (ORCPT ); Wed, 8 May 2019 21:36:58 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E76F6308FF15; Thu, 9 May 2019 01:36:57 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-17.pek2.redhat.com [10.72.12.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0095D19744; Thu, 9 May 2019 01:36:54 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@kernel.org, bp@alien8.de, hpa@zytor.com, kirill.shutemov@linux.intel.com, x86@kernel.org, dyoung@redhat.com, Baoquan He Subject: [PATCH v4 1/3] x86/boot: Add xloadflags bits for 5-level kernel checking Date: Thu, 9 May 2019 09:36:42 +0800 Message-Id: <20190509013644.1246-2-bhe@redhat.com> In-Reply-To: <20190509013644.1246-1-bhe@redhat.com> References: <20190509013644.1246-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 09 May 2019 01:36:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current kernel supports 5-level paging mode, and supports dynamically choosing paging mode during bootup according to kernel image, hardware and kernel parameter setting. This flexibility brings several issues to kexec/kdump: 1) Dynamic switching between paging modes requires code change in target kernel. So we can't do kexec-jumping from 5-level kernel to old 4-level kernel which lacks the code change. 2) Kexec jumping from 5-level kernel to 4-level kernel would fail, if kexec loading puts kernel image above 64 TB of memory. Because kexec loading searches area to put kernel from top to down in system RAM, the 2nd kernel will be loaded above 64 TB if the amount of system RAM is bigger than 64 TB. Here no need to worry about kexec_file loading, because it searches area from bottom to up, and can always find area below 4 GB. Solution: Add two bits XLF_5LEVEL and XLF_5LEVEL_ENABLED for 5-level kernel. - Bit XLF_5LEVEL indicates if 5-level related code is contained in this kernel. - Bit XLF_5LEVEL_ENABLED indicates if CONFIG_X86_5LEVEL=y is set. a) For issue 1), need check if XLF_5LEVEL is set, otherwise print out error message. - This checking need be added in kernel, for the code of kexec_file loading; - And also need be added into kexec_tools utility, for kexec loading. b) For issue 2), need check if both XLF_5LEVEL and XLF_5LEVEL_ENABLED are set, otherwise print out error message. - This only need be done in kexec_tools utility, because kexec loading does the searching in user space kexec_tools. So here add XLF_5LEVEL and XLF_5LEVEL_ENABLED into xloadflags. The later code will check XLF_5LEVEL bit in kexec_file implementation of kernel. And the kexec_tools code will check both XLF_5LEVEL and XLF_5LEVEL_ENABLED for kexec loading. Signed-off-by: Baoquan He Acked-by: Kirill A. Shutemov --- arch/x86/boot/header.S | 12 +++++++++++- arch/x86/include/uapi/asm/bootparam.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 850b8762e889..be19f4199727 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -419,7 +419,17 @@ xloadflags: # define XLF4 0 #endif - .word XLF0 | XLF1 | XLF23 | XLF4 +#ifdef CONFIG_X86_64 +#ifdef CONFIG_X86_5LEVEL +#define XLF56 (XLF_5LEVEL|XLF_5LEVEL_ENABLED) +#else +#define XLF56 XLF_5LEVEL +#endif +#else +#define XLF56 0 +#endif + + .word XLF0 | XLF1 | XLF23 | XLF4 | XLF56 cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line, #added with boot protocol diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h index 60733f137e9a..c895df5482c5 100644 --- a/arch/x86/include/uapi/asm/bootparam.h +++ b/arch/x86/include/uapi/asm/bootparam.h @@ -29,6 +29,8 @@ #define XLF_EFI_HANDOVER_32 (1<<2) #define XLF_EFI_HANDOVER_64 (1<<3) #define XLF_EFI_KEXEC (1<<4) +#define XLF_5LEVEL (1<<5) +#define XLF_5LEVEL_ENABLED (1<<6) #ifndef __ASSEMBLY__ -- 2.17.2