Re: [PATCH v4] KVM: selftests: Add a test for gPAT handling in L2
From: Sean Christopherson
Date: Fri May 29 2026 - 09:29:45 EST
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.