From: Sean Christopherson <seanjc@google.com>
To: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com
Subject: Re: [PATCH 4/5 v4] nSVM: Test addresses of MSR and IO permissions maps
Date: Wed, 24 Mar 2021 19:21:00 +0000 [thread overview]
Message-ID: <YFuRHBVy1cp+R7FQ@google.com> (raw)
In-Reply-To: <20210324175006.75054-5-krish.sadhukhan@oracle.com>
On Wed, Mar 24, 2021, Krish Sadhukhan wrote:
> According to section "Canonicalization and Consistency Checks" in APM vol 2,
> the following guest state is illegal:
>
> "The MSR or IOIO intercept tables extend to a physical address that
> is greater than or equal to the maximum supported physical address."
>
> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> ---
> x86/svm_tests.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/x86/svm_tests.c b/x86/svm_tests.c
> index 29a0b59..70442d2 100644
> --- a/x86/svm_tests.c
> +++ b/x86/svm_tests.c
> @@ -2304,6 +2304,33 @@ static void test_dr(void)
> vmcb->save.dr7 = dr_saved;
> }
>
> +/*
> + * If the MSR or IOIO intercept table extends to a physical address that
> + * is greater than or equal to the maximum supported physical address, the
> + * guest state is illegal.
> + *
> + * [ APM vol 2]
> + */
> +static void test_msrpm_iopm_bitmap_addrs(void)
> +{
> + u64 addr_spill_beyond_ram =
FWIW, it's not "beyond ram", it's beyond the legal physical address space. E.g.
the address can point at stuff other than RAM and be perfectly legal from a
consistency check perspective.
> + (u64)(((u64)1 << cpuid_maxphyaddr()) - 4096);
It'd be nice to also check a straight legal address, and an address that
straddles the high address => 0.
> +
> + /* MSR bitmap address */
> + vmcb->control.intercept |= 1ULL << INTERCEPT_MSR_PROT;
> + vmcb->control.msrpm_base_pa = addr_spill_beyond_ram;
> + report(svm_vmrun() == SVM_EXIT_ERR, "Test MSRPM address: %lx",
> + addr_spill_beyond_ram);
> + vmcb->control.intercept &= ~(1ULL << INTERCEPT_MSR_PROT);
> +
> + /* MSR bitmap address */
> + vmcb->control.intercept |= 1ULL << INTERCEPT_IOIO_PROT;
> + vmcb->control.msrpm_base_pa = addr_spill_beyond_ram;
Wrong bitmap.
> + report(svm_vmrun() == SVM_EXIT_ERR, "Test IOPM address: %lx",
> + addr_spill_beyond_ram);
> + vmcb->control.intercept &= ~(1ULL << INTERCEPT_IOIO_PROT);
The control should be save/restored, assuming the intercepts were clear will
cause reproducibility issues for other tests.
> +}
> +
> static void svm_guest_state_test(void)
> {
> test_set_guest(basic_guest_main);
> @@ -2313,6 +2340,7 @@ static void svm_guest_state_test(void)
> test_cr3();
> test_cr4();
> test_dr();
> + test_msrpm_iopm_bitmap_addrs();
> }
>
>
> --
> 2.27.0
>
next prev parent reply other threads:[~2021-03-24 19:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-24 17:50 [PATCH 0/5 v4] KVM: nSVM: Check addresses of MSR bitmap and IO bitmap tables on vmrun of nested guests Krish Sadhukhan
2021-03-24 17:50 ` [PATCH 1/5 v4] KVM: SVM: Move IOPM_ALLOC_ORDER and MSRPM_ALLOC_ORDER #defines to svm.h Krish Sadhukhan
2021-03-24 17:50 ` [PATCH 2/5 v4] KVM: nSVM: Check addresses of MSR and IO permission maps Krish Sadhukhan
2021-03-24 19:15 ` Sean Christopherson
2021-03-25 1:16 ` Krish Sadhukhan
2021-03-24 17:50 ` [PATCH 3/5 v4] KVM: nSVM: Cleanup in nested_svm_vmrun() Krish Sadhukhan
2021-03-24 17:50 ` [PATCH 4/5 v4] nSVM: Test addresses of MSR and IO permissions maps Krish Sadhukhan
2021-03-24 19:21 ` Sean Christopherson [this message]
2021-03-24 17:50 ` [PATCH 5/5 v4] SVM: Use ALIGN macro when aligning 'io_bitmap_area' Krish Sadhukhan
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=YFuRHBVy1cp+R7FQ@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=krish.sadhukhan@oracle.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 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.