From: Sean Christopherson <seanjc@google.com>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Fix MWAIT error message when guest assertion fails
Date: Tue, 28 Nov 2023 10:36:56 -0800 [thread overview]
Message-ID: <ZWYzSMWtwDiSFUR1@google.com> (raw)
In-Reply-To: <c964b29b08854b2779a75584cf2c3bb1e5ccb26a.camel@redhat.com>
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.
prev parent reply other threads:[~2023-11-28 18:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 18:21 [PATCH] KVM: selftests: Fix MWAIT error message when guest assertion fails Sean Christopherson
2023-11-19 17:38 ` Maxim Levitsky
2023-11-28 18:36 ` Sean Christopherson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZWYzSMWtwDiSFUR1@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).