Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3594428pxb; Sat, 13 Feb 2021 03:03:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBFJwUQ2VBSZoL76i60tFy3w5q4OYGkRATH9+m+NS0j6f3K3a/YP0VeMviiG3Iqv1TEWAL X-Received: by 2002:a17:906:b09a:: with SMTP id x26mr7218653ejy.199.1613214185399; Sat, 13 Feb 2021 03:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613214185; cv=none; d=google.com; s=arc-20160816; b=USknMU/oGrmegBGDWQcASafHwqg1+PEDAgB3l0dstTydVVpqVbeBWGRAMzMuuoHyy6 5tG97RwyxwE9XsWtbkeXBzGX2ZftZc98EKcthgBKM9kIHbHlyIhhnqKkC/cYRFUBAGAe IzpmFGvh/v0SyYKmH6WCeXAj+NjrXK7JzPZsaCjDNEfZ98HthXtmvJ/wcC4eLYpbPupT Ld7iJg5tHe1bmGCetFKJE/YfjLbM+DXUdZS9HBxPUak/yspG+tXB/gQl/WC/pHbULcut kSWK8TtyO0/9OXOkQri7MYyoSf4BazWSVaHBlARRAi9ZbbV69JoULRxvl6LkLNNiV+Zy kKsA== 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=Wg5Ly6Cridz2gU/LjH7NDrCS+07g7sn6x7iI4Ngz8YY=; b=DmVS0WDpNNP6k7OtWGmiTXmWz3Ab3lL06VLe+pnQq1gpMUXHhw79P/zhRCKDAaWIuO NCFE2VeEnPP0/SDnSPEn/BKqaaPkmpDRklkoAalUPwFMUv+Cbpma3OrBXznbb27COccP UE9GoCrpY6gPWc4xOfTFU9n2vHZeqKbToe6YY5jn9YKN2Wzlp4uzwjwxpk4iB1ajU5i9 Ngu6CBXogGDL8BMRQjF5hYkp9yZMbMRcxMpB9/89q6yo0Yacw+ymw4k0S8JoZsDnj449 zgxblyGu9brxpKccPgTJlgN6wo2n0FMCNqR+b1bZQsJTS+7HgDvflYSbCymjjspb0bOc Vlwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GxERvQ0V; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si8116424eji.536.2021.02.13.03.02.41; Sat, 13 Feb 2021 03:03:05 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=GxERvQ0V; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbhBMLCH (ORCPT + 99 others); Sat, 13 Feb 2021 06:02:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:53310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbhBMLCE (ORCPT ); Sat, 13 Feb 2021 06:02:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F41FC64E44 for ; Sat, 13 Feb 2021 11:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613214083; bh=G71u7RTd4A+rBB1I9GNDIIEuu107tc6tTr/aifGEocg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GxERvQ0VZIYnBHwi/rOGp9DB578dL+KH+k7p8P662CGeWvdboRzfuzLuCr5sfmEgv kWmT5MswkYSl2Ws4Xctgd6mpy4+2ilQmFBOa/qXQc0Rl2CSLsZ/Fccvyp5/Uu1+rj/ 3rFHXqglXncFU7yoMyYc2JGJvuiWjwIT19EuRqCkFUyxmlvLTdgIBUZg7VWIMLPefh VitmMS4egfS7kwjcsF4QMuMoxuMv9NeLnnwQMQlIqBDQyhnczuu/z/oKzFj+kT1n7/ KqzCF1E4Wir/qJY2512e6WhkcrgPJLew/1xm+YnimDrPJbfAMwH9RDIkbzOZqhq52l yzv3X8rb4uo1g== Received: by mail-ot1-f49.google.com with SMTP id y11so1720957otq.1 for ; Sat, 13 Feb 2021 03:01:22 -0800 (PST) X-Gm-Message-State: AOAM5317hk0LW2Uwe/gHstOtleq6CgRvDB8WkRRcOzoakBm+0xxGNTFZ 0ilLqVeXsNN+/QthyqNKc2A2aKt4i2Zd/sLCnU8= X-Received: by 2002:a05:6830:13ce:: with SMTP id e14mr4959394otq.108.1613214082190; Sat, 13 Feb 2021 03:01:22 -0800 (PST) MIME-Version: 1.0 References: <20210128193422.241155-1-ndesaulniers@google.com> In-Reply-To: From: Ard Biesheuvel Date: Sat, 13 Feb 2021 12:01:10 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] ARM: kprobes: rewrite test-[arm|thumb].c in UAL To: Arnd Bergmann Cc: Nick Desaulniers , Russell King , Arnd Bergmann , Nathan Chancellor , Linux ARM , Linux Kernel Mailing List , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 29 Jan 2021 at 00:30, Ard Biesheuvel wrote: > > On Thu, 28 Jan 2021 at 23:28, Arnd Bergmann wrote: > > > > On Thu, Jan 28, 2021 at 10:03 PM Ard Biesheuvel wrote: > > > On Thu, 28 Jan 2021 at 20:34, Nick Desaulniers wrote: > > > > @@ -468,15 +468,15 @@ void kprobe_thumb32_test_cases(void) > > > > > > > > TEST_UNSUPPORTED("strexb r0, r1, [r2]") > > > > TEST_UNSUPPORTED("strexh r0, r1, [r2]") > > > > - TEST_UNSUPPORTED("strexd r0, r1, [r2]") > > > > + TEST_UNSUPPORTED("strexd r0, r1, r2, [r2]") > > > > TEST_UNSUPPORTED("ldrexb r0, [r1]") > > > > TEST_UNSUPPORTED("ldrexh r0, [r1]") > > > > - TEST_UNSUPPORTED("ldrexd r0, [r1]") > > > > + TEST_UNSUPPORTED("ldrexd r0, r1, [r1]") > > > > > > > > TEST_GROUP("Data-processing (shifted register) and (modified immediate)") > > > > > > > > #define _DATA_PROCESSING32_DNM(op,s,val) \ > > > > - TEST_RR(op s".w r0, r",1, VAL1,", r",2, val, "") \ > > > > + TEST_RR(op s" r0, r",1, VAL1,", r",2, val, "") \ > > > > > > What is wrong with these .w suffixes? Shouldn't the assembler accept > > > these even on instructions that only exist in a wide encoding? > > > > I don't know if that is a bug in the integrated assembler or > > intentional behavior, but it may be easier to just change the > > kernel than the compiler in this case, as it also makes it work > > for older versions. > > > > FWIW, I needed a related change in a couple of other files: > > > > For fully specified test cases, I suppose removing the .w is fine. But > for the macros below, it really isn't: it depends on the actual > register assignment whether narrow encodings exist or not, and in that > case, we definitely want the wide one. The fact that instantiating the > macro in a different way can only produce wide encodings in the first > place should really not trigger an error. > > Things like this can break the Thumb2 build very subtly, so if the > integrated assembler is not up to that, we should simply disable it > for Thumb2 builds. > As mentioned in issue #1271, my observation here is not entirely accurate. In the general case, macros that take register names as inputs can produce narrow or wide opcodes depending on which exact registers are being used (narrow opcodes mostly only support registers r0-r7) However, in this particular case, all the ldr/str instructions are either the pre-indexed or the post-indexed variants, for which only a wide encoding exists, and so omitting the .w suffix is safe here. However, if we apply the change below, can we please document this in a comment, i.e., that encoding T4 is used for LDR/STR, and so the result is guaranteed to be wide in spite of the missing suffix? > > diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S > > index 6acdfde56849..3ced01d9afe4 100644 > > --- a/arch/arm/lib/copy_from_user.S > > +++ b/arch/arm/lib/copy_from_user.S > > @@ -60,7 +60,7 @@ > > #define LDR1W_SHIFT 0 > > > > .macro ldr1w ptr reg abort > > - USERL(\abort, W(ldr) \reg, [\ptr], #4) > > + USERL(\abort, ldr \reg, [\ptr], #4) > > .endm > > > > .macro ldr4w ptr reg1 reg2 reg3 reg4 abort > > @@ -80,7 +80,7 @@ > > #define STR1W_SHIFT 0 > > > > .macro str1w ptr reg abort > > - W(str) \reg, [\ptr], #4 > > + str \reg, [\ptr], #4 > > .endm > > > > .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort > > diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S > > index 485fa3cffdbe..a6a96f814720 100644 > > --- a/arch/arm/lib/copy_to_user.S > > +++ b/arch/arm/lib/copy_to_user.S > > @@ -34,7 +34,7 @@ > > #define LDR1W_SHIFT 0 > > > > .macro ldr1w ptr reg abort > > - W(ldr) \reg, [\ptr], #4 > > + ldr \reg, [\ptr], #4 > > .endm > > > > .macro ldr4w ptr reg1 reg2 reg3 reg4 abort > > @@ -77,7 +77,7 @@ > > #define STR1W_SHIFT 0 > > > > .macro str1w ptr reg abort > > - USERL(\abort, W(str) \reg, [\ptr], #4) > > + USERL(\abort, str \reg, [\ptr], #4) > > .endm > > > > .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort > > diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S > > index e4caf48c089f..7b980a1a4227 100644 > > --- a/arch/arm/lib/memcpy.S > > +++ b/arch/arm/lib/memcpy.S > > @@ -15,7 +15,7 @@ > > #define STR1W_SHIFT 0 > > > > .macro ldr1w ptr reg abort > > - W(ldr) \reg, [\ptr], #4 > > + ldr \reg, [\ptr], #4 > > .endm > > > > .macro ldr4w ptr reg1 reg2 reg3 reg4 abort > > @@ -31,7 +31,7 @@ > > .endm > > > > .macro str1w ptr reg abort > > - W(str) \reg, [\ptr], #4 > > + str \reg, [\ptr], #4 > > .endm > > > > .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort > > diff --git a/arch/arm/lib/memmove.S b/arch/arm/lib/memmove.S > > index 6fecc12a1f51..35c5c06b7588 100644 > > --- a/arch/arm/lib/memmove.S > > +++ b/arch/arm/lib/memmove.S > > @@ -84,24 +84,24 @@ WEAK(memmove) > > addne pc, pc, ip @ C is always clear here > > b 7f > > 6: W(nop) > > - W(ldr) r3, [r1, #-4]! > > - W(ldr) r4, [r1, #-4]! > > - W(ldr) r5, [r1, #-4]! > > - W(ldr) r6, [r1, #-4]! > > - W(ldr) r7, [r1, #-4]! > > - W(ldr) r8, [r1, #-4]! > > - W(ldr) lr, [r1, #-4]! > > + ldr r3, [r1, #-4]! > > + ldr r4, [r1, #-4]! > > + ldr r5, [r1, #-4]! > > + ldr r6, [r1, #-4]! > > + ldr r7, [r1, #-4]! > > + ldr r8, [r1, #-4]! > > + ldr lr, [r1, #-4]! > > > > add pc, pc, ip > > nop > > W(nop) > > - W(str) r3, [r0, #-4]! > > - W(str) r4, [r0, #-4]! > > - W(str) r5, [r0, #-4]! > > - W(str) r6, [r0, #-4]! > > - W(str) r7, [r0, #-4]! > > - W(str) r8, [r0, #-4]! > > - W(str) lr, [r0, #-4]! > > + str r3, [r0, #-4]! > > + str r4, [r0, #-4]! > > + str r5, [r0, #-4]! > > + str r6, [r0, #-4]! > > + str r7, [r0, #-4]! > > + str r8, [r0, #-4]! > > + str lr, [r0, #-4]! > > > > CALGN( bcs 2b )