Message ID | 20231107182159.404770-1-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp423526vqo; Tue, 7 Nov 2023 10:22:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0cRoVbRlRoVRyp1gU+di1hHv40k8CHf+x0sGSgdfgHSTz7CIr5k2IeBsFFmBNioyw2Vsf X-Received: by 2002:a17:903:1c5:b0:1cc:66d5:493e with SMTP id e5-20020a17090301c500b001cc66d5493emr25802804plh.8.1699381365291; Tue, 07 Nov 2023 10:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699381365; cv=none; d=google.com; s=arc-20160816; b=Gf/a3/nQBzN68Z5lSZt3LtK4wZY73WDGv8E/pdKWMgPt1shKLY2phOD54A+LQtddxd 57wCTJQxXZuECXxwhGQjiAYgkyLZ1X71WHCi/aNkb0ks3XlKdCc8qy2mpvfNZN+keX6T evuDf0OWUTds+DGLoy0L5d6MsUP07lOhhdHMsOHLJEW6oUPWekKIpC8Mpvc53HeKC7Fg P/GBui0ulQjKG/nWNjE8ObicXvsgH6rldYV1pSpIWZOg9qlMKrFsuPn8XSYooepdS6lQ lpvcsYtFnGOkVbyRuV7aPPPvdrXEktnjXHKZyeGQ2as6MGkzzBxNAqBb6APtU5c8V8gw g6mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :reply-to:dkim-signature; bh=pF19+OXVW5UGsHvBJEM1Rd3K8EFj2d9Zm0BTvFFwkOQ=; fh=a/B0iV5LWklS7QUR0cRnqbJdAtXzyhd2Xbve3+VFDMU=; b=ymxCzEeoxvCywVUXdRLrH4WSOv5Pcy72KUi6AUv7v/EANPNZLEws1mBOMG4a/2AXbq 8w6VCne9cgPRiaApxObeafDaNCfU2kaNLJWeWA+nAHwFOGsDTWf7Ft42qDqP49drl/Du K7VerJFGYTU+Ph6THb+l93vC1Y6bz0g85w8398xnfSL+iCXrMQCvuiwgMxloYn4OQ7hF lYhVROfB97iAIZ82BfDk9YGKyteTWMULKtlrhg/6Tf3NLe0KNwdtOZJk2qgAaLVxfaEu fxh76oSTh/jwEu/HCtblIhVuWJooDf234P7PfCBW6DGaUqvGaJ+WOP1bDJljSyoJEE34 42Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iDLrIUwp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u4-20020a170902b28400b001cc330e48e6si299913plr.80.2023.11.07.10.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 10:22:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iDLrIUwp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A430381C00E1; Tue, 7 Nov 2023 10:22:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230505AbjKGSWF (ORCPT <rfc822;lhua1029@gmail.com> + 32 others); Tue, 7 Nov 2023 13:22:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234905AbjKGSWE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Nov 2023 13:22:04 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 551EA183 for <linux-kernel@vger.kernel.org>; Tue, 7 Nov 2023 10:22:02 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d9cb79eb417so5985303276.2 for <linux-kernel@vger.kernel.org>; Tue, 07 Nov 2023 10:22:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699381321; x=1699986121; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=pF19+OXVW5UGsHvBJEM1Rd3K8EFj2d9Zm0BTvFFwkOQ=; b=iDLrIUwp0Ijph4F3Az7lVjSHowRY4OUyYh2DU1g+ztoDpy3vYqHsAopDKg6Iz5AY/Q 1ixMOCTp18Cwu8LkaawJyZThs6812KUqudT3jwQkb+xtOXx0F1msW0veZ9exnGI5E7iW 5MiTZ8lvNH4aUqff85s9DNsZLrEvGayqZYKJlnuxGLnswPh52gxSSWSFvPSAfncMHpnI NVAboraXOtYGpuAVuvJKW0Fyb30VVN537ocaXmvdw+kdYRdOxteQkltsFnokIIa4Xko+ VwvPorGoCJ/mZnt8eVonKO/PP2oQIiFYQJnNoB6RI4jCnV4e6p4MmF4z1kjkxS99YCro 1kgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699381321; x=1699986121; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pF19+OXVW5UGsHvBJEM1Rd3K8EFj2d9Zm0BTvFFwkOQ=; b=vnzFaDU2OL8q0Syz28xid6TFlLb+ZmjJW88FN98eg4v+o+7hAvobLxx1A5e2lS01Vj KItO2R6KBYOMSVvvy1Po6aLRzhavjkKKjBdgKe/lBxjLid6BoWzkYnzDIXwHr6qIs3hL cYlzEhjvcuCajBz0KCpx/nlFtdlhXKB+B12FKgpe8kS+qTT5zpbzDrYPlxtT55FwzJ1J QZF67MWWLjR2Z7Y43bh8KPiixcCS+hYpj092YiiVUmr2Gt0TncMnIT8WGXzjeUisNpIz oq7UbdPBVIGTeP66GyvjEj0aoftN37c5csjYbuX8DWlmK4FuLVdBGIxbCrUaWWNTCIRO fbZA== X-Gm-Message-State: AOJu0YwIGgJCTFAbjl/QVhtuujwxvDYE9aZAidY4uFfi5Gw1+BatQhdN edJZkquPZBKenZDBiyMXV+kCeEwEvwU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a5b:9d2:0:b0:d9a:bce6:acf3 with SMTP id y18-20020a5b09d2000000b00d9abce6acf3mr672242ybq.0.1699381321569; Tue, 07 Nov 2023 10:22:01 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Tue, 7 Nov 2023 10:21:59 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Message-ID: <20231107182159.404770-1-seanjc@google.com> Subject: [PATCH] KVM: selftests: Fix MWAIT error message when guest assertion fails From: Sean Christopherson <seanjc@google.com> To: Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 07 Nov 2023 10:22:37 -0800 (PST) X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781930514771008089 X-GMAIL-MSGID: 1781930514771008089 |
Series |
KVM: selftests: Fix MWAIT error message when guest assertion fails
|
|
Commit Message
Sean Christopherson
Nov. 7, 2023, 6:21 p.m. UTC
Print out the test and vector as intended when a guest assert fails an
assertion regarding MONITOR/MWAIT faulting. Unfortunately, the guest
printf support doesn't detect such issues at compile-time, so the bug
manifests as a confusing error message, e.g. in the most confusing case,
the test complains that it got vector "0" instead of expected vector "0".
Fixes: 0f52e4aaa614 ("KVM: selftests: Convert the MONITOR/MWAIT test to use printf guest asserts")
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
base-commit: 45b890f7689eb0aba454fc5831d2d79763781677
Comments
On Tue, 2023-11-07 at 10:21 -0800, Sean Christopherson wrote: > Print out the test and vector as intended when a guest assert fails an > assertion regarding MONITOR/MWAIT faulting. Unfortunately, the guest > printf support doesn't detect such issues at compile-time, so the bug > manifests as a confusing error message, e.g. in the most confusing case, > the test complains that it got vector "0" instead of expected vector "0". > > Fixes: 0f52e4aaa614 ("KVM: selftests: Convert the MONITOR/MWAIT test to use printf guest asserts") > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c > index 80aa3d8b18f8..853802641e1e 100644 > --- a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c > +++ b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c > @@ -27,10 +27,12 @@ do { \ > \ > if (fault_wanted) \ > __GUEST_ASSERT((vector) == UD_VECTOR, \ > - "Expected #UD on " insn " for testcase '0x%x', got '0x%x'", vector); \ > + "Expected #UD on " insn " for testcase '0x%x', got '0x%x'", \ > + testcase, vector); \ > else \ > __GUEST_ASSERT(!(vector), \ > - "Expected success on " insn " for testcase '0x%x', got '0x%x'", vector); \ > + "Expected success on " insn " for testcase '0x%x', got '0x%x'", \ > + testcase, vector); \ > } while (0) > > static void guest_monitor_wait(int testcase) > > base-commit: 45b890f7689eb0aba454fc5831d2d79763781677 I think that these days the gcc (and llvm likely) support printf annotations, and usually complain, we should look at adding these to have a warning in such cases. Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Best regards, Maxim Levitsky
On Sun, Nov 19, 2023, Maxim Levitsky wrote: > On Tue, 2023-11-07 at 10:21 -0800, Sean Christopherson wrote: > > Print out the test and vector as intended when a guest assert fails an > > assertion regarding MONITOR/MWAIT faulting. Unfortunately, the guest > > printf support doesn't detect such issues at compile-time, so the bug > > manifests as a confusing error message, e.g. in the most confusing case, > > the test complains that it got vector "0" instead of expected vector "0". > > > > Fixes: 0f52e4aaa614 ("KVM: selftests: Convert the MONITOR/MWAIT test to use printf guest asserts") > > Signed-off-by: Sean Christopherson <seanjc@google.com> > > --- > > tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c > > index 80aa3d8b18f8..853802641e1e 100644 > > --- a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c > > +++ b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c > > @@ -27,10 +27,12 @@ do { \ > > \ > > if (fault_wanted) \ > > __GUEST_ASSERT((vector) == UD_VECTOR, \ > > - "Expected #UD on " insn " for testcase '0x%x', got '0x%x'", vector); \ > > + "Expected #UD on " insn " for testcase '0x%x', got '0x%x'", \ > > + testcase, vector); \ > > else \ > > __GUEST_ASSERT(!(vector), \ > > - "Expected success on " insn " for testcase '0x%x', got '0x%x'", vector); \ > > + "Expected success on " insn " for testcase '0x%x', got '0x%x'", \ > > + testcase, vector); \ > > } while (0) > > > > static void guest_monitor_wait(int testcase) > > > > base-commit: 45b890f7689eb0aba454fc5831d2d79763781677 > > I think that these days the gcc (and llvm likely) support printf annotations, > and usually complain, we should look at adding these to have a warning in > such cases. Huh. Well now I feel quite stupid for not realizing that's what __attribute__((__format__(printf, ...))) is for. There's even a handy dandy __printf() macro now. I'll post a v2 with the annotations and fixes for all existing violations.
diff --git a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c index 80aa3d8b18f8..853802641e1e 100644 --- a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c +++ b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c @@ -27,10 +27,12 @@ do { \ \ if (fault_wanted) \ __GUEST_ASSERT((vector) == UD_VECTOR, \ - "Expected #UD on " insn " for testcase '0x%x', got '0x%x'", vector); \ + "Expected #UD on " insn " for testcase '0x%x', got '0x%x'", \ + testcase, vector); \ else \ __GUEST_ASSERT(!(vector), \ - "Expected success on " insn " for testcase '0x%x', got '0x%x'", vector); \ + "Expected success on " insn " for testcase '0x%x', got '0x%x'", \ + testcase, vector); \ } while (0) static void guest_monitor_wait(int testcase)