50% Friday offer on business documents (kshs 1000)

2014-02-01 Thread Docs kenya Ltd


download the docs at www.emailmarketingkenya.info for only kshs 1000

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


Re: [PULL v2 0/8] vfio pull request

2014-02-01 Thread Peter Maydell
Applied, thanks.

For the record, it doesn't matter if you cc me or not, because I've set my
mail client to look for the magic words for you to fetch changes up to :-)

thanks
-- PMM

On 28 January 2014 15:58, Alex Williamson alex.william...@redhat.com wrote:

 I guess I should be addressing these to both Anthony and Peter now.
 Thanks for stepping in, Peter.  Thanks,

 Alex

 On Tue, 2014-01-28 at 08:44 -0700, Alex Williamson wrote:
 Anthony,

 My last vfio pull request didn't seem to make the most recent round of
 merges.  The only difference in this request is trivial patch 8/8, the
 rest is a resend.  I've not rebased in order to maintain the commit
 IDs from my previous tag, the merge to current HEAD is still clean.
 Please pull.  Thanks,

 Alex

 The following changes since commit 1cf892ca2689c84960b4ce4d2723b6bee453711c:

   SPARC: Fix LEON3 power down instruction (2014-01-15 15:37:33 +1000)

 are available in the git repository at:

   git://github.com/awilliam/qemu-vfio.git tags/vfio-pci-for-qemu-20140128.0

 for you to fetch changes up to 8b6d14087d487203f4d1a67aeaddc3be6c73f49f:

   vfio: correct debug macro typo (2014-01-28 08:23:19 -0700)

 
 vfio-pci updates include:
  - Destroy MemoryRegions on device teardown
  - Print warnings around PCI option ROM failures
  - Skip bogus mappings from 64bit BAR sizing
  - Act on DMA mapping failures
  - Fix alignment to avoid MSI-X table mapping
  - Fix debug macro typo

 
 Alex Williamson (3):
   vfio: Destroy memory regions
   vfio: Filter out bogus mappings
   vfio-pci: Fail initfn on DMA mapping errors

 Alexey Kardashevskiy (2):
   kvm: initialize qemu_host_page_size
   vfio: fix mapping of MSIX bar

 Bandan Das (3):
   vfio: warn if host device rom can't be read
   vfio: Do not reattempt a failed rom read
   vfio: correct debug macro typo

  hw/misc/vfio.c  | 78 
 ++---
  include/exec/exec-all.h |  1 +
  kvm-all.c   |  1 +
  translate-all.c | 14 +
  4 files changed, 77 insertions(+), 17 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Measuring KVM Performance using Hardware Performance Counters

2014-02-01 Thread Xin Tong
I am getting very weird profile results by running operf on linux on
the host and profiling the a kvm virtual machine running dacapo
eclipse benchmark.  I am expecting a lot of time should be spent in
the qemu-system-x86_64 as the instructions from the eclipse benchmark
would be treated as part of the qemu-system-x86_64 process, but the
results tell different. any suggestions ?


CPU_CLK_UNHALTED % Module
 Symbol/Functions
1054 31.49 /kvm
 /kvm
645 19.27 /kvm_intel
/kvm_intel
248 7.41
/home/xtong/qemu-kvm-1.2.0/install/bin/qemu-system-x86_64
/home/xtong/qemu-kvm-1.2.0/install/bin/qemu-system-x86_64
215 6.42 /usr/lib/debug/boot/vmlinux-3.11.0-13-generic
native_write_msr_safe
101 3.02 /usr/lib/debug/boot/vmlinux-3.11.0-13-generic
native_read_msr_safe
93   2.78 /lib/x86_64-linux-gnu/libc-2.15.so
/lib/x86_64-linux-gnu/libc-2.15.so
77   2.30 /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4
 /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4
65   1.94 /usr/lib/debug/boot/vmlinux-3.11.0-13-generic
 __srcu_read_lock
48   1.43 /usr/lib/debug/boot/vmlinux-3.11.0-13-generic
 __srcu_read_unlock
40   1.20 /usr/lib/debug/boot/vmlinux-3.11.0-13-generic
 native_load_tr_desc
29   0.87 /usr/lib/debug/boot/vmlinux-3.11.0-13-generic
 __ticket_spin_lock
25   0.75 /usr/lib/debug/boot/vmlinux-3.11.0-13-generic
 guest_exit
21   0.63 /usr/lib/debug/boot/vmlinux-3.11.0-13-generic
 native_load_gdt
