[kvm-unit-tests PATCH 2/5] x86: Convert inputs-only "safe" instruction helpers to asm_safe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Convert processor.h's "safe" helpers that do not have outputs to use
asm_safe() instead of open coding the equivalent.  Leave instructions
without outputs for a separate, future change as handling outputs is a
bit more complex.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
 lib/x86/processor.h | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index 6555056e..e05b3fd0 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -434,11 +434,7 @@ static inline int wrmsr_safe(u32 index, u64 val)
 {
 	u32 a = val, d = val >> 32;
 
-	asm volatile (ASM_TRY("1f")
-		      "wrmsr\n\t"
-		      "1:"
-		      : : "a"(a), "d"(d), "c"(index) : "memory");
-	return exception_vector();
+	return asm_safe("wrmsr", "a"(a), "d"(d), "c"(index));
 }
 
 static inline int rdpmc_safe(u32 index, uint64_t *val)
@@ -465,10 +461,7 @@ static inline uint64_t rdpmc(uint32_t index)
 
 static inline int write_cr0_safe(ulong val)
 {
-	asm volatile(ASM_TRY("1f")
-		     "mov %0,%%cr0\n\t"
-		     "1:": : "r" (val));
-	return exception_vector();
+	return asm_safe("mov %0,%%cr0", "r" (val));
 }
 
 static inline void write_cr0(ulong val)
@@ -500,10 +493,7 @@ static inline ulong read_cr2(void)
 
 static inline int write_cr3_safe(ulong val)
 {
-	asm volatile(ASM_TRY("1f")
-		     "mov %0,%%cr3\n\t"
-		     "1:": : "r" (val));
-	return exception_vector();
+	return asm_safe("mov %0,%%cr3", "r" (val));
 }
 
 static inline void write_cr3(ulong val)
@@ -528,10 +518,7 @@ static inline void update_cr3(void *cr3)
 
 static inline int write_cr4_safe(ulong val)
 {
-	asm volatile(ASM_TRY("1f")
-		     "mov %0,%%cr4\n\t"
-		     "1:": : "r" (val));
-	return exception_vector();
+	return asm_safe("mov %0,%%cr4", "r" (val));
 }
 
 static inline void write_cr4(ulong val)
-- 
2.40.0.348.gf938b09366-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux