From patchwork Tue Jan 8 15:28:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154979 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5006599jaa; Tue, 8 Jan 2019 07:28:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN6XYFENNCPUTP34tUInH7cdwA/9+JXmJ6ouO1Mvp9oORGeZHbFn2d4nyuIV6a26hhG6hHav X-Received: by 2002:a17:902:4464:: with SMTP id k91mr2227727pld.13.1546961318319; Tue, 08 Jan 2019 07:28:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546961318; cv=none; d=google.com; s=arc-20160816; b=Tz4/XdGNvzMFQacKAqUoErNtOgzFkKV/n22qp4MjoEBc7kB3zspPdbVK+SfXnmdzKf 70u79Y0M7feRwjlsRHwYCToJx5HT9R1/3g0X4AIt3xc4bYaGakuSIm9sTkEhJJRo7tmw JqjITIJEMQxADe9B3lToVubJZ01Lu12/VwVBeekJ2vi7L+YgwmIzp1Mhv6R/1TSX02tW FGnBAFOsIJtW2hop7+3zFxQ47feXTpvbFbvxyJIYTDfOCgOkOiyG0qKIMjFU8ressp9g r0zJ/Io/nXNdpbYdH8FX74fDQXsLsz7ZCd4h5VBTe5k0nkeFT29rz6W43VdsmBUz1mPg 53zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4K6IrfJGLuqOXV0rX4sdp3u8fI3xqpWy1jqXH78SKIU=; b=x9LUBzhpOE2EIScUwkqiztI6V2bz8tmRUSGCMRO25VVDt+mBpltVMehdfVF1Q2PsRm u37JspBdGqkdpWBGFGnQNOofN1v+vqI3SZkeil6ZEBpVf4+a6U3ZG0A4coYlpMVAirLS 9bI5uigM0lNR4um05ueV4ivdC74vZ0qYFTz++X+zk+8NRie9q5ybjnhAtbCq1W5O2E2w QyRNaYEf7GEfPoQejSPHdn7MGsjFqftoJdI6utjb0q++eX3ueicqLh9C0Lyqk3HYYx4g JKJ6SCdoREun25K5BTYU4G0uYqiiu9F0oKDz/PNikY7jpU5SXIAnlwEHMV2pGJO2Fbp+ TAzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HTr1FAIf; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-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 k5si17139203pfj.153.2019.01.08.07.28.38; Tue, 08 Jan 2019 07:28:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-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=HTr1FAIf; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-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 S1727772AbfAHP2h (ORCPT + 3 others); Tue, 8 Jan 2019 10:28:37 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:45075 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727295AbfAHP2h (ORCPT ); Tue, 8 Jan 2019 10:28:37 -0500 Received: by mail-ed1-f65.google.com with SMTP id d39so4569855edb.12 for ; Tue, 08 Jan 2019 07:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4K6IrfJGLuqOXV0rX4sdp3u8fI3xqpWy1jqXH78SKIU=; b=HTr1FAIfKdIpzMCSqSHifDPKvfZQ5ijKIqyxAnzCi6g+18bJJRAYJuSaxfi0gCcH4j RBOPMO/39tjOYjMTrkw23K7iszPzbSV44PnfbAewgf89PWnO2woiZ9lFTs0ZsbAjpo0K AoB0adGfIfHS546s3DhS1X4e8Apo0TCdZdKHg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4K6IrfJGLuqOXV0rX4sdp3u8fI3xqpWy1jqXH78SKIU=; b=aQOG2KqdEFLsUZb+Lv+beSxren1s+Po4IySRwgzDJ6+sVa8dWhQXQOWGp+4Xiggke9 V/AfHBAm761Qi3OHNEvS2QcwD1O5TLcTyxL3r7DeFfUYwb/h5CAywMW+foE3XD7/3PmR wMgQ3EErRYDanyiIvSojFEFDLGtWov8WldceWwJDyJ+AsAG00G23GOLNLvDidWmay1zs fx8Cwp/xIlH2OaxgYEVh1DuAa4WxZdLXM0FZPxBw+3y2OKOGXfQW0+LM2uIJhNgBIS92 gKQ8TzBxmtlBLo9n6aBtsxj4ix5LNYAf0v+sXcex8I8V8EDRiDg/jde7pyMWdLs/U/LZ +6Jg== X-Gm-Message-State: AJcUukdkhapLC0TxaGfr8MHAoq+oUgj+bVxM/r3WsZEsK8LW8pvzu1xg H7y4S/vgNrle+2LhAlmVbmB2IQQ1ck62aA== X-Received: by 2002:a17:906:1189:: with SMTP id n9-v6mr2216625eja.2.1546961315691; Tue, 08 Jan 2019 07:28:35 -0800 (PST) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id m44sm65715edm.54.2019.01.08.07.28.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jan 2019 07:28:34 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, leif.lindholm@linaro.org, lersek@redhat.com, mingo@kernel.org, Ard Biesheuvel , Heinrich Schuchardt Subject: [PATCH] efi: use 32-bit alignment for efi_guid_t Date: Tue, 8 Jan 2019 16:28:29 +0100 Message-Id: <20190108152829.11579-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The UEFI spec and EDK2 reference implementation both define EFI_GUID as struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment is 32 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM), this means that firmware services invoked by the kernel may assume that efi_guid_t* arguments are 32-bit aligned, and use memory accessors that do not tolerate misalignment. So let's set the minimum alignment to 32 bits. Note that the UEFI spec as well as some comments in the EDK2 code base suggest that EFI_GUID should be 64-bit aligned, but this appears to be a mistake, given that no code seems to exist that actually enforces that or relies on it. Reported-by: Heinrich Schuchardt , Signed-off-by: Ard Biesheuvel --- include/linux/efi.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Leif Lindholm diff --git a/include/linux/efi.h b/include/linux/efi.h index 45ff763fba76..be08518c2553 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -48,7 +48,20 @@ typedef u16 efi_char16_t; /* UNICODE character */ typedef u64 efi_physical_addr_t; typedef void *efi_handle_t; -typedef guid_t efi_guid_t; +/* + * The UEFI spec and EDK2 reference implementation both define EFI_GUID as + * struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment + * is 32 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM), + * this means that firmware services invoked by the kernel may assume that + * efi_guid_t* arguments are 32-bit aligned, and use memory accessors that + * do not tolerate misalignment. So let's set the minimum alignment to 32 bits. + * + * Note that the UEFI spec as well as some comments in the EDK2 code base + * suggest that EFI_GUID should be 64-bit aligned, but this appears to be + * a mistake, given that no code seems to exist that actually enforces that + * or relies on it. + */ +typedef guid_t efi_guid_t __aligned(__alignof__(u32)); #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)