From patchwork Mon May 8 14:04:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 91169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2189013vqo; Mon, 8 May 2023 07:14:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7h5ehYtooxMj+5bRmMKuD4FDXA8rM2QHzapX3Qm3zIBAFgR+nmYsVZ5JWEg1KUw66FtnsU X-Received: by 2002:a05:6a20:7d86:b0:100:e8cf:4bd6 with SMTP id v6-20020a056a207d8600b00100e8cf4bd6mr1493911pzj.55.1683555275403; Mon, 08 May 2023 07:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683555275; cv=none; d=google.com; s=arc-20160816; b=SEQsEgaCEe2cFy66uW7QeIpNSYdmvbVZVErQ+nyQcZHOqEeH/MJfVDOX6O0Tv3ZUeY ITKX40kvikqS5+LTEOefj2FiOj0+X4O3z6VmkwJ2lMfgoJ6DnTvGPiXOYNYSQYbuu6Wk Hs5EQzqHjsXu5rIX2G/rf3eehLJf7T47TxJO39WZ+mvffA4cs+mlCuoW1+Rzl5fyXn4j qq3rDAIixblDAwj2Yu12XZYC4z44oXW1twxTfZ0UQ6jvOIZTH9OhlxND3pPALgD3BBZY uutm25K7jnV8JjgjBBYDIFRNunkTNWqltVSYhaCwz/VQYwYg0Ci3fpUMIG+TY3Ycx66p ZMyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=31tKUF0XOqo9VkRjDJPUdomXdb9oKFooHh4XcuaTp98=; b=U2WbHEe1f9z61FgQuo6uGN1C7WWTZasQcbYu5gyGhVK0went73U945duMCGO0ErOGY dBgwoeXhaZOQEl4ktArQW131RCkBc552PBaEk7b42qSAQzwTYvLtrIXGS+LcxQ4c0wvc EfKj2dUqeMUhIPLueVqEqPxREOCbWO/fvClXPMYCy5cqE/Jg2cvJ6qNInPeeXpuny6fJ RjZIRr3i7YvCSI8TWEwTUvXcNMpfzFWRWAcZ6JD4rxG0GET27xB0dIwK5cr5HWhtd0eB IF3pXAA/fHFgYiIY+Kjhx9RXD3Z1i/N2ijw6V1gVk0aOgfgPFIKThQyyP9UQEy9/F2UO 4IKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gYmjyMig; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="W/CfOTMj"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a63dc01000000b0052ca3209fc9si8775944pgg.654.2023.05.08.07.14.20; Mon, 08 May 2023 07:14:35 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=gYmjyMig; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="W/CfOTMj"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234300AbjEHOEj (ORCPT + 99 others); Mon, 8 May 2023 10:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233920AbjEHOEi (ORCPT ); Mon, 8 May 2023 10:04:38 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E1C836562; Mon, 8 May 2023 07:04:37 -0700 (PDT) Date: Mon, 08 May 2023 14:04:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1683554675; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=31tKUF0XOqo9VkRjDJPUdomXdb9oKFooHh4XcuaTp98=; b=gYmjyMigisB6tExIqYnIkmqzmnR9xy23FHymUGUXsWegGW0I0ci94YBMFL4BwE56ZFex88 NSJ7NBeXvEbZFVtc0wTM8zeqLNWDibu/TSNyvTKPPMCKy+RV+jodBecKaLOLtUa39tMuDD 1A4U2i9Sky0IZ0Le964CrhqVoH4dSjjCRYaqr22NU8obOy6L869mCfWjBX5eqs4suCh2jH wA/gw44Z8rDE5i1b9Izb70FTSMt02A7/vJONj0372KxJrxAh86/W3pmv8ZgZL0284OQUsZ r6mCZMrLLSUlxJd+4tymRPJ92Ct+ItvKoNPaO8kVprglA98ZO06uEqCKqor9BQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1683554675; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=31tKUF0XOqo9VkRjDJPUdomXdb9oKFooHh4XcuaTp98=; b=W/CfOTMjvtQHE6JeSd3BBpvPynHLBAMrJk3mTDtP/Hx0foC62dehi3xBUE83w3ElYZHz3e W6MOHwiE68AEfJAg== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/misc] tools/x86/kcpuid: Dump the correct CPUID function in error Cc: "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230426094107.27348-1-bp@alien8.de> References: <20230426094107.27348-1-bp@alien8.de> MIME-Version: 1.0 Message-ID: <168355467536.404.8937977023899677332.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764232394008301476?= X-GMAIL-MSGID: =?utf-8?q?1765335656363831976?= The following commit has been merged into the x86/misc branch of tip: Commit-ID: 0150d1bfbedf29d7473ae458815781488f62d11d Gitweb: https://git.kernel.org/tip/0150d1bfbedf29d7473ae458815781488f62d11d Author: Borislav Petkov (AMD) AuthorDate: Wed, 26 Apr 2023 11:41:07 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 08 May 2023 15:50:27 +02:00 tools/x86/kcpuid: Dump the correct CPUID function in error The tool uses the 16 least significant bits of the CPUID leaf as an index into its array of CPUID function field descriptions. However, when that index is non-existent, it uses the same, truncated index to report it, which is wrong: $ kcpuid -l 0x80000034 ERR: invalid input index (0x34) Use the original index number in the error message. Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20230426094107.27348-1-bp@alien8.de --- tools/arch/x86/kcpuid/kcpuid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c index 416f5b3..24b7d01 100644 --- a/tools/arch/x86/kcpuid/kcpuid.c +++ b/tools/arch/x86/kcpuid/kcpuid.c @@ -517,15 +517,16 @@ static void show_range(struct cpuid_range *range) static inline struct cpuid_func *index_to_func(u32 index) { struct cpuid_range *range; + u32 func_idx; range = (index & 0x80000000) ? leafs_ext : leafs_basic; - index &= 0x7FFFFFFF; + func_idx = index & 0xffff; - if (((index & 0xFFFF) + 1) > (u32)range->nr) { + if ((func_idx + 1) > (u32)range->nr) { printf("ERR: invalid input index (0x%x)\n", index); return NULL; } - return &range->funcs[index]; + return &range->funcs[func_idx]; } static void show_info(void)