Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3412314pxf; Mon, 22 Mar 2021 06:01:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1HTe3r5gVnWG9sKyaQHVJ7fcIxMDBWnq9VRfF3N+vbfSeGdNFC7m2HA6oXYvxy1f3uJ+d X-Received: by 2002:ac2:599c:: with SMTP id w28mr8885924lfn.381.1616418067629; Mon, 22 Mar 2021 06:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616418067; cv=none; d=google.com; s=arc-20160816; b=nF8tm74Co7z7P2m0yy2/CZRK5GvByBGNrC1kO+wsgM1yU0kso/J0Pnq0/7oJCieqx1 E32H8JXuR0L9K4YngCopbSETecRESjOXuNWrGfRZAW0fZhfPtG/MpnAxIQEHMaTR+5Ae ETpWCmu9gfyXeVFINyYSRIwLLopWfdWfiozhrbNMwS/aC1lTfhWvLP0SGpObT1cmdmPA nbfNUwr7L0aJeS+yudwWUkiB7/um4JnOxFJmtCKi15ClTdqu6ZjJ++aD6MMJQ/ZI+Qlf YYa+zhGqU1NYdMo7C3PnTVJGy9oywu7+Jlj8AK/hNPu17Dpf8bnrwcm4ZTVkwm+LenwA A7Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GkBeuoqfnMT7d8nU1giE9XyX+GbbberMwOrFPCuJ2to=; b=QCM42cEoT0le1CrPBzOffpc/McD/FRAmUICIHfDDqwL+ZAT7tKd1OveZ2NacSfonHo F66OMIpx8BgUh4UbzjiHWr+nSxgDF2M5jdGhZZ46uM7ACtN84dJeIvNxbBZM+w2XxJMw omppRL3RloCsIM9AZDf6Qtvk+2vTfLqsh9AUXCORDjYKew4bhKW9/dbag/lvNBd2Vf0H 8nURmDvGT2qAGUckWBHyvv5sJxsQo6G+OEgdTiO8rqhMIyPDPbmZSPEjYcB8M8QTYgVY o/ne30GolDu0wUTzAcCtFOZM8Hf5eXLn51VaTxRbScNV973PPNQtvYbgAIW0WzgbS18e fLQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jKIIblSQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si10506203edq.173.2021.03.22.06.00.43; Mon, 22 Mar 2021 06:01:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=jKIIblSQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231147AbhCVM7D (ORCPT + 99 others); Mon, 22 Mar 2021 08:59:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:40980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232577AbhCVMry (ORCPT ); Mon, 22 Mar 2021 08:47:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1C74619B2; Mon, 22 Mar 2021 12:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616417026; bh=xb6ghuOPd3lUfE0yZi8fZ0KJp+paEtbTLac7jBrUwts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jKIIblSQzq0CFiSeYOcvi/elEGeaN4Gf3JUZ58AsIe7wy1VZBmRGrajYYQw0gFWoE 3LOZYQ/zmRh8COUOECd0tvwGsUhRHByhX6iS+Hfv0DxFT9NvVWuG2xrHFUrSfRIO+x Evz7nt8J49x488XEchyUYyWFA2aMjqE7uDrNUwmw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel Subject: [PATCH 5.4 57/60] efi: use 32-bit alignment for efi_guid_t literals Date: Mon, 22 Mar 2021 13:28:45 +0100 Message-Id: <20210322121924.261609295@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121922.372583154@linuxfoundation.org> References: <20210322121922.372583154@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel commit fb98cc0b3af2ba4d87301dff2b381b12eee35d7d upstream. Commit 494c704f9af0 ("efi: Use 32-bit alignment for efi_guid_t") updated the type definition of efi_guid_t to ensure that it always appears sufficiently aligned (the UEFI spec is ambiguous about this, but given the fact that its EFI_GUID type is defined in terms of a struct carrying a uint32_t, the natural alignment is definitely >= 32 bits). However, we missed the EFI_GUID() macro which is used to instantiate efi_guid_t literals: that macro is still based on the guid_t type, which does not have a minimum alignment at all. This results in warnings such as In file included from drivers/firmware/efi/mokvar-table.c:35: include/linux/efi.h:1093:34: warning: passing 1-byte aligned argument to 4-byte aligned parameter 2 of 'get_var' may result in an unaligned pointer access [-Walign-mismatch] status = get_var(L"SecureBoot", &EFI_GLOBAL_VARIABLE_GUID, NULL, &size, ^ include/linux/efi.h:1101:24: warning: passing 1-byte aligned argument to 4-byte aligned parameter 2 of 'get_var' may result in an unaligned pointer access [-Walign-mismatch] get_var(L"SetupMode", &EFI_GLOBAL_VARIABLE_GUID, NULL, &size, &setupmode); The distinction only matters on CPUs that do not support misaligned loads fully, but 32-bit ARM's load-multiple instructions fall into that category, and these are likely to be emitted by the compiler that built the firmware for loading word-aligned 128-bit GUIDs from memory So re-implement the initializer in terms of our own efi_guid_t type, so that the alignment becomes a property of the literal's type. Fixes: 494c704f9af0 ("efi: Use 32-bit alignment for efi_guid_t") Reported-by: Nathan Chancellor Reviewed-by: Nick Desaulniers Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Link: https://github.com/ClangBuiltLinux/linux/issues/1327 Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- include/linux/efi.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -63,8 +63,10 @@ typedef void *efi_handle_t; */ 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) +#define EFI_GUID(a, b, c, d...) (efi_guid_t){ { \ + (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ + (b) & 0xff, ((b) >> 8) & 0xff, \ + (c) & 0xff, ((c) >> 8) & 0xff, d } } /* * Generic EFI table header