Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2538270ybl; Sat, 14 Dec 2019 14:16:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwnkWLXyD4d0UxMHYL/6zYsOOKt/7w4rRGR4N7hCvJUnPxW6CGb8Z9o7mdUA9iuv5SSJN8u X-Received: by 2002:a05:6830:1689:: with SMTP id k9mr23634078otr.311.1576361787019; Sat, 14 Dec 2019 14:16:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576361787; cv=none; d=google.com; s=arc-20160816; b=ctyOtsJwpEpu1LE2lzfHC+2XzP6buYSNqctXJcyyl6NGe2cclrlPXr6Pf9Edyz+klY 7yyQ5cDS/bPss07apOIq/qdCRakekYFhoizQewT/Pxk0IjQ2XJ5tH4ZIZ49XNA0oz+n/ F0QdcgeWRnRzu3rhnWRuq61vAKX0eKiUtAiLGUwzZN7JQ/MmDi0zrZLvonm+I27pxniJ uc+q0Pr8q/G1QzKqwB5rGXGAqude7h1gItmbWycI0moj0aHmTiBffYb6vuxFgtuptfNj G31poLYkgIoRezv/tT2GvI9BmnRxjpEBbLtkgmU1ELuB1ms8CiMOhMmtcW3R8hK5eDAr uZeQ== 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=le9gTEplXasSXY5+vU+POpcZ8GAoVTNi2DgRESF94BM=; b=1AFP01aOdZ1A1SCe9LoAaDYTHLJk5iLI8ezb/6gGlkYCHL4hs0esJaz1JolEwe5A2I ARWdxWxpfTNCOIVzcD5Nyao5tx9xO71J9T3l+94zHdFu5Bi9lDUhdOHYKFrBwPWeNSuz xMbgF7ivK0m3VeWlFjlgQCdAO5Yiho28k1Fe5lLbJVZfOecG23ARdLvAMXUAsrxDyf3i nqEhXerXqxN4473FZKj9vqQr24IGi/x4odjwd642nbXcHj9I4dZs6X9P+ARGPx/+Y6XO hekQQ/ryoED8v1CAFcr1Mpvw6QXFUlgc8G+fNNBl0AwFRT+PYtXqcXT9lHz+8V2Ck7pI cpPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CgKhjGqM; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si10357439otc.62.2019.12.14.14.16.16; Sat, 14 Dec 2019 14:16:27 -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=@linaro.org header.s=google header.b=CgKhjGqM; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727070AbfLNWOm (ORCPT + 99 others); Sat, 14 Dec 2019 17:14:42 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34992 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727006AbfLNWOm (ORCPT ); Sat, 14 Dec 2019 17:14:42 -0500 Received: by mail-wm1-f66.google.com with SMTP id p17so2566582wmb.0 for ; Sat, 14 Dec 2019 14:14:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=le9gTEplXasSXY5+vU+POpcZ8GAoVTNi2DgRESF94BM=; b=CgKhjGqMjA2Ua4JZEnoVl9pkDc3irF6rNmQisnnigTz32BBdJj0Xz5PRQaXiAcUw5V eblM0Al8GX6idpxU+O+1z5URLpOZ39TTZ9JqoXlta344q/oKLNxi0oMNdlPCLT6eq6o+ Paz31NM4grktE57soKYFyBqOda9J/Jq0tUuk20g6wllWE8fCCbvikAuTBkKc0zPh46DO 4AwgSLVhpYWXLe1/PrthS5cK77yZPjZBr4fX6TFxqtMFhoeG7JmJl9uQq0Pk7O8HleWr 8qOWZPATz2piV8ARXFuxta9CBPDQYfHUvve4r8JUb3Pma5oXnOSAgKdOZ0UJcz5bo96Z 2JLA== 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=le9gTEplXasSXY5+vU+POpcZ8GAoVTNi2DgRESF94BM=; b=uBazg1iwx6EoOKLOKDHbgmxckCUTT/cCGsGIVq5utc5ui0pQcCcygUkDDuUhya5wGO +Yp80Cw74Tc/htuievZeeyb88CK+pJfj5kePthjs6VQigLzb3WwYmpcDMX8UGSJ7ob8j 0ktkJSY+9ddHq4d/41HzrTkccqQd2Lrpb/Hui3eLiY5Uw9+4/6SlgrVYpe8g6blNa7Xt fTSEDcAN7FtAYZQe42pBKhtR26FUJggKkKehvZJOo3xF778XdWXvbTzSnv17yWnyCG5Q JO27PH+Sim9i6B+2Y5rCwovtc0siGFYEx1MX+llpjO435XIzsSDfQFZNhBcL5SqINloe 5wXQ== X-Gm-Message-State: APjAAAX5T3fqyYKWEtFOkQQhvhd2D8HExOeNTKfG1gBboTReEAtl1206 DHEj1GzG+ikzUqjfOLLZ6/kHpnMrf1kNDXuG4FIuLg== X-Received: by 2002:a1c:7205:: with SMTP id n5mr22174711wmc.9.1576361679990; Sat, 14 Dec 2019 14:14:39 -0800 (PST) MIME-Version: 1.0 References: <20191214175735.22518-1-ardb@kernel.org> <20191214175735.22518-6-ardb@kernel.org> <20191214194626.GA140998@rani.riverdale.lan> <20191214194936.GB140998@rani.riverdale.lan> <20191214201334.GC140998@rani.riverdale.lan> <20191214211725.GG140998@rani.riverdale.lan> In-Reply-To: From: Ard Biesheuvel Date: Sat, 14 Dec 2019 22:14:38 +0000 Message-ID: Subject: Re: [PATCH 05/10] efi/libstub: distinguish between native/mixed not 32/64 bit To: Arvind Sankar Cc: Ard Biesheuvel , Linux Kernel Mailing List , linux-efi , Hans de Goede , Matthew Garrett , Ingo Molnar , Andy Lutomirski , Thomas Gleixner 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 Sat, 14 Dec 2019 at 22:30, Ard Biesheuvel wrote: > > On Sat, 14 Dec 2019 at 22:17, Arvind Sankar wrote: > > > > On Sat, Dec 14, 2019 at 08:27:50PM +0000, Ard Biesheuvel wrote: > > > On Sat, 14 Dec 2019 at 21:13, Arvind Sankar wrote: > > > > > > > > On Sat, Dec 14, 2019 at 07:54:25PM +0000, Ard Biesheuvel wrote: > > > > > On Sat, 14 Dec 2019 at 20:49, Arvind Sankar wrote: > > > > > > > > > > > > On Sat, Dec 14, 2019 at 02:46:27PM -0500, Arvind Sankar wrote: > > > > > > > On Sat, Dec 14, 2019 at 06:57:30PM +0100, Ard Biesheuvel wrote: > > > > > > > > + > > > > > > > > +#define efi_table_attr(table, attr, instance) ({ \ > > > > > > > > + __typeof__(((table##_t *)0)->attr) __ret; \ > > > > > > > > + if (efi_is_native()) { \ > > > > > > > > + __ret = ((table##_t *)instance)->attr; \ > > > > > > > > + } else { \ > > > > > > > > + __typeof__(((table##_32_t *)0)->attr) at; \ > > > > > > > > + at = (((table##_32_t *)(unsigned long)instance)->attr); \ > > > > > > > > + __ret = (__typeof__(__ret))(unsigned long)at; \ > > > > > > > > + } \ > > > > > > > > + __ret; \ > > > > > > > > +}) > > > > > > > > > > Yes. I'm open to suggestions on how to improve this, but mixed mode is > > > somewhat of a maintenance burden, so if new future functionality needs > > > to leave mixed mode behind, I'm not too bothered. > > > > > > > Maybe just do > > if (sizeof(at) < sizeof(__ret)) > > __ret = (__typeof__(__ret))(uintptr_t)at; > > else > > __ret = (__typeof__(__ret))at; > > That should cover most of the cases. > > But the compiler will still be unhappy about the else clause if __ret > is a pointer type, since we'll be casting an u32 to a pointer, I think the answer is to have efi_table_ptr() for pointers and efi_table_attr() for other types.