Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp457588pxb; Thu, 19 Aug 2021 03:47:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc5H0jq+XWGXLnnilpZpTO7Vecpa3ovP2wefm00lp4pWD71SH62qc+l9RVQ5fFksQsW6rX X-Received: by 2002:a02:664e:: with SMTP id l14mr12405639jaf.56.1629370064979; Thu, 19 Aug 2021 03:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629370064; cv=none; d=google.com; s=arc-20160816; b=ISpHFWjJqtedklcGM7glsvKqrbR9+KRm8OMqAAdX1Sk4nO+iy5Ndhm3H3DBgw/3AYa DL+a9MUSerWNveDFzTInllB/8dIIhJcf6iDjsqR3kGZCFTDfyygOqm18hYeknewKftCg Pt9t9M9l9lOocyWqpMUTl2kybMwKKNoQj9vnUox53gN5VqGgVLmJ8bgnxYFVxGTt3CgB d4pG9+QbgEnIPpucGKQoRyvfxES1PmFTLUZ4K/QO8yTtxwJA1QWnHys8p+YSrFvmRota ICdkQVOvpNvtXVq91MRb42GxS1PWwRgUjTrtpqL9PHf4SmxriHyCjcfgwHfFjqHc7Oa5 jv9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sMPlIl0Hz40M1f3YPGZe0Jffy/8QBdXGitdWTD9fvQE=; b=if5Pi1Vs626O/i6Mrhuoo8oRYQqVCGgU5YFjgSKpCgU1doa/iLe3tAkJqPaWpySG2V ZkTY0T9ypRvwsQV4oElQI0NPtpaoAlHJhqJNHZGJwT4gXYxbwGWKTXF1NlNl6TvMW5dN JTGWgx2S0P6DJPlFi2LyrTMUvi4hPmWhR+n7UFhlWQCy/qKqC9c2q4YMvfzrVda+1FU4 JUhRHLnrT4yV+C+/T/OKhabJOhmwpl0TdxL+avWU2aqMcFmlNjl0KIMxdEGGgak8/VTb +NcAg9HysacJjU6r3RMAGcCqI4Qwp6OqvYKd4J96g7pmzUBgzWU4tj9/PCwlgkOO1HkP nlCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Zk5WbWk8; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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. [23.128.96.18]) by mx.google.com with ESMTP id w6si3771066ilu.79.2021.08.19.03.47.32; Thu, 19 Aug 2021 03:47:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Zk5WbWk8; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S238349AbhHSKsD (ORCPT + 99 others); Thu, 19 Aug 2021 06:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238318AbhHSKsC (ORCPT ); Thu, 19 Aug 2021 06:48:02 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A80EC061575; Thu, 19 Aug 2021 03:47:26 -0700 (PDT) Received: from zn.tnic (p200300ec2f0f6a00d82486aa7bad8753.dip0.t-ipconnect.de [IPv6:2003:ec:2f0f:6a00:d824:86aa:7bad:8753]) (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 078381EC046C; Thu, 19 Aug 2021 12:47:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1629370041; 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=sMPlIl0Hz40M1f3YPGZe0Jffy/8QBdXGitdWTD9fvQE=; b=Zk5WbWk88Bwd/ar+HuFJKTkOFMbe1OEJlM433bqbt6HY16PKJe3KGAk67rCVcLfsR6fniX hQ/NGyRH0pkk0dkr0ma74JiSWcOdVsGrRqvKUsac0Ud+avXe7gBHEuEI4/X8S5OJDFZhQG CCWIW1u7f+LlC42eHiH2SJEGBHiifOQ= Date: Thu, 19 Aug 2021 12:47:59 +0200 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Michael Roth , Vlastimil Babka , tony.luck@intel.com, brijesh.ksingh@gmail.com Subject: Re: [PATCH Part1 RFC v4 24/36] x86/compressed/acpi: move EFI config table access to common code Message-ID: References: <20210707181506.30489-1-brijesh.singh@amd.com> <20210707181506.30489-25-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210707181506.30489-25-brijesh.singh@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Jul 07, 2021 at 01:14:54PM -0500, Brijesh Singh wrote: > From: Michael Roth > > Future patches for SEV-SNP-validated CPUID will also require early > parsing of the EFI configuration. Move the related code into a set of > helpers that can be re-used for that purpose. > > Signed-off-by: Michael Roth > Signed-off-by: Brijesh Singh > --- > arch/x86/boot/compressed/Makefile | 1 + > arch/x86/boot/compressed/acpi.c | 124 +++++--------- > arch/x86/boot/compressed/efi-config-table.c | 180 ++++++++++++++++++++ > arch/x86/boot/compressed/misc.h | 50 ++++++ > 4 files changed, 272 insertions(+), 83 deletions(-) > create mode 100644 arch/x86/boot/compressed/efi-config-table.c arch/x86/boot/compressed/efi.c should be good enough. And in general, this patch is hard to review because it does a bunch of things at the same time. You should split it: - the first patch sould carve out only the functionality into helpers without adding or changing the existing functionality. - later ones should add the new functionality, in single logical steps. Some preliminary comments below as far as I can: > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile > index 431bf7f846c3..b41aecfda49c 100644 > --- a/arch/x86/boot/compressed/Makefile > +++ b/arch/x86/boot/compressed/Makefile > @@ -100,6 +100,7 @@ endif > vmlinux-objs-$(CONFIG_ACPI) += $(obj)/acpi.o > > vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o > +vmlinux-objs-$(CONFIG_EFI) += $(obj)/efi-config-table.o > efi-obj-$(CONFIG_EFI_STUB) = $(objtree)/drivers/firmware/efi/libstub/lib.a > > $(obj)/vmlinux: $(vmlinux-objs-y) $(efi-obj-y) FORCE > diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c > index 8bcbcee54aa1..e087dcaf43b3 100644 > --- a/arch/x86/boot/compressed/acpi.c > +++ b/arch/x86/boot/compressed/acpi.c > @@ -24,42 +24,36 @@ struct mem_vector immovable_mem[MAX_NUMNODES*2]; > * Search EFI system tables for RSDP. If both ACPI_20_TABLE_GUID and > * ACPI_TABLE_GUID are found, take the former, which has more features. > */ > +#ifdef CONFIG_EFI > +static bool > +rsdp_find_fn(efi_guid_t guid, unsigned long vendor_table, bool efi_64, > + void *opaque) > +{ > + acpi_physical_address *rsdp_addr = opaque; > + > + if (!(efi_guidcmp(guid, ACPI_TABLE_GUID))) { > + *rsdp_addr = vendor_table; > + } else if (!(efi_guidcmp(guid, ACPI_20_TABLE_GUID))) { > + *rsdp_addr = vendor_table; > + return false; No "return false" in the ACPI_TABLE_GUID branch above? Maybe this has to do with the preference to ACPI_20_TABLE_GUID. In any case, this looks silly. Please do the iteration simple and stupid without the function pointer and get rid of that efi_foreach_conf_entry() thing - this is not firmware. > diff --git a/arch/x86/boot/compressed/efi-config-table.c b/arch/x86/boot/compressed/efi-config-table.c > new file mode 100644 > index 000000000000..d1a34aa7cefd > --- /dev/null > +++ b/arch/x86/boot/compressed/efi-config-table.c ... > +/* If you're going to add proper comments, make them kernel-doc. I.e., it should start with /** and then use ./scripts/kernel-doc -none arch/x86/boot/compressed/efi-config-table.c to check them all they're proper. > + * Given boot_params, retrieve the physical address of EFI system table. > + * > + * @boot_params: pointer to boot_params > + * @sys_table_pa: location to store physical address of system table > + * @is_efi_64: location to store whether using 64-bit EFI or not > + * > + * Returns 0 on success. On error, return params are left unchanged. > + */ > +int > +efi_bp_get_system_table(struct boot_params *boot_params, There's no need for the "_bp_" - just efi_get_system_table(). Ditto for the other naming. I'll review the rest properly after you've split it. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette