From patchwork Mon Oct 17 21:01:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: D Scott Phillips X-Patchwork-Id: 13009618 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4D91C433FE for ; Mon, 17 Oct 2022 21:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=WXcZk4q+OSu9i802AYqblrOp1SHZZEECrKAlxnx6ph0=; b=DVmyU4LoX7iWbu lO6yuojaAUSmt++SLpuES0o23ZJzVcl9l1ek15Bcvn1/iNUBYU6QgRFqChNerpDqs7BCg3wXx8PxP BG0TPXyWdskHaXJ5cEKSO2avtbJ7eOEjoDg+ekvSSeZK0cSiAO9eMcdTH60odQY9w9UGyMaobf/9R k0+bVyiqqy1i/w9t7SnosBtpKC0av9amp6rvmebHNOXOdBY0qSroRlTATMYa7rO4EXUxCv05G+Pqn a+x6/XVI+OGabpsFjkB3GczkwYwCYG12WRBSShJ62c5uGt3NzjGnSSXMMx7vHUXYTgBXmWN8fzs7a FPomULRwNRcotJXByLiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okXEv-00EvG5-ME; Mon, 17 Oct 2022 21:01:37 +0000 Received: from mail-mw2nam04on2133.outbound.protection.outlook.com ([40.107.101.133] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okXEs-00EvEm-LM for linux-arm-kernel@lists.infradead.org; Mon, 17 Oct 2022 21:01:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VBa0oSrXkCypnTutvhGGoraFx3/mfkKR0+WOYCOeqtAXTGGJ7DAZyubsI2SLA3r/nq7YkEgK5HnQqAZDmohkhxIY8tVaJgETznplNH7H1pQGRgk+J+LUgxfIsTeTeCHP9a2FHZ4f1A8+6JL9PTAcEcFerdeMf1cCTdq9wMN0lUugRbJMAWV2B3aJ5MCcgrSYXbzdVYyiOnKSAwzTAQC4R4gr4k6u3ENORI0jMWTirHGx4ZStcPrINjvjoMUuDmNPYV/K4VC4OL5aDRSgYH/4ukuLdeL6g+rm6FkBZJFTQFxQGOloaeHZTmV0vyzgZoJVyw0kdA49xBLIRk1l10f90w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZAMzGQI/CKCgLg9METi7F4Sp7wWqYEvDlBsM6H7MhSk=; b=eGb6kKeRgwpiEK+la/fGpjGxtsrh4LpWkST8cr1wLkACcRV2pCTZ6JRKWC+zO/M+2a01qbNS+LBlkY6D6A/k5655hpuLcUAV8lt9HBjYjOQm0M+1s8l+1S2u6333Fszp3nJfDznzWUAuap5XqRJo4cj4gN+oy6ZEjTIErZt5YPvthlqZCbvQTNaa0jYAgymwpytUKhh+7MYwaD1Lft3wj7GiWlEl7DwIWIUdYdR5QSlZZsp8axbO8vxxFFn1Kx5JN22Jo14Q1nilkxumjx85xmIwxx/iuiQUxVNAdsvT1iiNjudjrac7r4x23NDrNzU7aB8VxVqKNVBQmgBmatjbUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZAMzGQI/CKCgLg9METi7F4Sp7wWqYEvDlBsM6H7MhSk=; b=SOEU0RVDGt8kUXAkpSrP4nQoiFNj1uRXB9fmgmnKb21GcUWrjq+EWQrQJWJaoQcSPel0NH8zEQS+xqL0ScI+aX8+E8NO+NIyJkK5Po2NVZrVQsrTocIavIfLQNp/zlFYEVVLVp7BDbQd67TbwgFDjovlYihRb55XRgHuirjm7tc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from MWHPR0101MB2893.prod.exchangelabs.com (2603:10b6:301:33::25) by DM6PR01MB4281.prod.exchangelabs.com (2603:10b6:5:24::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Mon, 17 Oct 2022 21:01:27 +0000 Received: from MWHPR0101MB2893.prod.exchangelabs.com ([fe80::1a41:ea01:e01b:7051]) by MWHPR0101MB2893.prod.exchangelabs.com ([fe80::1a41:ea01:e01b:7051%5]) with mapi id 15.20.5723.032; Mon, 17 Oct 2022 21:01:27 +0000 From: D Scott Phillips To: linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , Will Deacon , James Morse , Geert Uytterhoeven , Darren Hart , patches@amperecomputing.com Subject: [PATCH] arm64: Fix bit-shifting UB in MIDR_AMPERE1 Date: Mon, 17 Oct 2022 14:01:19 -0700 Message-Id: <20221017210119.3581-1-scott@os.amperecomputing.com> X-Mailer: git-send-email 2.37.3 X-ClientProxiedBy: CH0PR03CA0415.namprd03.prod.outlook.com (2603:10b6:610:11b::26) To MWHPR0101MB2893.prod.exchangelabs.com (2603:10b6:301:33::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR0101MB2893:EE_|DM6PR01MB4281:EE_ X-MS-Office365-Filtering-Correlation-Id: bf4e98ae-2444-4a9f-4e81-08dab082bf55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FIVY3K4YI0Ozx/GBs3u+4JGBRzK6fp4S93Sdf2bj9uWNUQx33PYs+z5SxlWjLnbAOemOyLjJtv9BuVzViglvQcSJTZeANIjHcQ80GGFbOQuawWMG5k1xmD6R2CcrgL8VWLPbzqPcd3TOxngp0d2Zav8y7bsfx+VMWdK/NuuR/b60j998dKnrvPfWiPG3s81sqXMXEA7ilIzE+BS6PcpTX/tLDtB6NXhYIio2SjJLI6IGu00wDyF+WvCPFePiF/V9S9bWxc4s61W11qQYNNssgzc82/vDXQxY7o1qMjuvMitFmtlTjzCzVqc6F8gy16ZaICYQzPYDhyNfBEMdwHc5BrRxI44VjZAdFbzDYDzoG+2ItGPHzzoyFcCNIrCXghaXfxfXRdnvQph2lHfM4M7xI4nRgUxm/j+20DJUuuxXjTvZ0siqj/vf/c56b/GDYI5hxFIYq8ftiwZvNWpJyAxRYmhG647DlNZPk44TALo1dc5kagf+UPHcu45rQ9AMcswcdfnhq2EM/jubw/l1R9SuPXyjvnDTs/T9Bjvi1cBUP/3lzufRgvzGhHJ4R/kt+O1SGoNfXhHGi4o1RUEwNqLpRnwk7jP4s+tI00ajwTfFjs4QN4VQuffa27hr6rh3e0HCs9XuzUPW4TDEULsOBIUpDwIqbZ7kTeZFgykrhOxx/VE9PPr1kmQWCfz5+jyOvThAahknEYajC/gHXgVzmsVdTe1Ga9K5pLn56R15ARiDBUmAHXVeE9eKkmwa/3aaV332 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR0101MB2893.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(136003)(39850400004)(376002)(396003)(366004)(451199015)(6916009)(54906003)(316002)(8936002)(5660300002)(2616005)(1076003)(6512007)(26005)(186003)(86362001)(2906002)(66556008)(83380400001)(6666004)(107886003)(8676002)(66946007)(4326008)(52116002)(66476007)(6506007)(41300700001)(38100700002)(478600001)(6486002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w6JO/6wnXBv5Loj08sSeKEiaOf/Lp1WHtRAi7u7IgCDlBIY/4ms8CykG1S7cyjfWG4wlchcjXsvmXNhIA6S7TNcKQDjmHDOTXj/btsb5+mWQuRHfBr49v9oJ5x3eatp2kB5eQDen/cvBTNlBA4QaxFvESo9bU72+Z7zBCZ5f2hiaO7z2ww9Wt3B0ZcD9yt39YrELZMjyaKAJR/jeVYG5x7s85enAqD2TnmfFq5atpRfC8WWYUOBsDCP1HREvcg5thkgzRWcGJNeN/4zjxPmR9n7UZeR9hM7tadBROCzwxb5DCQikoh1zdtU/zIsUa0ctL/ldmRIdbSW9juhBspBIaZXcmTjNveBK+229fJ9y5fvsv1vl9/aPhLB+sg9m5K2T+bvWnTUUYzy7NszB9Gho+Rr0NUbt83HJSsPiFe/NiHuMgwDRzUSLpNIP/z1oSUmjtmGCdlgSfxPX69TKoAThhG2MpG6LHIBTv8uVrHw5jP03gLD9TYJlFcGRRtePWamMuWz/3Yl5AqVjNB1VESepVdgLxF6B4TnOKgY18D37ehXXDaniS/YilijDJIpNNkMrCNKXJrJ1WB9WT2y5BipUayQnTAUZ0lezfZB70HrVIT+chWGS/ZxvTOpXBKgkX8A7CzmVrSJM05nHA9b+xd7tJtXCbaWkgLZJtoNyXit/Pb2cfJE5Vio+wsiSxZS+bkdJB6RjLgRBeL0mGGVW78Q6QESJQiD/PU64iRNBeHf6as96dopDhF/GaUQ3mfFJEBqXStcHxSQfR6sGaK81ELWqfJMjuhB/pBo/vP0rw0ilwjsyjJGBxTNg/PLnawtPzNP6Ks5WlIw0dFNvPitvb9AIr3NPW+98CvSoLTgOibJHTmJjEBXVGSLjemqZxazP3iFD14BCPR70rjckvhZkJtlB0nZV460iLRiKhFrCBr1z+io99V5B3vXZq/Dxi5FJYv6v2ZbmnVXlcHe5y1dVhYmFzaMbEW++3yFOyn/x4vF/b0V8zbBVkBjRPlGIEeIw7Gs5+hmbpl8mHkGLLR+ponqF6siO6W5mDP7U2UZcEYkc717ZX0uUJ3CwEPh/DB+qIGnOWiIs9C2Q6MSIvDdH0dMeL4BhhXPQeLwwLzAxj7AeHnuJGKKihjDyw5kJO5hCiLo2n8OqvC12y9qTMi2vZwKNk7g7VtDI2vigsknkqiM6IYkxzRdZHI5iLlSoeZoex/UuT7soDc+y3NWgyrcywfczz4bhiPV9HSvf5ZK/ELZ5ch6w/Mf8h7UdefDnjwE2yzyApdm1/iUsqpXlPrFs7Zvkilf91rsZPzIvE3pdJbEq+N6cJNt6XVN2YG/oQPKSakeYF0qD2quDIWkILoGEx8w0rOc4Lp8v3w2jrHw1dwssIAUpS3jbLzvB+hoCytBON1XhVH2+heuFEc3eOvhwUejtihPzm5h05yBoimhb9QhiMkteEUVeUlifqG/kctedJBESuQZVwGfBpFhVap36+Y6ON5WxfquwPzJyFjtjjn/ptLpKKpuvdIqKZEaJlUHg+3UDQYNiMXFE8ewfKe82Vu46L7ohSe3rzqPvajUARP5smf3dvOJgOwGy3XWc9v+HD5DLjLC/fbc/S/bHC68oGN5QeQ== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf4e98ae-2444-4a9f-4e81-08dab082bf55 X-MS-Exchange-CrossTenant-AuthSource: MWHPR0101MB2893.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2022 21:01:26.8931 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hB4PzWlbVt/S0kQCm+iba3KZFae+yNdUdy1UwnYoBPe3cO7YetNVU9AarVg4ivm2iwycSI9isRbQ7kTdCIPCYFFINCShi6zfscXFcuXkNltg2Tdgkod0lt29w1/k9926 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4281 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221017_140134_970391_8E21BC81 X-CRM114-Status: GOOD ( 10.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org CONFIG_UBSAN_SHIFT with gcc-5 complains that shifting ARM_CPU_IMP_AMPERE (0xC0) into bits [31:24] is undefined behavior. Well, sort of, it actually spells the error as: /kisskb/src/arch/arm64/kernel/proton-pack.c: In function 'spectre_bhb_loop_affected': /kisskb/src/arch/arm64/include/asm/cputype.h:44:2: error: initializer element is not constant (((imp) << MIDR_IMPLEMENTOR_SHIFT) | \ ^ This isn't an issue for other Implementor codes, as all the other codes have zero in the top bit. Fixes: 0e5d5ae837c8ce04 ("arm64: Add AMPERE1 to the Spectre-BHB affected list") Reported-by: Geert Uytterhoeven Signed-off-by: D Scott Phillips --- arch/arm64/include/asm/cputype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h index abc418650fec..b28db64799eb 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -60,7 +60,7 @@ #define ARM_CPU_IMP_FUJITSU 0x46 #define ARM_CPU_IMP_HISI 0x48 #define ARM_CPU_IMP_APPLE 0x61 -#define ARM_CPU_IMP_AMPERE 0xC0 +#define ARM_CPU_IMP_AMPERE 0xC0u #define ARM_CPU_PART_AEM_V8 0xD0F #define ARM_CPU_PART_FOUNDATION 0xD00