Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp392917imu; Tue, 8 Jan 2019 22:48:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN7aRRkI/4+7gcm+lCOTWGyOjzEhOME1yh2llRZltrlufiyT3Lu4FBW/0rC1dVziEGorfNhb X-Received: by 2002:a63:da45:: with SMTP id l5mr4354313pgj.111.1547016533932; Tue, 08 Jan 2019 22:48:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547016533; cv=none; d=google.com; s=arc-20160816; b=AMUnuoXrj3QovgywosxTywY3BcUbrcvniVzfpFUzYH5upD2/1zgmzYCTb3nUR7ZIeF PmpioeATj9b1ZAaaEWNb/bHVHibMSItxSeVqAHxK2VEF7BM3usnKiY0RjOVyQ1YWBK1w UGioR8H1Jeg3mvjztLws9gK+cO1rpXGNKhvkkVlf3VlMTCFh1y+OU+AHlPS2bq7vyRYc wbyM8zNlwKOlUYOcmlmnHS+rsQeyXGEknyi64P3RuoMFYNuhU4gelPGwvF4+Q94KCCWE pTcEfiJH0Zf9UgUXBSPaugziAlCzVw9ULPwSR4ACh9Jp7tukd7+gCvIuVYePlfXCmiUB 27Mw== 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 :message-id:date:subject:cc:to:from; bh=JS4+GtBaSBYq/rtHGCZUKAjroz3bM1uP8SNrVZn/o/4=; b=rekYfstibLpkONa2o2CeETUnzxM85FHcwdTYLeJbY4sfTcM1JwcT4XDgLRDA3OSMl7 mr8E2B6z3i+ujiiqXVLI+XmvlxLunoQxmzdw/SJBzcNmHvLdqP+0esE9m2rowO2MkKJv VLa2DdioAiaUMYVeQuhPABdgUOBNcVlL1QoMFLWQtCv26YlsmWKEd9VgQw2b0cRCmfHF ApbnVhXRMY3vf3xN+FbaMUJDRboVDZDVi7IyTKI3EZQtXEJUFb+w15SJC2um8bjvDS4H ZpCi9FR/2fjU3if7/sp0JLL27P0qC7NNBbT6zeK+NvSKbpjONUWZNgqXxmPxHYFoxVHq jwbQ== 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 v10si17107538plg.82.2019.01.08.22.48.38; Tue, 08 Jan 2019 22:48:53 -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 S1729752AbfAIGpC (ORCPT + 99 others); Wed, 9 Jan 2019 01:45:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50276 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729401AbfAIGpB (ORCPT ); Wed, 9 Jan 2019 01:45:01 -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 C3F9EC057E26; Wed, 9 Jan 2019 06:45:01 +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 BCA875C1B5; Wed, 9 Jan 2019 06:44:54 +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, akpm@linux-foundation.org, Kairui Song Subject: [PATCH 1/2] x86, kexec_file_load: Don't setup EFI info if EFI runtime is not enabled Date: Wed, 9 Jan 2019 14:43:02 +0800 Message-Id: <20190109064302.26780-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.31]); Wed, 09 Jan 2019 06:45:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currenly 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