From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9A14C43334 for ; Tue, 4 Sep 2018 03:44:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 995252086A for ; Tue, 4 Sep 2018 03:44:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 995252086A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726815AbeIDIH2 (ORCPT ); Tue, 4 Sep 2018 04:07:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57588 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726090AbeIDIH2 (ORCPT ); Tue, 4 Sep 2018 04:07:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2152440241C4; Tue, 4 Sep 2018 03:44:20 +0000 (UTC) Received: from localhost (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A1A3A9E66; Tue, 4 Sep 2018 03:44:17 +0000 (UTC) Date: Tue, 4 Sep 2018 11:44:14 +0800 From: Baoquan He To: "H. Peter Anvin" Cc: tglx@linutronix.de, mingo@kernel.org, kirill.shutemov@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org Subject: Re: [PATCH 1/3] x86/boot: Add bit fields into xloadflags for 5-level kernel checking Message-ID: <20180904034414.GI1740@192.168.1.3> References: <20180829141624.13985-1-bhe@redhat.com> <20180829141624.13985-2-bhe@redhat.com> <6ea94875-ae07-6220-eb3e-d3f830cdac03@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6ea94875-ae07-6220-eb3e-d3f830cdac03@zytor.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 04 Sep 2018 03:44:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 04 Sep 2018 03:44:20 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi hpa, Thanks for looking into this. On 09/03/18 at 07:41pm, H. Peter Anvin wrote: > I don't understand why there is any reason not to always enter the target > kernel in 4-level mode. There certainly is no point whatsoever in having two > xloadflags: the only thing that could possibly matter is whether or not the > kernel in question *can* be entered in 5-level mode should that ever be necessary. This patchset is only used to fix kexec/kdump issues. We never stop kernel booting in 4-level mode from firmware as 1st kernel. However, there are issues when jump from the 1st kernel which is in 5-level mode to 2nd kernel. The reason is: 1) in arch/x86/kernel/relocate_kernel_64.S, we set X86_CR4_LA57 into cr4 if the 1st kernel is in 5-level mode. Then in arch/x86/boot/compressed/head_64.S, paging_prepare() is called to decide if 5-level mode will be enabled, and prepare the trampoline. If kexec/kdump kernel is expected to be in 4-level, e.g with 'nolv5' specified, it still can handle well. But for the old kernel w/o these 5-level codes, it will ignore the fact that X86_CR4_LA57 has been set in CR4 and proceed anyway, then #GP is triggered. That's why XLF_5LEVEL is used to mark. 2) For kexec_load interface, we put kernel/initrd at top of system RAM in kexec_tools utility. If the 1st kernel is in 5-level mode, the kexec-ed kernel has "CONFIG_X86_5LEVEL=n", we have to detect this and limit the kernel to be loaded under 64TB, since kexec-ed kernel will definitely run in 4-level mode. Putting kernel above 64TB will fail kexec-ed kernel booting. That's why *XLF_5LEVEL_ENABLED* is needed. Thanks Baoquan