Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2300925rwi; Thu, 3 Nov 2022 15:29:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ZSbk7YoJZo6+5gd+4OmDDiufZaqLu9JeY5mMHdyXR2W/WJ3iRABrAnuLzaoONKrOh82yZ X-Received: by 2002:a17:903:183:b0:187:4914:1def with SMTP id z3-20020a170903018300b0018749141defmr10405733plg.91.1667514544189; Thu, 03 Nov 2022 15:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667514544; cv=none; d=google.com; s=arc-20160816; b=KoADp6loADkSBFDUoyyilMI1eIcvIEV1vNCNlEQ68BIoUPPPrRkCMRIJV2lWrFewdP PWs+Xp3xbautn8Icdy+5RrUCUc41g4ZN1mT5FwUqFjftIpbqWIHYMycXV2uppzdY8vzY W/YSUrnIeKZ3REuQitxe6KlRJIjCw3zjo+9aAa8XO6F3P7cEopOPF43XReHFfcGYwUAE y/a0y4psnAKOEuxKCG6PjdzYdOet6y99lNahFIRmo7tV8urVimw6JT/sfehggnWBNHcG pE4PGqGxp2Rb95qcWbmMOQNa1xQ13C8BHhkWkT6rgurRTa6MPZzM6ReUI0ESTx0Dn9Xo ykmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=vvJEJ264ZheXx0sRztLACOjB54er/SHBBGAWfYziuwo=; b=JFY47PaBRX1NrFa0YIjg+lbnkMyqMZpHGc4WXWl6fXHOiIXyuyFHad77HI2cmVnzrT jZ9ZUXQQv9IuzfPssR6cj0M7NXJFfaa8bA9BJ37DaRDrWkPqK8kUwRF8tvYMOabMXUkC c9q8ycYaxToQZUtv5HVZsh39D7knl9AVzuNkafa/SUVsvzN9gIHgcxoB6e3XW+whB5NI M3URVrZ5VjHLg6BZ1b5QuUmjJgFhBQHCqxrKsdvPukkDEMBlc7RdF87mhPV6klNNp6as iSoQQesIBIQox1JRUd/7rjt//mLZBd3W0TzlNA4U4ekWmBaOj2flUuqI+AoSLXxkyM7q Q+gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pHqZDfEP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u7-20020a170902e80700b00176e4ac448esi2353871plg.224.2022.11.03.15.28.51; Thu, 03 Nov 2022 15:29:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pHqZDfEP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231612AbiKCVKR (ORCPT + 98 others); Thu, 3 Nov 2022 17:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbiKCVJu (ORCPT ); Thu, 3 Nov 2022 17:09:50 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58CDE23BF7 for ; Thu, 3 Nov 2022 14:08:15 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id b14-20020a056902030e00b006a827d81fd8so3143498ybs.17 for ; Thu, 03 Nov 2022 14:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=vvJEJ264ZheXx0sRztLACOjB54er/SHBBGAWfYziuwo=; b=pHqZDfEPOxY8hOzsv0ouJgt30fhvGw5PosROhzkdc1wNlLZejPwtw/j/LOA1O65C8k iJPybw/i/OoSblImCWxePOGCIurF3kagPrykiNc9hGc6ZEWWvBgpTDC0ciWZXALyi6Mf 6glfoWS2F/0lTZ0vd/a8NBbZ9fpB5+y3dNg9IyVc8p07YlJe1cZEJEFOlBDciVUhSN4h tc52nPRj220IevYk7H930WzB40mbb2liyaXp7Gt06HDWYtciiV9uXv35jBldzdiVvnKy ax1c9kpDUYPYZw6C1npkZ6+kZrfMnATwGmIw1TPzs+G2SKl86SuRYr6NCSpa/E0zN+pz af5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vvJEJ264ZheXx0sRztLACOjB54er/SHBBGAWfYziuwo=; b=Q34+hj39uDLiCfYwpAxOYrE/QYWSrbdGVlDvz0hcVN0MENinY7YLrE+hzhgpdSWC0K +OTDrsQVjfLxgHduRhKV1IdH0vnOEsi+gtonZcsbPasD7le5n8abTKXaRtQwJZfSI3m/ qBs524bTz4RdYtWjiMHMczyBps9TlBx2tFrm4bVfyXMIuUpBygaZYbphOL8GfFxP0CP4 y+afKOcBMxZNHueApTx7At+z24ekbTr/4U2Ibu99WvElKcNV35RqKS4gwGsL/WLsnq4B w3hdIZPp1CNOPNzDHVy8bn1hQSRyV2wC7JZtYHjh7hSpSbeDGRJHSwQcOVDEcVSAR3uA 9+gQ== X-Gm-Message-State: ACrzQf2gcXpm4khwRAtrH7X44M9vhaQWVY8Ha4mDt2/fWUhG4c5XPEiS x5YQaUNvPEwZsA2nKNeNACqJToYYZK6gp+on1AM= X-Received: from ndesaulniers-desktop.svl.corp.google.com ([2620:15c:2d1:203:33e8:ddbf:583c:50a8]) (user=ndesaulniers job=sendgmr) by 2002:a25:bccf:0:b0:6cb:83c8:4ceb with SMTP id l15-20020a25bccf000000b006cb83c84cebmr182458ybm.635.1667509689312; Thu, 03 Nov 2022 14:08:09 -0700 (PDT) Date: Thu, 3 Nov 2022 14:07:48 -0700 Mime-Version: 1.0 X-Developer-Key: i=ndesaulniers@google.com; a=ed25519; pk=UIrHvErwpgNbhCkRZAYSX0CFd/XFEwqX3D0xqtqjNug= X-Developer-Signature: v=1; a=ed25519-sha256; t=1667509668; l=2763; i=ndesaulniers@google.com; s=20220923; h=from:subject; bh=YqhBGxVFdvGLXPPYHWaXapaJALaw752j4veZvStNY7I=; b=C3CRtilMk0sQ0zoZnXPAuoWsu/v9ne9Gyvj9hg24XVyEmTOudrkm8wYpJxnWniDnk1IQbEI02x60 4jnYEXMEBr5PyTn2KFYcbiz7JnkH96J7jomce+uNV2WyYwqdbimW X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221103210748.1343090-1-ndesaulniers@google.com> Subject: [PATCH] x86/msr-index: make SPEC_CTRL_IBRS assembler-portable From: Nick Desaulniers To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Peter Zijlstra Cc: x86@kernel.org, "H. Peter Anvin" , Nathan Chancellor , Tom Rix , Pawan Gupta , Adrian Hunter , Josh Poimboeuf , Alexander Shishkin , Daniel Sneddon , Sandipan Das , Huang Rui , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, kernel-team@android.com, Nick Desaulniers , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GNU binutils' assembler (GAS) didn't support L suffixes on immediates until binutils 2.28 release. Building arch/x86/entry/entry_64.S with GAS v2.27 will produce the following assembler errors: arch/x86/entry/entry_64.S: Assembler messages: arch/x86/entry/entry_64.S:308: Error: found 'L', expected: ')' arch/x86/entry/entry_64.S:308: Error: found 'L', expected: ')' arch/x86/entry/entry_64.S:308: Error: junk `L<<(0)))' after expression arch/x86/entry/entry_64.S:596: Error: found 'L', expected: ')' arch/x86/entry/entry_64.S:596: Error: found 'L', expected: ')' arch/x86/entry/entry_64.S:596: Error: junk `L<<(0)))' after expression These come from the use of the preprocessor defined SPEC_CTRL_IBRS in the IBRS_ENTER and IBRS_EXIT assembler macros. SPEC_CTRL_IBRS was using the BIT macros from include/linux/bits.h which are only portable between C and assembler for assemblers such as GAS v2.28 (or newer) or clang because they use the L suffixes for immediate operands, which older GAS releases cannot parse. The kernel still supports GAS v2.23 and newer (and older for branches of stable). Let's expand the value of SPEC_CTRL_IBRS in place so that assemblers don't have issues parsing the value. Fixes: 2dbb887e875b ("x86/entry: Add kernel IBRS implementation") Reported-by: Greg Kroah-Hartman Signed-off-by: Nick Desaulniers --- Some other ideas considered: * Use U64_C from include/asm-generic/int-ll64.h rather than BIT for the value of SPEC_CTRL_IBRS. * Do so for the entirety of arch/x86/include/asm/msr-index.h or just SPEC_CTRL_IBRS? include/asm-generic/int-ll64.h doesn't define a UL suffix; add one? * Make include/linux/bits.h assembler-portable (for older assemblers) via the use of include/asm-generic/int-ll64.h. arch/x86/include/asm/msr-index.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 10ac52705892..0192d853136c 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -46,7 +46,7 @@ #define MSR_TEST_CTRL_SPLIT_LOCK_DETECT BIT(MSR_TEST_CTRL_SPLIT_LOCK_DETECT_BIT) #define MSR_IA32_SPEC_CTRL 0x00000048 /* Speculation Control */ -#define SPEC_CTRL_IBRS BIT(0) /* Indirect Branch Restricted Speculation */ +#define SPEC_CTRL_IBRS 1 /* Indirect Branch Restricted Speculation */ #define SPEC_CTRL_STIBP_SHIFT 1 /* Single Thread Indirect Branch Predictor (STIBP) bit */ #define SPEC_CTRL_STIBP BIT(SPEC_CTRL_STIBP_SHIFT) /* STIBP mask */ #define SPEC_CTRL_SSBD_SHIFT 2 /* Speculative Store Bypass Disable bit */ -- 2.38.1.431.g37b22c650d-goog