Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp357555pxb; Wed, 14 Apr 2021 17:43:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxk2h+Ld7pMXIu0lS4MuXUodOZE7ReT1PJLVm1vE7ScMkFNPFjE8faGbexBWl6X0+MJFsX X-Received: by 2002:a17:907:7baa:: with SMTP id ne42mr723459ejc.357.1618447433731; Wed, 14 Apr 2021 17:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447433; cv=none; d=google.com; s=arc-20160816; b=yeF4PG9pDmw+KMgQuQwGksHrXyztPSOT9Yl4mv7m8Nw/MjbNle8TV7U/PJ65u4PZwD GcM616T0dzPGn7rrPV9M5Win9X41d5XO9aWO66f+ymH+afGaLzXnOPnAZvS067y/i/oB 4m+D5rGP53jvKNjM4TXfyN8e5qVThn8XUdEflwcaVXfJWx6XyKEX9tYVtsm8c8dmukna OU0MBznnrveLmI7PgaLd5MgSdMCsgEEn6OeiyDKpmam8NTaD5b/YtyT6Xp2ksJNsqFHz DDtd6O6z3XnJrdTPyxDvTyPEfszavfQZYRW3Nu70CceFzwf+7y90KbJgDLS/IGUgF1+h 7FLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PUOYXNfICZdC1+9G6F70MzTNDWMZ0Mz9R8OhGw2MATA=; b=Dqy5LMwzIUaE0jZ0A3m5j6yHYoRa3ZyLM1MrHjuerY0f47d4ZTa5jqYMKpQuwUn1UU 3fAQ2mo1lBKrILKR1V/86g4Sb9PyOIqsqFqnI1sh4mv5JrsytTf6Sja87d4xdtIj1i3g X0WRLp5lQ+5RGuQDSDbFFI8qh6kFh0doxM0w2Zx2NanMZQUOp5XdZWIOtXmAdTfgvRNt v260AH1ovX/gzop3tVVW/fNfKdUkWnbeICY6qQxExTeSMHH8ybgNkUXfkAGljTH15Oa8 8VeebTZawgOjhnrhuXXyfZjgndIFP0yJHubFGanU4X8kqOEuGn41UmpeDX/4D0/1gLm0 lqCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=thrADslz; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si747061ejd.575.2021.04.14.17.43.31; Wed, 14 Apr 2021 17:43:53 -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=@google.com header.s=20161025 header.b=thrADslz; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353371AbhDNTWz (ORCPT + 99 others); Wed, 14 Apr 2021 15:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353370AbhDNTWy (ORCPT ); Wed, 14 Apr 2021 15:22:54 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7E3C061756 for ; Wed, 14 Apr 2021 12:22:30 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id r20so24475127ljk.4 for ; Wed, 14 Apr 2021 12:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PUOYXNfICZdC1+9G6F70MzTNDWMZ0Mz9R8OhGw2MATA=; b=thrADslz3ToX7uQBnxWvFoINCJNnr6ngJ+dVi9lut9X4zfnY8g1wvwlW0ElJoXAkx5 TMrFJGf4rs1Cvs85Z5PgLK2b4MB12ixyLb8wzp52LNINPbF6Orwb6o+8AAQXrKYiTKTw TrjFGLHCH8zBAjFQdc8gGv3bXXjOUxGY1oYulm/OmrIt4zCJXR6ZEfwbFGo3ZXNOf2m5 9R4EKJkcIeA4VQlAeY5l+GPe5sUzJ3Xf0CJO6079ZJNUoGRmmdKi07HsEdpyGNEglEx9 sy7DmPKgarJzSZNB4cpO704cM2jMIW6SXXtxRgjnonnAPEtkRIkdSCx/Pc8tPYTI/1fD ga4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PUOYXNfICZdC1+9G6F70MzTNDWMZ0Mz9R8OhGw2MATA=; b=d4QY52sWgMtpPbSEJwENlLCltNbaUIgaa/Xipec1pqbSqdEelUv6+hPV2PrP6jvTkC Q+QSYvk/1VyklE+4mz/nyJG0XyxLZbk4pzQCr+MnKXcNXVbsH0ZSC4/g3Xm54ngtFMk5 t2tw6z6coOu2vY2yG1KiNZpXgRXeZHD9vGBvo9PEIxJQb9SWpdSeQaMD1yjcKqerPIAM 7GyP8E77boM4/wzhjncKuuGd+r4TEILNryPOB/p6zPVkd3ccocjeAFQvNX6PAd7aGPXc ANUF6nRRv4lFXi4UfyiN1xUJRUK1/NrjQ866dVsPmK1KMBwORj1gcHb2nFeGeEqa6+Fq srNw== X-Gm-Message-State: AOAM531T77UDMW+m5dLB35eWURuFlsgkqWa9zABKfbdvhBLxcMtIes66 OH6BpQzKub9dl+eYCJ1G7mF+plQbEhL/3Mi3B2FeCQ== X-Received: by 2002:a2e:b008:: with SMTP id y8mr23815586ljk.233.1618428149110; Wed, 14 Apr 2021 12:22:29 -0700 (PDT) MIME-Version: 1.0 References: <20210414000803.662534-1-nathan@kernel.org> In-Reply-To: <20210414000803.662534-1-nathan@kernel.org> From: Nick Desaulniers Date: Wed, 14 Apr 2021 12:22:17 -0700 Message-ID: Subject: Re: [PATCH] arm64: alternatives: Move length validation in alternative_{insn,endif} To: Nathan Chancellor Cc: Catalin Marinas , Will Deacon , Sami Tolvanen , Jian Cai , Linux ARM , LKML , clang-built-linux , "# 3.4.x" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 13, 2021 at 5:09 PM Nathan Chancellor wrote: > > After commit 2decad92f473 ("arm64: mte: Ensure TIF_MTE_ASYNC_FAULT is > set atomically"), LLVM's integrated assembler fails to build entry.S: > > :5:7: error: expected assembly-time absolute expression > .org . - (664b-663b) + (662b-661b) > ^ > :6:7: error: expected assembly-time absolute expression > .org . - (662b-661b) + (664b-663b) > ^ > > The root cause is LLVM's assembler has a one-pass design, meaning it > cannot figure out these instruction lengths when the .org directive is > outside of the subsection that they are in, which was changed by the > .arch_extension directive added in the above commit. > > Apply the same fix from commit 966a0acce2fc ("arm64/alternatives: move > length validation inside the subsection") to the alternative_endif > macro, shuffling the .org directives so that the length validation > happen will always happen in the same subsections. alternative_insn has > not shown any issue yet but it appears that it could have the same issue > in the future so just preemptively change it. Thanks Nathan. Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers I did some additional disassembly comparison. In case we ever need it again, I'll copy it below for posterity. $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu make LLVM=1 LLVM_IAS=1 -j72 O=/tmp/a defconfig all $ b4 am https://lore.kernel.org/lkml/20210414000803.662534-1-nathan@kernel.org/ -o - | git am -3 $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu make LLVM=1 LLVM_IAS=1 -j72 O=/tmp/b defconfig all $ for f in $(find /tmp/a/arch/arm64 -name \*.o); do llvm-objdump -dr $f > $f.txt; done $ for f in $(find /tmp/b/arch/arm64 -name \*.o); do llvm-objdump -dr $f > $f.txt; done $ for f in $(find /tmp/a/arch/arm64 -name \*.o); do diff -u $f.txt $(echo $f.txt|sed 's/a/b/'); done | less For no difference. You can check more sections than .text by changing `-d` to `-D` for llvm-objdump, though you're going to get a lot of noise related to changes in .strtab and relocations referring to debug info (.debug_str). But if I drop your patch, rebuild, and recompare, I see the same differences. > > Cc: stable@vger.kernel.org > Fixes: f7b93d42945c ("arm64/alternatives: use subsections for replacement sequences") > Link: https://github.com/ClangBuiltLinux/linux/issues/1347 > Signed-off-by: Nathan Chancellor > --- > > Apologies if my explanation or terminology is off, I am only now getting > more familiar with assembly. > > arch/arm64/include/asm/alternative-macros.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h > index 5df500dcc627..8a078fc662ac 100644 > --- a/arch/arm64/include/asm/alternative-macros.h > +++ b/arch/arm64/include/asm/alternative-macros.h > @@ -97,9 +97,9 @@ > .popsection > .subsection 1 > 663: \insn2 > -664: .previous > - .org . - (664b-663b) + (662b-661b) > +664: .org . - (664b-663b) + (662b-661b) > .org . - (662b-661b) + (664b-663b) > + .previous > .endif > .endm > > @@ -169,11 +169,11 @@ > */ > .macro alternative_endif > 664: > + .org . - (664b-663b) + (662b-661b) > + .org . - (662b-661b) + (664b-663b) > .if .Lasm_alt_mode==0 > .previous > .endif > - .org . - (664b-663b) + (662b-661b) > - .org . - (662b-661b) + (664b-663b) > .endm > > /* > > base-commit: 738fa58ee1328481d1d7889e7c430b3401c571b9 > -- > 2.31.1.272.g89b43f80a5 > -- Thanks, ~Nick Desaulniers