Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp301750img; Wed, 27 Mar 2019 23:30:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvn/nkplBq/0FvYSyloP0TK6IAzsaoyymiJSc5vIvUTE63weLm2PxMMvBnCvZdaurUFF18 X-Received: by 2002:a62:5206:: with SMTP id g6mr23905010pfb.227.1553754643160; Wed, 27 Mar 2019 23:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553754643; cv=none; d=google.com; s=arc-20160816; b=J/+LNV4L88pmrK+FoWWv3CRjCmWmEJiSFq2tHVQy3/9eJRzIKuoOcbYOjoXSwlLThT ELSJtbPgTLCuNOwbSj0RRxBLEp7qiho1JeBPUBAkQwh2tKAL1I4ZGx1sDb0yepkwY5zA Vne1xSI1oJFBkKjCQJBEJJ7QeAIt56UZW32B4UtFwMF1bR/7o04llec1pjvW3xCDnTW/ X1Ls/H9mNkyIs6jQr3EsYKw/6Fun1ehUX+LI7+s3HO7cVGF8FYktBWiUa28PNUCwFs9/ jVoR1Om/OOl7Maxwu/MwM9Jt2lORowuvR9VMxdGW65k976TtLY5WwzHg3AJnkNhFRXpw tAVQ== 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; bh=GzOCQfUdqEg3EGPs7K/hJx0DlmRi7gu4IoAx7EBzfRs=; b=L9mnTKT/UfifGHMeS2KETzinD00c3luFk2VpLFKsXQU8lkjqfFE3zz8Wwr5gD18T5e npvqcgJOIomGaipMblncBlFW4SCJ1+033nwKTAeJQ9V9PHHCDFMW9WMQ5QTmBGvzGEwl jT2GVEbwbVJsNFDFyfOHl+jSGOHE1XUkoYWMtk14pK3EchuvgfnBQCfm8ndLnD0Vnmej 7VNMvl1jTsUhVGqlUZOxilGYY8QUDlc+pS4FJBOkEKOnN+KEI67sHUyzW2zgbyyiV5S3 iIF3Ju9X2/hw7msqdmdJjpgFZsTDiNZ/lfsbVlbad/LoxdPr3tnZ8X4TvFKOxrP0opvs ZxJg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v34si21393028plg.176.2019.03.27.23.30.27; Wed, 27 Mar 2019 23:30:43 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726289AbfC1G1m (ORCPT + 99 others); Thu, 28 Mar 2019 02:27:42 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:42479 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725875AbfC1G1m (ORCPT ); Thu, 28 Mar 2019 02:27:42 -0400 X-IronPort-AV: E=Sophos;i="5.60,278,1549900800"; d="scan'208";a="57898735" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 28 Mar 2019 14:27:36 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 3A70F4CD5D25; Thu, 28 Mar 2019 14:27:34 +0800 (CST) Received: from localhost.localdomain (10.167.225.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 28 Mar 2019 14:27:40 +0800 Date: Thu, 28 Mar 2019 14:26:45 +0800 From: Chao Fan To: Junichi Nomura CC: "bhe@redhat.com" , Borislav Petkov , Dave Young , "kasong@redhat.com" , "x86@kernel.org" , "kexec@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] x86/boot: Use EFI setup data if provided Message-ID: <20190328062645.GG4234@localhost.localdomain> References: <51D9A7D1-49BF-4679-B102-0FC5AC300C9F@alien8.de> <20190325101509.GA13160@dhcp-128-65.nay.redhat.com> <701c8e69-e1d4-c653-1d87-1c41789d3d54@ce.jp.nec.com> <20190325120149.GI12016@zn.tnic> <20190325122302.GC13160@dhcp-128-65.nay.redhat.com> <20190325123229.GL12016@zn.tnic> <20190325231000.GA9184@jeru.linux.bs1.fc.nec.co.jp> <20190326135714.GG1867@zn.tnic> <20190327014852.GA3659@MiWiFi-R3L-srv> <73322ba9-e436-68db-7863-afd31607d969@ce.jp.nec.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <73322ba9-e436-68db-7863-afd31607d969@ce.jp.nec.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Originating-IP: [10.167.225.56] X-yoursite-MailScanner-ID: 3A70F4CD5D25.AC066 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: fanc.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 28, 2019 at 04:17:16AM +0000, Junichi Nomura wrote: >On 2019/03/27 10:48, bhe@redhat.com wrote: >>>> So efi_get_rsdp_addr() needs to be refactored in such a way so that at >>>> least the loop towards the end gets carved out into a separate function >>>> - __efi_get_rsdp_addr() or so - which gets config_tables, nr_tables and >>>> size as arguments and finds the RSDP address in the kexec-ed kernel. >>> >>> You need to carve out the loop at the end and make it into a separate >>> __efi_get_rsdp_addr() function which gets the physical or the virtual >>> address. >> >> I guess Boris is suggesting code like below. Please correct me if I am >> wrong. >> >> static acpi_physical_address _efi_get_rsdp_addr(efi_config_table tbl, ...) >> { >> /* Get EFI tables from systab. */ >> for (i = 0; i < nr_tables; i++) { >> ... >> } >> return rsdp_addr; >> } >> >> static acpi_physical_address efi_get_rsdp_addr(void) >> { >> ... >> /* Get systab from boot params. */ >> ... >> /* Handle EFI bitness properly */ >> ... >> return _efi_get_rsdp_addr(); >> } >> >> >> static acpi_physical_address kexec_get_rsdp_addr(void) >> { >> if (!is_kexec_booted) >> return 0; >> >> efi_get_setup_data_addr(); >> ... >> /* Handle EFI bitness properly */ >> ... >> return _efi_get_rsdp_addr(); >> } > >I still don't get it... We still need systab for kexec case as well >to get nr_tables. Don't we? > >> acpi_physical_address get_rsdp_addr(void) >> { >> acpi_physical_address pa; >> >> pa = get_acpi_rsdp(); >> >> if (!pa) >> pa = boot_params->acpi_rsdp_addr; >> >> >> /** >> /*I think here we should check if it's kexec booted firstly. >> * Skip it if not kexec. this can avoid the wrong kexec virt >> * addr parsing./ >> if (!pa) >> pa = kexec_get_rdsp_addr(); <--- new function >> >> if (!pa) >> pa = efi_get_rsdp_addr(); >> > >Shouldn't t efi_get_rsdp_addr() check "is_kexec_booted" and exit >early so that it never tries to use virtual config_tables pointer >if for some unknown resason kexec_get_rsdp_addr() failed. In my understanding, in EFI issue, RSDP is from efi_get_rsdp_addr() or kexec_get_rdsp_addr()(only in kexec environment). So in these two functions only one can be excuted, so how about this: if (is_kexec_booted) pa = kexec_get_rdsp_addr(); <--- new function else pa = efi_get_rsdp_addr(); And also split the same code as _efi_get_rsdp_addr(). If there is something wrong in my understanding, please let me know. Thanks, Chao Fan > >Currently I check "is_kexec_booted" by subset of efi_get_setup_data_addr(). >Do you know a simpler way to check "is_kexec_booted"? > >> if (!pa) >> pa = bios_get_rsdp_addr(); >> >> return pa; >> } > >-- >Jun'ichi Nomura, NEC Corporation / NEC Solution Innovators, Ltd. >