Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp585889imm; Wed, 29 Aug 2018 07:18:51 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYzUqdfMgcdU6XEa7oDGOpcc1a4UE36GrtD3IGJFTn8AjcmQci9H+sIliBKZ4NKJVm61SNe X-Received: by 2002:a17:902:3fa5:: with SMTP id a34-v6mr2232571pld.244.1535552331175; Wed, 29 Aug 2018 07:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535552331; cv=none; d=google.com; s=arc-20160816; b=TlHgwPsjVloT72896Id0wBhcFQJQlNm0NPNb+Bj5KQrhD6n/Upq+KmDAoWDIAuy91v VP16nHUl5CPTgtG+0VAT4A2rcHWvnhNbc4FbdiVjVyg11qbVJfmdvUl4lKY/PPcOd9i9 mADOiTl90z+KhlehhiBhcyAG8aXZJ5bp3QdepEHk/DsqJMOqoZgjqaEtya4uia7rI9LZ if59zZlmV5EQi+Ief3hbwkAv0aj6pUGJxPfrU/L2mdzleonHo+rSvEZsUgbdO48ywSXC +NHO6KsjDi/Aw8WGxIGo7SQCHGMCRulQ2w2F6A9KFSVXDD6/szYeUhkHRqT7dWhw873K jH0A== 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:arc-authentication-results; bh=GVxKlfb8crFp31gWzVsB3tvh4iN+GFuUAerjy45SqdE=; b=npIcasVJ9hR/FyIoaShxJEUrOSfUTVvB62en+w7ta9l2TksjsooIVIfuj5IHeEmN3O wjw76dU2Z9AQhGRxpNDZgvxK6+PL0oPcVOH/3Kl+9tLeRN8Xec7ksbJa5oSrvqBqj3HQ 6C5YfshixhBuTalyZZEh5a/oF+avRbEUaLg/PIVff1IZSbYLB5OBntcXgsPgISs3QpDZ g+lWvuG6f41jLgfYRgEMaolD7yPIdrJYwmbgD1IC6RtF3YvhW8ZrZ5qCUzVaVVE/52bI 7iNzIn7DyB/AEOTAPFpb8BtDW7rM94iRpGjdbGAz0gb3KaObg+tSnD/zGpKgzM7WzAVE atJQ== 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 r10-v6si3703630pgv.168.2018.08.29.07.18.36; Wed, 29 Aug 2018 07:18:51 -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 S1728868AbeH2SNu (ORCPT + 99 others); Wed, 29 Aug 2018 14:13:50 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57162 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727444AbeH2SNu (ORCPT ); Wed, 29 Aug 2018 14:13:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBB6640216F6; Wed, 29 Aug 2018 14:16:40 +0000 (UTC) Received: from 192.168.1.2 (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8D7410EE780; Wed, 29 Aug 2018 14:16:35 +0000 (UTC) From: Baoquan He To: tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, kirill.shutemov@linux.intel.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, Baoquan He Subject: [PATCH 2/3] x86/kexec/64: Error out if try to jump to old 4-level kernel from 5-level kernel Date: Wed, 29 Aug 2018 22:16:23 +0800 Message-Id: <20180829141624.13985-3-bhe@redhat.com> In-Reply-To: <20180829141624.13985-1-bhe@redhat.com> References: <20180829141624.13985-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 29 Aug 2018 14:16:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 29 Aug 2018 14:16:40 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 In relocate_kernel() CR4.LA57 flag is set before kexec jumping if the kernel has 5-level paging enabled. Then in boot/compressed/head_64.S, it will check if the booting kernel is in 4-level or 5-level paging mode, and handle accordingly. However, the old kernel which doesn't contain the 5-level codes doesn't know how to cope with it, then #GP triggered. Instead of triggering #GP during kexec kernel boot, error out during kexec loading if find out we are trying to jump to old 4-level kernel from 5-level kernel. Signed-off-by: Baoquan He --- arch/x86/kernel/kexec-bzimage64.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c index 7326078eaa7a..f5fe94ee209a 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -316,6 +316,11 @@ static int bzImage64_probe(const char *buf, unsigned long len) return ret; } + if (!(header->xloadflags & XLF_5LEVEL) && pgtable_l5_enabled()) { + pr_err("Can not jump to old 4-level kernel from 5-level kernel.\n"); + return ret; + } + /* I've got a bzImage */ pr_debug("It's a relocatable bzImage64\n"); ret = 0; -- 2.13.6