...
Thank you.

On Wed, Jan 29, 2014 at 11:06 PM, Xin Tong xerox.time.t...@gmail.com wrote:
 Hi

 I would like to measure the performance of KVM by using hardware
 performance counters and I have some questions

 1. if i want to get the amount of time spent in instruction and device
 emulation, should i use oprofile on the kvm process on the host
 machine ?
 2. what about amount of time spent in TLB misses, kvm makes uses of
 nested page in which a tlb miss could be expensive.
 3. are there existing ways/measurements i can look into ?

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


Re: [PATCH 00/17] kvm-unit-tests/arm: initial drop

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:46PM +0100, Andrew Jones wrote:
 This is a v3 of a series that introduces arm to kvm-unit-tests.

Just a meta-comment:

It would be helpful if you include the v3 in your subjects so it's
easy to go back and track previous review comments.

git format-patch --subject-prefix PATCH v3

is your friend here.

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


Re: [PATCH 06/17] Add halt() and some error codes

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:52PM +0100, Andrew Jones wrote:
 Define a halt function that can be implemented by the test framework
 for use on error paths before exit() works. Also add some error codes
 that can be passed to halt() in case the serial isn't working either.
 Then, on register inspection of the halted guest we may be able to
 quickly determine the problem without having to find the halt()
 call-site. The error codes may of course also be used with exit().
 
 Signed-off-by: Andrew Jones drjo...@redhat.com
 
Acked-by: Christoffer Dall christoffer.d...@linaro.org
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/17] add 'make cscope' support

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:51PM +0100, Andrew Jones wrote:
 Add a Makefile target to quickly generate arch-specific cscope
 for kvm-unit-tests. Assumes a mostly flat directory structure,
 i.e. uses '-maxdepth 1' in the file search.
 
 Signed-off-by: Andrew Jones drjo...@redhat.com
 ---
  Makefile | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)
 
 diff --git a/Makefile b/Makefile
 index fa95d66386d49..283655957f39f 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -3,7 +3,7 @@ include config.mak
  
  DESTDIR := $(PREFIX)/share/qemu/tests
  
 -.PHONY: arch_clean clean
 +.PHONY: arch_clean clean cscope
  
  #make sure env CFLAGS variable is not used
  CFLAGS =
 @@ -52,3 +52,10 @@ install:
  
  clean: arch_clean
   $(RM) lib/.*.d $(libcflat) $(cflatobjs)
 +
 +cscope: common_dirs = lib
 +cscope:
 + rm -f ./cscope.*
 + find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
 + -name *.[chsS] -print | sed 's,^\./,,'  ./cscope.files

shouldn't you use single quotes for the -name pattern to avoid any
substitutions here?

 + cscope -bk
 -- 
 1.8.1.4
 

Otherwise:
Acked-by: Christoffer Dall christoffer.d...@linaro.org
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/17] move x86's simple heap management to common code

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:53PM +0100, Andrew Jones wrote:
 v3: fixed Christoffer's nits
 
 Signed-off-by: Andrew Jones drjo...@redhat.com

Reviewed-by: Christoffer Dall christoffer.d...@linaro.org
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 08/17] Introduce libio to common code for io read/write

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:54PM +0100, Andrew Jones wrote:
 v3:
  - get rid of CONFIG_64BIT, replace with asserts
  - get rid of {read,write}_len()
  - fix bad *64_to_cpu macros

note that putting the changelog after the --- prevents it from
getting committed, but I'm not sure if there are different
conventions for the unit-tests framework.

 
 Signed-off-by: Andrew Jones drjo...@redhat.com
 ---
  lib/libio.h | 173 
 
  1 file changed, 173 insertions(+)
  create mode 100644 lib/libio.h
 
 diff --git a/lib/libio.h b/lib/libio.h
 new file mode 100644
 index 0..6adc6a7bbee61
 --- /dev/null
 +++ b/lib/libio.h
 @@ -0,0 +1,173 @@
 +#ifndef _LIBIO_H_
 +#define _LIBIO_H_
 +/*
 + * Adapted from the Linux kernel's include/asm-generic/io.h and
 + * arch/arm/include/asm/io.h
 + */
 +#include libcflat.h
 +
 +#ifndef NDEBUG
 +#define LIBIO_ASSERT(expr) do { \
 + if (!(expr)) printf(%s:%d: assert failed!\n, __FILE__, __LINE__);\
 +} while (0)
 +#else
 +#define LIBIO_ASSERT(expr) do { } while (0)
 +#endif
 +
 +typedef u32 compat_ptr_t;
 +
 +/*
 + * Use compat_ptr() on 64-bit arches when casting 32-bit

arches? architectures? archs?

 + * addresses to pointers in order to avoid compiler warnings.
 + */
 +static inline void *compat_ptr(compat_ptr_t ptr)
 +{
 + return (void *)(unsigned long)ptr;
 +}
 +
 +static inline compat_ptr_t ptr_to_compat(void *ptr)
 +{
 + return (u32)(unsigned long)ptr;
 +}
 +
 +#ifndef __raw_readb
 +static inline u8 __raw_readb(const volatile void *addr)
 +{
 + return *(const volatile u8 *)addr;
 +}
 +#endif
 +
 +#ifndef __raw_readw
 +static inline u16 __raw_readw(const volatile void *addr)
 +{
 + return *(const volatile u16 *)addr;
 +}
 +#endif
 +
 +#ifndef __raw_readl
 +static inline u32 __raw_readl(const volatile void *addr)
 +{
 + return *(const volatile u32 *)addr;
 +}
 +#endif
 +
 +#ifndef __raw_readq
 +static inline u64 __raw_readq(const volatile void *addr)
 +{
 + LIBIO_ASSERT(sizeof(unsigned long) == sizeof(u64));
 + return *(const volatile u64 *)addr;
 +}
 +#endif
 +
 +#ifndef __raw_writeb
 +static inline void __raw_writeb(u8 b, volatile void *addr)
 +{
 + *(volatile u8 *)addr = b;
 +}
 +#endif
 +
 +#ifndef __raw_writew
 +static inline void __raw_writew(u16 b, volatile void *addr)
 +{
 + *(volatile u16 *)addr = b;
 +}
 +#endif
 +
 +#ifndef __raw_writel
 +static inline void __raw_writel(u32 b, volatile void *addr)
 +{
 + *(volatile u32 *)addr = b;
 +}
 +#endif
 +
 +#ifndef __raw_writeq
 +static inline void __raw_writeq(u64 b, volatile void *addr)
 +{
 + LIBIO_ASSERT(sizeof(unsigned long) == sizeof(u64));
 + *(volatile u64 *)addr = b;
 +}
 +#endif
 +
 +#ifndef __bswap16
 +static inline u16 __bswap16(u16 x)
 +{
 + return ((x  8)  0xff) | ((x  0xff)  8);
 +}
 +#endif
 +
 +#ifndef __bswap32
 +static inline u32 __bswap32(u32 x)
 +{
 + return ((x  0xff00)  24) | ((x  0x00ff)   8) |
 +((x  0xff00)   8) | ((x  0x00ff)  24);
 +}
 +#endif
 +
 +#ifndef __bswap64
 +static inline u64 __bswap64(u64 x)
 +{
 + return ((x  0x00ffULL)  56) |
 +((x  0xff00ULL)  40) |
 +((x  0x00ffULL)  24) |
 +((x  0xff00ULL)   8) |
 +((x  0x00ffULL)   8) |
 +((x  0xff00ULL)  24) |
 +((x  0x00ffULL)  40) |
 +((x  0xff00ULL)  56);
 +}
 +#endif
 +
 +#ifndef cpu_is_be
 +#define cpu_is_be 0
 +#endif
 +
 +#define le16_to_cpu(x) \
 + ({ u16 __r = cpu_is_be ? __bswap16(x) : (x); __r; })
 +#define cpu_to_le16 le16_to_cpu
 +
 +#define le32_to_cpu(x) \
 + ({ u32 __r = cpu_is_be ? __bswap32(x) : (x); __r; })
 +#define cpu_to_le32 le32_to_cpu
 +
 +#define le64_to_cpu(x) \
 + ({ u64 __r = cpu_is_be ? __bswap64(x) : (x); __r; })
 +#define cpu_to_le64 le64_to_cpu
 +
 +#define be16_to_cpu(x) \
 + ({ u16 __r = !cpu_is_be ? __bswap16(x) : (x); __r; })
 +#define cpu_to_be16 be16_to_cpu
 +
 +#define be32_to_cpu(x) \
 + ({ u32 __r = !cpu_is_be ? __bswap32(x) : (x); __r; })
 +#define cpu_to_be32 be32_to_cpu
 +
 +#define be64_to_cpu(x) \
 + ({ u64 __r = !cpu_is_be ? __bswap64(x) : (x); __r; })
 +#define cpu_to_be64 be64_to_cpu
 +
 +#ifndef rmb
 +#define rmb() do { } while (0)
 +#endif
 +#ifndef wmb
 +#define wmb() do { } while (0)
 +#endif
 +
 +#define readb(addr) \
 + ({ u8 __r = __raw_readb(addr); rmb(); __r; })
 +#define readw(addr) \
 + ({ u16 __r = le16_to_cpu(__raw_readw(addr)); rmb(); __r; })
 +#define readl(addr) \
 + ({ u32 __r = le32_to_cpu(__raw_readl(addr)); rmb(); __r; })
 +#define readq(addr) \
 + ({ u64 __r = le64_to_cpu(__raw_readq(addr)); rmb(); __r; })
 +
 +#define writeb(b, addr) \
 + ({ wmb(); __raw_writeb(b, addr); })
 +#define writew(b, addr) \
 + ({ wmb(); __raw_writew(cpu_to_le16(b), addr); })
 +#define writel(b, addr) \
 + ({ wmb(); 

Re: [PATCH 09/17] libfdt: Import libfdt source

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:55PM +0100, Andrew Jones wrote:
 This adds the applicable libfdt source files (unmodified) and a
 README to explain where the source came from. The README says
 
   The code in this directory is originally imported from the libfdt
   directory of git://git.jdl.com/software/dtc.git - version 1.4.0.
 
 Signed-off-by: Andrew Jones drjo...@redhat.com

FWIW: Acked-by: Christoffer Dall christoffer.d...@linaro.org
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/17] libfdt: get libfdt to build

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:56PM +0100, Andrew Jones wrote:
 Add string functions needed for libfdt, modify libfdt_env.h
 for this environment, and add a make target.

The endianness changes you're making to CPU_TO_FDTxx are not trivial to
review.  A motivational commit text here would have been immensely
helpful.

 
 Signed-off-by: Andrew Jones drjo...@redhat.com
 ---
  Makefile| 23 +-
  lib/libcflat.h  |  4 
  lib/libfdt/libfdt_env.h | 25 
  lib/string.c| 51 
 +
  4 files changed, 90 insertions(+), 13 deletions(-)
 
 diff --git a/Makefile b/Makefile
 index 283655957f39f..94c565242c1b7 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -16,6 +16,13 @@ cflatobjs := \
   lib/printf.o \
   lib/string.o
  
 +# libfdt paths
 +LIBFDT_objdir = lib/libfdt
 +LIBFDT_srcdir = lib/libfdt
 +LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
 +LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
 +LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
 +
  #include architecure specific make rules
  include config/config-$(ARCH).mak
  
 @@ -41,6 +48,20 @@ LDFLAGS += -pthread -lrt
  $(libcflat): $(cflatobjs)
   $(AR) rcs $@ $^
  
 +include $(LIBFDT_srcdir)/Makefile.libfdt
 +
 +.PHONY: libfdt
 +libfdt: $(LIBFDT_archive)
 +
 +$(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt 
 -Wno-sign-compare
 +$(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 + $(AR) rcs $@ $^
 +
 +libfdt_clean:
 + $(RM) $(LIBFDT_archive) \
 + $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) \
 + $(LIBFDT_objdir)/.*.d
 +
  %.o: %.S
   $(CC) $(CFLAGS) -c -nostdlib -o $@ $
  
 @@ -53,7 +74,7 @@ install:
  clean: arch_clean
   $(RM) lib/.*.d $(libcflat) $(cflatobjs)
  
 -cscope: common_dirs = lib
 +cscope: common_dirs = lib lib/libfdt
  cscope:
   rm -f ./cscope.*
   find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
 diff --git a/lib/libcflat.h b/lib/libcflat.h
 index a1be635ab4ee9..2cde64a560956 100644
 --- a/lib/libcflat.h
 +++ b/lib/libcflat.h
 @@ -43,6 +43,7 @@ extern void exit(int code);
  extern unsigned long strlen(const char *buf);
  extern char *strcat(char *dest, const char *src);
  extern int strcmp(const char *a, const char *b);
 +extern char *strchr(const char *s, int c);
  
  extern int printf(const char *fmt, ...);
  extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
 @@ -51,6 +52,9 @@ extern void puts(const char *s);
  
  extern void *memset(void *s, int c, size_t n);
  extern void *memcpy(void *dest, const void *src, size_t n);
 +extern int memcmp(const void *s1, const void *s2, size_t n);
 +extern void *memmove(void *dest, const void *src, size_t n);
 +extern void *memchr(const void *s, int c, size_t n);
  
  extern long atol(const char *ptr);
  #define ARRAY_SIZE(_a)  (sizeof(_a)/sizeof((_a)[0]))
 diff --git a/lib/libfdt/libfdt_env.h b/lib/libfdt/libfdt_env.h
 index 9dea97dfff818..46fcb6c29045f 100644
 --- a/lib/libfdt/libfdt_env.h
 +++ b/lib/libfdt/libfdt_env.h
 @@ -52,9 +52,16 @@
   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
 -#include stddef.h
 -#include stdint.h
 -#include string.h
 +#include libcflat.h
 +#include libio.h
 +
 +#ifndef HAVE_UINTS
 +typedef u8 uint8_t;
 +typedef u16 uint16_t;
 +typedef u32 uint32_t;
 +typedef u64 uint64_t;
 +typedef unsigned long uintptr_t;
 +#endif
  
  #ifdef __CHECKER__
  #define __force __attribute__((force))
 @@ -68,14 +75,9 @@ typedef uint16_t __bitwise fdt16_t;
  typedef uint32_t __bitwise fdt32_t;
  typedef uint64_t __bitwise fdt64_t;
  
 -#define EXTRACT_BYTE(x, n)   ((unsigned long long)((uint8_t *)x)[n])
 -#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0)  8) | EXTRACT_BYTE(x, 1))
 -#define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0)  24) | (EXTRACT_BYTE(x, 1)  
 16) | \
 -  (EXTRACT_BYTE(x, 2)  8) | EXTRACT_BYTE(x, 3))
 -#define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0)  56) | (EXTRACT_BYTE(x, 1)  
 48) | \
 -  (EXTRACT_BYTE(x, 2)  40) | (EXTRACT_BYTE(x, 3)  
 32) | \
 -  (EXTRACT_BYTE(x, 4)  24) | (EXTRACT_BYTE(x, 5)  
 16) | \
 -  (EXTRACT_BYTE(x, 6)  8) | EXTRACT_BYTE(x, 7))
 +#define CPU_TO_FDT16 cpu_to_be16
 +#define CPU_TO_FDT32 cpu_to_be32
 +#define CPU_TO_FDT64 cpu_to_be64
  
  static inline uint16_t fdt16_to_cpu(fdt16_t x)
  {
 @@ -106,6 +108,5 @@ static inline fdt64_t cpu_to_fdt64(uint64_t x)
  #undef CPU_TO_FDT64
  #undef CPU_TO_FDT32
  #undef CPU_TO_FDT16
 -#undef EXTRACT_BYTE
  
  #endif /* _LIBFDT_ENV_H */
 diff --git a/lib/string.c b/lib/string.c
 index 3a9caf720bf2b..234f96f4442f7 100644
 --- a/lib/string.c
 +++ b/lib/string.c
 @@ -31,6 +31,17 @@ int strcmp(const char *a, const char *b)
  return *a - *b;
  }
  
 +char *strchr(const char *s, int c)
 +{
 +unsigned char chr = (unsigned char)c;

why unsigned?

 +int n = strlen(s) + 1;


Re: [PATCH 12/17] Introduce virtio-testdev

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:58PM +0100, Andrew Jones wrote:
 virtio-testdev is a communication channel to qemu through virtio that
 can be used by test code to send commands. The only command currently
 implemented is EXIT, which allows the test code to exit with a given
 status code.
 
 Signed-off-by: Andrew Jones drjo...@redhat.com
 
 ---
 v3:
  - switched from iomaps to devicetree
  - fixed Christoffer's nits
  - don't call halt() explicitly, let exit() fall back to it
  - vm_{get,set} now {read,write} byte by byte like the kernel
 v2:
  - use readl/writel framework (libio) [Christoffer Dall]
  - keep the virtio abstraction in virtio-testdev [Alexander Graf]
 ---
  lib/libcflat.h   |   3 ++
  lib/virtio-testdev.c | 139 
 +++
  lib/virtio-testdev.h |   9 
  lib/virtio.c | 126 ++
  lib/virtio.h |  74 +++
  5 files changed, 351 insertions(+)
  create mode 100644 lib/virtio-testdev.c
  create mode 100644 lib/virtio-testdev.h
  create mode 100644 lib/virtio.c
  create mode 100644 lib/virtio.h
 
 diff --git a/lib/libcflat.h b/lib/libcflat.h
 index fdaaf2a8ab31d..84b8783bacfdc 100644
 --- a/lib/libcflat.h
 +++ b/lib/libcflat.h
 @@ -60,6 +60,9 @@ extern long atol(const char *ptr);
  #define ARRAY_SIZE(_a)  (sizeof(_a)/sizeof((_a)[0]))
  
  #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
 +#define container_of(ptr, type, member) ({   \
 + const typeof( ((type *)0)-member ) *__mptr = (ptr);\
 + (type *)( (char *)__mptr - offsetof(type,member) );})
  
  #define __unused __attribute__((__unused__))
  #define NULL ((void *)0UL)
 diff --git a/lib/virtio-testdev.c b/lib/virtio-testdev.c
 new file mode 100644
 index 0..d4a69ede12a7a
 --- /dev/null
 +++ b/lib/virtio-testdev.c
 @@ -0,0 +1,139 @@
 +#include libcflat.h
 +#include virtio.h
 +
 +#define TESTDEV_MAJOR_VER 1
 +#define TESTDEV_MINOR_VER 1
 +
 +#define VIRTIO_ID_TESTDEV 0x
 +
 +#define CONFIG_SIZE 64
 +
 +enum {
 + VERSION = 1,
 + CLEAR,
 + EXIT,
 +};
 +
 +#define TOKEN_OFFSET 0x0
 +#define NARGS_OFFSET 0x4
 +#define NRETS_OFFSET 0x8
 +#define ARG_OFFSET(n)(0xc + (n) * 4)
 +#define __RET_OFFSET(nargs, n)   (ARG_OFFSET(nargs) + (n) * 4)
 +
 +static struct virtio_dev *testdev;
 +
 +static u32 testdev_readl(unsigned offset)
 +{
 + if (offset  (CONFIG_SIZE - 4)) {
 + printf(%s: offset 0x%x to big!\n, __func__, offset);
 + exit(EINVAL);
 + }
 +
 + return virtio_config_readl(testdev, offset);
 +}
 +
 +static void testdev_writel(unsigned offset, u32 val)
 +{
 + if (offset  (CONFIG_SIZE - 4)) {
 + printf(%s: offset 0x%x to big!\n, __func__, offset);
 + exit(EINVAL);
 + }
 +
 + virtio_config_writel(testdev, offset, val);
 +}
 +
 +/*
 + * We have to write all args; nargs, nrets, ... first to avoid executing
 + * the token's operation until all args are in place. Then issue the op,
 + * and then read the return values. Reading the return values (or just
 + * sanity checking by reading token) will read a zero into qemu's copy
 + * of the token, which allows us to prepare additional ops without
 + * re-executing the last one.
 + */
 +void virtio_testdev(u32 token, u32 nargs, u32 nrets, ...)
 +{
 + va_list va;
 + unsigned off;
 + u32 n;
 +
 + if (!testdev)
 + return;
 +
 + testdev_writel(NARGS_OFFSET, nargs);
 + testdev_writel(NRETS_OFFSET, nrets);
 +
 + va_start(va, nrets);
 +
 + off = ARG_OFFSET(0);
 + n = nargs;
 + while (n--) {
 + testdev_writel(off, va_arg(va, unsigned));
 + off += 4;
 + }
 +
 + /* this runs the op, but then resets token to zero */
 + testdev_writel(TOKEN_OFFSET, token);
 +
 + /* sanity check */
 + if (testdev_readl(TOKEN_OFFSET) != 0) {
 + printf(virtio-testdev token should always read as zero!\n);
 + exit(EIO);
 + }
 +
 + off = __RET_OFFSET(nargs, 0);
 + n = nrets;
 + while (n--) {
 + u32 *r = va_arg(va, unsigned *);
 + *r = testdev_readl(off);
 + off += 4;
 + }
 +
 + va_end(va);
 +}
 +
 +void virtio_testdev_version(u32 *version)
 +{
 + virtio_testdev(VERSION, 0, 1, version);
 +}
 +
 +void virtio_testdev_clear(void)
 +{
 + virtio_testdev(CLEAR, 0, 0);
 +}
 +
 +void virtio_testdev_exit(int code)
 +{
 + virtio_testdev(EXIT, 1, 0, code);
 +}
 +
 +void virtio_testdev_init(void)
 +{
 + u16 major, minor;
 + u32 version;
 +
 + testdev = virtio_bind(VIRTIO_ID_TESTDEV);
 + if (testdev == NULL) {
 + printf(Can't find virtio-testdev. 
 +Is '-device virtio-testdev' 
 +on the qemu command line?\n);
 + exit(ENODEV);
 + }
 +
 + 

Re: [PATCH 13/17] arm: initial drop

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:21:59PM +0100, Andrew Jones wrote:
 This is the initial arm test framework and a first simple test that
 checks some bootinfo. kvm isn't needed to run this test. This patch
 also adds a common build environment variable, $QEMU_BIN, which
 allows makefiles to call on qemu when needed.
 
 Try it out with
   yum install gcc-arm-linux-gnu dtc
   export QEMU=[qemu with mach-virt and virtio-testdev]
   ./configure --cross-prefix=arm-linux-gnu- --arch=arm
   make
   ./run_tests.sh
 
 Signed-off-by: Andrew Jones drjo...@redhat.com
 
 ---

[...]

 diff --git a/lib/arm/setup.c b/lib/arm/setup.c
 new file mode 100644
 index 0..1db249a1eb94c
 --- /dev/null
 +++ b/lib/arm/setup.c
 @@ -0,0 +1,46 @@
 +#include libcflat.h
 +#include devicetree.h
 +#include arm/sysinfo.h
 +#include heap.h
 +
 +extern void io_init(void);
 +extern void setup_args(char *args);
 +
 +extern unsigned long stacktop;
 +
 +void *mem_start;
 +size_t mem_size;
 +char *bootargs;

const char *bootargs?

 +
 +static void read_bootinfo(const void *fdt)
 +{
 + int ret;
 +

[...]

Reviewed-by: Christoffer Dall christoffer.d...@linaro.org
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 16/17] arm: add useful headers from the linux kernel

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:22:02PM +0100, Andrew Jones wrote:
 We're going to need PSR bit defines and pt_regs. We'll also need
 pt_regs offsets in assembly code. This patch adapts the linux
 kernel's ptrace.h and asm-offsets to this framework. Even though
 lib/arm/asm-offsets.h is a generated file, we still commit it,
 as it's unlikely to change. Also adapt cp15.h from the kernel,
 since we'll need bit defines from there too.
 
 Signed-off-by: Andrew Jones drjo...@redhat.com
 ---

[...]

 +
 +asm-offsets: scripts/arm/asm-offsets.flat
 + $(QEMU) -device virtio-testdev -display none -serial stdio \
 + -M virt -cpu $(PROCESSOR) \
 + -kernel $^  lib/arm/asm-offsets.h || true

I still disagree with this requirement to have the correct version of
qemu on the build machine.

[...]

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


Re: [PATCH 15/17] printf: support field padding

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:22:01PM +0100, Andrew Jones wrote:
 Support format flags for field padding, such as %08x, allowing
 register dumps to be easier on the eyes.
 
 Signed-off-by: Andrew Jones drjo...@redhat.com

Reviewed-by: Christoffer Dall christoffer.d...@linaro.org
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 17/17] arm: vectors support

2014-02-01 Thread Christoffer Dall
On Tue, Jan 21, 2014 at 05:22:03PM +0100, Andrew Jones wrote:
 Add support for tests to use exception handlers.
 
 v2 - v3:
 - squashed in 'arm: Simplify exceptions_init in cstart.S' from
   Christoffer Dall
 - suggested function name changes and comment additions [Christoffer Dall]
 - fix a bug with stack restore from usr mode exceptions that Christoffer
   pointed out. Add a get_sp() accessor too.

hmmm, how did you address this, the only change I can see is using r6
instead of r2, which I'm not sure how changes anything.

The problem is that your ldmia is replacing the usr sp, not the svc sp,
so maybe you need to do ldmia sp!, [ r0 - pc ]^ (don't remember if that
particular combination works) or you need to do something more fancy...

Otherwise this is looking good.

Thanks,
Christoffer

 
 Signed-off-by: Andrew Jones drjo...@redhat.com
 ---
  arm/cstart.S  | 168 
 ++
  arm/flat.lds  |   7 ++-
  arm/selftest.c| 119 +++
  arm/unittests.cfg |  20 +-
  config/config-arm.mak |   1 +
  lib/arm/processor.c   | 103 +++
  lib/arm/processor.h   |  35 +++
  lib/libcflat.h|   2 +
  8 files changed, 453 insertions(+), 2 deletions(-)
  create mode 100644 lib/arm/processor.c
  create mode 100644 lib/arm/processor.h
 
 diff --git a/arm/cstart.S b/arm/cstart.S
 index 4de04b62c28c2..74674fd41c1b3 100644
 --- a/arm/cstart.S
 +++ b/arm/cstart.S
 @@ -1,3 +1,7 @@
 +#define __ASSEMBLY__
 +#include arm/asm-offsets.h
 +#include arm/ptrace.h
 +#include arm/cp15.h
  
  .arm
  
 @@ -10,6 +14,13 @@ start:
* See the kernel doc Documentation/arm/Booting
*/
   ldr sp, =stacktop
 + push{r0-r3}
 +
 + /* set up vector table and mode stacks */
 + bl  exceptions_init
 +
 + /* complete setup */
 + pop {r0-r3}
   bl  setup
  
   /* start the test */
 @@ -20,9 +31,166 @@ start:
   bl  exit
   b   halt
  
 +.macro set_mode_stack mode, stack
 + add \stack, #S_FRAME_SIZE
 + msr cpsr_c, #(\mode | PSR_I_BIT | PSR_F_BIT)
 + mov sp, \stack
 +.endm
 +
 +exceptions_init:
 + mrc p15, 0, r2, c1, c0, 0   @ read SCTLR
 + bic r2, #CR_V   @ SCTLR.V := 0
 + mcr p15, 0, r2, c1, c0, 0   @ write SCTLR
 + ldr r2, =vector_table
 + mcr p15, 0, r2, c12, c0, 0  @ write VBAR
 +
 + mrs r2, cpsr
 + ldr r1, =exception_stacks
 + /* first frame for svc mode */
 + set_mode_stack  UND_MODE, r1
 + set_mode_stack  ABT_MODE, r1
 + set_mode_stack  IRQ_MODE, r1
 + set_mode_stack  FIQ_MODE, r1
 + msr cpsr_cxsf, r2   @ back to svc mode
 + mov pc, lr
 +
  .text
  
  .globl halt
  halt:
  1:   wfi
   b   1b
 +
 +/*
 + * Vector stubs.
 + * Simplified version of the Linux kernel implementation
 + *   arch/arm/kernel/entry-armv.S
 + *
 + * Each mode has an S_FRAME_SIZE sized stack initialized
 + * in exceptions_init
 + */
 +.macro vector_stub, name, vec, mode, correction=0
 +.align 5
 +vector_\name:
 +.if \correction
 + sub lr, lr, #\correction
 +.endif
 + /*
 +  * Save r0, r1, lr_exception (parent PC)
 +  * and spsr_exception (parent CPSR)
 +  */
 + str r0, [sp, #S_R0]
 + str r1, [sp, #S_R1]
 + str lr, [sp, #S_PC]
 + mrs r0, spsr
 + str r0, [sp, #S_PSR]
 +
 + /* Prepare for SVC32 mode. */
 + mrs r0, cpsr
 + bic r0, #MODE_MASK
 + orr r0, #SVC_MODE
 + msr spsr_cxsf, r0
 +
 + /* Branch to handler in SVC mode */
 + mov r0, #\vec
 + mov r1, sp
 + ldr lr, =vector_common
 + movspc, lr
 +.endm
 +
 +vector_stub  rst,0, UND_MODE
 +vector_stub  und,1, UND_MODE
 +vector_stub  pabt,   3, ABT_MODE, 4
 +vector_stub  dabt,   4, ABT_MODE, 8
 +vector_stub  irq,6, IRQ_MODE, 4
 +vector_stub  fiq,7, FIQ_MODE, 4
 +
 +.align 5
 +vector_svc:
 + /*
 +  * Save r0, r1, lr_exception (parent PC)
 +  * and spsr_exception (parent CPSR)
 +  */
 + push{ r1 }
 + ldr r1, =exception_stacks
 + str r0, [r1, #S_R0]
 + pop { r0 }
 + str r0, [r1, #S_R1]
 + str lr, [r1, #S_PC]
 + mrs r0, spsr
 + str r0, [r1, #S_PSR]
 +
 + /*
 +  * Branch to handler, still in SVC mode.
 +  * r0 := 2 is the svc vector number.
 +  */
 + mov r0, #2
 + ldr lr, =vector_common
 + mov pc, lr
 +
 +vector_common:
 + /* make room for pt_regs */
 + sub sp, #S_FRAME_SIZE
 + tst sp, #4  @ check stack alignment
 + subne   sp, #4
 +
 + /* store registers r0-r12 */
 + stmia   sp, { r0-r12 }  @ stored wrong r0 and r1, fix later
 +
 + /* get registers saved in the stub */
 + ldr r2, [r1, #S_R0] @ r0
 + ldr r3, [r1, #S_R1] @