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, seanjc@google.com
Subject: [PATCH 2/4 v5] KVM: X86: Add a utility function to read current RIP
Date: Tue, 23 Mar 2021 13:50:04 -0400	[thread overview]
Message-ID: <20210323175006.73249-3-krish.sadhukhan@oracle.com> (raw)
In-Reply-To: <20210323175006.73249-1-krish.sadhukhan@oracle.com>

Some tests may require to know the current RIP to compares tests results. Add
a function to read current RIP.

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 lib/x86/processor.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index 87112bd..5604874 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -489,6 +489,13 @@ static inline unsigned long long rdtsc(void)
 	return r;
 }
 
+static inline u64 read_rip(void)
+{
+	u64 val;
+	asm volatile ("lea (%%rip),%0" : "=r"(val) : : "memory");
+	return val;
+}
+
 /*
  * Per the advice in the SDM, volume 2, the sequence "mfence; lfence"
  * executed immediately before rdtsc ensures that rdtsc will be
-- 
2.27.0


  parent reply	other threads:[~2021-03-23 18:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 17:50 [PATCH 0/4 v5] nSVM: Test host RFLAGS.TF on VMRUN Krish Sadhukhan
2021-03-23 17:50 ` [PATCH 1/4 v5] KVM: nSVM: If VMRUN is single-stepped, queue the #DB intercept in nested_svm_vmexit() Krish Sadhukhan
2021-03-26 17:32   ` Paolo Bonzini
2021-03-30  0:16     ` Krish Sadhukhan
2021-03-23 17:50 ` Krish Sadhukhan [this message]
2021-03-23 17:50 ` [PATCH 3/4 v5] KVM: nSVM: Add assembly label to VMRUN instruction Krish Sadhukhan
2021-03-23 17:50 ` [PATCH 4/4 v5] nSVM: Test effect of host RFLAGS.TF on VMRUN Krish Sadhukhan
2021-03-26 17:35 ` [PATCH 0/4 v5] nSVM: Test " 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=20210323175006.73249-3-krish.sadhukhan@oracle.com \
    --to=krish.sadhukhan@oracle.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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).