Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7655670ioo; Fri, 3 Jun 2022 10:42:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ0K575HXPqLEajmzw1i0W4HAuoKJpAA5gJxi2KSnCU9cXTZ1lIO1ITZ6ijyaPGRuudmDe X-Received: by 2002:a17:907:9622:b0:70a:af2d:dace with SMTP id gb34-20020a170907962200b0070aaf2ddacemr8638342ejc.326.1654278155914; Fri, 03 Jun 2022 10:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654278155; cv=none; d=google.com; s=arc-20160816; b=spa7/HLiH3rHoevLI2Xwyg8PX4S7Da3O0yEw+Zve4Z0NkeOxSo2M7S0+VXYvD/ZJ6h LcivCgLYXqP0QFTDOlJ0iJoqoX93yBBH3Llc7ld7S0kKESDOMf6KHzbvhDyOI34jW+YW Vhu2IyIkBJlZz1lMCIjL9mzPe2b5+BJ3VGjjAu8J7NrofYte6a1Uv+FCm8csO5IWIAKP cbjvv8Y/voapsYz+ZE6tjBa3ttPd7hATYTPYXTb7AtEXAlDyJwcaoxre86YXH8s8pxsI P//DIy38wJtJTdjVVh+lYllzd0aw+454Rr1OxSMJpiULNUpZyk/+1HrGZU/RVmdsMdIO 6CTw== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=WmOqgdw/lnzn8y98yzEspXlCbFr81s8ZPh+l/fuZnvU=; b=EMR8+1y2CtbV/xID/Ao1cciB7EGQ1+xFP6tFldk5WJhqwf9sNuj5Ul81bqmEc2Vz2M erlyi3YjJAFY8hsGpaHpEUMHpcgYotGnTGJtxDXSh+LQkurussE96sG2frNuISJuD6Kg qcoKSUdWdXE7pSGDbHhTHq8QPP/iFr1FlvUpBa6pT5dQpY7aZ+UCp/RakFIU/lWxQ8In aDkxheb53Ggh7pwHQpe/Q9dsID95VvdX7Tm2JnepCVXZkl9bSBospUrYwZs9PfKqaViX 0TKQ52BssgJKXezxabJ73eZk/DNodMBD1wAfOO/xpfMFXEpqlXP/Y/qDXkdkrHoHH+Z/ fH9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=xeAlMB6i; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs6-20020a1709073e8600b006ff42751e72si9979863ejc.816.2022.06.03.10.42.08; Fri, 03 Jun 2022 10:42:35 -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=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=xeAlMB6i; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239957AbiFCBet (ORCPT + 99 others); Thu, 2 Jun 2022 21:34:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238982AbiFCBeo (ORCPT ); Thu, 2 Jun 2022 21:34:44 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E26E233376 for ; Thu, 2 Jun 2022 18:34:42 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id i185so6133478pge.4 for ; Thu, 02 Jun 2022 18:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=WmOqgdw/lnzn8y98yzEspXlCbFr81s8ZPh+l/fuZnvU=; b=xeAlMB6iggUl/Q8oT9BpeIQvESRsiCcKlbCJYKeCd+AcQwHrX+ICmf4uTA0ijqOnhb hxEH8wEdkCxiO39rdJvSTuiSk+QmJah1jdSSFKYR16Vch89RSDb+rLFKgvEqB6nzM7C/ x4GILcrRidctOmr4tvRVPSzso60xvcL3oT7C4uJfyvIcemKJ6ei+Ip1bkliuZ3M4nug4 dLqxlSUe7qMZIQlVWMIx2+W6w0hvM/XeGRINsuZ7tlNzTFbUXJ3f2kA0S6pxoSkhCPaH rF4/o2im3XsBaehO8nwSNKjSVo5nSQNm5L5QqiUfKUZEs5D8sga4hDWdZOW1h9YwCAjo brwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=WmOqgdw/lnzn8y98yzEspXlCbFr81s8ZPh+l/fuZnvU=; b=uSC57xdVN0YNYtR2z17tsA9wzHqgK/vfbQhR9fYNpDhYc63aGcyOE1YSN/mLPyOu/A jdxAg0u26FpCM+EuX51NXeILhrXI+JeIEgtGFHgEqOXUkcLJmhWOR0XUC87e9HVCfi/z GiS6F1XOR9CcgXb83EfAVm1oJ2td7koGDqxFPaIh+HQdyecLsBqbQTVYY+D+x5dx+M7f J7WpEESuIUw5848NWa/XkDOf1JxdS2c0ImmbxFpf55euAsHhNWj+P3BnoB6jwB7XhI09 Lm5EqoJrAH3UuMFjZ1bKi5Zq81mLLaTQa2kqjbleToQH7UYN/b8UZJxBjI+AxCeoLPh/ Y18w== X-Gm-Message-State: AOAM531dHEglYHH5j9P2gQMDDbrsSMr2mKP1GQk+XPKTcSQ5dkxnIvZk PnToEC5ZQpYFSzEVEZSjMQsHZQ== X-Received: by 2002:a05:6a00:2353:b0:518:96b7:ceb8 with SMTP id j19-20020a056a00235300b0051896b7ceb8mr8062973pfj.5.1654220082298; Thu, 02 Jun 2022 18:34:42 -0700 (PDT) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id s6-20020a170902ea0600b0016232dbd01fsm4082360plg.292.2022.06.02.18.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 18:34:41 -0700 (PDT) Date: Thu, 02 Jun 2022 18:34:41 -0700 (PDT) X-Google-Original-Date: Thu, 02 Jun 2022 18:34:32 PDT (-0700) Subject: Re: [PATCH] riscv: Move alternative length validation into subsection In-Reply-To: <20220516214520.3252074-1-nathan@kernel.org> CC: Paul Walmsley , aou@eecs.berkeley.edu, ndesaulniers@google.com, heiko@sntech.de, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, nathan@kernel.org, lkp@intel.com From: Palmer Dabbelt To: nathan@kernel.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On Mon, 16 May 2022 14:45:21 PDT (-0700), nathan@kernel.org wrote: > After commit 49b290e430d3 ("riscv: prevent compressed instructions in > alternatives"), builds with LLVM's integrated assembler fail: > > In file included from arch/riscv/mm/init.c:10: > In file included from ./include/linux/mm.h:29: > In file included from ./include/linux/pgtable.h:6: > In file included from ./arch/riscv/include/asm/pgtable.h:108: > ./arch/riscv/include/asm/tlbflush.h:23:2: error: expected assembly-time absolute expression > ALT_FLUSH_TLB_PAGE(__asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory")); > ^ > ./arch/riscv/include/asm/errata_list.h:33:5: note: expanded from macro 'ALT_FLUSH_TLB_PAGE' > asm(ALTERNATIVE("sfence.vma %0", "sfence.vma", SIFIVE_VENDOR_ID, \ > ^ > ./arch/riscv/include/asm/alternative-macros.h:187:2: note: expanded from macro 'ALTERNATIVE' > _ALTERNATIVE_CFG(old_content, new_content, vendor_id, errata_id, CONFIG_k) > ^ > ./arch/riscv/include/asm/alternative-macros.h:113:2: note: expanded from macro '_ALTERNATIVE_CFG' > __ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)) > ^ > ./arch/riscv/include/asm/alternative-macros.h:110:2: note: expanded from macro '__ALTERNATIVE_CFG' > ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c) > ^ > ./arch/riscv/include/asm/alternative-macros.h:99:3: note: expanded from macro 'ALT_NEW_CONTENT' > ".org . - (889b - 888b) + (887b - 886b)\n" \ > ^ > :26:6: note: instantiated into assembly here > .org . - (889b - 888b) + (887b - 886b) > ^ > > This error happens because LLVM's integrated assembler has a one-pass > design, which means it cannot figure out the instruction lengths when > the .org directive is outside of the subsection that contains the > instructions, which was changed by the .option directives added by the > above change. > > Move the .org directives before the .previous directive so that these > directives are always within the same subsection, which resolves the > failures and does not introduce any new issues with GNU as. This was > done for arm64 in commit 966a0acce2fc ("arm64/alternatives: move length > validation inside the subsection") and commit 22315a2296f4 ("arm64: > alternatives: Move length validation in alternative_{insn, endif}"). > > While there is no error from the assembly versions of the macro, they > appear to have the same problem so just make the same change there as > well so that there are no problems in the future. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1640 > Reported-by: kernel test robot > Signed-off-by: Nathan Chancellor > --- > arch/riscv/include/asm/alternative-macros.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h > index e13b1f6bb400..ec2f3f1b836f 100644 > --- a/arch/riscv/include/asm/alternative-macros.h > +++ b/arch/riscv/include/asm/alternative-macros.h > @@ -27,9 +27,9 @@ > \new_c > .option pop > 889 : > - .previous > .org . - (889b - 888b) + (887b - 886b) > .org . - (887b - 886b) + (889b - 888b) > + .previous > .endif > .endm > > @@ -94,9 +94,9 @@ > new_c "\n" \ > ".option pop\n" \ > "889 :\n" \ > - ".previous\n" \ > ".org . - (887b - 886b) + (889b - 888b)\n" \ > ".org . - (889b - 888b) + (887b - 886b)\n" \ > + ".previous\n" \ > ".endif\n" > > #define __ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, enable) \ > > base-commit: 93c0651617a62a69717299f1464dda798af8bebb Thanks, this in on for-next (still for 5.19). I'm going to CC stable so it'll get backported, as it seems pretty harmless.