Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4523863ybv; Mon, 17 Feb 2020 00:34:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxndxRamaKSpHaBSwTLZ7Yri9zMHs4STgKtcgcXtQpjEKjb2gar4e2uVtWitYGff8d8PoDb X-Received: by 2002:a9d:638d:: with SMTP id w13mr10045753otk.220.1581928493222; Mon, 17 Feb 2020 00:34:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581928493; cv=none; d=google.com; s=arc-20160816; b=gg9gZJ+fDJvvO8raKgFzH0kKkcisI5LIfrebpmxk5s7lWsgQjRZLEwbSDNfbcpuzIZ oBdO5t9oXSP2joRDMGYTAKt4pYezm8BSY3jlABrzgzD4umXUS+MMe1vH0HMUzjfmSrU2 a2GZrmyUIzRgKdBvKzCVkzbhZ4BS1xbWlCNTEo8pq8AAv6qyyLh+mT80ylS4l1YIyXnB KE1Egzw09Vuhkwxq0FZM1WrvKQxKMtKQyptO3DnN+SyAgKKhsRPT42yJrPmsYXW/0qIM HSlXkmaWyQW+Wl2oe0zE6NkX5uEfDBAzFby54XUbMahkkiLfTzPuQWV0KccESXSAhz7N kYBA== 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:dkim-signature; bh=/+2/jhKGTvzVYAoiqFgB0jbdQqzeK22nPu7wmwOsKDU=; b=EH3Hh/7CuD3n484uLrG7SwGcju8BeFT8cAMf83QH/wy5C9yhpkPSYNXWkXyetBm6Io ND2DelPG1BzvnWgkKeZidQ9D0aQOxEpg+R8tRLVb9Spd+yeqFFoYXlwwx5k3ylF2To68 L7POeKTMcE5yqiH4pNQFvh2s4Wu8llJsIclw/XDDGeC6Da+f3HB858rh6okvUJhbxPrk KtH5+gZ4I2LCxKJ1GVt1aNmFf1RUJIiX+GAiPf9hPvZAlOxMEnHOjBg7Eq6sQlPdDQvs skeyqjZbx+xS2gb9n3iN1IXCEiwm+aqWPqMYhXGc51Z1QA6pal+h0zvIu6HVTahC9svW pNNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1Qsi15U7; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si6623602otp.25.2020.02.17.00.34.41; Mon, 17 Feb 2020 00:34:53 -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=@kernel.org header.s=default header.b=1Qsi15U7; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728435AbgBQIcy (ORCPT + 99 others); Mon, 17 Feb 2020 03:32:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:38502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728217AbgBQIcx (ORCPT ); Mon, 17 Feb 2020 03:32:53 -0500 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B89220725 for ; Mon, 17 Feb 2020 08:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581928372; bh=OwgMBsjVSCrvbV4TA2D+tr7AeyhpUQsV01Ho7eUVod0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=1Qsi15U7hTxkN1xdFFORkwVFajZ/gVGeHxiOLjCR1d1WrYJ9ngmW56hFGfLcG/vY1 yFRc7dkoBHwkAs70yIqaRDY9Vu0PEbjZQ8KREpRR1jIe9ShqQQ8YZsxqi0qc6UGTsy AQfPaISrmT2i+Qx8knFGeMyJCWj2aw4n+uLS5irs= Received: by mail-wm1-f45.google.com with SMTP id s10so16186256wmh.3 for ; Mon, 17 Feb 2020 00:32:52 -0800 (PST) X-Gm-Message-State: APjAAAUUG4eb7AxYqGd2QbGhwcySHbZWECfQYwx6OiKU7r/UT45sxuua V2q3/+g5RWpOo5zjtaa9ttz3vqsJKZVbrY7ZU8HCwA== X-Received: by 2002:a1c:bc46:: with SMTP id m67mr20313635wmf.40.1581928370477; Mon, 17 Feb 2020 00:32:50 -0800 (PST) MIME-Version: 1.0 References: <20200216182334.8121-1-ardb@kernel.org> <20200216182334.8121-13-ardb@kernel.org> <20200216191219.GA589207@rani.riverdale.lan> In-Reply-To: <20200216191219.GA589207@rani.riverdale.lan> From: Ard Biesheuvel Date: Mon, 17 Feb 2020 09:32:39 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 12/18] efi: clean up config_parse_tables() To: Arvind Sankar Cc: linux-efi , linux-arm-kernel , Linux Kernel Mailing List , "the arch/x86 maintainers" 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 On Sun, 16 Feb 2020 at 20:12, Arvind Sankar wrote: > > On Sun, Feb 16, 2020 at 07:23:28PM +0100, Ard Biesheuvel wrote: > > config_parse_tables() is a jumble of pointer arithmetic, due to the > > fact that on x86, we may be dealing with firmware whose native word > > size differs from the kernel's. > > > > This is not a concern on other architectures, and doesn't quite > > justify the state of the code, so let's clean it up by adding a > > non-x86 code path, constifying statically allocated tables and > > replacing preprocessor conditionals with IS_ENABLED() checks. > > > > Signed-off-by: Ard Biesheuvel > > --- > > arch/ia64/kernel/efi.c | 3 +- > > arch/x86/platform/efi/efi.c | 6 +-- > > drivers/firmware/efi/arm-init.c | 5 +-- > > drivers/firmware/efi/efi.c | 47 ++++++++++---------- > > include/linux/efi.h | 5 ++- > > 5 files changed, 32 insertions(+), 34 deletions(-) > > ... if (!retval) > > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > > index 2bfd6c0806ce..db1fe765380f 100644 > > --- a/drivers/firmware/efi/efi.c > > +++ b/drivers/firmware/efi/efi.c ... > > @@ -498,39 +498,38 @@ static __init int match_config_table(efi_guid_t *guid, > > return 0; > > } > > > > -int __init efi_config_parse_tables(void *config_tables, int count, int sz, > > - efi_config_table_type_t *arch_tables) > > +int __init efi_config_parse_tables(const efi_config_table_t *config_tables, > > + int count, > > + const efi_config_table_type_t *arch_tables) > > { > > - void *tablep; > > + const efi_config_table_64_t *tbl64 = (void *)config_tables; > > + const efi_config_table_32_t *tbl32 = (void *)config_tables; > > + const efi_guid_t *guid; > > + unsigned long table; > > int i; > > > > - tablep = config_tables; > > pr_info(""); > > for (i = 0; i < count; i++) { > > - efi_guid_t guid; > > - unsigned long table; > > - > > - if (efi_enabled(EFI_64BIT)) { > > - u64 table64; > > - guid = ((efi_config_table_64_t *)tablep)->guid; > > - table64 = ((efi_config_table_64_t *)tablep)->table; > > - table = table64; > > -#ifndef CONFIG_64BIT > > - if (table64 >> 32) { > > + if (!IS_ENABLED(CONFIG_X86)) { > > + guid = &config_tables[i].guid; > > + table = (unsigned long)config_tables[i].table; > > + } else if (efi_enabled(EFI_64BIT)) { > > + guid = &tbl64[i].guid; > > + table = tbl64[i].table; > > + > > + if (IS_ENABLED(CONFIG_X64_32) && > ^^^ typo, should be X86 > Noted, thanks for spotting that.