Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2139404imm; Mon, 3 Sep 2018 20:45:58 -0700 (PDT) X-Google-Smtp-Source: ANB0VdazCGTvsmpI6A3a7OEwZj2Om+jvknrdMULq95qDqa9fBkUJ3+oBWMarqQxodoTaDFtYZrIt X-Received: by 2002:a63:b207:: with SMTP id x7-v6mr4119537pge.401.1536032758473; Mon, 03 Sep 2018 20:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536032758; cv=none; d=google.com; s=arc-20160816; b=GzBPlueCTPsMI242wJKj7EyemXpCbbWdQBL38LfDYEg1+XePJIq/rIqBYl2f6rNDSh 9uOMdkKQ4C/bB5We6kEZZpT+3ItWZubSdl99Zm57f9VV+Li3FdO/By5zyW8a7h139CxC JrIFXwDiDCjd7h9iJaz/V1FKaSztQYteZHazF4XTRsbY9DEWhvP0sc4cKyTJAQrGP2ou hDQKscycYMdjsR+0J3ktoCzzaUP53eB9MPDzthiTpVRcILNNGsKmEcT5Fr1IA3Nla4wH TPRf9FaCUCAFj/izJMb3WyoyiGcSe/GxAe1pzVzRpvXHDl3LulR7Nni5mrQrdUi5/3d3 TSZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=sIID0ocSVmmM5hHk0o+QnOnzoaW9kooZxhLdnLo/VGQ=; b=qInVQqAiWkmOJWR0A0bpdCYTue/cBnfnfZG6Iutd0rzUM3/SU99o0CgkiRRyzX2yy3 vfSYzT93CbhXc1AmFBDD0gIXRW19EpniABz2iOYkW1l5B/H9uL/77FaOVXV4NxPC5qao QoqEXmFEFStYqbQkXU3xNbA3nY7V050OuzQFcdCo+UjlzB4w5O+zyroz2Q56CGK+T1OG zZfJoSOIatNsUvIacP7oWc6Fzf6S4YnWQtPG1vO8R4vlwDe7bImBNFSdVkd83ZlsHoRL KuvCM+6XAI3ZoO4ZH6AyzNXvSXUD0jnQEeiJIZ1EHBLYdipY5LRcJXx6XaLynn+Bq/tO A4HA== 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 e1-v6si19947338pfa.274.2018.09.03.20.45.43; Mon, 03 Sep 2018 20:45:58 -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 S1726706AbeIDIH2 (ORCPT + 99 others); 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