Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4559290imu; Tue, 15 Jan 2019 02:02:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN7k7WIi3IMeEd2obnYUxNS4emELuBmkfdYC3bZAZtqlc2t1ZCOmJ9XlL58ZICgwiUcTvgW0 X-Received: by 2002:a17:902:3383:: with SMTP id b3mr3189946plc.170.1547546525969; Tue, 15 Jan 2019 02:02:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547546525; cv=none; d=google.com; s=arc-20160816; b=hQozv1F6LFcRleZNVzu2FJ9XwoiOQyjdGjXRMiPyRVPlMlmK2JerMChMWnoRKFYsWq x3Rk3ACgBM7sWdnfJyibzeYKhIlz3aouofT46m4dvdcWt0v3LkAXU2UtX4xFAAsMKM9b bQmdlKu5BnHJgBhAChcDTtskE7TEXFMOxmZlAvkSdjosyyMR02/PchDL2pSnlDfQ6uGp 8S+PIgXymPLiMUm69aVLnu8JE9ad6Z89ye4lGwcFm5N+AZSzbuS2kWRZNUgGnkJ98ret y3r1o6z88NQufD7TShV6SS2A0HV4gVRbM1jz/2RU5e7PKUVqOvn22lCXfVVszSthH3vA F4ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tEpaKNifW3kORBqqetgaaVDufZTF4kGiwtNGKzSFBO4=; b=iTkyZGEjBaoI8Mp+XsRYScWr6nd5Q9CA01fqznm9AWA7MyUMACBawUg/fs5kxh4hKZ zl0nw35dltySwCBNPUSnrse5zgC/IqNeXeBaBLo3/x+b/djQzUS+QtQlQLLyTyYZgoSC O9zctHVQg8iOnTTYMX5BSCOmvaK1UqE8sBd/agqDmt2EMBakKDn6ujqJrBw5IEcIbT5q iKuRch0Eld5phG1ZhA2Vtc+rdKRvpc5smPJ9w1g2k7eTcdsIJOlsVhoG+6f+eVXsZmRT u93e3VAtGGOwhwHAcRgVS2XI2MUtBosTHdTKC/md1A2E0QrLp1isHcngSKVkDbsInIEY ZvlA== 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 r18si2674800pgu.552.2019.01.15.02.01.50; Tue, 15 Jan 2019 02:02:05 -0800 (PST) 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 S1728076AbfAOJ7h (ORCPT + 99 others); Tue, 15 Jan 2019 04:59:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53696 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbfAOJ7h (ORCPT ); Tue, 15 Jan 2019 04:59:37 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6509889AE1; Tue, 15 Jan 2019 09:59:36 +0000 (UTC) Received: from kasong-desktop-nay-redhat-com.nay.redhat.com (unknown [10.66.128.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 687E75C543; Tue, 15 Jan 2019 09:59:28 +0000 (UTC) From: Kairui Song To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, dyoung@redhat.com, bhe@redhat.com, kexec@lists.infradead.org, akpm@linux-foundation.org, robert.moore@intel.com, erik.schmauss@intel.com, rafael.j.wysocki@intel.com, lenb@kernel.org, Kairui Song Subject: [PATCH v2 1/2] x86, kexec_file_load: Don't setup EFI info if EFI runtime is not enabled Date: Tue, 15 Jan 2019 17:58:33 +0800 Message-Id: <20190115095834.22617-2-kasong@redhat.com> In-Reply-To: <20190115095834.22617-1-kasong@redhat.com> References: <20190115095834.22617-1-kasong@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 15 Jan 2019 09:59:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently with "efi=noruntime" in kernel command line, calling kexec_file_load will raise below problem: [ 97.967067] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 [ 97.967894] #PF error: [normal kernel read fault] ... [ 97.980456] Call Trace: [ 97.980724] efi_runtime_map_copy+0x28/0x30 [ 97.981267] bzImage64_load+0x688/0x872 [ 97.981794] arch_kexec_kernel_image_load+0x6d/0x70 [ 97.982441] kimage_file_alloc_init+0x13e/0x220 [ 97.983035] __x64_sys_kexec_file_load+0x144/0x290 [ 97.983586] do_syscall_64+0x55/0x1a0 [ 97.983962] entry_SYSCALL_64_after_hwframe+0x44/0xa9 When efi runtime is not enabled, efi memmap is not mapped, so just skip EFI info setup. Suggested-by: Dave Young Signed-off-by: Kairui Song --- arch/x86/kernel/kexec-bzimage64.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c index 0d5efa34f359..53917a3ebf94 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -167,6 +167,9 @@ setup_efi_state(struct boot_params *params, unsigned long params_load_addr, struct efi_info *current_ei = &boot_params.efi_info; struct efi_info *ei = ¶ms->efi_info; + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return 0; + if (!current_ei->efi_memmap_size) return 0; -- 2.20.1