kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com
Subject: Re: [PATCH 0/8] Add printf and formatted asserts in the guest
Date: Thu, 23 Mar 2023 13:57:30 -0700	[thread overview]
Message-ID: <ZBy9OjvXoq0PM7Kz@google.com> (raw)
In-Reply-To: <20230301053425.3880773-1-aaronlewis@google.com>

On Wed, Mar 01, 2023, Aaron Lewis wrote:
> I say unintentionally assert because the test ends with a formatted
> assert firing.  This is intentional, and is meant to demonstrate the
> formatted assert.
> 
> That is one reason I don't really expect the selftest to be accepted with
> this series.  The other reason is it doesn't test anything in the kernel.

I don't have any objection to a selftest that tests selftests.  But it should
actually be a proper test and not something the user has to manually verify.
One thought would be to have the host side of the test pass in params to the
guest, and then have the the guest assert (or not) with a hardcoded format string.

Then on the host side, don't treat UCALL_ABORT as a failure and instead verify
that it fired when expected, and also provided the correct string, e.g. with a
strcmp() or whatever.  And do the same for GUEST_PRINTF/UCALL_PRINTF.

And it should be arch-agnostic, because at a galnce, the actual guts in patches 3-7
don't have an arch specific enabling.

E.g. something like this, and then use PRINTF_STRING and ASSERT_STRING in the
host to generate and verify the string.

#define PRINTF_STRING "Got params a = '0x%lx' and b = '0x%lx instead'"
#define ASSERT_STRING "Expected 0x%lx, got 0x%lx instead"

static void guest_code(uint64_t a, uint64_t b)
{
	GUEST_PRINTF(PRINTF_STRING, a, b);
	GUEST_ASSERT_FMT(a == b, ASSERT_FMT, a, b);
	GUEST_DONE();
}

> And if the selftest is not accepted then the first two patches can be
> omitted too.  The core of the series are patches 3-7.

As above, the first two patches should be omitted anyways, because guest_print_test.c
shouldn't be x86-specific.

      parent reply	other threads:[~2023-03-23 20:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01  5:34 [PATCH 0/8] Add printf and formatted asserts in the guest Aaron Lewis
2023-03-01  5:34 ` [PATCH 1/8] KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible Aaron Lewis
2023-03-01  5:34 ` [PATCH 2/8] KVM: selftests: Add XFEATURE masks to common code Aaron Lewis
2023-03-01  5:34 ` [PATCH 3/8] KVM: selftests: Add strnlen() to the string overrides Aaron Lewis
2023-03-01  5:34 ` [PATCH 4/8] KVM: selftests: Copy printf.c to KVM selftests Aaron Lewis
2023-03-23 22:04   ` Sean Christopherson
2023-04-17 15:59     ` Aaron Lewis
2023-04-18 15:03       ` Sean Christopherson
2023-04-18 16:06         ` Andrew Jones
2023-04-20 17:50           ` Sean Christopherson
2023-04-21  6:03             ` Andrew Jones
2023-03-01  5:34 ` [PATCH 5/8] KVM: selftests: Add vsprintf() " Aaron Lewis
2023-03-23 21:59   ` Sean Christopherson
2023-04-17 16:08     ` Aaron Lewis
2023-04-18 15:04       ` Sean Christopherson
2023-03-01  5:34 ` [PATCH 6/8] KVM: selftests: Add additional pages to the guest to accommodate ucall Aaron Lewis
2023-03-23 22:07   ` Sean Christopherson
2023-03-01  5:34 ` [PATCH 7/8] KVM: selftests: Add string formatting options to ucall Aaron Lewis
2023-03-01  8:07   ` Shaoqin Huang
2023-03-02 14:52     ` Aaron Lewis
2023-03-23 22:12   ` Sean Christopherson
2023-03-01  5:34 ` [PATCH 8/8] KVM: selftests: Add a selftest for guest prints and formatted asserts Aaron Lewis
2023-03-23 20:57 ` 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=ZBy9OjvXoq0PM7Kz@google.com \
    --to=seanjc@google.com \
    --cc=aaronlewis@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --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).