Message ID | 20240223-x86-insn-decoder-line-fix-v2-1-cde49c69f402@valentinobst.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-78367-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp577475dyb; Fri, 23 Feb 2024 05:19:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUXWywKiYRiuWJ8A+pez1XwGegkMfUNKRXmtYgqmQq2rHl0+9DUgTHjZEIqmHZ4KvnpEU+nEs0Ivf8p3/YUQRY71AhSyQ== X-Google-Smtp-Source: AGHT+IF5JFFzUhXtKsTKAnWxn94MYGKVx63dIreEHx2O4CB0kJDQUV3FB4xUHSHOk1IpQqShCcIj X-Received: by 2002:a05:6a21:3994:b0:1a0:e233:a610 with SMTP id ad20-20020a056a21399400b001a0e233a610mr1667104pzc.5.1708694340906; Fri, 23 Feb 2024 05:19:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708694340; cv=pass; d=google.com; s=arc-20160816; b=MQkqIgrdKoAKeVGBreCOZtShcsc4c9kriTyNddo7Q/U8l7X9jejTRtkODrA/DJ8jJL djC4h769imBsottKhyJmpz6Dzjm3iFJogoRMxMkGwuz5hueZE/KnCuBZsGpFwq5icqT0 iTzarRtM64bTEqBbotzUqZ4rmFsjCASe/Hy7Es5GTso5eAIMN+mnXtCv6726MNjn/yRR W+kHkqWesE/WXowYXVM+AOUbb7QyLBNwc/qiPrmL+mQxqtwD62M81X1i1W6sI8Zai9sb m3cUFt7rYDj7Z0G3NTebHnkxUxkIizncj4smEhdLHQzUBRme/tFhiq4s3LVajW2/bOiX 7MrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:cc:to:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=kS2Hw6pIj4tsje1wX8XCk/qCELPZ9hG3AxvFbikR1ZU=; fh=EklKl7IXwTpgLv46meMcLZ/u/V/hQXiHaDNR0CDTmjw=; b=FTVt20NBxy6mhwoOA4j19s67kvxnRRzW8CvWxrLYlM1GhZn3V/eggInVCgjg7CIS/P 7rhrPXtwvp3EoviRMkBbLUX3Vokt6mn6TGR3+aPSlC7ZuWN0QzSl37BkIvDeTssfcNqW g8ftEhiD9p5//VUn5BxmEG2tyirA8USA2eiLIRav2Dnxkmhc2HGcn/txjW/Q54ni8iR3 K1y4rRZDgDfap3mDr9+nmDCbFnyiRRT/qbkyryFSV+uSHrT565tfInKQBeIn27+X/OEh 9LPscRYFmKYse5awylMT5JKy9hxc7XugqSeNeFdzeuC0TcOPS6HE3oz9T8q1T3NNGLDK +5WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@valentinobst.de header.s=s1-ionos header.b=YP916j38; arc=pass (i=1 spf=pass spfdomain=valentinobst.de dkim=pass dkdomain=valentinobst.de); spf=pass (google.com: domain of linux-kernel+bounces-78367-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78367-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n29-20020a63721d000000b005dc529b2a4fsi12320495pgc.741.2024.02.23.05.19.00 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:19:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78367-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@valentinobst.de header.s=s1-ionos header.b=YP916j38; arc=pass (i=1 spf=pass spfdomain=valentinobst.de dkim=pass dkdomain=valentinobst.de); spf=pass (google.com: domain of linux-kernel+bounces-78367-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78367-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5BB922862D2 for <ouuuleilei@gmail.com>; Fri, 23 Feb 2024 13:19:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7B6E81727; Fri, 23 Feb 2024 13:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=valentinobst.de header.i=kernel@valentinobst.de header.b="YP916j38" Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 947997EF0A; Fri, 23 Feb 2024 13:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708694280; cv=none; b=pVc7VAQ00iKZ5ivS7BT4YvOCP3aKf1prDXKipntQD49Dwodvvc6yFarsNmJSJEWfpLMfExFxJVxIlSJmwASkaPf0cUKLQ0LMApttLYwjfuIkhUufj34A8W46lKC98l1nDXpIO94PzOd9bPGbrcQs3b0Dc+N0JTkrSEJlkayU/ck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708694280; c=relaxed/simple; bh=2JY+3DjG6lK45y3gH2HcJ0xwn7fJU24FgxnMJ0ij53U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=kNyymquj5H739AkYBobzCOKaYNP/u6t9edZpcZtP/+wF9mCtmEcbX3/jWLcdaZuR7IgefUHxhgfPTUPqaI7XJqihY6PxJvBQ5JWIXyNsqQsPQXlANw3qV0GIQxjvjlIxFnKn5dvMx+qq/VGh7ijNbFwfnJKB9LIxNAaObCc/LvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=valentinobst.de; spf=pass smtp.mailfrom=valentinobst.de; dkim=pass (2048-bit key) header.d=valentinobst.de header.i=kernel@valentinobst.de header.b=YP916j38; arc=none smtp.client-ip=212.227.17.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=valentinobst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=valentinobst.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=valentinobst.de; s=s1-ionos; t=1708694262; x=1709299062; i=kernel@valentinobst.de; bh=2JY+3DjG6lK45y3gH2HcJ0xwn7fJU24FgxnMJ0ij53U=; h=X-UI-Sender-Class:From:Date:Subject:To:Cc; b=YP916j382Om/wJDpeMVdPKBp4Rq2vdl1ggRz6j7ycQC09X1AUejyZV16GPL2ZGuA AdZ32MlIlampf/ejsFeqx4SKY+ly0BQbHq2VFR3miRHX0pN5O30o+BriwCKrPMBpz RVnM8amUiQ0poElLXTvIiNhy6sqDqgOF9dnELQRUaV2weqylbF0ow9vigEiLwgmDW T49+6Fi4KGIykidzw1M876t1sN+a2EvRW6OIBdyiOobb3/DMKUmG0OrYvD2GtIqww 1xTBLUBLVv+9eKchqulOq6Wuut4I8lJAauzq4K4zg89E0qU8rhTGGGe/wGtarNKxR yNy9aMVni1jchYY7Xw== X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from [192.168.0.101] ([95.223.130.98]) by mrelayeu.kundenserver.de (mreue106 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MPoTl-1rINoF3RnX-00MxPZ; Fri, 23 Feb 2024 14:11:16 +0100 From: Valentin Obst <kernel@valentinobst.de> Date: Fri, 23 Feb 2024 14:10:51 +0100 Subject: [PATCH v2] x86/tools: fix line number reported for malformed lines Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240223-x86-insn-decoder-line-fix-v2-1-cde49c69f402@valentinobst.de> X-B4-Tracking: v=1; b=H4sIAFuZ2GUC/42NQQqDMBBFryKz7hQntUa68h7FhSaTOiBJSSRYx Ls39QRdvgf//R0SR+EEj2qHyFmSBF9AXSow8+hfjGILg6pVUytFuHUtik8eLZtgOeIintHJhno ip5j0TTkHZf+OXPTZfg6FZ0lriJ/zKtPP/lPNhISNNvY+kqbOtH0eF/ar+DCl9WoZhuM4vmBqy QPIAAAA To: Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@kernel.org>, Ingo Molnar <mingo@redhat.com>, Thomas Gleixner <tglx@linutronix.de> Cc: Andreas Hindborg <a.hindborg@samsung.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, John Baublitz <john.m.baublitz@gmail.com>, Masami Hiramatsu <mhiramat@kernel.org>, Miguel Ojeda <ojeda@kernel.org>, Peter Zijlstra <peterz@infradead.org>, =?utf-8?q?Sergio_Gonz=C3=A1lez_Colla?= =?utf-8?q?do?= <sergio.collado@gmail.com>, linux-kernel@vger.kernel.org, stable@vger.kernel.org, x86@kernel.org, Valentin Obst <kernel@valentinobst.de> X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1708693872; l=4956; i=kernel@valentinobst.de; s=20240131; h=from:subject:message-id; bh=l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aNYlBt P7BPMzy+nS+n0/OTcCc5tKW+cks14Qu52DFNCEn1Xs7yR2Akwyo0xfierH0NTPDHMC2M0U3qu 6dej5GbJ58PAD8B/TWfrHUq6Mj1T5QK7C5RDIofuPn3nQemMYyFEI1T3coA9Ye1UXZevM05UA WmmYC06RaO1OmKnJch1DnF4nk9qq+dysMqMhP1HnUc95fsu1cBtP9Frx+SJZxrYpwkrGyhm/P BTB5CDhiE8leou4PM0NmjALHxKQZ+KRiEo6N/TWYRI/pAKh4mNGfM4= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791695877408624774 X-GMAIL-MSGID: 1791695877408624774 |
Series |
[v2] x86/tools: fix line number reported for malformed lines
|
|
Commit Message
Valentin Obst
Feb. 23, 2024, 1:10 p.m. UTC
While debugging the `X86_DECODER_SELFTEST` failure first reported in [1], we noticed that the line numbers reported by the `insn_decoder_test` tool do not correspond to the line in the output of `objdump_reformat.awk` that was causing the failure: # TEST posttest llvm-objdump -d -j .text ./vmlinux | \ awk -f ./arch/x86/tools/objdump_reformat.awk | \ arch/x86/tools/insn_decoder_test -y -v arch/x86/tools/insn_decoder_test: error: malformed line 1657116: 68db0 $ llvm-objdump -d -j .text ./vmlinux | \ awk -f ./arch/x86/tools/objdump_reformat.awk > objdump_reformat.txt $ head -n `echo 1657116+2 | bc` objdump_reformat.txt | tail -n 5 ffffffff815430b1 41 8b 47 1c movl ffffffff815430b5 89 c1 movl ffffffff815430b7 81 c9 00 40 00 00 orl ffffffff815430bd 41 89 4e 18 movl ffffffff815430c1 a8 40 testb These lines are perfectly fine. The reason is that the line count reported by the tool only includes instruction lines, i.e., it does not count symbol lines. This behavior was introduced in Commit 35039eb6b199 ("x86: Show symbol name if insn decoder test failed"), which included symbol lines in the output of the awk script. This broke the `instuction lines == total lines` property without accounting for it in `insn_decoder_test.c`. Add a new variable to count the combined (insn+symbol) line count and report this in the error message. With this patch, the line reported by the tool is the line causing the failure (long line wrapped at 75 chars): # TEST posttest llvm-objdump -d -j .text ./vmlinux | \ awk -f ./arch/x86/tools/objdump_reformat.awk | \ arch/x86/tools/insn_decoder_test -y -v arch/x86/tools/insn_decoder_test: error: malformed line 1699686: 68db0 $ head -n ` echo 1699686+2 | bc` objdump_reformat.txt | tail -n 5 ffffffff81568dac c3 retq <_RNvXsP_NtCs7qddEHlz8fK_4core3fmtRINtNtNtNtB7_4iter8adapters5chain5Chain INtNtBA_7flatten7FlattenINtNtB7_6option8IntoIterNtNtB7_4char11EscapeDebug EEINtB1a_7FlatMapNtNtNtB7_3str4iter5CharsB1T_NtB2D_23CharEscapeDebugConti nueEENtB5_5Debug3fmtB7_>:ffffffff81568db0 ffffffff81568dad 0f 1f 00 nopl ffffffff81568db0 f3 0f 1e fa endbr64 ffffffff81568db4 41 56 pushq [In this case the line causing the failure is interpreted as two lines by the tool (due to its length, but this is fixed by [1, 2]), and the second line is reported. Still the spatial closeness between the reported line and the line causing the failure would have made debugging a lot easier.] Link: https://lore.kernel.org/lkml/Y9ES4UKl%2F+DtvAVS@gmail.com/T/ [1] Link: https://lore.kernel.org/rust-for-linux/20231119180145.157455-1-sergio.collado@gmail.com/ [2] Fixes: 35039eb6b199 ("x86: Show symbol name if insn decoder test failed") Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Tested-by: Miguel Ojeda <ojeda@kernel.org> Reported-by: John Baublitz <john.m.baublitz@gmail.com> Debugged-by: John Baublitz <john.m.baublitz@gmail.com> Signed-off-by: Valentin Obst <kernel@valentinobst.de> --- Changes in v2: - Added tags 'Reviewed-by', 'Tested-by', 'Reported-by', 'Debugged-by', 'Link', and 'Fixes'. - Explain why this patch fixes the commit mentioned in the 'Fixes' tag. - CCed the stable list and sent to all x86 maintainers. - Link to v1: https://lore.kernel.org/r/20240221-x86-insn-decoder-line-fix-v1-1-47cd5a1718c6@valentinobst.de --- arch/x86/tools/insn_decoder_test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- base-commit: b401b621758e46812da61fa58a67c3fd8d91de0d change-id: 20240221-x86-insn-decoder-line-fix-7b1f2e1732ff Best regards, -- Valentin Obst <kernel@valentinobst.de>
Comments
On Fri, Feb 23, 2024 at 2:17 PM Valentin Obst <kernel@valentinobst.de> wrote: > > - Explain why this patch fixes the commit mentioned in the 'Fixes' tag. Thanks for this! > - CCed the stable list and sent to all x86 maintainers. Sorry if I was not clear -- the "Cc: stable@vger.kernel.org" needs to be in the commit message itself, see: https://docs.kernel.org/process/submitting-patches.html#select-the-recipients-for-your-patch But I would wait a few days for a v3 to see if x86 says something meanwhile -- patches to stable need to arrive in mainline anyway :) Cheers, Miguel
diff --git a/arch/x86/tools/insn_decoder_test.c b/arch/x86/tools/insn_decoder_test.c index 472540aeabc2..727017a3c3c7 100644 --- a/arch/x86/tools/insn_decoder_test.c +++ b/arch/x86/tools/insn_decoder_test.c @@ -114,6 +114,7 @@ int main(int argc, char **argv) unsigned char insn_buff[16]; struct insn insn; int insns = 0; + int lines = 0; int warnings = 0; parse_args(argc, argv); @@ -123,6 +124,8 @@ int main(int argc, char **argv) int nb = 0, ret; unsigned int b; + lines++; + if (line[0] == '<') { /* Symbol line */ strcpy(sym, line); @@ -134,12 +137,12 @@ int main(int argc, char **argv) strcpy(copy, line); tab1 = strchr(copy, '\t'); if (!tab1) - malformed_line(line, insns); + malformed_line(line, lines); s = tab1 + 1; s += strspn(s, " "); tab2 = strchr(s, '\t'); if (!tab2) - malformed_line(line, insns); + malformed_line(line, lines); *tab2 = '\0'; /* Characters beyond tab2 aren't examined */ while (s < tab2) { if (sscanf(s, "%x", &b) == 1) {