Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp406452imu; Tue, 8 Jan 2019 23:07:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN7oaCgvxj/b9DHyyIUMreH+VBfVHXX02i2kZ76zWPOnoPDwX0218Lq4kpuL6FXMcQDEQ1v8 X-Received: by 2002:a62:a99:: with SMTP id 25mr4777139pfk.121.1547017638856; Tue, 08 Jan 2019 23:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547017638; cv=none; d=google.com; s=arc-20160816; b=Rx+aFeQ6cOl7hsI4DJbJFun2gvYzE2xmaAaP+thqlfQUBMW9GkBBpxEJrAso32uIF3 gLtLl2i+/Stj/tT6wpL0AQpOZ6alRDuZsFXr8d8E4ZzaER1id7y4y0vx6llkeO5XH8lU XoRMTlTEvkID2K31GK9bgEll70AXOswgU7iKcU74N4I3+Mk+Ck+akPY7zE+Fn7c5LT+x 3RFfu8zbvADUtojsDZK/TrIA1Alnkr+SUxt3/n8Dahkg8g8m9/Bggg1YjJP5wCXM3C3j HrvmCIOxdogxMz+Q1Z1X0KtUXAhJkFZEAnyT3BjU9UJQpAVzudqB+6rGoLPEOzLpx9G2 4QDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=uqxheNDTbBo/VXGa6i8Z5NG+TW3Y21vOW+J5TKQOgbs=; b=tR14nle55mvSIuz5H7lpSQI9m9j9Zio6e1XAcMB96hSIisbSgkZC9eXz4dszzIXo4V HufX9b2Czz10Ijbwpoo1VNIDb8To1o0wiWCZp8H/q1moKdCNWV/SQzzXCSzyCGtoW7yA wanNI3mHx6VYYezfu1Cr6rIHaQDQjR+ZqYBJ32Xy4cPG1tm5htWSAXsbaiel1UcNaI/D n5MUE8eNO9TIY+wWiV85AESrPk90dGRUq6mLijDDZDao9bqw1Ng5vzRxjhg5q2bR5ff8 IjRQJCo5sMOTb7+KWhN+HNAzeB89CQ/tIIq/y4SueXsjWiFk6hPFiJABkelEZsW0Tm0f ARvg== 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 f10si10155075pln.289.2019.01.08.23.07.02; Tue, 08 Jan 2019 23:07:18 -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 S1729663AbfAIG4B (ORCPT + 99 others); Wed, 9 Jan 2019 01:56:01 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:32835 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728661AbfAIG4B (ORCPT ); Wed, 9 Jan 2019 01:56:01 -0500 Received: by mail-it1-f194.google.com with SMTP id m8so11956171itk.0 for ; Tue, 08 Jan 2019 22:56:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uqxheNDTbBo/VXGa6i8Z5NG+TW3Y21vOW+J5TKQOgbs=; b=Icr8ftT2pyfAdDl8uZnnrGtaFFgFbwSxEX8VBQkr8bVxmVqVI+vQgNzlrPCvj3ydl7 9J/2dV9G8Xjlxr/+DmClvi9vXUSxJIIHTHfaITroF529md92T90WnTWmHd/msE0mU8X4 CUBshcHIeLC0h97mzqFK88gr7lfk30a1zgw1idSLlRW46EgYyloOCm1fbSajMbOW/wjW ahvNXvpQUdfYOXzpsDmoLq4YzzPVC0ItBLerbegjmStK+cGMtYC1xHR3uagjgfMu1Y2h MMEl/lBUUVE7l24U5ZrwSA+N+1ipDE3EfgiEwcIjT0zPaW3a+VljFjtRakjQyvJRNzWs U6sw== X-Gm-Message-State: AJcUukffoNtQQ/4LrfRh6TlOcWYwmDD/ecAj6esa847H0TGpywTMHuUR 5Pef7p52qgusZh8ZHxJM1whPKZwF05joMtpPS8vm1BFEhyLRVw== X-Received: by 2002:a02:95e4:: with SMTP id b91mr2941097jai.15.1547016960274; Tue, 08 Jan 2019 22:56:00 -0800 (PST) MIME-Version: 1.0 References: <20190109064727.27936-1-kasong@redhat.com> In-Reply-To: <20190109064727.27936-1-kasong@redhat.com> From: Kairui Song Date: Wed, 9 Jan 2019 14:55:49 +0800 Message-ID: Subject: Re: [PATCH 2/2] x86, kexec_file_load: make it work with efi=noruntime or efi=oldmap To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, Dave Young , akpm@linux-foundation.org, robert.moore@intel.com, erik.schmauss@intel.com, rafael.j.wysocki@intel.com, lenb@kernel.org, kexec@lists.infradead.org, Baoquan He Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CCing more people On Wed, Jan 9, 2019 at 2:47 PM 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 a 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 > > +#endif > /* Setup EDD info */ > memcpy(params->eddbuf, boot_params.eddbuf, > EDDMAXNR * sizeof(struct edd_info)); > diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c > index 483d0ce5180a..dac1e34a931c 100644 > --- a/drivers/acpi/acpica/tbxfroot.c > +++ b/drivers/acpi/acpica/tbxfroot.c > @@ -108,8 +108,7 @@ acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) > * > ******************************************************************************/ > > -acpi_status ACPI_INIT_FUNCTION > -acpi_find_root_pointer(acpi_physical_address *table_address) > +acpi_status acpi_find_root_pointer(acpi_physical_address *table_address) > { > u8 *table_ptr; > u8 *mem_rover; > diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h > index 7aa38b648564..869d75ecaf7d 100644 > --- a/include/acpi/acpixf.h > +++ b/include/acpi/acpixf.h > @@ -474,7 +474,7 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_INIT_FUNCTION > ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_INIT_FUNCTION > acpi_reallocate_root_table(void)) > > -ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_INIT_FUNCTION > +ACPI_EXTERNAL_RETURN_STATUS(acpi_status > acpi_find_root_pointer(acpi_physical_address > *rsdp_address)) > ACPI_EXTERNAL_RETURN_STATUS(acpi_status > -- > 2.20.1 > -- Best Regards, Kairui Song