linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Jim Mattson <jmattson@google.com>,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Liran Alon <liran.alon@oracle.com>,
	Miaohe Lin <linmiaohe@huawei.com>
Subject: [PATCH 6/6] KVM: selftests: enlightened VMPTRLD with an incorrect GPA
Date: Mon,  9 Mar 2020 16:52:16 +0100	[thread overview]
Message-ID: <20200309155216.204752-7-vkuznets@redhat.com> (raw)
In-Reply-To: <20200309155216.204752-1-vkuznets@redhat.com>

Check that guest doesn't hang when an invalid eVMCS GPA is specified.
Testing that #UD is injected would probably be better but selftests lack
the infrastructure currently.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 tools/testing/selftests/kvm/x86_64/evmcs_test.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/x86_64/evmcs_test.c b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
index 10e9c158dc96..fed8f933748b 100644
--- a/tools/testing/selftests/kvm/x86_64/evmcs_test.c
+++ b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
@@ -72,6 +72,10 @@ void guest_code(struct vmx_pages *vmx_pages)
 		l1_guest_code(vmx_pages);
 
 	GUEST_DONE();
+
+	/* Try enlightened vmptrld with an incorrect GPA */
+	evmcs_vmptrld(0xdeadbeef, vmx_pages->enlightened_vmcs);
+	GUEST_ASSERT(vmlaunch());
 }
 
 int main(int argc, char *argv[])
@@ -120,7 +124,7 @@ int main(int argc, char *argv[])
 		case UCALL_SYNC:
 			break;
 		case UCALL_DONE:
-			goto done;
+			goto part1_done;
 		default:
 			TEST_ASSERT(false, "Unknown ucall 0x%x.", uc.cmd);
 		}
@@ -152,6 +156,10 @@ int main(int argc, char *argv[])
 			    (ulong) regs2.rdi, (ulong) regs2.rsi);
 	}
 
-done:
+part1_done:
+	_vcpu_run(vm, VCPU_ID);
+	TEST_ASSERT(run->exit_reason == KVM_EXIT_SHUTDOWN,
+		    "Unexpected successful VMEnter with invalid eVMCS pointer!");
+
 	kvm_vm_free(vm);
 }
-- 
2.24.1


  parent reply	other threads:[~2020-03-09 15:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 15:52 [PATCH 0/6] KVM: nVMX: propperly handle enlightened vmptrld failure conditions Vitaly Kuznetsov
2020-03-09 15:52 ` [PATCH 1/6] KVM: nVMX: avoid NULL pointer dereference with incorrect EVMCS GPAs Vitaly Kuznetsov
2020-03-09 15:52 ` [PATCH 2/6] KVM: nVMX: stop abusing need_vmcs12_to_shadow_sync for eVMCS mapping Vitaly Kuznetsov
2020-03-09 15:52 ` [PATCH 3/6] KVM: nVMX: properly handle errors in nested_vmx_handle_enlightened_vmptrld() Vitaly Kuznetsov
2020-03-10 20:08   ` kbuild test robot
2020-03-10 20:08   ` [RFC PATCH] KVM: nVMX: nested_vmx_handle_enlightened_vmptrld() can be static kbuild test robot
2020-03-11 11:49     ` Vitaly Kuznetsov
2020-03-11 17:45       ` Paolo Bonzini
2020-03-09 15:52 ` [PATCH 4/6] KVM: selftests: define and use EVMCS_VERSION Vitaly Kuznetsov
2020-03-09 15:52 ` [PATCH 5/6] KVM: selftests: test enlightened vmenter with wrong eVMCS version Vitaly Kuznetsov
2020-03-09 15:52 ` Vitaly Kuznetsov [this message]
2020-03-14 11:52 ` [PATCH 0/6] KVM: nVMX: propperly handle enlightened vmptrld failure conditions Paolo Bonzini

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=20200309155216.204752-7-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liran.alon@oracle.com \
    --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).