Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp16170imu; Thu, 10 Jan 2019 16:06:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN7KcTN4K6PbPpZueUslpnFYsTG2nLKgb286j9oIjTn3MxikcTcH1J4jZYpLgmbzuBzN66yt X-Received: by 2002:a63:f811:: with SMTP id n17mr11544782pgh.23.1547165171867; Thu, 10 Jan 2019 16:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547165171; cv=none; d=google.com; s=arc-20160816; b=xi5v4eaf0blcushH9tQnQoDzXr1Z41+fYQ7KSXnj4dDITGkoyR41Rhe+MAHbkXtFzw NsU4IS7dv+taq1pwScYGBgSIPi1xND+zZNUkAsrw2PqpDUnCkPo305snvizSRcUqcJ02 frWBJHcai1jcbyJYrOYV2Bd5h2axnaGkIdHjMme7qvpQxv00v/I3vXJ9nSQwhO2h5gD9 ZMhfdVTOzfukexHSckIdM1SkR3EpJ60gnOx73BmUnbDOdgu05dpKj3o2SwFAw2ndURcc WybYyKJKBqekspquSGPL4C9qASpf3YkOKclP8VBF3MtGydhux00Bm8jg5fsyVRfTaaY8 Yvtg== 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:dkim-signature; bh=wIoi8pczJERT7x9PNmm27meszqDlWs6BJCu2jPvHxX4=; b=uoNZ4SvqNFehWVhUndSD+SMcHfHl8EsGdrxUTLMY8G00Y1nJav9krXr1sHIV2chvEY FF1UYjPSv/YBI0070hGepPNcGo4MPvc2B80XImP0qorz9+1CfxJo3V0BJ64ejqCjoQ2n G8xpeoFkNO5L0APPG4Cfy3ddYNg4G3rYEVtMzssF2bR+PiO1ONND8612C0fpajQ9yiRL Vu33cZGs8nTA9iz23+6nvnNVGmJ2GXbqW8LGTsS+6G0aUU7dyI49hJ0Em8LKeQPOMtXt kCjkLueC9G9846WAxroyWkNjDOa+AKcCtgNUwzkbr463KCRHmoDWbPu9tSkBVgkgJO9U nm9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=BEedg4qt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m11si15584254plt.26.2019.01.10.16.05.53; Thu, 10 Jan 2019 16:06:11 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=BEedg4qt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728530AbfAJVPd (ORCPT + 99 others); Thu, 10 Jan 2019 16:15:33 -0500 Received: from mail.skyhub.de ([5.9.137.197]:38948 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727401AbfAJVPc (ORCPT ); Thu, 10 Jan 2019 16:15:32 -0500 Received: from zn.tnic (p200300EC2BC5CF00CD9D2FB5DCB47746.dip0.t-ipconnect.de [IPv6:2003:ec:2bc5:cf00:cd9d:2fb5:dcb4:7746]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 395B91EC08EA; Thu, 10 Jan 2019 22:15:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1547154931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=wIoi8pczJERT7x9PNmm27meszqDlWs6BJCu2jPvHxX4=; b=BEedg4qtQMmw3erjh/8ZHwGe1dyTnbdt8uDgxuBqRSHzN/uTadQG/W7EL+/bf54qSkRyOV po7juCdIWZWl58iHPIYvU1K/2kmtDt9aFcexJKL97LDlNIDmeAqUOBAEQrjQs1ygsmZwZX fTkBDhNQZiWw7glG2UcZS145+lc94nY= Date: Thu, 10 Jan 2019 22:15:23 +0100 From: Borislav Petkov To: Chao Fan Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, keescook@chromium.org, bhe@redhat.com, msys.mizuma@gmail.com, indou.takao@jp.fujitsu.com, caoj.fnst@cn.fujitsu.com Subject: Re: [PATCH v15 3/6] x86/boot: Introduce efi_get_rsdp_addr() to find RSDP from EFI table Message-ID: <20190110211523.GG17621@zn.tnic> References: <20190107032243.25324-1-fanc.fnst@cn.fujitsu.com> <20190107032243.25324-4-fanc.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190107032243.25324-4-fanc.fnst@cn.fujitsu.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 07, 2019 at 11:22:40AM +0800, Chao Fan wrote: > Memory information in SRAT is necessary to fix the conflict between > KASLR and memory-hotremove. So RSDP and SRAT should be parsed. > > When booting form KEXEC/EFI/BIOS, the methods to compute RSDP > are different. When booting from EFI, EFI table points to RSDP. > So parse the EFI table and find the RSDP. > > Signed-off-by: Chao Fan > --- > arch/x86/boot/compressed/acpi.c | 83 +++++++++++++++++++++++++++++++++ > 1 file changed, 83 insertions(+) > > diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c > index 7ca5001d7639..f74c5d033d79 100644 > --- a/arch/x86/boot/compressed/acpi.c > +++ b/arch/x86/boot/compressed/acpi.c > @@ -5,6 +5,8 @@ > #include "../string.h" > > #include > +#include > +#include > > /* > * Max length of 64-bit hex address string is 19, prefix "0x" + 16 hex > @@ -28,3 +30,84 @@ static acpi_physical_address get_acpi_rsdp(void) > #endif > return 0; > } > + > +/* Search EFI table for RSDP. */ > +static acpi_physical_address efi_get_rsdp_addr(void) > +{ > + acpi_physical_address rsdp_addr = 0; <---- newline here. > +#ifdef CONFIG_EFI > + efi_system_table_t *systab; > + struct efi_info *ei; > + bool efi_64; > + char *sig; > + int size; > + int i; > + > + ei = &boot_params->efi_info; > + sig = (char *)&ei->efi_loader_signature; > + > + if (!strncmp(sig, EFI64_LOADER_SIGNATURE, 4)) { > + efi_64 = true; > + } else if (!strncmp(sig, EFI32_LOADER_SIGNATURE, 4)) { > + efi_64 = false; > + } else { > + debug_putstr("Wrong EFI loader signature.\n"); > + return 0; > + } > + > + /* Get systab from boot params. Based on efi_init(). */ > +#ifdef CONFIG_X86_64 > + systab = (efi_system_table_t *)(ei->efi_systab | ((__u64)ei->efi_systab_hi<<32)); > +#else > + if (ei->efi_systab_hi || ei->efi_memmap_hi) { > + debug_putstr("Error getting RSDP address: EFI system table located above 4GB.\n"); > + return 0; > + } > + systab = (efi_system_table_t *)ei->efi_systab; > +#endif > + > + if (!systab) > + error("EFI system table is not found."); s/is// > + > + /* > + * Get EFI tables from systab. Based on efi_config_init() and > + * efi_config_parse_tables(). > + */ > + size = efi_64 ? sizeof(efi_config_table_64_t) : > + sizeof(efi_config_table_32_t); > + > + for (i = 0; i < systab->nr_tables; i++) { > + void *config_tables; > + unsigned long table; > + efi_guid_t guid; > + > + config_tables = (void *)(systab->tables + size * i); > + if (efi_64) { > + efi_config_table_64_t *tmp_table; > + u64 table64; > + > + tmp_table = config_tables; > + guid = tmp_table->guid; > + table64 = tmp_table->table; > + table = table64; That table64 looks superfluous. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.