On Wed, Apr 27, 2016 at 06:23:27PM +0200, Alexander Gordeev wrote: > On Wed, Apr 27, 2016 at 03:46:57PM +0200, Andrew Jones wrote: > > On Wed, Apr 27, 2016 at 03:13:53PM +0200, Alexander Gordeev wrote: > > > Make x86 consistent with other architectures and put > > > IO specific defines to lib/x86/asm/io.h > > > > > > Cc: Andrew Jones <drjones@xxxxxxxxxx> > > > Cc: Thomas Huth <thuth@xxxxxxxxxx> > > > Cc: Radim Krčmář <rkrcmar@xxxxxxxxxx> > > > Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxx> > > > --- > > > lib/x86/asm/io.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > lib/x86/asm/pci.h | 2 +- > > > lib/x86/io.c | 2 +- > > > lib/x86/io.h | 40 ---------------------------------------- > > > lib/x86/vm.h | 12 +----------- > > > x86/eventinj.c | 7 +------ > > > x86/hyperv.c | 1 + > > > x86/hyperv.h | 1 - > > > x86/hyperv_stimer.c | 1 - > > > x86/hyperv_synic.c | 1 - > > > x86/init.c | 2 +- > > > x86/svm.c | 1 - > > > x86/vmexit.c | 1 - > > > x86/vmx.c | 1 - > > > x86/vmx_tests.c | 1 - > > > 15 files changed, 58 insertions(+), 67 deletions(-) > > > create mode 100644 lib/x86/asm/io.h > > > delete mode 100644 lib/x86/io.h > > > > > > diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h > > > new file mode 100644 > > > index 0000000..68b10e5 > > > --- /dev/null > > > +++ b/lib/x86/asm/io.h > > > @@ -0,0 +1,52 @@ > > > +#ifndef _ASM_X86_IO_H_ > > > +#define _ASM_X86_IO_H_ > > > + > > > +#include "asm/page.h" > > > > why is this include here? > > Just to conform to other archs which also include it. > But probably it needs revising in the other archs instead.. I guess, I'd better to remove this one at this stage, since I do not grasp the idea behind all archs header inclusion policy. It seems it could be cleaned up further, and if so - it is better to address in a separate patch. > > > + > > > +static inline unsigned char inb(unsigned short port) > > > +{ > > > + unsigned char value; > > > + asm volatile("inb %w1, %0" : "=a" (value) : "Nd" (port)); > > > + return value; > > > +} > > > + > > > +static inline unsigned short inw(unsigned short port) > > > +{ > > > + unsigned short value; > > > + asm volatile("inw %w1, %0" : "=a" (value) : "Nd" (port)); > > > + return value; > > > +} > > > + > > > +static inline unsigned int inl(unsigned short port) > > > +{ > > > + unsigned int value; > > > + asm volatile("inl %w1, %0" : "=a" (value) : "Nd" (port)); > > > + return value; > > > +} > > > + > > > +static inline void outb(unsigned char value, unsigned short port) > > > +{ > > > + asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port)); > > > +} > > > + > > > +static inline void outw(unsigned short value, unsigned short port) > > > +{ > > > + asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port)); > > > +} > > > + > > > +static inline void outl(unsigned int value, unsigned short port) > > > +{ > > > + asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port)); > > > +} > > > + > > > +static inline unsigned long virt_to_phys(const void *virt) > > > +{ > > > + return (unsigned long)virt; > > > +} > > > + > > > +static inline void *phys_to_virt(unsigned long phys) > > > +{ > > > + return (void *)phys; > > > +} > > > + > > > +#endif > > > diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h > > > index 4ec20e1..cddde41 100644 > > > --- a/lib/x86/asm/pci.h > > > +++ b/lib/x86/asm/pci.h > > > @@ -7,7 +7,7 @@ > > > */ > > > #include "libcflat.h" > > > #include "pci.h" > > > -#include "x86/io.h" > > > +#include "x86/asm/io.h" > > > > > > static inline uint32_t pci_config_read(pcidevaddr_t dev, uint8_t reg) > > > { > > > diff --git a/lib/x86/io.c b/lib/x86/io.c > > > index d3b971e..d396d42 100644 > > > --- a/lib/x86/io.c > > > +++ b/lib/x86/io.c > > > @@ -1,6 +1,6 @@ > > > #include "libcflat.h" > > > #include "smp.h" > > > -#include "io.h" > > > +#include "asm/io.h" > > > #ifndef USE_SERIAL > > > #define USE_SERIAL > > > #endif > > > diff --git a/lib/x86/io.h b/lib/x86/io.h > > > deleted file mode 100644 > > > index bd6341c..0000000 > > > --- a/lib/x86/io.h > > > +++ /dev/null > > > @@ -1,40 +0,0 @@ > > > -#ifndef IO_H > > > -#define IO_H > > > - > > > -static inline unsigned char inb(unsigned short port) > > > -{ > > > - unsigned char value; > > > - asm volatile("inb %w1, %0" : "=a" (value) : "Nd" (port)); > > > - return value; > > > -} > > > - > > > -static inline unsigned short inw(unsigned short port) > > > -{ > > > - unsigned short value; > > > - asm volatile("inw %w1, %0" : "=a" (value) : "Nd" (port)); > > > - return value; > > > -} > > > - > > > -static inline unsigned int inl(unsigned short port) > > > -{ > > > - unsigned int value; > > > - asm volatile("inl %w1, %0" : "=a" (value) : "Nd" (port)); > > > - return value; > > > -} > > > - > > > -static inline void outb(unsigned char value, unsigned short port) > > > -{ > > > - asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port)); > > > -} > > > - > > > -static inline void outw(unsigned short value, unsigned short port) > > > -{ > > > - asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port)); > > > -} > > > - > > > -static inline void outl(unsigned int value, unsigned short port) > > > -{ > > > - asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port)); > > > -} > > > - > > > -#endif > > > diff --git a/lib/x86/vm.h b/lib/x86/vm.h > > > index 72f84e6..21ed2b6 100644 > > > --- a/lib/x86/vm.h > > > +++ b/lib/x86/vm.h > > > @@ -2,7 +2,7 @@ > > > #define VM_H > > > > > > #include "processor.h" > > > -#include "asm/page.h" > > > +#include "asm/io.h" > > > > > > void setup_vm(); > > > > > > @@ -27,14 +27,4 @@ unsigned long *install_large_page(unsigned long *cr3,unsigned long phys, > > > void *virt); > > > unsigned long *install_page(unsigned long *cr3, unsigned long phys, void *virt); > > > > > > -static inline unsigned long virt_to_phys(const void *virt) > > > -{ > > > - return (unsigned long)virt; > > > -} > > > - > > > -static inline void *phys_to_virt(unsigned long phys) > > > -{ > > > - return (void *)phys; > > > -} > > > - > > > #endif > > > diff --git a/x86/eventinj.c b/x86/eventinj.c > > > index 57c2a2d..84dfe71 100644 > > > --- a/x86/eventinj.c > > > +++ b/x86/eventinj.c > > > @@ -16,11 +16,6 @@ static inline void io_delay(void) > > > { > > > } > > > > > > -static inline void outl(int addr, int val) > > > -{ > > > - asm volatile ("outl %1, %w0" : : "d" (addr), "a" (val)); > > > -} > > > - > > > void apic_self_ipi(u8 v) > > > { > > > apic_icr_write(APIC_DEST_SELF | APIC_DEST_PHYSICAL | APIC_DM_FIXED | > > > @@ -32,7 +27,7 @@ void apic_self_nmi(void) > > > apic_icr_write(APIC_DEST_PHYSICAL | APIC_DM_NMI | APIC_INT_ASSERT, 0); > > > } > > > > > > -#define flush_phys_addr(__s) outl(0xe4, __s) > > > +#define flush_phys_addr(__s) outl(__s, 0xe4) > > > #define flush_stack() do { \ > > > int __l; \ > > > flush_phys_addr(virt_to_phys(&__l)); \ > > > diff --git a/x86/hyperv.c b/x86/hyperv.c > > > index 824773d..2511aa2 100644 > > > --- a/x86/hyperv.c > > > +++ b/x86/hyperv.c > > > @@ -1,4 +1,5 @@ > > > #include "hyperv.h" > > > +#include "asm/io.h" > > > > > > static void synic_ctl(u8 ctl, u8 vcpu_id, u8 sint) > > > { > > > diff --git a/x86/hyperv.h b/x86/hyperv.h > > > index faf931b..434a933 100644 > > > --- a/x86/hyperv.h > > > +++ b/x86/hyperv.h > > > @@ -3,7 +3,6 @@ > > > > > > #include "libcflat.h" > > > #include "processor.h" > > > -#include "io.h" > > > > > > #define HYPERV_CPUID_FEATURES 0x40000003 > > > > > > diff --git a/x86/hyperv_stimer.c b/x86/hyperv_stimer.c > > > index bf2e429..9a971ef 100644 > > > --- a/x86/hyperv_stimer.c > > > +++ b/x86/hyperv_stimer.c > > > @@ -5,7 +5,6 @@ > > > #include "vm.h" > > > #include "apic.h" > > > #include "desc.h" > > > -#include "io.h" > > > #include "smp.h" > > > #include "atomic.h" > > > #include "hyperv.h" > > > diff --git a/x86/hyperv_synic.c b/x86/hyperv_synic.c > > > index 6e08894..4bd07c3 100644 > > > --- a/x86/hyperv_synic.c > > > +++ b/x86/hyperv_synic.c > > > @@ -5,7 +5,6 @@ > > > #include "vm.h" > > > #include "apic.h" > > > #include "desc.h" > > > -#include "io.h" > > > #include "smp.h" > > > #include "atomic.h" > > > #include "hyperv.h" > > > diff --git a/x86/init.c b/x86/init.c > > > index 344dc1c..f47d671 100644 > > > --- a/x86/init.c > > > +++ b/x86/init.c > > > @@ -1,6 +1,6 @@ > > > #include "libcflat.h" > > > #include "apic.h" > > > -#include "io.h" > > > +#include "asm/io.h" > > > > > > #define KBD_CCMD_READ_OUTPORT 0xD0 /* read output port */ > > > #define KBD_CCMD_WRITE_OUTPORT 0xD1 /* write output port */ > > > diff --git a/x86/svm.c b/x86/svm.c > > > index 934b2ae..401ff6c 100644 > > > --- a/x86/svm.c > > > +++ b/x86/svm.c > > > @@ -6,7 +6,6 @@ > > > #include "vm.h" > > > #include "smp.h" > > > #include "types.h" > > > -#include "io.h" > > > > > > /* for the nested page table*/ > > > u64 *pml4e; > > > diff --git a/x86/vmexit.c b/x86/vmexit.c > > > index 9e04975..db7dbd8 100644 > > > --- a/x86/vmexit.c > > > +++ b/x86/vmexit.c > > > @@ -6,7 +6,6 @@ > > > #include "x86/vm.h" > > > #include "x86/desc.h" > > > #include "x86/acpi.h" > > > -#include "x86/io.h" > > > > > > struct test { > > > void (*func)(void); > > > diff --git a/x86/vmx.c b/x86/vmx.c > > > index 6618008..411ed32 100644 > > > --- a/x86/vmx.c > > > +++ b/x86/vmx.c > > > @@ -35,7 +35,6 @@ > > > #include "vmx.h" > > > #include "msr.h" > > > #include "smp.h" > > > -#include "io.h" > > > > > > u64 *vmxon_region; > > > struct vmcs *vmcs_root; > > > diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c > > > index 71c571c..e83c8a2 100644 > > > --- a/x86/vmx_tests.c > > > +++ b/x86/vmx_tests.c > > > @@ -7,7 +7,6 @@ > > > #include "msr.h" > > > #include "processor.h" > > > #include "vm.h" > > > -#include "io.h" > > > #include "fwcfg.h" > > > #include "isr.h" > > > #include "apic.h" > > > -- > > > 1.8.3.1 > > > > Thanks, > > drew -- 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