From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 024D77E9 for ; Fri, 3 Jun 2022 01:34:42 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id g205so6096342pfb.11 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=ddke4yFXODC58C+VUaqbpzmVFAW89NiE3JoVnsjvhl3nXoX2x3tptkaKVdsOJ9ZRvl H+pTZJidJBRQq+t4h/8Ap/BsSrtoZL7MGxROIWL+vRZ5dOZnUHXLqStdyIMvh3fV9ndr He4/Tcwi52hlZAZM41l8RrxcF2h82LAL0THg5FyvGj1twwEeQu1kBC0UF5QsnNhWvyPX 5DTXWm4bp1GKsKpfdqBMugE/jLSQ5d9u5uNlpBeGYge9+MpWTKrUyPkL5sreLeFP9JfT HVAD91AWkF9AwAstkRWwQILvXfY6lgD0vbxXCddashGcx8XE6r3vSinPm21FPbEP6c6p XnAQ== X-Gm-Message-State: AOAM532ieRt2+vPd1ndQ1jrhm6Jxodqn27QIAfBJ1V+X0lWHSVGP9LLr FGHD3+LIzOa7OvP2XHB203sZOA== X-Google-Smtp-Source: ABdhPJxwYUZESxzEAwVBw31/r+YLXs53IRagWzDsSQ7NAeM1zO5QT7RF2ZuUyKJXdRv88efZm8Br8Q== 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: Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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. From mboxrd@z Thu Jan 1 00:00:00 1970 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 259B1C433EF for ; Fri, 3 Jun 2022 01:35: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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Mime-Version:Message-ID:To:From:CC:In-Reply-To: Subject:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References:List-Owner; bh=bR2lf7U9Guhyq+SPlyta2BTd7xqkq/TutkGqDHhvXPs=; b=bUrkiPOkRJWinD8AiTMxAlw1BQ U5HToyxboPtFdH/DH1j05757G+gekZ49hYXGZDg8vEdO9svrU8bNanNU3pi+4hQLpI8OeuHekOjIw zGsUVeIU876rE0dVE4jtDcK5vHZRz7gXca1KcwO2nRnMVNdSfCuI5RZtQdsZ6sfM8sQujIPLeIxjs MxjW9/66wTLuXEZP6UhJ6QCfPGEuLHlnJmtmQoh0sr0MfLbl1RNHdQgaq6NhsazUT4EozLJlZGxZz kgDJ+z0O4mT0kzjvgAbhirhQVgnQ+owFciAH45+e1WlGL2LTHDA44R1LaH70eoUoNBs9MdjvS17ZG gQ1XZm4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwwDA-005KGT-Ut; Fri, 03 Jun 2022 01:34:48 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwwD7-005KEb-9t for linux-riscv@lists.infradead.org; Fri, 03 Jun 2022 01:34:46 +0000 Received: by mail-pf1-x432.google.com with SMTP id p8so6118691pfh.8 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=7ErK/0d9xu/hVBg1w/9qm5JCx8JpR8SHxMUcoSxVkxvBtzrBvtbJdnE55G1DChj8RH 0+GlRMSYLWyym64jmjqjuagt0wZe2SJPnDaREK6/6/QHeuCIqJCRpyb/WW2eAWysi86x IZoNCTWoQ5u7heGFK2RCwKNjBr2a3QiEtt1NlKEU265oYCDwTGJMgIBX5pHVRNArmmTf w9rHmYq7P2IiarYTNC3/TWgfQ4sSMl/RgHlFEIscpwKEbr3Chopbif/SV5+Ik7LRR5/E oYHqELhT/8OCnxrmUtOM9FH3sAPnVy//eH1R0R5/ntsiuwHY+k4IMy2jtcmS+3bMZNes DCMw== X-Gm-Message-State: AOAM533TGW7EMN+HJnCHRkR1k+SR2l7tS1xgC4TgqzQFq1rAjYrlH6/y Ugt5TMZc/TXsiwQDvjmA2QUZ2g== X-Google-Smtp-Source: ABdhPJxwYUZESxzEAwVBw31/r+YLXs53IRagWzDsSQ7NAeM1zO5QT7RF2ZuUyKJXdRv88efZm8Br8Q== 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220602_183445_385420_6D132E41 X-CRM114-Status: GOOD ( 23.52 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv