From: Sean Christopherson <seanjc@google.com>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [kvm-unit-tests PATCH 5/5] nVMX: add a test for canonical checks of various host state vmcs12 fields.
Date: Fri, 14 Feb 2025 14:08:18 -0800 [thread overview]
Message-ID: <Z6--0nKVbsxfm9ao@google.com> (raw)
In-Reply-To: <20240907005440.500075-6-mlevitsk@redhat.com>
On Fri, Sep 06, 2024, Maxim Levitsky wrote:
> +#define TEST_VALUE1 0xff45454545000000
> +#define TEST_VALUE2 0xff55555555000000
> +
> +static void vmx_canonical_test_guest(void)
> +{
> + while (true)
> + vmcall();
> +}
...
> +static void test_host_value_natively(const char *field_name, u64 vmcs_field, u64 value)
The error messages say "directly", wheras this says "natively". I don't have a
strong preference, but they should use the same terminology. I'll go with
"direct", because "native" has paravirt connotations that could confuse things.
> +{
> + int vector;
> + u64 actual_value;
> +
> + /*
> + * Set the register via host native interface (e.g lgdt) and check
> + * that we got no exception
> + */
> + vector = set_host_value(vmcs_field, value);
> + if (vector) {
> + report(false,
report_fail()
> + "Exception %d when setting %s to 0x%lx via host",
> + vector, field_name, value);
> + return;
> + }
> +
> + /*
> + * Now check that the host value matches what we expect for fields
> + * that can be read back (these that we can't we assume that are correct)
> + */
> +
> + if (get_host_value(vmcs_field, &actual_value))
> + actual_value = value;
> +
> + report(actual_value == value,
Rather than clobber actual_value, incorporate the get() in the report, e.g.
report(get_host_value(vmcs_field, &actual_value) || actual_value == value
> + "%s: HOST value is set to test value 0x%lx directly",
> + field_name, value);
Print the actual value as well, otherwise debugging is painful (well, more painful).
> +}
> +
> +static void test_host_value_via_guest(const char *field_name, u64 vmcs_field, u64 value)
It's not via "guest", it's via the HOST_xxx fields in the VMCS. test_host_value_vmcs()?
> +{
> + u64 actual_value;
> +
> + /* Set host state field in the vmcs and do the VM entry
> + * Success of VM entry already shows that L0 accepted the value
> + */
> + vmcs_write(vmcs_field, TEST_VALUE2);
This should be value, not TEST_VALUE2. Ditto below. The whole @value idea is
rather pointless though. There's one caller, and it passes one value. The only
requirement is that the "direct" vs. "vmcs" settings use different values, e.g.
to avoid false passes. To handle that, just use more descriptive names for the
#defines.
> + enter_guest();
> + skip_exit_vmcall();
> +
> + /*
> + * Now check that the host value matches what we expect for fields
> + * that can be read back (these that we can't we assume that are correct)
> + */
> +
> + if (get_host_value(vmcs_field, &actual_value))
> + actual_value = value;
> +
> + /* Check that now the msr value is the same as the field value */
> + report(actual_value == TEST_VALUE2,
> + "%s: HOST value is set to test value 0x%lx via VMLAUNCH/VMRESUME",
> + field_name, value);
> +}
next prev parent reply other threads:[~2025-02-14 22:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-07 0:54 [kvm-unit-tests PATCH 0/5] Collection of tests for canonical checks on LA57 enabled CPUs Maxim Levitsky
2024-09-07 0:54 ` [kvm-unit-tests PATCH 1/5] x86: add _safe and _fep_safe variants to segment base load instructions Maxim Levitsky
2024-09-07 0:54 ` [kvm-unit-tests PATCH 2/5] x86: add a few functions for gdt manipulation Maxim Levitsky
2024-09-07 0:54 ` [kvm-unit-tests PATCH 3/5] x86: move struct invpcid_desc descriptor to processor.h Maxim Levitsky
2024-09-07 0:54 ` [kvm-unit-tests PATCH 4/5] Add a test for writing canonical values to various msrs and fields Maxim Levitsky
2025-02-14 22:00 ` Sean Christopherson
2024-09-07 0:54 ` [kvm-unit-tests PATCH 5/5] nVMX: add a test for canonical checks of various host state vmcs12 fields Maxim Levitsky
2025-02-14 22:08 ` Sean Christopherson [this message]
2024-11-03 21:08 ` [kvm-unit-tests PATCH 0/5] Collection of tests for canonical checks on LA57 enabled CPUs Maxim Levitsky
2024-11-22 1:31 ` Maxim Levitsky
2024-12-14 0:19 ` Maxim Levitsky
2025-02-14 21:25 ` Sean Christopherson
2025-02-24 17:23 ` 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=Z6--0nKVbsxfm9ao@google.com \
--to=seanjc@google.com \
--cc=kvm@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