i386 Vmi io header
RFC PATCH 16/24 i386 Vmi io header
Move I/O instruction building to the sub-arch layer. Some very crafty but esoteric macros are used here to get optimized native instructions for port I/O in Linux be writing raw instruction strings. Adding a wrapper layer here is fairly easy, and makes the full range of I/O instructions available to the VMI interface.
Also, slowing down I/O is not a useful operation in a VM, so there is a VMI call specifically to allow making it a NOP. I could find no place where SLOW_IO_BY_JUMPING is still used, and consider it obsoleted. Even on older 386 systems, the I/O delay approximation by touching the extra page register is likely to better.
include/asm-i386/io.h +7 -14
@@ -4,6 +4,7 @@#include <linux/config.h> #include <linux/string.h> #include <linux/compiler.h> +#include <mach_io.h> /* * This file contains the definitions for the x86 IO instructions
@@ -296,19 +297,11 @@ static inline void flush_write_buffers(v#endif /* __KERNEL__ */ -#ifdef SLOW_IO_BY_JUMPING -#define __SLOW_DOWN_IO "jmp 1f; 1: jmp 1f; 1:" -#else -#define __SLOW_DOWN_IO "outb %%al,$0x80;" -#endif -static inline void slow_down_io (void ) { - __asm__ __volatile__( - __SLOW_DOWN_IO + __SLOW_DOWN_IO;#ifdef REALLY_SLOW_IO - __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO + __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO;#endif - : : ); }#ifdef CONFIG_X86_NUMAQ
@@ -346,11 +339,11 @@ static inline unsigned type in##bwl(int#define BUILDIO (bwl,bw,type) \ static inline void out##bwl##_local(unsigned type value, int port) { \ - __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \ + __BUILDOUTINST(bwl,bw,value,port); \ } \ static inline unsigned type in##bwl##_local(int port) { \ unsigned type value; \ - __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \ + __BUILDININST(bwl,bw,value,port); \ return value; \ } \ static inline void out##bwl##_local_p(unsigned type value, int port) { \
@@ -373,10 +366,10 @@ static inline unsigned type in##bwl##_p(return value; \ } \ static inline void outs##bwl(int port, const void *addr, unsigned long count) { \ - __asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); \ + __BUILDOUTSINST(bwl,addr,count,port); \ } \ static inline void ins##bwl(int port, void *addr, unsigned long count) { \ - __asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); \ + __BUILDINSINST(bwl,addr,count,port); \ }BUILDIO (b,b,char)
include/asm-i386/mach-vmi/mach_io.h +155 -0
155 lines not on this page · raw message
include/asm-i386/mach-default/mach_io.h +22 -0
@@ -0,0 +1,22 @@ +#ifndef _MACH_ASM_IO_H +#define _MACH_ASM_IO_H + +#ifdef SLOW_IO_BY_JUMPING +#define __SLOW_DOWN_IO asm volatile("jmp 1f; 1: jmp 1f; 1:") +#else +#define __SLOW_DOWN_IO asm volatile("outb %al, $0x80") +#endif + +#define __BUILDOUTINST (bwl,bw,value,port) \ + __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)) +#define __BUILDININST (bwl,bw,value,port) \ + __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)) +#define __BUILDOUTSINST (bwl,addr,count,port) \ + __asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)) +#define __BUILDINSINST (bwl,addr,count,port) \ + __asm__ __volatile__("rep; ins" #bwl \ + : "+D"(addr), "+c"(count) \ + : "d"(port) \ + : "memory") + +#endif
Quoted 11 lines · Zachary Amsden
Move I/O instruction building to the sub-arch layer. Some very crafty but esoteric macros are used here to get optimized native instructions for port I/O in Linux be writing raw instruction strings. Adding a wrapper layer here is fairly easy, and makes the full range of I/O instructions available to the VMI interface.
Also, slowing down I/O is not a useful operation in a VM, so there is a VMI call specifically to allow making it a NOP. I could find no place where
SLOW_IO_BY_JUMPINGis still used, and consider it obsoleted. Even on older 386 systems, the I/O delay approximation by touching the extra page register is likely to better.
This sounds like a prime candidate for the alternate instruction interfaces and I don't see that being used here.
Eric
Quoted 16 lines · Eric W. Biederman
Quoted 6 lines · Zachary Amsden
Move I/O instruction building to the sub-arch layer. Some very crafty but esoteric macros are used here to get optimized native instructions for port I/O in Linux be writing raw instruction strings. Adding a wrapper layer here is fairly easy, and makes the full range of I/O instructions available to the VMI interface.
Quoted 6 lines
Also, slowing down I/O is not a useful operation in a VM, so there is a VMI call specifically to allow making it a NOP. I could find no place where
SLOW_IO_BY_JUMPINGis still used, and consider it obsoleted. Even on older 386 systems, the I/O delay approximation by touching the extra page register is likely to better.
Quoted 2 lines
This sounds like a prime candidate for the alternate instruction interfaces and I don't see that being used here.
The problem is that floppy controllers and other crufty hardware actually do need those slowing port operations to work reliably. If you look at the usage of slow_down_io, you get scared pretty quick. If you want your driver to use it, you have the option of defining REALLY_SLOW_IO in your C file, then suffix your I/O calls with _p. The definition of SLOW_DOWN_IO actually used to be raw assembly instructions encapsulated in quotations. I just realized this does actually change the semantics of drivers/net/de600.c, which really is the only driver which defines SLOW_IO_BY_JUMPING.
This usage of predefined macros in the driver causing port I/O semantics to change seems a little strange to try to wrap onto an alternate instruction interfaces, since it is dependent definitions local to each .C file, rather than global processor or derived feature bits.
The VMI call wrappers are very much similar to the alternate instruction interfaces - they just leave the alternative to be defined by the hypervisor.