All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krish Sadhukhan <krish.sadhukhan@oracle.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com,
	vkuznets@redhat.com, wanpengli@tencent.com, joro@8bytes.org
Subject: [PATCH 1/2 v2] nSVM: Add a variant of svm_vmrun() for setting guest RIP to custom code
Date: Mon, 19 Jul 2021 13:46:16 -0400	[thread overview]
Message-ID: <20210719174617.241568-2-krish.sadhukhan@oracle.com> (raw)
In-Reply-To: <20210719174617.241568-1-krish.sadhukhan@oracle.com>

Current implementations of svm_vmrun() and test_run() set the guest RIP to a
wrapper function which executes the guest code being used by tests. This is
not suitable for tests like testing the effect of guest EFLAGS.TF on VMRUN
because the trap handler will point to the second guest instruction to which
the test code does not have access.

Therefore, move the contents of svm_vmrun() to a new function called
__svm_vmrun() and add guest RIP as a function parameter so that it will
set the VMCB guest RIP field to the memory location passed in. Call this
new function in svm_vmrun() and pass the wrapper guest code in order to
maintain the existing interface.

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 x86/svm.c | 9 +++++++--
 x86/svm.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/x86/svm.c b/x86/svm.c
index f185ca0..4b46281 100644
--- a/x86/svm.c
+++ b/x86/svm.c
@@ -227,9 +227,9 @@ struct svm_test *v2_test;
 
 u64 guest_stack[10000];
 
-int svm_vmrun(void)
+int __svm_vmrun(u64 rip)
 {
-	vmcb->save.rip = (ulong)test_thunk;
+	vmcb->save.rip = (ulong)rip;
 	vmcb->save.rsp = (ulong)(guest_stack + ARRAY_SIZE(guest_stack));
 	regs.rdi = (ulong)v2_test;
 
@@ -244,6 +244,11 @@ int svm_vmrun(void)
 	return (vmcb->control.exit_code);
 }
 
+int svm_vmrun(void)
+{
+	return __svm_vmrun((u64)test_thunk);
+}
+
 extern u64 *vmrun_rip;
 
 static void test_run(struct svm_test *test)
diff --git a/x86/svm.h b/x86/svm.h
index 995b0f8..92fa277 100644
--- a/x86/svm.h
+++ b/x86/svm.h
@@ -408,6 +408,7 @@ void inc_test_stage(struct svm_test *test);
 void vmcb_ident(struct vmcb *vmcb);
 struct regs get_regs(void);
 void vmmcall(void);
+int __svm_vmrun(u64 rip);
 int svm_vmrun(void);
 void test_set_guest(test_guest_func func);
 
-- 
2.27.0


  reply	other threads:[~2021-07-19 21:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19 17:46 [PATCH 0/2 v2] Test: nSVM: Test the effect of guest EFLAGS.TF on VMRUN Krish Sadhukhan
2021-07-19 17:46 ` Krish Sadhukhan [this message]
2021-07-19 17:46 ` [PATCH 2/2 " Krish Sadhukhan
2021-07-26 12:14 ` [PATCH 0/2 " 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=20210719174617.241568-2-krish.sadhukhan@oracle.com \
    --to=krish.sadhukhan@oracle.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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.