From patchwork Wed Nov 9 12:38:24 2022 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: 17537 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp308865wru; Wed, 9 Nov 2022 04:39:42 -0800 (PST) X-Google-Smtp-Source: AMsMyM7jpTWt2d2q8QbvoCuTA2hS9e7x8kyL45SWqa2RYeL1UBp7S/oyhE4nBwug1TOXJVrM9id7 X-Received: by 2002:a63:e44f:0:b0:46f:be60:ada3 with SMTP id i15-20020a63e44f000000b0046fbe60ada3mr44858694pgk.577.1667997582215; Wed, 09 Nov 2022 04:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667997582; cv=none; d=google.com; s=arc-20160816; b=Un7Kdc4aSUkRdTXV1IG1Geug3ZvKW8dunzvvnw5ASJonQFo0ams/pLnegK0ZwD33Xv milVo1zvlv07biqEIJ7uD/TLR3f3GsNSoXr9C99g0U7PZUflvh8bGOFmsHM28NA9p691 CY8Rjm4ocRbJuEhus+UC9zhfXub+Wid3TUu+ZX3Ip8iceyt3RUoHbTIzP+jamhmbxLfo KaWjplvoSurrfvxeIRIsv5KazhXGuYzyqB8BvkGrhBU8l0cCN1AjM6EXhqMkRW4c2GCP YyZra1VpQ3tQUCMwOb9+EXKQkIjCDJA2Q//ARwunbg8YleGpoPIgT6+77qyVWLbFBlkH fNWw== 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=LK9EehdZiIwa5K6hobz+g0DwtgtF0AoOZ+vJ/cDRSTQ=; b=EW9WW3UsiTh4cumsL75/9Cg3Q/TlqvGKg8GJUSAylRrze8w2xuMKlUMSQLzmrrQ2+t Wa9+CtbSfxvCA2Ywbok6VH7mwQyTYy8GtPBD/+r94TMiNGGLeUbB7hrsuXYlIIOE8Xjw +0xcB6qV3I9OeAx9QdIWPnVfyz1VuPL5jNPR7l3iH193kj1mxvgt4LTsFxodQ2ZY0ug7 asPSxFtLc9wC+SFhrEK3KiQYvsLgQMRSj4nA9Xu7oSFTNLg2gx2Rw57khR8gRMEXa3sf cO7ZNP0iezYrJjJNsH6I433ohjT1W4pfZ7mr8R5uwP0JMBy5iLet9wocCLCmzDlk0sJJ Tlxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=X8v+aomF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 h191-20020a6383c8000000b00473d2c2c081si202326pge.689.2022.11.09.04.39.28; Wed, 09 Nov 2022 04:39:42 -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=@linutronix.de header.s=2020 header.b=X8v+aomF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S229949AbiKIMic (ORCPT + 99 others); Wed, 9 Nov 2022 07:38:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiKIMia (ORCPT ); Wed, 9 Nov 2022 07:38:30 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415485F5D; Wed, 9 Nov 2022 04:38:27 -0800 (PST) Date: Wed, 09 Nov 2022 12:38:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667997505; 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=LK9EehdZiIwa5K6hobz+g0DwtgtF0AoOZ+vJ/cDRSTQ=; b=X8v+aomFyx+6qc64lsUgqcWnLs18jl2WeFenLKsSMchrZ0ZxEvrz5EIwyc1IMAF2F5FW8T HISO1hwgxFBtBZrXHIBVMed5aw0Znht/g3wMWyJwB2hLuI77hhVsqy4OuawYnFqpHynSDE hcPW7bh9bRoad7sPsnXFPd2AoJjZLPDMK4DNLRZJ16RbxR/Gn6CwZZLztAjll5nVpgqSDU 9G8ZkGuEB/OWYS4odt5stkzvMkrEM1O2LbJ3mzgyyzYN9fxBTP3g2JOBYfc2wnY7VxPlFp wyD1EhhyBCH+RihPn7sdKXCXK41AXPOm+90Wz1hZCURg46G9vlAyqmJh2b2DHQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667997505; 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=LK9EehdZiIwa5K6hobz+g0DwtgtF0AoOZ+vJ/cDRSTQ=; b=j8vSZZIKZIusfpm1+LokwLrBq+BhGrnFw5Vz30eY0DGuBIWuHzDlq8YVklpsW54ZJU46ge 7PNcUTWq56EgKUCw== From: "tip-bot2 for Andrew Cooper" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fpu] x86/fpu/xstate: Fix XSTATE_WARN_ON() to emit relevant diagnostics Cc: Andrew Cooper , Borislav Petkov , , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220810221909.12768-1-andrew.cooper3@citrix.com> References: <20220810221909.12768-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Message-ID: <166799750447.4906.6850685710564265854.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 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?1749022232359296712?= X-GMAIL-MSGID: =?utf-8?q?1749022232359296712?= The following commit has been merged into the x86/fpu branch of tip: Commit-ID: 48280042f2c6e3ac2cfb1d8b752ab4a7e0baea24 Gitweb: https://git.kernel.org/tip/48280042f2c6e3ac2cfb1d8b752ab4a7e0baea24 Author: Andrew Cooper AuthorDate: Wed, 10 Aug 2022 23:19:09 +01:00 Committer: Borislav Petkov CommitterDate: Wed, 09 Nov 2022 13:28:31 +01:00 x86/fpu/xstate: Fix XSTATE_WARN_ON() to emit relevant diagnostics "XSAVE consistency problem" has been reported under Xen, but that's the extent of my divination skills. Modify XSTATE_WARN_ON() to force the caller to provide relevant diagnostic information, and modify each caller suitably. For check_xstate_against_struct(), this removes a double WARN() where one will do perfectly fine. CC stable as this has been wonky debugging for 7 years and it is good to have there too. Signed-off-by: Andrew Cooper Signed-off-by: Borislav Petkov Cc: Link: https://lore.kernel.org/r/20220810221909.12768-1-andrew.cooper3@citrix.com --- arch/x86/kernel/fpu/xstate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 59e543b..c2dde46 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -440,8 +440,8 @@ static void __init __xstate_dump_leaves(void) } } -#define XSTATE_WARN_ON(x) do { \ - if (WARN_ONCE(x, "XSAVE consistency problem, dumping leaves")) { \ +#define XSTATE_WARN_ON(x, fmt, ...) do { \ + if (WARN_ONCE(x, "XSAVE consistency problem: " fmt, ##__VA_ARGS__)) { \ __xstate_dump_leaves(); \ } \ } while (0) @@ -554,8 +554,7 @@ static bool __init check_xstate_against_struct(int nr) (nr >= XFEATURE_MAX) || (nr == XFEATURE_PT_UNIMPLEMENTED_SO_FAR) || ((nr >= XFEATURE_RSRVD_COMP_11) && (nr <= XFEATURE_RSRVD_COMP_16))) { - WARN_ONCE(1, "no structure for xstate: %d\n", nr); - XSTATE_WARN_ON(1); + XSTATE_WARN_ON(1, "No structure for xstate: %d\n", nr); return false; } return true; @@ -598,12 +597,13 @@ static bool __init paranoid_xstate_size_valid(unsigned int kernel_size) * XSAVES. */ if (!xsaves && xfeature_is_supervisor(i)) { - XSTATE_WARN_ON(1); + XSTATE_WARN_ON(1, "Got supervisor feature %d, but XSAVES not advertised\n", i); return false; } } size = xstate_calculate_size(fpu_kernel_cfg.max_features, compacted); - XSTATE_WARN_ON(size != kernel_size); + XSTATE_WARN_ON(size != kernel_size, + "size %u != kernel_size %u\n", size, kernel_size); return size == kernel_size; }