Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp181907yba; Wed, 8 May 2019 18:40:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz537xo9pnn8qchbSH7YfgCdF8WqhvccclWsubZheBXYqL4fQCpKSPuNWliQnE8N2b5Ns9c X-Received: by 2002:a63:f843:: with SMTP id v3mr1891237pgj.69.1557366027335; Wed, 08 May 2019 18:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557366027; cv=none; d=google.com; s=arc-20160816; b=FSriFgD0wK8uJ+8HelJho3gaTb377qb7s7y4Lqfj+H5CNPpe9xhR4dKv9v82UE0fIn nBYPLrgf6U0boGY44XHuEz4O2lltMQazM5fbBylLNebem/fir53PfxcV7PW3OW5sR0yR OltatgQeb1RkVVy1oOwvokvapU6Xln7xMkSOed8SkrvXfx3OVBwSgQGr6jE27D0ToAq1 lcpXlGv/LR+BBzzXlHLiNeIDKIp0Tf9w7aPIIlsng7FPTG9oGi6f1pyooMfrS8vrpk4c O5pHO0f8kB/a0wAmX892R3mLkmzDg016dG0w2jWg3r4Sy5pEjlZSLRGNmHvsqQxMvah1 9v4Q== 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=1U3uhsGVsmZ3BJYEJKdGtI3PNsAOVTn592evuc/zSjQ=; b=KvV0xRhaJnqC4w63VgYHIiwy3+YECDhNzDJNhOtDgbu8JHq9ATyBMBVXxz20TadoH6 KpsPYbWrY4L+s86DczKvleCCTR4rM5w2PG4Gwfdjk1b031KlYUS7yRkJuSazL6Cs+RLh 8PoqHbE7NeLwPQ9pgfhITQH4fPIhWXOyXOxUblsjBqIkxFDxWybnKoHC8nHKG2EO9ZWv ks7Volfu38GVI98gPzP3ZPHKmI90u9RRV/Fi/LYln9Bt6JexJpSqzS3j40Hl46Lq9zUC aJL10OTVH1AC/sQ6oVJOC6p86i5SkpuS5rxPKBvpMh4cr0l5cZmDrQB4nEBU17r9yqZb 5w7Q== 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 c3si933342pgc.99.2019.05.08.18.40.11; Wed, 08 May 2019 18:40:27 -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 S1726100AbfEIBhC (ORCPT + 99 others); Wed, 8 May 2019 21:37:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36540 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725778AbfEIBhB (ORCPT ); Wed, 8 May 2019 21:37:01 -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 626E9307D935; Thu, 9 May 2019 01:37:01 +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 6DB1F19744; Thu, 9 May 2019 01:36:58 +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 2/3] x86/kexec/64: Error out if try to jump to old 4-level kernel from 5-level kernel Date: Thu, 9 May 2019 09:36:43 +0800 Message-Id: <20190509013644.1246-3-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.48]); Thu, 09 May 2019 01:37:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the running kernel has 5-level paging activated, the 5-level paging mode is preserved across kexec. If the kexec'ed kernel does not contain support for handling active 5-level paging mode in the decompressor, the decompressor will crash with #GP. Prevent this situation at load time. If 5-level paging is active, check the xloadflags whether the kexec kernel can handle 5-level paging at least in the decompressor. If not, reject the load attempt and print out error message. Signed-off-by: Baoquan He Acked-by: Kirill A. Shutemov --- 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 22f60dd26460..858cc892672f 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -321,6 +321,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.17.2