From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: Yosry Ahmed <yosry@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] KVM: selftests: Add a test for gPAT handling in L2
Date: Fri, 29 May 2026 15:55:57 -0700 [thread overview]
Message-ID: <ahoZfWeYsAICk9xc@google.com> (raw)
In-Reply-To: <CALMp9eQ+XmKbpY8QePbjZMA9fNm4-77zbDBNX2M-ZOdumNGyxw@mail.gmail.com>
On Fri, May 29, 2026, Jim Mattson wrote:
> On Fri, May 29, 2026 at 6:29 AM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Thu, May 28, 2026, Yosry Ahmed wrote:
> > > > +int main(int argc, char *argv[])
> > > > +{
> > > > + TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
> > > > + TEST_REQUIRE(kvm_has_cap(KVM_CAP_NESTED_STATE));
> > > > + TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) &
> > > > + KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT);
> > > > +
> > > > + if (!kvm_cpu_has(X86_FEATURE_NPT))
> > > > + goto skip_npt;
> > > > +
> > > > + gpat_test("Invalid gPAT", l1_guest_code_invalid_gpat, npt_enabled = true);
> > > > + gpat_test("Nested NPT enabled", l1_guest_code, npt_enabled = true);
> > > > +skip_npt:
> > > > + gpat_test("Nested NPT disabled", l1_guest_code, npt_enabled = false);
> > > > + return 0;
> > > > +}
> > >
> > > The goto is really unnecessary here:
> > >
> > > if (kvm_cpu_has(X86_FEATURE_NPT)) {
> > > gpat_test("Invalid gPAT", l1_guest_code_invalid_gpat,
> > > npt_enabled = true);
> > > gpat_test("Nested NPT enabled", l1_guest_code, npt_enabled = true);
> > > }
> > > gpat_test("Nested NPT disabled", l1_guest_code, npt_enabled = false);
> >
> > Well, it's necessary to avoid the indentation.
>
> Or refactor as:
>
> if (kvm_cpu_has(X86_FEATURE_NPT))
> run_npt_tests();
Anyone have a strong preference? I like the goto approach (obviously), so that
that all the gpat_test() invocations are prettily aligned. But I can live with
an if-statement as Yosry suggested. I think the only option I don't like is
moving the NPT tests to a separate helper (it's two lines of code, and testing
the NPT case really is the focal point of the test).
next prev parent reply other threads:[~2026-05-29 22:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 23:10 [PATCH v4] KVM: selftests: Add a test for gPAT handling in L2 Sean Christopherson
2026-05-29 0:47 ` Yosry Ahmed
2026-05-29 13:27 ` Sean Christopherson
2026-05-29 14:10 ` Jim Mattson
2026-05-29 22:55 ` Sean Christopherson [this message]
2026-05-29 23:01 ` Yosry Ahmed
2026-06-03 18:33 ` Sean Christopherson
2026-06-03 18:39 ` Yosry Ahmed
2026-06-05 18:31 ` Sean Christopherson
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=ahoZfWeYsAICk9xc@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yosry@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.