Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1583646imu; Wed, 16 Jan 2019 23:20:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN6FhCv1l3vie4nSv8wub87AQN1A+mx3OECpeKDwwKVNqZsNdij0pbrh6nzbofQu28zJJLIm X-Received: by 2002:a62:32c4:: with SMTP id y187mr14248994pfy.195.1547709629596; Wed, 16 Jan 2019 23:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547709629; cv=none; d=google.com; s=arc-20160816; b=uEUTP7D/kLm4IjKg2um3bsqHG/qm85V/z937TTXUAoN1I7pYN/htVeWHPXXPkrSAG9 qgnRBKdTaXzmByY0VM3NvNzNq5WmnUF1FrQZaur254tRk1z1xeCUDud/CcYBH7mXyqPT 2FE1UFfC4WEKzbL1VZ9WCIYNTLseKVROxL6qsQLvRdhSc/VITf1kEUewR6AeFiKgmxU1 T5jIPaHM4PcX5yrFdi0pflkcA1I4Cbj51hrVfrEQDhhajSyoxIbtOBBlFF8cUqQLvNXI KatGSqx7m0YuqGA17LQArDgG4JvIVc+4ZmicidDTO4Nltm1y72lMSfuVl1etR+j3YM59 J4wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=kU5uCXkNPSW7dAAy0JwiLOH+xHkCQRNdAOJo3lJJZVQ=; b=xwEbbYUztSmhE++DirK7NX3kKVsDH1vYZZeyizyUFlGZ+tZwgwKZ0WpgO5rvdKe1KG ioZu/rQ+/pEr5PwKrm/tb5Ui8HRV9JKRl2YOyxHbklvjwV+KyQxb0DQx/NIuqIjOTCSP e4K1HMg9ySJO3dJZZySzyHnYKrGw+wRot+tvmK9mH91nLEGfLXr+2wk8WpEZGPmOCuQb vagWBYl6Oz8bs3tXHsHHN435Unco1OLqkyij7acK1hHldXwXbTbPV8SSX76IZLcbEULS PG3ECXnlIUSG3E+Ahz6VvjoNHfn6IK/MzsYHpPwTMA6z83/gfpVCBP1r13WgVFj8I9CJ t9QQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si797194pgi.387.2019.01.16.23.20.14; Wed, 16 Jan 2019 23:20:29 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733144AbfAPWYT (ORCPT + 99 others); Wed, 16 Jan 2019 17:24:19 -0500 Received: from mga04.intel.com ([192.55.52.120]:32938 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729639AbfAPWYS (ORCPT ); Wed, 16 Jan 2019 17:24:18 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 14:24:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="292139511" Received: from rjwysock-mobl1.ger.corp.intel.com (HELO [10.249.133.54]) ([10.249.133.54]) by orsmga005.jf.intel.com with ESMTP; 16 Jan 2019 14:24:14 -0800 Subject: Re: [PATCH v2 2/2] x86, kexec_file_load: make it work with efi=noruntime or efi=old_map To: Dave Young , Kairui Song Cc: Borislav Petkov , linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, Baoquan He , kexec@lists.infradead.org, akpm@linux-foundation.org, robert.moore@intel.com, erik.schmauss@intel.com, Len Brown , Chao Fan References: <20190115095834.22617-1-kasong@redhat.com> <20190115095834.22617-3-kasong@redhat.com> <20190115231005.GF6596@zn.tnic> <20190116033243.GB9649@dhcp-128-65.nay.redhat.com> <20190116065126.GC6468@dhcp-128-65.nay.redhat.com> From: "Rafael J. Wysocki" Organization: Intel Technology Poland Sp. z o. o., KRS 101882, ul. Slowackiego 173, 80-298 Gdansk Message-ID: Date: Wed, 16 Jan 2019 23:24:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190116065126.GC6468@dhcp-128-65.nay.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/16/2019 7:51 AM, Dave Young wrote: > On 01/16/19 at 01:09pm, Kairui Song wrote: >> On Wed, Jan 16, 2019 at 11:32 AM Dave Young wrote: >>> On 01/16/19 at 12:10am, Borislav Petkov wrote: >>>> On Tue, Jan 15, 2019 at 05:58:34PM +0800, Kairui Song wrote: >>>>> When efi=noruntime or efi=oldmap is used, EFI services won't be available >>>>> in the second kernel, therefore the second kernel will not be able to get >>>>> the ACPI RSDP address from firmware by calling EFI services and won't >>>>> boot. Previously we are expecting the user to set the acpi_rsdp= >>>>> on kernel command line for second kernel as there was no way to pass RSDP >>>>> address to second kernel. >>>>> >>>>> After commit e6e094e053af ('x86/acpi, x86/boot: Take RSDP address from >>>>> boot params if available'), now it's possible to set an acpi_rsdp_addr >>>>> parameter in the boot_params passed to second kernel, this commit make >>>>> use of it, detect and set the RSDP address when it's required for second >>>>> kernel to boot. >>>>> >>>>> Tested with an EFI enabled KVM VM with efi=noruntime. >>>>> >>>>> Suggested-by: Dave Young >>>>> Signed-off-by: Kairui Song >>>>> --- >>>>> arch/x86/kernel/kexec-bzimage64.c | 21 +++++++++++++++++++++ >>>>> drivers/acpi/acpica/tbxfroot.c | 3 +-- >>>>> include/acpi/acpixf.h | 2 +- >>>>> 3 files changed, 23 insertions(+), 3 deletions(-) >>>>> >>>>> diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c >>>>> index 53917a3ebf94..0a90dcbd041f 100644 >>>>> --- a/arch/x86/kernel/kexec-bzimage64.c >>>>> +++ b/arch/x86/kernel/kexec-bzimage64.c >>>>> @@ -20,6 +20,7 @@ >>>>> #include >>>>> #include >>>>> #include >>>>> +#include >>>>> >>>>> #include >>>>> #include >>>>> @@ -255,8 +256,28 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params, >>>>> /* Setup EFI state */ >>>>> setup_efi_state(params, params_load_addr, efi_map_offset, efi_map_sz, >>>>> efi_setup_data_offset); >>>>> + >>>>> +#ifdef CONFIG_ACPI >>>>> + /* Setup ACPI RSDP pointer in case EFI is not available in second kernel */ >>>>> + if (!acpi_disabled && (!efi_enabled(EFI_RUNTIME_SERVICES) || efi_enabled(EFI_OLD_MEMMAP))) { >>>>> + /* Copied from acpi_os_get_root_pointer accordingly */ >>>>> + params->acpi_rsdp_addr = boot_params.acpi_rsdp_addr; >>>>> + if (!params->acpi_rsdp_addr) { >>>>> + if (efi_enabled(EFI_CONFIG_TABLES)) { >>>>> + if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) >>>>> + params->acpi_rsdp_addr = efi.acpi20; >>>>> + else if (efi.acpi != EFI_INVALID_TABLE_ADDR) >>>>> + params->acpi_rsdp_addr = efi.acpi; >>>>> + } else if (IS_ENABLED(CONFIG_ACPI_LEGACY_TABLES_LOOKUP)) { >>>>> + acpi_find_root_pointer(¶ms->acpi_rsdp_addr); >>>>> + } >>>>> + } >>>>> + if (!params->acpi_rsdp_addr) >>>>> + pr_warn("RSDP is not available for second kernel\n"); >>>>> + } >>>>> #endif >>>> Amazing the amount of ACPI RDSP parsing and fiddling patches flying >>>> around these days... >>>> >>>> In any case, this needs to be synchronized with: >>>> >>>> https://lkml.kernel.org/r/20190107032243.25324-1-fanc.fnst@cn.fujitsu.com >>>> >>>> and checked whether the above can be used instead of sprinkling of ACPI >>>> parsing code left and right. >>> Both Baoquan and Chao are cced for comments. >>> The above KASLR patches seems some early code to parsing acpi, but I think in this >>> patch just call acpi function to get the root pointer no need to add the >>> duplicate logic of if/else/else if. >>> >>> Kairui, do you have any reason for the checking? Is there some simple >>> acpi function to just return the root pointer? >> Hi, I'm afraid that would require moving multiple structure and >> function out of .init, >> acpi_os_get_root_pointer is an ideal function to do the job, but it's >> in .init and (on x86) it will call x86_init.acpi.get_root_pointer (by >> calling acpi_arch_get_root_pointer) which will also be freed after >> init, unless I change the x86_init, move they out of .init which is >> not a good idea. >> >> Maybe I could split acpi_os_get_root_pointer into two, one gets freed >> after init, one for later use. But the "acpi_rsdp_addr" trick only >> works for x86, and this would change more common acpi driver code so >> not sure if a good idea. > Can the acpi root pointer be saved after initialized? If that is good > then a new function to get it would be easier. But need opinion from > acpi people. For that, please repost the series with a CC to linux-acpi@vger.kernel.org. Thanks!