kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krish Sadhukhan <krish.sadhukhan@oracle.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, jmattson@google.com,
	sean.j.christopherson@intel.com
Subject: [PATCH 3/3] kvm-unit-tests: nVMX: Test GUEST_LIMIT_GDTR and GUEST_LIMIT_IDTR on vmentry of nested guests
Date: Fri, 22 May 2020 20:26:03 -0400	[thread overview]
Message-ID: <20200523002603.32450-4-krish.sadhukhan@oracle.com> (raw)
In-Reply-To: <20200523002603.32450-1-krish.sadhukhan@oracle.com>

According to section "Checks on Guest Descriptor-Table Registers" in Intel
SDM vol 3C, the following checks are performed on the Guest Descriptor-Table
Registers on vmentry of nested guests:

    - Bits 31:16 of each limit field must be 0.

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 x86/vmx_tests.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index f400408..7b6205d 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -7836,6 +7836,17 @@ static void vmx_guest_state_area_test(void)
 	test_canonical(GUEST_BASE_IDTR, "GUEST_BASE_IDTR", false);
 #endif
 
+	u32 guest_desc_limit_saved = vmcs_read(GUEST_LIMIT_GDTR);
+	TEST_GUEST_VMCS_FIELD_RESERVED_BITS(16, 31, 4, GUEST_LIMIT_GDTR,
+	    "GUEST_LIMIT_GDTR", guest_desc_limit_saved, "GUEST_LIMIT_GDTR",
+	    true);
+	vmcs_write(GUEST_LIMIT_GDTR, guest_desc_limit_saved);
+	guest_desc_limit_saved = vmcs_read(GUEST_LIMIT_IDTR);
+	TEST_GUEST_VMCS_FIELD_RESERVED_BITS(16, 31, 4, GUEST_LIMIT_IDTR,
+	    "GUEST_LIMIT_IDTR", guest_desc_limit_saved, "GUEST_LIMIT_IDTR",
+	    true);
+	vmcs_write(GUEST_LIMIT_IDTR, guest_desc_limit_saved);
+
 	/*
 	 * Let the guest finish execution
 	 */
-- 
1.8.3.1


      parent reply	other threads:[~2020-05-23  1:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-23  0:26 [PATCH 0/3] kvm-unit-tests: nVMX: Test base and limit fields of guest GDTR and IDTR Krish Sadhukhan
2020-05-23  0:26 ` [PATCH 1/3] kvm-unit-tests: nVMX: Test GUEST_BASE_GDTR and GUEST_BASE_IDTR on vmentry of nested guests Krish Sadhukhan
2020-05-27  5:17   ` Sean Christopherson
2020-05-23  0:26 ` [PATCH 2/3] kvm-unit-tests: nVMX: Optimize test_guest_dr7() by factoring out the loops into a macro Krish Sadhukhan
2020-05-23  0:26 ` Krish Sadhukhan [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=20200523002603.32450-4-krish.sadhukhan@oracle.com \
    --to=krish.sadhukhan@oracle.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.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).