Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1725649ybm; Tue, 21 May 2019 20:21:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/MaVc13wG07Y7sVs0WBBTgMStDty2b8CwuJRO6SUoHwgon2PkybgYE4TlGdq4toZGNLxg X-Received: by 2002:a63:2785:: with SMTP id n127mr18635654pgn.99.1558495315780; Tue, 21 May 2019 20:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558495315; cv=none; d=google.com; s=arc-20160816; b=ImFqk1rLh/I7oTNvvLJenShP3djgqJR0DdhC2XweR95DapApkJFU9AWpc7xEc6umIy bbvl7FSOk0PtjrCTxsnGwOyaxn2UMeujS7liaVFOjJMejxvPPwWqdGTPHj5em+6y2nNK ZGqRVieUDu1VOhKr7lSrW0aDWN0JSNPIAbIwIA5l/2JmJ7/3lANXbUB2hCGI2TN8KdgZ IzF9odjolmsBqriAKFur93NM2y92ZmRD/Wx+0/9xbk28hFzhiBnfTuNL9aflaLvZsiWA 7CpGg4wpCwTa9FHeCmFY+bU/zr/sdz8uS0bSR09yq0qXmbEVWjXfcDL0tfdeBzZJ/Q9m O0JA== 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; bh=1u7Go1GFKm87HwyzNbo/odVr1ZVPic6KmkR8rR2QSjM=; b=GhzkdZ7FR19HstpIHLFveP6HyIKMHHjgXHMbKzRyhSnlsH133I2bQdYAfh8ptetJgy l1O0hX4l2e7vURR0+I10uAdlB7seyTs+rleqDSYTRzFzMxwNkwYi2DrlcWTwSzifvZCn uDlwXBXmZacwFs4XWaPTunl9TuSmAdjV5J26zB8pEygIA6f08097Myj/JsxKNT9TYl9N cfV01/fTvEgWeNkRaOhqeVfLwC7sxmT36DCcELQ4x8JF9dxAYfcZ3j4BnzL/+s6RcuCP x5zt/g3QKpSjpPmiGU+gQNMsnGkP/M4YJTRM4RjiwVK8jb/qQdylvPulEJgDW2PJXNRz haww== 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 f4si23768770pgd.325.2019.05.21.20.21.40; Tue, 21 May 2019 20:21:55 -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 S1728236AbfEVDUg (ORCPT + 99 others); Tue, 21 May 2019 23:20:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56044 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727733AbfEVDUg (ORCPT ); Tue, 21 May 2019 23:20:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BCDE308338E; Wed, 22 May 2019 03:20:36 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 187D962660; Wed, 22 May 2019 03:20:32 +0000 (UTC) Date: Wed, 22 May 2019 11:20:29 +0800 From: Dave Young To: Baoquan He Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, bp@alien8.de, hpa@zytor.com, kirill.shutemov@linux.intel.com, x86@kernel.org Subject: Re: [PATCH v4 2/3] x86/kexec/64: Error out if try to jump to old 4-level kernel from 5-level kernel Message-ID: <20190522032029.GB31269@dhcp-128-65.nay.redhat.com> References: <20190509013644.1246-1-bhe@redhat.com> <20190509013644.1246-3-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190509013644.1246-3-bhe@redhat.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 22 May 2019 03:20:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/09/19 at 09:36am, Baoquan He wrote: > 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 +++++ How about the userspace kexec-tools? It needs a similar detection, but I'm not sure how to detect paging mode, maybe some sysfs entry or vmcoreinfo in /proc/vmcore > 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"); 4-level kernel sounds not very clear, maybe something like below? "5-level paging enabled, can not kexec into an old kernel without 5-level paging facility"? > + return ret; > + } > + > /* I've got a bzImage */ > pr_debug("It's a relocatable bzImage64\n"); > ret = 0; > -- > 2.17.2 > Thanks Dave