Use barrier() for memory mapped IO functions.
This fixes pvscsi driver to boot on QEMU's pvscsi controller. Test command: qemu -m 512 --enable-kvm -device pvscsi,id=pvscsi0 -device scsi-disk,bus=pvscsi0.0,drive=drive0 -drive id=drive0,if=none,file=ubuntu1410.img,if=none -bios seabios/out/bios.bin
Signed-off-by: Ameya Palande 2ameya@gmail.com --- src/x86.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/x86.h b/src/x86.h index 57773d2..570f2f6 100644 --- a/src/x86.h +++ b/src/x86.h @@ -176,22 +176,37 @@ static inline void outsl(u16 port, u32 *data, u32 count) { }
static inline void writel(void *addr, u32 val) { + barrier(); *(volatile u32 *)addr = val; } static inline void writew(void *addr, u16 val) { + barrier(); *(volatile u16 *)addr = val; } static inline void writeb(void *addr, u8 val) { + barrier(); *(volatile u8 *)addr = val; } static inline u32 readl(const void *addr) { - return *(volatile const u32 *)addr; + u32 val; + + val = *(volatile const u32 *)addr; + barrier(); + return val; } static inline u16 readw(const void *addr) { - return *(volatile const u16 *)addr; + u16 val; + + val = *(volatile const u16 *)addr; + barrier(); + return val; } static inline u8 readb(const void *addr) { - return *(volatile const u8 *)addr; + u8 val; + + val = *(volatile const u8 *)addr; + barrier(); + return val; }
// GDT bits
On Tue, Feb 17, 2015 at 02:00:49PM -0800, Ameya Palande wrote:
Use barrier() for memory mapped IO functions.
This fixes pvscsi driver to boot on QEMU's pvscsi controller. Test command: qemu -m 512 --enable-kvm -device pvscsi,id=pvscsi0 -device scsi-disk,bus=pvscsi0.0,drive=drive0 -drive id=drive0,if=none,file=ubuntu1410.img,if=none -bios seabios/out/bios.bin
Thanks. I didn't think it was standard for a barrier to be present in these functions, but I now see that Linux also uses barrier here. So, I've committed your patch (with a couple of minor changes).
Thanks, also, for tracking down the PVSCSI problem.
-Kevin
Hi Kevin,
On Wed, Feb 18, 2015 at 12:15 PM, Kevin O'Connor kevin@koconnor.net wrote:
On Tue, Feb 17, 2015 at 02:00:49PM -0800, Ameya Palande wrote:
Use barrier() for memory mapped IO functions.
This fixes pvscsi driver to boot on QEMU's pvscsi controller. Test command: qemu -m 512 --enable-kvm -device pvscsi,id=pvscsi0 -device scsi-disk,bus=pvscsi0.0,drive=drive0 -drive id=drive0,if=none,file=ubuntu1410.img,if=none -bios seabios/out/bios.bin
Thanks. I didn't think it was standard for a barrier to be present in these functions, but I now see that Linux also uses barrier here. So, I've committed your patch (with a couple of minor changes).
Thanks for applying this patch!
Since memory mapped read and write are now protected by barriers, how should we deal about use of (potentially redundant) barriers in: src/hw/usb-ehci.c src/hw/usb-ohci.c src/hw/usb-uhci.c
Interestingly "src/hw/usb-xhci.c" doesn't use barrier() at all! Wondering if that was correct?
Thanks, also, for tracking down the PVSCSI problem.
I could get it booting only under QEMU. I wanted to test seabios under ESXi to make sure it really boots under ESXi's pvscsi implementation. Does anyone know a way to get seabios running under ESXi so that pvscsi validity can be checked?
Cheers, Ameya.