Some tests may require to know the current RIP to compares tests results. Add a function to read current RIP. This will be used by a test in this series. Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> --- 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