Message ID | 320c4dba-9919-404b-8a26-a8af16be1845@app.fastmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2086285wrn; Tue, 24 Jan 2023 03:07:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXuNFHACwMpECEGjGEYWB71Y3IHkFivuymwVR+Amm2vmyO3an/JbW7McCurGq0Wosnn3Nqy+ X-Received: by 2002:a05:6a20:1b04:b0:af:88d2:33f8 with SMTP id ch4-20020a056a201b0400b000af88d233f8mr49071062pzb.7.1674558466320; Tue, 24 Jan 2023 03:07:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674558466; cv=none; d=google.com; s=arc-20160816; b=yJVEAKQBqp3Pu+Ae3z8CPKlQn+XmfPb8T8zwq725Ko34fksgBQGVnRs0VrobK9SEeo 0dLyMiuNYLeksyf4j/0RHhbtEgsCB+XpiWqJDPIZ9CWc4KPI228sFe8bH794yCvvds1q vx4qEp8mhSqwzsTuWej3vKUZ6KGuml8WYokBatlBXaq95LtwUxRrSIzhRrYEAmLk9ZcD 46BcTr8AWRR92ufUEyNWp/YBaAdZwCeOEjCTbDTGdfpoa3AVRuqSoDyyP4Quw2h38UBh eupY5zNy26kTIpBATUTgsXI6Vg3RiSADlwCVPriCmemWZlJABWFEf3fmLp2aR3zENk4O HXKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:message-id:mime-version :user-agent:feedback-id:dkim-signature:dkim-signature; bh=tEYZlf43dWAmtICS4wUuBE8sXSOA8yFH1Yjm+gpaNlY=; b=fG/+OCdFqPpJfRfnbM01mPQjVJ5gwuDvK8qJmM8rsYoPbHP/x4d6x7UvjeVP1i0Q0Y M+4qPN1oxaalsRBw/T3V5xdiUpJ0Fibbc/L896+J14FFrpNjMyjoIPXS+8FmAyqK2YFM I/QbySoSk/EAka7yU7Sx/DGGGPyajNSvTN3chAvvjQME00MocpKONuilKBoGWB+LrMd2 lysTTlALAyIpAWp/uOO2owc1N48FpCOn+zw1z1f+gUkAYnm+oWteg2brZjredbvuuLpy sM1WbbiGwPr4qzxRIJt6HU8oV8plKk5RtEeyiDNq43FvER6wtfk8NX6CwUbbqZk9F8lf diqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@readahead.eu header.s=fm3 header.b=txsl7iat; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=IIRMCaC8; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k189-20020a6384c6000000b004d056225b6fsi1871306pgd.811.2023.01.24.03.07.34; Tue, 24 Jan 2023 03:07:46 -0800 (PST) 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=@readahead.eu header.s=fm3 header.b=txsl7iat; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=IIRMCaC8; 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 S233798AbjAXLF6 (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Tue, 24 Jan 2023 06:05:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233831AbjAXLFl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 24 Jan 2023 06:05:41 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F40FD3C21; Tue, 24 Jan 2023 03:05:31 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 268D05C092A; Tue, 24 Jan 2023 06:05:31 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute6.internal (MEProxy); Tue, 24 Jan 2023 06:05:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=readahead.eu; h= cc:cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t= 1674558331; x=1674644731; bh=tEYZlf43dWAmtICS4wUuBE8sXSOA8yFH1Yj m+gpaNlY=; b=txsl7iatIcaamMHLXf8zCa7fxGJWLBs3beJ3qWIPLnrmhAR8mkd TGncrksVfnrw2IH2M/tyfIJCgC+nJ2Pm1iy1A7gaWiuANkGwaRJGigsX3QCBJzrH yncwMBb1uwnu3RelAwAk7o1OiRQwSKH/b6AsSG4yhPesLEHrRnjXhqMF7gNY86op N6yc5JlcERAXkKveXq53ET0NlokxxY1gT9JNjUPO0lIFHv1Cg7SlYLIWuV/CB7t8 +ZM45RFqA5vKnoSaS54REFYYok94sAUyknyn/YMmVpxde5F7u4Fipc1Zi3ycIffi 8L9FNnObaQIRZQkhqdnvDxmtPeN25ret+fQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1674558331; x= 1674644731; bh=tEYZlf43dWAmtICS4wUuBE8sXSOA8yFH1Yjm+gpaNlY=; b=I IRMCaC8HW9R8RhfwAjJzkzQR9L9J+v6Z5833TBT9/nk+2IOv0HkaL3Q+ql4QpciA casH/tqUAhLB6b30QuZQPKIt6BTZdrMibpe/ORcLFWVDzVhXkqIRpt7uWNI5Nb+x cDhl8Bt9qxMIr379A0pHnPisMvXawP4qouNJjTgfrn4FCVzeaXUsal+IOx8TQmUu OZDtoHQvYfINJ0evvvztAviS6UCEE+hcOeNl9cd0dUpCX8gXpEjl66Uvssgc/310 sX8GzGGbP2ytFh10P4KFzkvbcazKNFt7iF0EzJpywSGFYqSS8wfN8efiVqFwS+HK DeJ/rp6N4q22vmjwbObqg== X-ME-Sender: <xms:ervPY9PqKQxmW8F_Hw3upBubqdBeT7sloadYjPmus650w5xpiYKblA> <xme:ervPY_-pTJMPlmQfbKMimrxA9M2sG8AzB9jnCyoB9mHrYATqiQhUo4tg8dqIXONVQ U31iLcSV3ntgAy5Ylk> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddvtddgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkfffhvfevufgtsehttdertderredtnecuhfhrohhmpedfffgrvhhi ugcutfhhvghinhhssggvrhhgfdcuoegurghvihgusehrvggruggrhhgvrggurdgvuheqne cuggftrfgrthhtvghrnhepveeiffetveejgfdtteevleetleejtddvvdeftdffkeejveef veeguedtkefgjeevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepuggrvhhiugesrhgvrggurghhvggrugdrvghu X-ME-Proxy: <xmx:ervPY8TT02hhkl4kBCUKqOeUqXT8jvKw5oHsWzVLmLBdrJnJgaCEOw> <xmx:ervPY5uuBmiSPv7WRiVrRl2IArYAgG4ntwASmneewz3WYYmvNsAstA> <xmx:ervPY1de3-hxqTtyw4tXQMsV7nuuGH1PEaYzm2IslwBANQDQFxZgwg> <xmx:e7vPY-HMpGr6ZGh_JkcEWmhnFvNZs93AeYGQ9dk1gP7-ltkOvBBGlg> Feedback-ID: id2994666:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3334A1700089; Tue, 24 Jan 2023 06:05:30 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-85-gd6d859e0cf-fm-20230116.001-gd6d859e0 Mime-Version: 1.0 Message-Id: <320c4dba-9919-404b-8a26-a8af16be1845@app.fastmail.com> Date: Tue, 24 Jan 2023 12:04:59 +0100 From: "David Rheinsberg" <david@readahead.eu> To: linux-kernel@vger.kernel.org Cc: rust-for-linux@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>, x86@kernel.org, "Dave Hansen" <dave.hansen@linux.intel.com>, "Borislav Petkov" <bp@alien8.de>, "Ingo Molnar" <mingo@redhat.com>, "Thomas Gleixner" <tglx@linutronix.de> Subject: [PATCH] x86/insn_decoder_test: allow longer symbol-names Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755901818188596519?= X-GMAIL-MSGID: =?utf-8?q?1755901818188596519?= |
Series |
x86/insn_decoder_test: allow longer symbol-names
|
|
Commit Message
David Rheinsberg
Jan. 24, 2023, 11:04 a.m. UTC
Increase the allowed line-length of the insn-decoder-test to 4k to allow
for symbol-names longer than 256 characters.
The insn-decoder-test takes objdump output as input, which may contain
symbol-names as instruction arguments. With rust-code entering the
kernel, those symbol-names will include mangled-symbols which might
exceed the current line-length-limit of the tool.
By bumping the line-length-limit of the tool to 4k, we get a reasonable
buffer for all objdump outputs I have seen so far. Unfortunately, ELF
symbol-names are not restricted in length, so technically this might
still end up failing if we encounter longer names in the future.
My compile-failure looks like this:
arch/x86/tools/insn_decoder_test: error: malformed line 1152000:
tBb_+0xf2>
..which overflowed by 10 characters reading this line:
ffffffff81458193: 74 3d je ffffffff814581d2 <_RNvXse_NtNtNtCshGpAVYOtgW1_4core4iter8adapters7flattenINtB5_13FlattenCompatINtNtB7_3map3MapNtNtNtBb_3str4iter5CharsNtB1v_17CharEscapeDefaultENtNtBb_4char13EscapeDefaultENtNtBb_3fmt5Debug3fmtBb_+0xf2>
Signed-off-by: David Rheinsberg <david@readahead.eu>
---
arch/x86/tools/insn_decoder_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
* David Rheinsberg <david@readahead.eu> wrote: > Increase the allowed line-length of the insn-decoder-test to 4k to allow > for symbol-names longer than 256 characters. > > The insn-decoder-test takes objdump output as input, which may contain > symbol-names as instruction arguments. With rust-code entering the > kernel, those symbol-names will include mangled-symbols which might > exceed the current line-length-limit of the tool. > > By bumping the line-length-limit of the tool to 4k, we get a reasonable > buffer for all objdump outputs I have seen so far. Unfortunately, ELF > symbol-names are not restricted in length, so technically this might > still end up failing if we encounter longer names in the future. > > My compile-failure looks like this: > > arch/x86/tools/insn_decoder_test: error: malformed line 1152000: > tBb_+0xf2> > > ..which overflowed by 10 characters reading this line: > > ffffffff81458193: 74 3d je ffffffff814581d2 <_RNvXse_NtNtNtCshGpAVYOtgW1_4core4iter8adapters7flattenINtB5_13FlattenCompatINtNtB7_3map3MapNtNtNtBb_3str4iter5CharsNtB1v_17CharEscapeDefaultENtNtBb_4char13EscapeDefaultENtNtBb_3fmt5Debug3fmtBb_+0xf2> > > Signed-off-by: David Rheinsberg <david@readahead.eu> > --- > arch/x86/tools/insn_decoder_test.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/tools/insn_decoder_test.c b/arch/x86/tools/insn_decoder_test.c > index 472540aeabc2..366e07546344 100644 > --- a/arch/x86/tools/insn_decoder_test.c > +++ b/arch/x86/tools/insn_decoder_test.c > @@ -106,7 +106,7 @@ static void parse_args(int argc, char **argv) > } > } > > -#define BUFSIZE 256 > +#define BUFSIZE 4096 That hard-coded constant is a bit lame and will cause trouble the minute *that* size is exceeded - don't we have some more natural figure, such as KSYM_SYMBOL_LEN? Thanks, Ingo
Hi Ingo! On Wed, Jan 25, 2023, at 12:30 PM, Ingo Molnar wrote: > * David Rheinsberg <david@readahead.eu> wrote: >> diff --git a/arch/x86/tools/insn_decoder_test.c b/arch/x86/tools/insn_decoder_test.c >> index 472540aeabc2..366e07546344 100644 >> --- a/arch/x86/tools/insn_decoder_test.c >> +++ b/arch/x86/tools/insn_decoder_test.c >> @@ -106,7 +106,7 @@ static void parse_args(int argc, char **argv) >> } >> } >> >> -#define BUFSIZE 256 >> +#define BUFSIZE 4096 > > That hard-coded constant is a bit lame and will cause trouble the minute > *that* size is exceeded - don't we have some more natural figure, such as > KSYM_SYMBOL_LEN? Thanks for the hint! I tried mentioning this in the commit-message. I am unsure whether a fixed-size limit is the correct thing to do. However, given that this is a compile-time test-tool, I thought bumping the limit for this stack buffer to be sufficient. I am open to other suggestions. The input to this tool is the output of objdump, so effectively annotated x86-assembly. To get a proper estimate of how long such a line could be, I would have to audit all instructions and know what kind of arguments are possible. Can some of them take multiple symbols as argument? Are there other possibly long encodings of arguments to consider? Lastly, shouldn't this use KSYM_NAME_LEN rather than KSYM_SYMBOL_LEN? And then how much room for normal instruction-encoding should I calculate? I feel like whatever I do (even with those constants), I would end up with only an estimate and wouldn't actually end up closing this issue. The current workaround is to just disable CONFIG_X86_DECODER_SELFTEST, which I thought is a sad state. I can gladly use `256 + KSYM_NAME_LEN` and add a comment ala "room for insn-encoding and a symbol name". Would that be acceptable? The alternative would be to try to dyn-alloc a buffer and increase it to the actual line-length? Open to suggestions! Thanks David
On Fri, Jan 27, 2023 at 11:39 AM David Rheinsberg <david@readahead.eu> wrote: > > The current workaround is to just disable CONFIG_X86_DECODER_SELFTEST, which I thought is a sad state. I can gladly use `256 + KSYM_NAME_LEN` and add a comment ala "room for insn-encoding and a symbol name". Would that be acceptable? The alternative would be to try to dyn-alloc a buffer and increase it to the actual line-length? John independently hit this issue again. Could we fix this? Going for the `256 + KSYM_NAME_LEN` sounds good enough for the moment since it would be a clear improvement, though I agree this could be cleaned up further. Sergio took the approach David suggested in a related patch [1], but perhaps it is best to submit the fix on its own so that it is easier to put it in. David, would you be so kind as to submit a v2 with that? Hopefully x86 can pick it up, otherwise with an Acked-by I am happy to take it too; and then Sergio can submit his patch on top again. Thanks! (Cc'ing also Masami who wrote this originally) [1] https://lore.kernel.org/rust-for-linux/20231119180145.157455-1-sergio.collado@gmail.com/ Cheers, Miguel
diff --git a/arch/x86/tools/insn_decoder_test.c b/arch/x86/tools/insn_decoder_test.c index 472540aeabc2..366e07546344 100644 --- a/arch/x86/tools/insn_decoder_test.c +++ b/arch/x86/tools/insn_decoder_test.c @@ -106,7 +106,7 @@ static void parse_args(int argc, char **argv) } } -#define BUFSIZE 256 +#define BUFSIZE 4096 int main(int argc, char **argv) {