[patch 3/8] test: protect fwcfg accesses with lock

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

 



So multiple CPU's can access fwcfg safely.

Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>

Index: qemu-kvm/kvm/user/test/lib/x86/fwcfg.c
===================================================================
--- qemu-kvm.orig/kvm/user/test/lib/x86/fwcfg.c
+++ qemu-kvm/kvm/user/test/lib/x86/fwcfg.c
@@ -1,4 +1,7 @@
 #include "fwcfg.h"
+#include "smp.h"
+
+static struct spinlock lock;
 
 uint64_t fwcfg_get_u(uint16_t index, int bytes)
 {
@@ -6,11 +9,13 @@ uint64_t fwcfg_get_u(uint16_t index, int
     uint8_t b;
     int i;
 
+    spin_lock(&lock);
     asm volatile ("out %0, %1" : : "a"(index), "d"((uint16_t)BIOS_CFG_IOPORT));
     for (i = 0; i < bytes; ++i) {
         asm volatile ("in %1, %0" : "=a"(b) : "d"((uint16_t)(BIOS_CFG_IOPORT + 1)));
         r |= (uint64_t)b << (i * 8);
     }
+    spin_unlock(&lock);
     return r;
 }
 


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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