Commit 17ae5ebc authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: selftests: Define cpu_relax() helpers for s390 and x86

Add cpu_relax() for s390 and x86 for use in arch-agnostic tests.  arm64
already defines its own version.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Message-Id: <20220226001546.360188-28-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent a4187c9b
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef SELFTEST_KVM_PROCESSOR_H #ifndef SELFTEST_KVM_PROCESSOR_H
#define SELFTEST_KVM_PROCESSOR_H #define SELFTEST_KVM_PROCESSOR_H
#include <linux/compiler.h>
/* Bits in the region/segment table entry */ /* Bits in the region/segment table entry */
#define REGION_ENTRY_ORIGIN ~0xfffUL /* region/segment table origin */ #define REGION_ENTRY_ORIGIN ~0xfffUL /* region/segment table origin */
#define REGION_ENTRY_PROTECT 0x200 /* region protection bit */ #define REGION_ENTRY_PROTECT 0x200 /* region protection bit */
...@@ -19,4 +21,10 @@ ...@@ -19,4 +21,10 @@
#define PAGE_PROTECT 0x200 /* HW read-only bit */ #define PAGE_PROTECT 0x200 /* HW read-only bit */
#define PAGE_NOEXEC 0x100 /* HW no-execute bit */ #define PAGE_NOEXEC 0x100 /* HW no-execute bit */
/* Is there a portable way to do this? */
static inline void cpu_relax(void)
{
barrier();
}
#endif #endif
...@@ -363,6 +363,11 @@ static inline unsigned long get_xmm(int n) ...@@ -363,6 +363,11 @@ static inline unsigned long get_xmm(int n)
return 0; return 0;
} }
static inline void cpu_relax(void)
{
asm volatile("rep; nop" ::: "memory");
}
bool is_intel_cpu(void); bool is_intel_cpu(void);
bool is_amd_cpu(void); bool is_amd_cpu(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment