All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/9] Cleanup low-level arch code
@ 2016-04-27 13:13 Alexander Gordeev
  2016-04-27 13:13 ` [PATCH v2 1/9] Remove unused and unnecessary PHYS32 macro Alexander Gordeev
                   ` (9 more replies)
  0 siblings, 10 replies; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm; +Cc: Alexander Gordeev

This is 2nd attempt to make mainly x86 arch code consistent
with other architectures.

Changes since v1:
  - arm compilation error fixed;
  - disabling memory re-ordering for generic memory barriers added;

Alexander Gordeev (9):
  Remove unused and unnecessary PHYS32 macro
  Move phys_addr_t type definition to lib/libcflat.h
  x86: Introduce lib/x86/asm/page.h
  x86: Introduce lib/x86/asm/io.h
  x86: Introduce lib/x86/asm/barrier.h
  x86: Optimize virt_to_phys() and phys_to_virt()
  io: Make ioremap() prototype conform to Linux one
  io/x86: Factor out ioremap()
  io: Disable memory re-ordering for generic memory barriers

 arm/selftest.c          |  1 -
 lib/alloc.h             |  5 -----
 lib/arm/asm/page.h      |  2 --
 lib/arm/asm/setup.h     |  1 -
 lib/arm/setup.c         |  1 -
 lib/asm-generic/io.h    | 13 +++++++++----
 lib/libcflat.h          |  2 ++
 lib/powerpc/asm/setup.h |  1 -
 lib/ppc64/asm/io.h      |  2 ++
 lib/x86/asm/barrier.h   |  8 ++++++++
 lib/x86/asm/io.h        | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/x86/asm/page.h      | 30 +++++++++++++++++++++++++++++
 lib/x86/asm/pci.h       |  2 +-
 lib/x86/io.c            | 16 +++++++++++++++-
 lib/x86/io.h            | 40 ---------------------------------------
 lib/x86/smp.h           |  4 ----
 lib/x86/vm.c            | 17 -----------------
 lib/x86/vm.h            | 24 +-----------------------
 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/kvmclock.c          |  1 +
 x86/svm.c               |  1 -
 x86/vmexit.c            | 11 ++---------
 x86/vmx.c               |  1 -
 x86/vmx_tests.c         |  1 -
 29 files changed, 124 insertions(+), 123 deletions(-)
 create mode 100644 lib/x86/asm/barrier.h
 create mode 100644 lib/x86/asm/io.h
 create mode 100644 lib/x86/asm/page.h
 delete mode 100644 lib/x86/io.h

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 1/9] Remove unused and unnecessary PHYS32 macro
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 13:13 ` [PATCH v2 2/9] Move phys_addr_t type definition to lib/libcflat.h Alexander Gordeev
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Suggested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/alloc.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/lib/alloc.h b/lib/alloc.h
index 7a73c18..0b4b4bd 100644
--- a/lib/alloc.h
+++ b/lib/alloc.h
@@ -58,11 +58,7 @@ static inline void *memalign(size_t alignment, size_t size)
 	return alloc_ops->memalign(alignment, size);
 }
 
-#ifdef PHYS32
-typedef u32 phys_addr_t;
-#else
 typedef u64 phys_addr_t;
-#endif
 #define INVALID_PHYS_ADDR (~(phys_addr_t)0)
 
 /*
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v2 2/9] Move phys_addr_t type definition to lib/libcflat.h
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
  2016-04-27 13:13 ` [PATCH v2 1/9] Remove unused and unnecessary PHYS32 macro Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 13:42   ` Andrew Jones
  2016-04-27 13:13 ` [PATCH v2 3/9] x86: Introduce lib/x86/asm/page.h Alexander Gordeev
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

This change leads to removing '#include <alloc.h>'s from
several places that only included alloc.h to get the typedef.

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Suggested-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 arm/selftest.c          | 1 -
 lib/alloc.h             | 1 -
 lib/arm/asm/page.h      | 2 --
 lib/arm/asm/setup.h     | 1 -
 lib/arm/setup.c         | 1 -
 lib/libcflat.h          | 2 ++
 lib/powerpc/asm/setup.h | 1 -
 7 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/arm/selftest.c b/arm/selftest.c
index 75dc91f..a8ae191 100644
--- a/arm/selftest.c
+++ b/arm/selftest.c
@@ -7,7 +7,6 @@
  */
 #include <libcflat.h>
 #include <util.h>
-#include <alloc.h>
 #include <devicetree.h>
 #include <asm/setup.h>
 #include <asm/ptrace.h>
diff --git a/lib/alloc.h b/lib/alloc.h
index 0b4b4bd..c12bd15 100644
--- a/lib/alloc.h
+++ b/lib/alloc.h
@@ -58,7 +58,6 @@ static inline void *memalign(size_t alignment, size_t size)
 	return alloc_ops->memalign(alignment, size);
 }
 
-typedef u64 phys_addr_t;
 #define INVALID_PHYS_ADDR (~(phys_addr_t)0)
 
 /*
diff --git a/lib/arm/asm/page.h b/lib/arm/asm/page.h
index df76969..3802641 100644
--- a/lib/arm/asm/page.h
+++ b/lib/arm/asm/page.h
@@ -16,8 +16,6 @@
 
 #define PAGE_ALIGN(addr)	ALIGN(addr, PAGE_SIZE)
 
-#include <alloc.h>
-
 typedef u64 pteval_t;
 typedef u64 pmdval_t;
 typedef u64 pgdval_t;
diff --git a/lib/arm/asm/setup.h b/lib/arm/asm/setup.h
index cb8fdbd..a502a04 100644
--- a/lib/arm/asm/setup.h
+++ b/lib/arm/asm/setup.h
@@ -6,7 +6,6 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 #include <libcflat.h>
-#include <alloc.h>	/* phys_addr_t */
 #include <asm/page.h>
 #include <asm/pgtable-hwdef.h>
 
diff --git a/lib/arm/setup.c b/lib/arm/setup.c
index 8c6172f..1cba23a 100644
--- a/lib/arm/setup.c
+++ b/lib/arm/setup.c
@@ -13,7 +13,6 @@
 #include <libcflat.h>
 #include <libfdt/libfdt.h>
 #include <devicetree.h>
-#include <alloc.h>
 #include <asm/thread_info.h>
 #include <asm/setup.h>
 #include <asm/page.h>
diff --git a/lib/libcflat.h b/lib/libcflat.h
index b58a8a1..f2ec33f 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -60,6 +60,8 @@ typedef _Bool		bool;
 #define PRIx64  __PRI64_PREFIX	"x"
 #define PRIxPTR __PRIPTR_PREFIX	"x"
 
+typedef u64			phys_addr_t;
+
 extern void puts(const char *s);
 extern void exit(int code);
 extern void abort(void);
diff --git a/lib/powerpc/asm/setup.h b/lib/powerpc/asm/setup.h
index 29a6d7d..b1e1e5a 100644
--- a/lib/powerpc/asm/setup.h
+++ b/lib/powerpc/asm/setup.h
@@ -6,7 +6,6 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 #include <libcflat.h>
-#include <alloc.h>	/* phys_addr_t */
 
 #define NR_CPUS			8	/* arbitrarily set for now */
 extern u32 cpus[NR_CPUS];
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v2 3/9] x86: Introduce lib/x86/asm/page.h
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
  2016-04-27 13:13 ` [PATCH v2 1/9] Remove unused and unnecessary PHYS32 macro Alexander Gordeev
  2016-04-27 13:13 ` [PATCH v2 2/9] Move phys_addr_t type definition to lib/libcflat.h Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 13:45   ` Andrew Jones
  2016-04-27 13:13 ` [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h Alexander Gordeev
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

Make x86 consistent with other architectures and put
memory page specific defines to lib/x86/asm/page.h

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/x86/asm/page.h | 27 +++++++++++++++++++++++++++
 lib/x86/vm.c       | 17 -----------------
 lib/x86/vm.h       | 14 +-------------
 3 files changed, 28 insertions(+), 30 deletions(-)
 create mode 100644 lib/x86/asm/page.h

diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
new file mode 100644
index 0000000..edfe325
--- /dev/null
+++ b/lib/x86/asm/page.h
@@ -0,0 +1,27 @@
+#ifndef _ASM_X86_PAGE_H_
+#define _ASM_X86_PAGE_H_
+
+#define PAGE_SIZE 4096ul
+#ifdef __x86_64__
+#define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
+#else
+#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
+#endif
+
+#define PTE_PRESENT (1ull << 0)
+#define PTE_PSE     (1ull << 7)
+#define PTE_WRITE   (1ull << 1)
+#define PTE_USER    (1ull << 2)
+#define PTE_ADDR    (0xffffffffff000ull)
+
+#ifdef __x86_64__
+#define	PAGE_LEVEL	4
+#define	PGDIR_WIDTH	9
+#define	PGDIR_MASK	511
+#else
+#define	PAGE_LEVEL	2
+#define	PGDIR_WIDTH	10
+#define	PGDIR_MASK	1023
+#endif
+
+#endif
diff --git a/lib/x86/vm.c b/lib/x86/vm.c
index 7ce7bbc..9c94ca5 100644
--- a/lib/x86/vm.c
+++ b/lib/x86/vm.c
@@ -2,13 +2,6 @@
 #include "vm.h"
 #include "libcflat.h"
 
-#define PAGE_SIZE 4096ul
-#ifdef __x86_64__
-#define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
-#else
-#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
-#endif
-
 static void *free = 0;
 static void *vfree_top = 0;
 
@@ -44,16 +37,6 @@ void free_page(void *page)
 extern char edata;
 static unsigned long end_of_memory;
 
-#ifdef __x86_64__
-#define	PAGE_LEVEL	4
-#define	PGDIR_WIDTH	9
-#define	PGDIR_MASK	511
-#else
-#define	PAGE_LEVEL	2
-#define	PGDIR_WIDTH	10
-#define	PGDIR_MASK	1023
-#endif
-
 unsigned long *install_pte(unsigned long *cr3,
 			   int pte_level,
 			   void *virt,
diff --git a/lib/x86/vm.h b/lib/x86/vm.h
index 28794d7..72f84e6 100644
--- a/lib/x86/vm.h
+++ b/lib/x86/vm.h
@@ -2,19 +2,7 @@
 #define VM_H
 
 #include "processor.h"
-
-#define PAGE_SIZE 4096ul
-#ifdef __x86_64__
-#define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
-#else
-#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
-#endif
-
-#define PTE_PRESENT (1ull << 0)
-#define PTE_PSE     (1ull << 7)
-#define PTE_WRITE   (1ull << 1)
-#define PTE_USER    (1ull << 2)
-#define PTE_ADDR    (0xffffffffff000ull)
+#include "asm/page.h"
 
 void setup_vm();
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
                   ` (2 preceding siblings ...)
  2016-04-27 13:13 ` [PATCH v2 3/9] x86: Introduce lib/x86/asm/page.h Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 13:46   ` Andrew Jones
  2016-04-27 13:51   ` Andrew Jones
  2016-04-27 13:13 ` [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h Alexander Gordeev
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

Make x86 consistent with other architectures and put
IO specific defines to lib/x86/asm/io.h

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 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"
+
+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


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
                   ` (3 preceding siblings ...)
  2016-04-27 13:13 ` [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 13:52   ` Andrew Jones
  2016-04-27 13:13 ` [PATCH v2 6/9] x86: Optimize virt_to_phys() and phys_to_virt() Alexander Gordeev
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

Make x86 consistent with other architectures and put
memory barrier defines to lib/x86/asm/barrier.h

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/x86/asm/barrier.h | 8 ++++++++
 lib/x86/asm/io.h      | 1 +
 lib/x86/smp.h         | 4 ----
 x86/kvmclock.c        | 1 +
 4 files changed, 10 insertions(+), 4 deletions(-)
 create mode 100644 lib/x86/asm/barrier.h

diff --git a/lib/x86/asm/barrier.h b/lib/x86/asm/barrier.h
new file mode 100644
index 0000000..0ca1c56
--- /dev/null
+++ b/lib/x86/asm/barrier.h
@@ -0,0 +1,8 @@
+#ifndef _ASM_X86_BARRIER_H_
+#define _ASM_X86_BARRIER_H_
+
+#define mb()	asm volatile("mfence":::"memory")
+#define rmb()	asm volatile("lfence":::"memory")
+#define wmb()	asm volatile("sfence" ::: "memory")
+
+#endif
diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
index 68b10e5..5b901a3 100644
--- a/lib/x86/asm/io.h
+++ b/lib/x86/asm/io.h
@@ -2,6 +2,7 @@
 #define _ASM_X86_IO_H_
 
 #include "asm/page.h"
+#include "asm/barrier.h"
 
 static inline unsigned char inb(unsigned short port)
 {
diff --git a/lib/x86/smp.h b/lib/x86/smp.h
index 566018f..afabac8 100644
--- a/lib/x86/smp.h
+++ b/lib/x86/smp.h
@@ -2,10 +2,6 @@
 #define __SMP_H
 #include <asm/spinlock.h>
 
-#define mb() 	asm volatile("mfence":::"memory")
-#define rmb()	asm volatile("lfence":::"memory")
-#define wmb()	asm volatile("sfence" ::: "memory")
-
 void smp_init(void);
 
 int cpu_count(void);
diff --git a/x86/kvmclock.c b/x86/kvmclock.c
index 327e60d..208d43c 100644
--- a/x86/kvmclock.c
+++ b/x86/kvmclock.c
@@ -3,6 +3,7 @@
 #include "atomic.h"
 #include "processor.h"
 #include "kvmclock.h"
+#include "asm/barrier.h"
 
 #define unlikely(x)	__builtin_expect(!!(x), 0)
 #define likely(x)	__builtin_expect(!!(x), 1)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v2 6/9] x86: Optimize virt_to_phys() and phys_to_virt()
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
                   ` (4 preceding siblings ...)
  2016-04-27 13:13 ` [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 13:58   ` Andrew Jones
  2016-04-27 13:13 ` [PATCH v2 7/9] io: Make ioremap() prototype conform to Linux one Alexander Gordeev
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

Make use of generic implementations and remove x86
specific virt_to_phys() and phys_to_virt() functions.

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/asm-generic/io.h |  2 ++
 lib/x86/asm/io.h     | 10 +---------
 lib/x86/asm/page.h   |  3 +++
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
index 931415a..3585ac0 100644
--- a/lib/asm-generic/io.h
+++ b/lib/asm-generic/io.h
@@ -165,7 +165,9 @@ static inline unsigned long virt_to_phys(volatile void *address)
 {
 	return __pa((unsigned long)address);
 }
+#endif
 
+#ifndef phys_to_virt
 static inline void *phys_to_virt(unsigned long address)
 {
 	return __va(address);
diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
index 5b901a3..74451d5 100644
--- a/lib/x86/asm/io.h
+++ b/lib/x86/asm/io.h
@@ -40,14 +40,6 @@ 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;
-}
+#include <asm-generic/io.h>
 
 #endif
diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
index edfe325..a9280ed 100644
--- a/lib/x86/asm/page.h
+++ b/lib/x86/asm/page.h
@@ -24,4 +24,7 @@
 #define	PGDIR_MASK	1023
 #endif
 
+#define __va(x)		((void *)((unsigned long) (x)))
+#define __pa(x)		((unsigned long) (x))
+
 #endif
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v2 7/9] io: Make ioremap() prototype conform to Linux one
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
                   ` (5 preceding siblings ...)
  2016-04-27 13:13 ` [PATCH v2 6/9] x86: Optimize virt_to_phys() and phys_to_virt() Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 13:59   ` Andrew Jones
  2016-04-27 13:13 ` [PATCH v2 8/9] io/x86: Factor out ioremap() Alexander Gordeev
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

This update also adds missing __iomem specificator which
has been used by existing IO accessors.

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/asm-generic/io.h | 4 ++--
 lib/ppc64/asm/io.h   | 2 ++
 lib/x86/asm/io.h     | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
index 3585ac0..28fe981 100644
--- a/lib/asm-generic/io.h
+++ b/lib/asm-generic/io.h
@@ -153,10 +153,10 @@ static inline u64 __bswap64(u64 x)
 	({ wmb(); __raw_writeq(cpu_to_le64(b), addr); })
 
 #ifndef ioremap
-static inline void *ioremap(u64 phys_addr, size_t size __unused)
+static inline void __iomem *ioremap(phys_addr_t phys_addr, size_t size __unused)
 {
 	assert(sizeof(long) == 8 || !(phys_addr >> 32));
-	return (void *)(unsigned long)phys_addr;
+	return (void __iomem *)(unsigned long)phys_addr;
 }
 #endif
 
diff --git a/lib/ppc64/asm/io.h b/lib/ppc64/asm/io.h
index 4f2c31b..2b4dd2b 100644
--- a/lib/ppc64/asm/io.h
+++ b/lib/ppc64/asm/io.h
@@ -9,5 +9,7 @@
 #error Undefined byte order
 #endif
 
+#define __iomem
+
 #include <asm-generic/io.h>
 #endif
diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
index 74451d5..c37450f 100644
--- a/lib/x86/asm/io.h
+++ b/lib/x86/asm/io.h
@@ -4,6 +4,8 @@
 #include "asm/page.h"
 #include "asm/barrier.h"
 
+#define __iomem
+
 static inline unsigned char inb(unsigned short port)
 {
     unsigned char value;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v2 8/9] io/x86: Factor out ioremap()
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
                   ` (6 preceding siblings ...)
  2016-04-27 13:13 ` [PATCH v2 7/9] io: Make ioremap() prototype conform to Linux one Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 14:11   ` Andrew Jones
  2016-04-27 13:13 ` [PATCH v2 9/9] io: Disable memory re-ordering for generic memory barriers Alexander Gordeev
  2016-04-27 13:34 ` [PATCH v2 0/9] Cleanup low-level arch code Andrew Jones
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/x86/asm/io.h |  3 +++
 lib/x86/io.c     | 14 ++++++++++++++
 x86/vmexit.c     | 10 ++--------
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
index c37450f..d8c5dbd 100644
--- a/lib/x86/asm/io.h
+++ b/lib/x86/asm/io.h
@@ -42,6 +42,9 @@ static inline void outl(unsigned int value, unsigned short port)
     asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port));
 }
 
+#define ioremap ioremap
+void __iomem *ioremap(phys_addr_t phys_addr, size_t size);
+
 #include <asm-generic/io.h>
 
 #endif
diff --git a/lib/x86/io.c b/lib/x86/io.c
index d396d42..a699509 100644
--- a/lib/x86/io.c
+++ b/lib/x86/io.c
@@ -1,4 +1,5 @@
 #include "libcflat.h"
+#include "vm.h"
 #include "smp.h"
 #include "asm/io.h"
 #ifndef USE_SERIAL
@@ -81,3 +82,16 @@ void exit(int code)
         asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
 #endif
 }
+
+void __iomem *ioremap(phys_addr_t phys_addr, size_t size)
+{
+	phys_addr_t base = ALIGN(phys_addr, PAGE_SIZE);
+	phys_addr_t off = phys_addr - base;
+	ulong nr = ALIGN(off + size + (PAGE_SIZE - 1), PAGE_SIZE) / PAGE_SIZE;
+	void *page = alloc_vpages(nr);
+
+	install_page((void *)read_cr3(), base, page);
+
+	return page + off;
+}
+
diff --git a/x86/vmexit.c b/x86/vmexit.c
index db7dbd8..c2e1e49 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -371,8 +371,7 @@ int main(int ac, char **av)
 {
 	struct fadt_descriptor_rev1 *fadt;
 	int i;
-	unsigned long membar = 0, base, offset;
-	void *m;
+	unsigned long membar = 0;
 	pcidevaddr_t pcidev;
 
 	smp_init();
@@ -394,12 +393,7 @@ int main(int ac, char **av)
 			}
 			if (pci_bar_is_memory(pcidev, i)) {
 				membar = pci_bar_addr(pcidev, i);
-				base = membar & ~4095;
-				offset = membar - base;
-				m = alloc_vpages(1);
-				
-				install_page((void *)read_cr3(), base, m);
-				pci_test.memaddr = m + offset;
+				pci_test.memaddr = ioremap(membar, PAGE_SIZE);
 			} else {
 				pci_test.iobar = pci_bar_addr(pcidev, i);
 			}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v2 9/9] io: Disable memory re-ordering for generic memory barriers
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
                   ` (7 preceding siblings ...)
  2016-04-27 13:13 ` [PATCH v2 8/9] io/x86: Factor out ioremap() Alexander Gordeev
@ 2016-04-27 13:13 ` Alexander Gordeev
  2016-04-27 14:14   ` Andrew Jones
  2016-04-27 13:34 ` [PATCH v2 0/9] Cleanup low-level arch code Andrew Jones
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 13:13 UTC (permalink / raw)
  To: kvm
  Cc: Alexander Gordeev, Andrew Jones, Thomas Huth,
	Radim Krčmář

Suggested-by: Thomas Huth <thuth@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/asm-generic/io.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
index 28fe981..1710cc4 100644
--- a/lib/asm-generic/io.h
+++ b/lib/asm-generic/io.h
@@ -127,11 +127,14 @@ static inline u64 __bswap64(u64 x)
 	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : ((u64)x); __r; })
 #define cpu_to_be64 be64_to_cpu
 
+#ifndef mb
+#define mb()	asm volatile("":::"memory")
+#endif
 #ifndef rmb
-#define rmb() do { } while (0)
+#define rmb()	asm volatile("":::"memory")
 #endif
 #ifndef wmb
-#define wmb() do { } while (0)
+#define wmb()	asm volatile("" ::: "memory")
 #endif
 
 #define readb(addr) \
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 0/9] Cleanup low-level arch code
  2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
                   ` (8 preceding siblings ...)
  2016-04-27 13:13 ` [PATCH v2 9/9] io: Disable memory re-ordering for generic memory barriers Alexander Gordeev
@ 2016-04-27 13:34 ` Andrew Jones
  9 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 13:34 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm


Please make sure you add 'kvm-unit-tests' to your PATCH prefix, i.e.
[kvm-unit-tests PATCH]. To make sure you don't forget just run

  git config format.subjectprefix 'kvm-unit-tests PATCH'

in your kvm-unit-tests git repository (see 'Patches' in the README).

On Wed, Apr 27, 2016 at 03:13:49PM +0200, Alexander Gordeev wrote:
> This is 2nd attempt to make mainly x86 arch code consistent
> with other architectures.
> 
> Changes since v1:
>   - arm compilation error fixed;
>   - disabling memory re-ordering for generic memory barriers added;
> 
> Alexander Gordeev (9):
>   Remove unused and unnecessary PHYS32 macro
>   Move phys_addr_t type definition to lib/libcflat.h
>   x86: Introduce lib/x86/asm/page.h
>   x86: Introduce lib/x86/asm/io.h
>   x86: Introduce lib/x86/asm/barrier.h
>   x86: Optimize virt_to_phys() and phys_to_virt()
>   io: Make ioremap() prototype conform to Linux one
>   io/x86: Factor out ioremap()
>   io: Disable memory re-ordering for generic memory barriers
> 
>  arm/selftest.c          |  1 -
>  lib/alloc.h             |  5 -----
>  lib/arm/asm/page.h      |  2 --
>  lib/arm/asm/setup.h     |  1 -
>  lib/arm/setup.c         |  1 -
>  lib/asm-generic/io.h    | 13 +++++++++----
>  lib/libcflat.h          |  2 ++
>  lib/powerpc/asm/setup.h |  1 -
>  lib/ppc64/asm/io.h      |  2 ++
>  lib/x86/asm/barrier.h   |  8 ++++++++
>  lib/x86/asm/io.h        | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/x86/asm/page.h      | 30 +++++++++++++++++++++++++++++
>  lib/x86/asm/pci.h       |  2 +-
>  lib/x86/io.c            | 16 +++++++++++++++-
>  lib/x86/io.h            | 40 ---------------------------------------
>  lib/x86/smp.h           |  4 ----
>  lib/x86/vm.c            | 17 -----------------
>  lib/x86/vm.h            | 24 +-----------------------
>  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/kvmclock.c          |  1 +
>  x86/svm.c               |  1 -
>  x86/vmexit.c            | 11 ++---------
>  x86/vmx.c               |  1 -
>  x86/vmx_tests.c         |  1 -
>  29 files changed, 124 insertions(+), 123 deletions(-)
>  create mode 100644 lib/x86/asm/barrier.h
>  create mode 100644 lib/x86/asm/io.h
>  create mode 100644 lib/x86/asm/page.h
>  delete mode 100644 lib/x86/io.h
> 
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 2/9] Move phys_addr_t type definition to lib/libcflat.h
  2016-04-27 13:13 ` [PATCH v2 2/9] Move phys_addr_t type definition to lib/libcflat.h Alexander Gordeev
@ 2016-04-27 13:42   ` Andrew Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 13:42 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 03:13:51PM +0200, Alexander Gordeev wrote:
> This change leads to removing '#include <alloc.h>'s from
> several places that only included alloc.h to get the typedef.
> 
> Cc: Andrew Jones <drjones@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Suggested-by: Andrew Jones <drjones@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  arm/selftest.c          | 1 -
>  lib/alloc.h             | 1 -
>  lib/arm/asm/page.h      | 2 --
>  lib/arm/asm/setup.h     | 1 -
>  lib/arm/setup.c         | 1 -
>  lib/libcflat.h          | 2 ++
>  lib/powerpc/asm/setup.h | 1 -
>  7 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/arm/selftest.c b/arm/selftest.c
> index 75dc91f..a8ae191 100644
> --- a/arm/selftest.c
> +++ b/arm/selftest.c
> @@ -7,7 +7,6 @@
>   */
>  #include <libcflat.h>
>  #include <util.h>
> -#include <alloc.h>
>  #include <devicetree.h>
>  #include <asm/setup.h>
>  #include <asm/ptrace.h>
> diff --git a/lib/alloc.h b/lib/alloc.h
> index 0b4b4bd..c12bd15 100644
> --- a/lib/alloc.h
> +++ b/lib/alloc.h
> @@ -58,7 +58,6 @@ static inline void *memalign(size_t alignment, size_t size)
>  	return alloc_ops->memalign(alignment, size);
>  }
>  
> -typedef u64 phys_addr_t;
>  #define INVALID_PHYS_ADDR (~(phys_addr_t)0)
>  
>  /*
> diff --git a/lib/arm/asm/page.h b/lib/arm/asm/page.h
> index df76969..3802641 100644
> --- a/lib/arm/asm/page.h
> +++ b/lib/arm/asm/page.h
> @@ -16,8 +16,6 @@
>  
>  #define PAGE_ALIGN(addr)	ALIGN(addr, PAGE_SIZE)
>  
> -#include <alloc.h>
> -
>  typedef u64 pteval_t;
>  typedef u64 pmdval_t;
>  typedef u64 pgdval_t;
> diff --git a/lib/arm/asm/setup.h b/lib/arm/asm/setup.h
> index cb8fdbd..a502a04 100644
> --- a/lib/arm/asm/setup.h
> +++ b/lib/arm/asm/setup.h
> @@ -6,7 +6,6 @@
>   * This work is licensed under the terms of the GNU LGPL, version 2.
>   */
>  #include <libcflat.h>
> -#include <alloc.h>	/* phys_addr_t */
>  #include <asm/page.h>
>  #include <asm/pgtable-hwdef.h>
>  
> diff --git a/lib/arm/setup.c b/lib/arm/setup.c
> index 8c6172f..1cba23a 100644
> --- a/lib/arm/setup.c
> +++ b/lib/arm/setup.c
> @@ -13,7 +13,6 @@
>  #include <libcflat.h>
>  #include <libfdt/libfdt.h>
>  #include <devicetree.h>
> -#include <alloc.h>
>  #include <asm/thread_info.h>
>  #include <asm/setup.h>
>  #include <asm/page.h>

setup.c is actually a primary user of alloc, as it inits
the physmem allocator, so including alloc.h is pretty
appropriate here, and should stay. And, if it wasn't
appropriate (which it is), then you should have removed
it from lib/powerpc/setup.c too.


> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index b58a8a1..f2ec33f 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -60,6 +60,8 @@ typedef _Bool		bool;
>  #define PRIx64  __PRI64_PREFIX	"x"
>  #define PRIxPTR __PRIPTR_PREFIX	"x"
>  
> +typedef u64			phys_addr_t;
> +
>  extern void puts(const char *s);
>  extern void exit(int code);
>  extern void abort(void);
> diff --git a/lib/powerpc/asm/setup.h b/lib/powerpc/asm/setup.h
> index 29a6d7d..b1e1e5a 100644
> --- a/lib/powerpc/asm/setup.h
> +++ b/lib/powerpc/asm/setup.h
> @@ -6,7 +6,6 @@
>   * This work is licensed under the terms of the GNU LGPL, version 2.
>   */
>  #include <libcflat.h>
> -#include <alloc.h>	/* phys_addr_t */
>  
>  #define NR_CPUS			8	/* arbitrarily set for now */
>  extern u32 cpus[NR_CPUS];
> -- 
> 1.8.3.1

Thanks,
drew

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 3/9] x86: Introduce lib/x86/asm/page.h
  2016-04-27 13:13 ` [PATCH v2 3/9] x86: Introduce lib/x86/asm/page.h Alexander Gordeev
@ 2016-04-27 13:45   ` Andrew Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 13:45 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 03:13:52PM +0200, Alexander Gordeev wrote:
> Make x86 consistent with other architectures and put
> memory page specific defines to lib/x86/asm/page.h
> 
> Cc: Andrew Jones <drjones@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  lib/x86/asm/page.h | 27 +++++++++++++++++++++++++++
>  lib/x86/vm.c       | 17 -----------------
>  lib/x86/vm.h       | 14 +-------------
>  3 files changed, 28 insertions(+), 30 deletions(-)
>  create mode 100644 lib/x86/asm/page.h

Reviewed-by: Andrew Jones <drjones@redhat.com>

> 
> diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
> new file mode 100644
> index 0000000..edfe325
> --- /dev/null
> +++ b/lib/x86/asm/page.h
> @@ -0,0 +1,27 @@
> +#ifndef _ASM_X86_PAGE_H_
> +#define _ASM_X86_PAGE_H_
> +
> +#define PAGE_SIZE 4096ul
> +#ifdef __x86_64__
> +#define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
> +#else
> +#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
> +#endif
> +
> +#define PTE_PRESENT (1ull << 0)
> +#define PTE_PSE     (1ull << 7)
> +#define PTE_WRITE   (1ull << 1)
> +#define PTE_USER    (1ull << 2)
> +#define PTE_ADDR    (0xffffffffff000ull)
> +
> +#ifdef __x86_64__
> +#define	PAGE_LEVEL	4
> +#define	PGDIR_WIDTH	9
> +#define	PGDIR_MASK	511
> +#else
> +#define	PAGE_LEVEL	2
> +#define	PGDIR_WIDTH	10
> +#define	PGDIR_MASK	1023
> +#endif
> +
> +#endif
> diff --git a/lib/x86/vm.c b/lib/x86/vm.c
> index 7ce7bbc..9c94ca5 100644
> --- a/lib/x86/vm.c
> +++ b/lib/x86/vm.c
> @@ -2,13 +2,6 @@
>  #include "vm.h"
>  #include "libcflat.h"
>  
> -#define PAGE_SIZE 4096ul
> -#ifdef __x86_64__
> -#define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
> -#else
> -#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
> -#endif
> -
>  static void *free = 0;
>  static void *vfree_top = 0;
>  
> @@ -44,16 +37,6 @@ void free_page(void *page)
>  extern char edata;
>  static unsigned long end_of_memory;
>  
> -#ifdef __x86_64__
> -#define	PAGE_LEVEL	4
> -#define	PGDIR_WIDTH	9
> -#define	PGDIR_MASK	511
> -#else
> -#define	PAGE_LEVEL	2
> -#define	PGDIR_WIDTH	10
> -#define	PGDIR_MASK	1023
> -#endif
> -
>  unsigned long *install_pte(unsigned long *cr3,
>  			   int pte_level,
>  			   void *virt,
> diff --git a/lib/x86/vm.h b/lib/x86/vm.h
> index 28794d7..72f84e6 100644
> --- a/lib/x86/vm.h
> +++ b/lib/x86/vm.h
> @@ -2,19 +2,7 @@
>  #define VM_H
>  
>  #include "processor.h"
> -
> -#define PAGE_SIZE 4096ul
> -#ifdef __x86_64__
> -#define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
> -#else
> -#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
> -#endif
> -
> -#define PTE_PRESENT (1ull << 0)
> -#define PTE_PSE     (1ull << 7)
> -#define PTE_WRITE   (1ull << 1)
> -#define PTE_USER    (1ull << 2)
> -#define PTE_ADDR    (0xffffffffff000ull)
> +#include "asm/page.h"
>  
>  void setup_vm();
>  
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h
  2016-04-27 13:13 ` [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h Alexander Gordeev
@ 2016-04-27 13:46   ` Andrew Jones
  2016-04-27 16:23     ` Alexander Gordeev
  2016-04-27 13:51   ` Andrew Jones
  1 sibling, 1 reply; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 13:46 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

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@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  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?

> +
> +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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h
  2016-04-27 13:13 ` [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h Alexander Gordeev
  2016-04-27 13:46   ` Andrew Jones
@ 2016-04-27 13:51   ` Andrew Jones
  1 sibling, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 13:51 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

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@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  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

One other thing. Please prepare the patches with 'format-patch -M', as
lib/x86/io.h -> lib/x86/asm/io.h is just a rename.

thanks,
drew


> 
> 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"
> +
> +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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h
  2016-04-27 13:13 ` [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h Alexander Gordeev
@ 2016-04-27 13:52   ` Andrew Jones
  2016-04-27 16:26     ` Alexander Gordeev
  0 siblings, 1 reply; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 13:52 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 03:13:54PM +0200, Alexander Gordeev wrote:
> Make x86 consistent with other architectures and put
> memory barrier defines to lib/x86/asm/barrier.h
> 
> Cc: Andrew Jones <drjones@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  lib/x86/asm/barrier.h | 8 ++++++++
>  lib/x86/asm/io.h      | 1 +
>  lib/x86/smp.h         | 4 ----
>  x86/kvmclock.c        | 1 +
>  4 files changed, 10 insertions(+), 4 deletions(-)
>  create mode 100644 lib/x86/asm/barrier.h

Reviewed-by: Andrew Jones <drjones@redhat.com>

> 
> diff --git a/lib/x86/asm/barrier.h b/lib/x86/asm/barrier.h
> new file mode 100644
> index 0000000..0ca1c56
> --- /dev/null
> +++ b/lib/x86/asm/barrier.h
> @@ -0,0 +1,8 @@
> +#ifndef _ASM_X86_BARRIER_H_
> +#define _ASM_X86_BARRIER_H_
> +
> +#define mb()	asm volatile("mfence":::"memory")
> +#define rmb()	asm volatile("lfence":::"memory")
> +#define wmb()	asm volatile("sfence" ::: "memory")
> +
> +#endif
> diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> index 68b10e5..5b901a3 100644
> --- a/lib/x86/asm/io.h
> +++ b/lib/x86/asm/io.h
> @@ -2,6 +2,7 @@
>  #define _ASM_X86_IO_H_
>  
>  #include "asm/page.h"
> +#include "asm/barrier.h"
>  
>  static inline unsigned char inb(unsigned short port)
>  {
> diff --git a/lib/x86/smp.h b/lib/x86/smp.h
> index 566018f..afabac8 100644
> --- a/lib/x86/smp.h
> +++ b/lib/x86/smp.h
> @@ -2,10 +2,6 @@
>  #define __SMP_H
>  #include <asm/spinlock.h>
>  
> -#define mb() 	asm volatile("mfence":::"memory")
> -#define rmb()	asm volatile("lfence":::"memory")
> -#define wmb()	asm volatile("sfence" ::: "memory")
> -
>  void smp_init(void);
>  
>  int cpu_count(void);
> diff --git a/x86/kvmclock.c b/x86/kvmclock.c
> index 327e60d..208d43c 100644
> --- a/x86/kvmclock.c
> +++ b/x86/kvmclock.c
> @@ -3,6 +3,7 @@
>  #include "atomic.h"
>  #include "processor.h"
>  #include "kvmclock.h"
> +#include "asm/barrier.h"
>  
>  #define unlikely(x)	__builtin_expect(!!(x), 0)
>  #define likely(x)	__builtin_expect(!!(x), 1)
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 6/9] x86: Optimize virt_to_phys() and phys_to_virt()
  2016-04-27 13:13 ` [PATCH v2 6/9] x86: Optimize virt_to_phys() and phys_to_virt() Alexander Gordeev
@ 2016-04-27 13:58   ` Andrew Jones
  2016-04-27 16:54     ` Alexander Gordeev
  0 siblings, 1 reply; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 13:58 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 03:13:55PM +0200, Alexander Gordeev wrote:
> Make use of generic implementations and remove x86
> specific virt_to_phys() and phys_to_virt() functions.

I would drop this patch. If x86 needs/wants more stuff from
lib/asm-generic/io.h at a later time, then it can be brought
in then.

thanks,
drew

> 
> Cc: Andrew Jones <drjones@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  lib/asm-generic/io.h |  2 ++
>  lib/x86/asm/io.h     | 10 +---------
>  lib/x86/asm/page.h   |  3 +++
>  3 files changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> index 931415a..3585ac0 100644
> --- a/lib/asm-generic/io.h
> +++ b/lib/asm-generic/io.h
> @@ -165,7 +165,9 @@ static inline unsigned long virt_to_phys(volatile void *address)
>  {
>  	return __pa((unsigned long)address);
>  }
> +#endif
>  
> +#ifndef phys_to_virt
>  static inline void *phys_to_virt(unsigned long address)
>  {
>  	return __va(address);
> diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> index 5b901a3..74451d5 100644
> --- a/lib/x86/asm/io.h
> +++ b/lib/x86/asm/io.h
> @@ -40,14 +40,6 @@ 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;
> -}
> +#include <asm-generic/io.h>
>  
>  #endif
> diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
> index edfe325..a9280ed 100644
> --- a/lib/x86/asm/page.h
> +++ b/lib/x86/asm/page.h
> @@ -24,4 +24,7 @@
>  #define	PGDIR_MASK	1023
>  #endif
>  
> +#define __va(x)		((void *)((unsigned long) (x)))
> +#define __pa(x)		((unsigned long) (x))
> +
>  #endif
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 7/9] io: Make ioremap() prototype conform to Linux one
  2016-04-27 13:13 ` [PATCH v2 7/9] io: Make ioremap() prototype conform to Linux one Alexander Gordeev
@ 2016-04-27 13:59   ` Andrew Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 13:59 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 03:13:56PM +0200, Alexander Gordeev wrote:
> This update also adds missing __iomem specificator which
> has been used by existing IO accessors.
> 
> Cc: Andrew Jones <drjones@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  lib/asm-generic/io.h | 4 ++--
>  lib/ppc64/asm/io.h   | 2 ++
>  lib/x86/asm/io.h     | 2 ++
>  3 files changed, 6 insertions(+), 2 deletions(-)

Reviewed-by: Andrew Jones <drjones@redhat.com>

> 
> diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> index 3585ac0..28fe981 100644
> --- a/lib/asm-generic/io.h
> +++ b/lib/asm-generic/io.h
> @@ -153,10 +153,10 @@ static inline u64 __bswap64(u64 x)
>  	({ wmb(); __raw_writeq(cpu_to_le64(b), addr); })
>  
>  #ifndef ioremap
> -static inline void *ioremap(u64 phys_addr, size_t size __unused)
> +static inline void __iomem *ioremap(phys_addr_t phys_addr, size_t size __unused)
>  {
>  	assert(sizeof(long) == 8 || !(phys_addr >> 32));
> -	return (void *)(unsigned long)phys_addr;
> +	return (void __iomem *)(unsigned long)phys_addr;
>  }
>  #endif
>  
> diff --git a/lib/ppc64/asm/io.h b/lib/ppc64/asm/io.h
> index 4f2c31b..2b4dd2b 100644
> --- a/lib/ppc64/asm/io.h
> +++ b/lib/ppc64/asm/io.h
> @@ -9,5 +9,7 @@
>  #error Undefined byte order
>  #endif
>  
> +#define __iomem
> +
>  #include <asm-generic/io.h>
>  #endif
> diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> index 74451d5..c37450f 100644
> --- a/lib/x86/asm/io.h
> +++ b/lib/x86/asm/io.h
> @@ -4,6 +4,8 @@
>  #include "asm/page.h"
>  #include "asm/barrier.h"
>  
> +#define __iomem
> +
>  static inline unsigned char inb(unsigned short port)
>  {
>      unsigned char value;
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 8/9] io/x86: Factor out ioremap()
  2016-04-27 13:13 ` [PATCH v2 8/9] io/x86: Factor out ioremap() Alexander Gordeev
@ 2016-04-27 14:11   ` Andrew Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 14:11 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 03:13:57PM +0200, Alexander Gordeev wrote:
> Cc: Andrew Jones <drjones@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  lib/x86/asm/io.h |  3 +++
>  lib/x86/io.c     | 14 ++++++++++++++
>  x86/vmexit.c     | 10 ++--------
>  3 files changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> index c37450f..d8c5dbd 100644
> --- a/lib/x86/asm/io.h
> +++ b/lib/x86/asm/io.h
> @@ -42,6 +42,9 @@ static inline void outl(unsigned int value, unsigned short port)
>      asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port));
>  }
>  
> +#define ioremap ioremap
> +void __iomem *ioremap(phys_addr_t phys_addr, size_t size);
> +
>  #include <asm-generic/io.h>
>  
>  #endif
> diff --git a/lib/x86/io.c b/lib/x86/io.c
> index d396d42..a699509 100644
> --- a/lib/x86/io.c
> +++ b/lib/x86/io.c
> @@ -1,4 +1,5 @@
>  #include "libcflat.h"
> +#include "vm.h"
>  #include "smp.h"
>  #include "asm/io.h"
>  #ifndef USE_SERIAL
> @@ -81,3 +82,16 @@ void exit(int code)
>          asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
>  #endif
>  }
> +
> +void __iomem *ioremap(phys_addr_t phys_addr, size_t size)
> +{
> +	phys_addr_t base = ALIGN(phys_addr, PAGE_SIZE);

ALIGN() aligns up, so base will be larger than phys_addr, and then...

> +	phys_addr_t off = phys_addr - base;

...here off is going to be some massive number. But then...

> +	ulong nr = ALIGN(off + size + (PAGE_SIZE - 1), PAGE_SIZE) / PAGE_SIZE;

...it probably gets small again here after adding size (PAGE_SIZE called
from vmexit.c) and PAGE_SIZE-1. So you probably end up with nr=1 anyway.

Also, since ALIGN() aligns up, you don't need the '+ (PAGE_SIZE - 1)'
here.

> +	void *page = alloc_vpages(nr);
> +
> +	install_page((void *)read_cr3(), base, page);
> +
> +	return page + off;
> +}
> +
> diff --git a/x86/vmexit.c b/x86/vmexit.c
> index db7dbd8..c2e1e49 100644
> --- a/x86/vmexit.c
> +++ b/x86/vmexit.c
> @@ -371,8 +371,7 @@ int main(int ac, char **av)
>  {
>  	struct fadt_descriptor_rev1 *fadt;
>  	int i;
> -	unsigned long membar = 0, base, offset;
> -	void *m;
> +	unsigned long membar = 0;
>  	pcidevaddr_t pcidev;
>  
>  	smp_init();
> @@ -394,12 +393,7 @@ int main(int ac, char **av)
>  			}
>  			if (pci_bar_is_memory(pcidev, i)) {
>  				membar = pci_bar_addr(pcidev, i);
> -				base = membar & ~4095;
> -				offset = membar - base;
> -				m = alloc_vpages(1);
> -				
> -				install_page((void *)read_cr3(), base, m);
> -				pci_test.memaddr = m + offset;
> +				pci_test.memaddr = ioremap(membar, PAGE_SIZE);
>  			} else {
>  				pci_test.iobar = pci_bar_addr(pcidev, i);
>  			}
> -- 
> 1.8.3.1
>

Thanks,
drew 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 9/9] io: Disable memory re-ordering for generic memory barriers
  2016-04-27 13:13 ` [PATCH v2 9/9] io: Disable memory re-ordering for generic memory barriers Alexander Gordeev
@ 2016-04-27 14:14   ` Andrew Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 14:14 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář


s/Disable/Disallow/ <<< $SUBJECT

On Wed, Apr 27, 2016 at 03:13:58PM +0200, Alexander Gordeev wrote:
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Cc: Andrew Jones <drjones@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  lib/asm-generic/io.h | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> index 28fe981..1710cc4 100644
> --- a/lib/asm-generic/io.h
> +++ b/lib/asm-generic/io.h
> @@ -127,11 +127,14 @@ static inline u64 __bswap64(u64 x)
>  	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : ((u64)x); __r; })
>  #define cpu_to_be64 be64_to_cpu
>  
> +#ifndef mb
> +#define mb()	asm volatile("":::"memory")
> +#endif
>  #ifndef rmb
> -#define rmb() do { } while (0)
> +#define rmb()	asm volatile("":::"memory")
>  #endif
>  #ifndef wmb
> -#define wmb() do { } while (0)
> +#define wmb()	asm volatile("" ::: "memory")
>  #endif
>  
>  #define readb(addr) \
> -- 
> 1.8.3.1

Otherwise

Reviewed-by: Andrew Jones <drjones@redhat.com>


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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h
  2016-04-27 13:46   ` Andrew Jones
@ 2016-04-27 16:23     ` Alexander Gordeev
  2016-04-28  9:24       ` Alexander Gordeev
  0 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 16:23 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, Thomas Huth, Radim Krčmář

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@redhat.com>
> > Cc: Thomas Huth <thuth@redhat.com>
> > Cc: Radim Krčmář <rkrcmar@redhat.com>
> > Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> > ---
> >  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..

> > +
> > +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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h
  2016-04-27 13:52   ` Andrew Jones
@ 2016-04-27 16:26     ` Alexander Gordeev
  2016-04-28 16:23       ` Alexander Gordeev
  0 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 16:26 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 03:52:51PM +0200, Andrew Jones wrote:
> On Wed, Apr 27, 2016 at 03:13:54PM +0200, Alexander Gordeev wrote:
> > Make x86 consistent with other architectures and put
> > memory barrier defines to lib/x86/asm/barrier.h
> > 
> > Cc: Andrew Jones <drjones@redhat.com>
> > Cc: Thomas Huth <thuth@redhat.com>
> > Cc: Radim Krčmář <rkrcmar@redhat.com>
> > Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> > ---
> >  lib/x86/asm/barrier.h | 8 ++++++++
> >  lib/x86/asm/io.h      | 1 +
> >  lib/x86/smp.h         | 4 ----
> >  x86/kvmclock.c        | 1 +
> >  4 files changed, 10 insertions(+), 4 deletions(-)
> >  create mode 100644 lib/x86/asm/barrier.h
> 
> Reviewed-by: Andrew Jones <drjones@redhat.com>

I forgot about your _ASM_X86 vs _ASMX86 nit.
I will resend this (and others affected).

> > 
> > diff --git a/lib/x86/asm/barrier.h b/lib/x86/asm/barrier.h
> > new file mode 100644
> > index 0000000..0ca1c56
> > --- /dev/null
> > +++ b/lib/x86/asm/barrier.h
> > @@ -0,0 +1,8 @@
> > +#ifndef _ASM_X86_BARRIER_H_
> > +#define _ASM_X86_BARRIER_H_
> > +
> > +#define mb()	asm volatile("mfence":::"memory")
> > +#define rmb()	asm volatile("lfence":::"memory")
> > +#define wmb()	asm volatile("sfence" ::: "memory")
> > +
> > +#endif
> > diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> > index 68b10e5..5b901a3 100644
> > --- a/lib/x86/asm/io.h
> > +++ b/lib/x86/asm/io.h
> > @@ -2,6 +2,7 @@
> >  #define _ASM_X86_IO_H_
> >  
> >  #include "asm/page.h"
> > +#include "asm/barrier.h"
> >  
> >  static inline unsigned char inb(unsigned short port)
> >  {
> > diff --git a/lib/x86/smp.h b/lib/x86/smp.h
> > index 566018f..afabac8 100644
> > --- a/lib/x86/smp.h
> > +++ b/lib/x86/smp.h
> > @@ -2,10 +2,6 @@
> >  #define __SMP_H
> >  #include <asm/spinlock.h>
> >  
> > -#define mb() 	asm volatile("mfence":::"memory")
> > -#define rmb()	asm volatile("lfence":::"memory")
> > -#define wmb()	asm volatile("sfence" ::: "memory")
> > -
> >  void smp_init(void);
> >  
> >  int cpu_count(void);
> > diff --git a/x86/kvmclock.c b/x86/kvmclock.c
> > index 327e60d..208d43c 100644
> > --- a/x86/kvmclock.c
> > +++ b/x86/kvmclock.c
> > @@ -3,6 +3,7 @@
> >  #include "atomic.h"
> >  #include "processor.h"
> >  #include "kvmclock.h"
> > +#include "asm/barrier.h"
> >  
> >  #define unlikely(x)	__builtin_expect(!!(x), 0)
> >  #define likely(x)	__builtin_expect(!!(x), 1)
> > -- 
> > 1.8.3.1
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe kvm" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 6/9] x86: Optimize virt_to_phys() and phys_to_virt()
  2016-04-27 13:58   ` Andrew Jones
@ 2016-04-27 16:54     ` Alexander Gordeev
  2016-04-27 18:19       ` Andrew Jones
  0 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-27 16:54 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 03:58:02PM +0200, Andrew Jones wrote:
> On Wed, Apr 27, 2016 at 03:13:55PM +0200, Alexander Gordeev wrote:
> > Make use of generic implementations and remove x86
> > specific virt_to_phys() and phys_to_virt() functions.
> 
> I would drop this patch. If x86 needs/wants more stuff from
> lib/asm-generic/io.h at a later time, then it can be brought
> in then.

Will drop it.

But I do not get your point :) The x86 variants almost duplicate
the generic ones - so why x86 would not want to bring it?

> thanks,
> drew
> 
> > 
> > Cc: Andrew Jones <drjones@redhat.com>
> > Cc: Thomas Huth <thuth@redhat.com>
> > Cc: Radim Krčmář <rkrcmar@redhat.com>
> > Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> > ---
> >  lib/asm-generic/io.h |  2 ++
> >  lib/x86/asm/io.h     | 10 +---------
> >  lib/x86/asm/page.h   |  3 +++
> >  3 files changed, 6 insertions(+), 9 deletions(-)
> > 
> > diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> > index 931415a..3585ac0 100644
> > --- a/lib/asm-generic/io.h
> > +++ b/lib/asm-generic/io.h
> > @@ -165,7 +165,9 @@ static inline unsigned long virt_to_phys(volatile void *address)
> >  {
> >  	return __pa((unsigned long)address);
> >  }
> > +#endif
> >  
> > +#ifndef phys_to_virt
> >  static inline void *phys_to_virt(unsigned long address)
> >  {
> >  	return __va(address);
> > diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> > index 5b901a3..74451d5 100644
> > --- a/lib/x86/asm/io.h
> > +++ b/lib/x86/asm/io.h
> > @@ -40,14 +40,6 @@ 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;
> > -}
> > +#include <asm-generic/io.h>
> >  
> >  #endif
> > diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
> > index edfe325..a9280ed 100644
> > --- a/lib/x86/asm/page.h
> > +++ b/lib/x86/asm/page.h
> > @@ -24,4 +24,7 @@
> >  #define	PGDIR_MASK	1023
> >  #endif
> >  
> > +#define __va(x)		((void *)((unsigned long) (x)))
> > +#define __pa(x)		((unsigned long) (x))
> > +
> >  #endif
> > -- 
> > 1.8.3.1
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe kvm" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 6/9] x86: Optimize virt_to_phys() and phys_to_virt()
  2016-04-27 16:54     ` Alexander Gordeev
@ 2016-04-27 18:19       ` Andrew Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-27 18:19 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 06:54:22PM +0200, Alexander Gordeev wrote:
> On Wed, Apr 27, 2016 at 03:58:02PM +0200, Andrew Jones wrote:
> > On Wed, Apr 27, 2016 at 03:13:55PM +0200, Alexander Gordeev wrote:
> > > Make use of generic implementations and remove x86
> > > specific virt_to_phys() and phys_to_virt() functions.
> > 
> > I would drop this patch. If x86 needs/wants more stuff from
> > lib/asm-generic/io.h at a later time, then it can be brought
> > in then.
> 
> Will drop it.
> 
> But I do not get your point :) The x86 variants almost duplicate
> the generic ones - so why x86 would not want to bring it?

yes, but a whole file full of stuff is a lot to bring in just to
take advantage of two functions (virt_to_phys/phys_to_virt) that
are likely better off being written more arch-specific sometime
anyway.

thanks,
drew

> 
> > thanks,
> > drew
> > 
> > > 
> > > Cc: Andrew Jones <drjones@redhat.com>
> > > Cc: Thomas Huth <thuth@redhat.com>
> > > Cc: Radim Krčmář <rkrcmar@redhat.com>
> > > Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> > > ---
> > >  lib/asm-generic/io.h |  2 ++
> > >  lib/x86/asm/io.h     | 10 +---------
> > >  lib/x86/asm/page.h   |  3 +++
> > >  3 files changed, 6 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> > > index 931415a..3585ac0 100644
> > > --- a/lib/asm-generic/io.h
> > > +++ b/lib/asm-generic/io.h
> > > @@ -165,7 +165,9 @@ static inline unsigned long virt_to_phys(volatile void *address)
> > >  {
> > >  	return __pa((unsigned long)address);
> > >  }
> > > +#endif
> > >  
> > > +#ifndef phys_to_virt
> > >  static inline void *phys_to_virt(unsigned long address)
> > >  {
> > >  	return __va(address);
> > > diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> > > index 5b901a3..74451d5 100644
> > > --- a/lib/x86/asm/io.h
> > > +++ b/lib/x86/asm/io.h
> > > @@ -40,14 +40,6 @@ 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;
> > > -}
> > > +#include <asm-generic/io.h>
> > >  
> > >  #endif
> > > diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
> > > index edfe325..a9280ed 100644
> > > --- a/lib/x86/asm/page.h
> > > +++ b/lib/x86/asm/page.h
> > > @@ -24,4 +24,7 @@
> > >  #define	PGDIR_MASK	1023
> > >  #endif
> > >  
> > > +#define __va(x)		((void *)((unsigned long) (x)))
> > > +#define __pa(x)		((unsigned long) (x))
> > > +
> > >  #endif
> > > -- 
> > > 1.8.3.1
> > > 
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe kvm" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h
  2016-04-27 16:23     ` Alexander Gordeev
@ 2016-04-28  9:24       ` Alexander Gordeev
  2016-04-28 11:13         ` Andrew Jones
  0 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-28  9:24 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, Thomas Huth, Radim Krčmář

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@redhat.com>
> > > Cc: Thomas Huth <thuth@redhat.com>
> > > Cc: Radim Krčmář <rkrcmar@redhat.com>
> > > Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> > > ---
> > >  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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h
  2016-04-28  9:24       ` Alexander Gordeev
@ 2016-04-28 11:13         ` Andrew Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-28 11:13 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Thu, Apr 28, 2016 at 11:24:38AM +0200, Alexander Gordeev wrote:
> 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
...
> > > > 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.

Agreed it would be a different patch. But in this case, none needed.

The policy is to only include what's needed in source files.
Also, header files should only include what's needed [most] of
the time. I've made at least one exception, commit 957b6055, and
other cases for convenience could probably be made, but case-by-
case.

Also, in this case, lib/arm[64]/asm/io.h includes asm/page.h
because virt_to_phys/phys_to_virt builds on helpers that are
in asm/page.h And, if you're wondering about asm/barrier.h,
that's because asm-generic/io.h is included at the bottom, and
we want to override the generic barriers before defining other
generic functions that use them.

Thanks,
drew

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h
  2016-04-27 16:26     ` Alexander Gordeev
@ 2016-04-28 16:23       ` Alexander Gordeev
  2016-04-28 17:00         ` Andrew Jones
  0 siblings, 1 reply; 28+ messages in thread
From: Alexander Gordeev @ 2016-04-28 16:23 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, Thomas Huth, Radim Krčmář

On Wed, Apr 27, 2016 at 06:26:56PM +0200, Alexander Gordeev wrote:
> On Wed, Apr 27, 2016 at 03:52:51PM +0200, Andrew Jones wrote:
> > On Wed, Apr 27, 2016 at 03:13:54PM +0200, Alexander Gordeev wrote:
> > > Make x86 consistent with other architectures and put
> > > memory barrier defines to lib/x86/asm/barrier.h
> > > 
> > > Cc: Andrew Jones <drjones@redhat.com>
> > > Cc: Thomas Huth <thuth@redhat.com>
> > > Cc: Radim Krčmář <rkrcmar@redhat.com>
> > > Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> > > ---
> > >  lib/x86/asm/barrier.h | 8 ++++++++
> > >  lib/x86/asm/io.h      | 1 +
> > >  lib/x86/smp.h         | 4 ----
> > >  x86/kvmclock.c        | 1 +
> > >  4 files changed, 10 insertions(+), 4 deletions(-)
> > >  create mode 100644 lib/x86/asm/barrier.h
> > 
> > Reviewed-by: Andrew Jones <drjones@redhat.com>
> 
> I forgot about your _ASM_X86 vs _ASMX86 nit.
> I will resend this (and others affected).

Actually, all x86 headers have _ASM_X86 prefix, except
lib/x86/asm/bitops.h. So either introduce _ASM_X86_BARRIER_H_
and _ASM_X86_PAGE_H_ and change _ASMX86_BITOPS_H_ or fix them
all. Or just do not do anything about that? :)

> > > 
> > > diff --git a/lib/x86/asm/barrier.h b/lib/x86/asm/barrier.h
> > > new file mode 100644
> > > index 0000000..0ca1c56
> > > --- /dev/null
> > > +++ b/lib/x86/asm/barrier.h
> > > @@ -0,0 +1,8 @@
> > > +#ifndef _ASM_X86_BARRIER_H_
> > > +#define _ASM_X86_BARRIER_H_

Or _ASMX86_BARRIER_H_?

> > > +
> > > +#define mb()	asm volatile("mfence":::"memory")
> > > +#define rmb()	asm volatile("lfence":::"memory")
> > > +#define wmb()	asm volatile("sfence" ::: "memory")
> > > +
> > > +#endif
> > > diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> > > index 68b10e5..5b901a3 100644
> > > --- a/lib/x86/asm/io.h
> > > +++ b/lib/x86/asm/io.h
> > > @@ -2,6 +2,7 @@
> > >  #define _ASM_X86_IO_H_
> > >  
> > >  #include "asm/page.h"
> > > +#include "asm/barrier.h"
> > >  
> > >  static inline unsigned char inb(unsigned short port)
> > >  {
> > > diff --git a/lib/x86/smp.h b/lib/x86/smp.h
> > > index 566018f..afabac8 100644
> > > --- a/lib/x86/smp.h
> > > +++ b/lib/x86/smp.h
> > > @@ -2,10 +2,6 @@
> > >  #define __SMP_H
> > >  #include <asm/spinlock.h>
> > >  
> > > -#define mb() 	asm volatile("mfence":::"memory")
> > > -#define rmb()	asm volatile("lfence":::"memory")
> > > -#define wmb()	asm volatile("sfence" ::: "memory")
> > > -
> > >  void smp_init(void);
> > >  
> > >  int cpu_count(void);
> > > diff --git a/x86/kvmclock.c b/x86/kvmclock.c
> > > index 327e60d..208d43c 100644
> > > --- a/x86/kvmclock.c
> > > +++ b/x86/kvmclock.c
> > > @@ -3,6 +3,7 @@
> > >  #include "atomic.h"
> > >  #include "processor.h"
> > >  #include "kvmclock.h"
> > > +#include "asm/barrier.h"
> > >  
> > >  #define unlikely(x)	__builtin_expect(!!(x), 0)
> > >  #define likely(x)	__builtin_expect(!!(x), 1)
> > > -- 
> > > 1.8.3.1
> > > 
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe kvm" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h
  2016-04-28 16:23       ` Alexander Gordeev
@ 2016-04-28 17:00         ` Andrew Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Andrew Jones @ 2016-04-28 17:00 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: kvm, Thomas Huth, Radim Krčmář

On Thu, Apr 28, 2016 at 06:23:18PM +0200, Alexander Gordeev wrote:
> On Wed, Apr 27, 2016 at 06:26:56PM +0200, Alexander Gordeev wrote:
> > On Wed, Apr 27, 2016 at 03:52:51PM +0200, Andrew Jones wrote:
> > > On Wed, Apr 27, 2016 at 03:13:54PM +0200, Alexander Gordeev wrote:
> > > > Make x86 consistent with other architectures and put
> > > > memory barrier defines to lib/x86/asm/barrier.h
> > > > 
> > > > Cc: Andrew Jones <drjones@redhat.com>
> > > > Cc: Thomas Huth <thuth@redhat.com>
> > > > Cc: Radim Krčmář <rkrcmar@redhat.com>
> > > > Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> > > > ---
> > > >  lib/x86/asm/barrier.h | 8 ++++++++
> > > >  lib/x86/asm/io.h      | 1 +
> > > >  lib/x86/smp.h         | 4 ----
> > > >  x86/kvmclock.c        | 1 +
> > > >  4 files changed, 10 insertions(+), 4 deletions(-)
> > > >  create mode 100644 lib/x86/asm/barrier.h
> > > 
> > > Reviewed-by: Andrew Jones <drjones@redhat.com>
> > 
> > I forgot about your _ASM_X86 vs _ASMX86 nit.
> > I will resend this (and others affected).
> 
> Actually, all x86 headers have _ASM_X86 prefix, except
> lib/x86/asm/bitops.h. So either introduce _ASM_X86_BARRIER_H_
> and _ASM_X86_PAGE_H_ and change _ASMX86_BITOPS_H_ or fix them
> all. Or just do not do anything about that? :)

It doesn't matter to me. Definitely don't fix anything, just
pick whichever you like for this one :)

> 
> > > > 
> > > > diff --git a/lib/x86/asm/barrier.h b/lib/x86/asm/barrier.h
> > > > new file mode 100644
> > > > index 0000000..0ca1c56
> > > > --- /dev/null
> > > > +++ b/lib/x86/asm/barrier.h
> > > > @@ -0,0 +1,8 @@
> > > > +#ifndef _ASM_X86_BARRIER_H_
> > > > +#define _ASM_X86_BARRIER_H_
> 
> Or _ASMX86_BARRIER_H_?

Whatever :)

thanks,
drew

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2016-04-28 17:00 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-27 13:13 [PATCH v2 0/9] Cleanup low-level arch code Alexander Gordeev
2016-04-27 13:13 ` [PATCH v2 1/9] Remove unused and unnecessary PHYS32 macro Alexander Gordeev
2016-04-27 13:13 ` [PATCH v2 2/9] Move phys_addr_t type definition to lib/libcflat.h Alexander Gordeev
2016-04-27 13:42   ` Andrew Jones
2016-04-27 13:13 ` [PATCH v2 3/9] x86: Introduce lib/x86/asm/page.h Alexander Gordeev
2016-04-27 13:45   ` Andrew Jones
2016-04-27 13:13 ` [PATCH v2 4/9] x86: Introduce lib/x86/asm/io.h Alexander Gordeev
2016-04-27 13:46   ` Andrew Jones
2016-04-27 16:23     ` Alexander Gordeev
2016-04-28  9:24       ` Alexander Gordeev
2016-04-28 11:13         ` Andrew Jones
2016-04-27 13:51   ` Andrew Jones
2016-04-27 13:13 ` [PATCH v2 5/9] x86: Introduce lib/x86/asm/barrier.h Alexander Gordeev
2016-04-27 13:52   ` Andrew Jones
2016-04-27 16:26     ` Alexander Gordeev
2016-04-28 16:23       ` Alexander Gordeev
2016-04-28 17:00         ` Andrew Jones
2016-04-27 13:13 ` [PATCH v2 6/9] x86: Optimize virt_to_phys() and phys_to_virt() Alexander Gordeev
2016-04-27 13:58   ` Andrew Jones
2016-04-27 16:54     ` Alexander Gordeev
2016-04-27 18:19       ` Andrew Jones
2016-04-27 13:13 ` [PATCH v2 7/9] io: Make ioremap() prototype conform to Linux one Alexander Gordeev
2016-04-27 13:59   ` Andrew Jones
2016-04-27 13:13 ` [PATCH v2 8/9] io/x86: Factor out ioremap() Alexander Gordeev
2016-04-27 14:11   ` Andrew Jones
2016-04-27 13:13 ` [PATCH v2 9/9] io: Disable memory re-ordering for generic memory barriers Alexander Gordeev
2016-04-27 14:14   ` Andrew Jones
2016-04-27 13:34 ` [PATCH v2 0/9] Cleanup low-level arch code Andrew Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.