* [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
@ 2008-06-25 20:39 Jerone Young
2008-06-25 20:39 ` [PATCH 1 of 4] Consilidate libcflat for x86 to single lib for all archs Jerone Young
` (5 more replies)
0 siblings, 6 replies; 17+ messages in thread
From: Jerone Young @ 2008-06-25 20:39 UTC (permalink / raw)
To: kvm; +Cc: kvm-ppc
This set of patches are to consolidate test libraries into a single library archive. This lib archive is libcflat. This will allow common code to be shared among archs.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
26 files changed, 602 insertions(+), 427 deletions(-)
user/Makefile | 11 +-
user/config-powerpc.mak | 10 +
user/config-x86-common.mak | 16 +--
user/main.c | 2
user/test/lib/libcflat.h | 37 +++++++
user/test/lib/panic.c | 13 ++
user/test/lib/powerpc/44x/map.c | 51 +++++++++
user/test/lib/powerpc/44x/tlbwe.S | 29 +++++
user/test/lib/powerpc/io.c | 35 ++++++
user/test/lib/printf.c | 179 +++++++++++++++++++++++++++++++++
user/test/lib/string.c | 21 +++
user/test/lib/x86/apic.h | 14 ++
user/test/lib/x86/io.c | 23 ++++
user/test/lib/x86/smp.c | 150 ++++++++++++++++++++++++++++
user/test/lib/x86/smp.h | 16 +++
user/test/x86/lib/apic.h | 14 --
user/test/x86/lib/exit.c | 5
user/test/x86/lib/printf.c | 195 -------------------------------------
user/test/x86/lib/printf.h | 2
user/test/x86/lib/smp.c | 151 ----------------------------
user/test/x86/lib/smp.h | 16 ---
user/test/x86/lib/string.c | 21 ---
user/test/x86/lib/string.h | 7 -
user/test/x86/port80.c | 3
user/test/x86/smptest.c | 5
user/test/x86/tsc.c | 3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1 of 4] Consilidate libcflat for x86 to single lib for all archs
2008-06-25 20:39 [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Jerone Young
@ 2008-06-25 20:39 ` Jerone Young
2008-06-25 20:39 ` [PATCH 2 of 4] Add Makefile and test changes required for x86 to use libcflat Jerone Young
` (4 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Jerone Young @ 2008-06-25 20:39 UTC (permalink / raw)
To: kvm; +Cc: kvm-ppc
8 files changed, 453 insertions(+)
user/test/lib/libcflat.h | 37 +++++++++
user/test/lib/panic.c | 13 +++
user/test/lib/printf.c | 179 ++++++++++++++++++++++++++++++++++++++++++++++
user/test/lib/string.c | 21 +++++
user/test/lib/x86/apic.h | 14 +++
user/test/lib/x86/io.c | 23 +++++
user/test/lib/x86/smp.c | 150 ++++++++++++++++++++++++++++++++++++++
user/test/lib/x86/smp.h | 16 ++++
This patch lays the ground work for a sinlge libcflat library that can be used for x86. But this allows for other archs to share common code, and build a single archive for tests to use libcflat functions.
Signed-off-by: Jerone Young <jyoung5@.us.com>
diff --git a/user/test/lib/libcflat.h b/user/test/lib/libcflat.h
new file mode 100644
--- /dev/null
+++ b/user/test/lib/libcflat.h
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#ifndef __LIBCFLAT_H
+#define __LIBCFLAT_H
+
+#include <stdarg.h>
+
+extern int main(void);
+extern void exit(int code);
+extern void panic(char *fmt, ...);
+
+extern unsigned long strlen(const char *buf);
+extern char *strcat(char *dest, const char *src);
+
+extern int printf(const char *fmt, ...);
+extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
+
+extern void puts(const char *s);
+
+#endif
diff --git a/user/test/lib/panic.c b/user/test/lib/panic.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/panic.c
@@ -0,0 +1,13 @@
+#include "libcflat.h"
+
+void panic(char *fmt, ...)
+{
+ va_list va;
+ char buf[2000];
+
+ va_start(va, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, va);
+ va_end(va);
+ puts(buf);
+ exit(-1);
+}
diff --git a/user/test/lib/printf.c b/user/test/lib/printf.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/printf.c
@@ -0,0 +1,179 @@
+#include "libcflat.h"
+
+typedef struct pstream {
+ char *buffer;
+ int remain;
+ int added;
+} pstream_t;
+
+static void addchar(pstream_t *p, char c)
+{
+ if (p->remain) {
+ *p->buffer++ = c;
+ --p->remain;
+ }
+ ++p->added;
+}
+
+void print_str(pstream_t *p, const char *s)
+{
+ while (*s)
+ addchar(p, *s++);
+}
+
+static char digits[16] = "0123456789abcdef";
+
+void print_int(pstream_t *ps, long long n, int base)
+{
+ char buf[sizeof(long) * 3 + 2], *p = buf;
+ int s = 0, i;
+
+ if (n < 0) {
+ n = -n;
+ s = 1;
+ }
+
+ while (n) {
+ *p++ = digits[n % base];
+ n /= base;
+ }
+
+ if (s)
+ *p++ = '-';
+
+ if (p == buf)
+ *p++ = '0';
+
+ for (i = 0; i < (p - buf) / 2; ++i) {
+ char tmp;
+
+ tmp = buf[i];
+ buf[i] = p[-1-i];
+ p[-1-i] = tmp;
+ }
+
+ *p = 0;
+
+ print_str(ps, buf);
+}
+
+void print_unsigned(pstream_t *ps, unsigned long long n, int base)
+{
+ char buf[sizeof(long) * 3 + 1], *p = buf;
+ int i;
+
+ while (n) {
+ *p++ = digits[n % base];
+ n /= base;
+ }
+
+ if (p == buf)
+ *p++ = '0';
+
+ for (i = 0; i < (p - buf) / 2; ++i) {
+ char tmp;
+
+ tmp = buf[i];
+ buf[i] = p[-1-i];
+ p[-1-i] = tmp;
+ }
+
+ *p = 0;
+
+ print_str(ps, buf);
+}
+
+int vsnprintf(char *buf, int size, const char *fmt, va_list va)
+{
+ pstream_t s;
+
+ s.buffer = buf;
+ s.remain = size - 1;
+ s.added = 0;
+ while (*fmt) {
+ char f = *fmt++;
+ int nlong = 0;
+
+ if (f != '%') {
+ addchar(&s, f);
+ continue;
+ }
+ morefmt:
+ f = *fmt++;
+ switch (f) {
+ case '%':
+ addchar(&s, '%');
+ break;
+ case '\0':
+ --fmt;
+ break;
+ case 'l':
+ ++nlong;
+ goto morefmt;
+ case 'd':
+ switch (nlong) {
+ case 0:
+ print_int(&s, va_arg(va, int), 10);
+ break;
+ case 1:
+ print_int(&s, va_arg(va, long), 10);
+ break;
+ default:
+ print_int(&s, va_arg(va, long long), 10);
+ break;
+ }
+ break;
+ case 'x':
+ switch (nlong) {
+ case 0:
+ print_unsigned(&s, va_arg(va, unsigned), 16);
+ break;
+ case 1:
+ print_unsigned(&s, va_arg(va, unsigned long), 16);
+ break;
+ default:
+ print_unsigned(&s, va_arg(va, unsigned long long), 16);
+ break;
+ }
+ break;
+ case 'p':
+ print_str(&s, "0x");
+ print_unsigned(&s, (unsigned long)va_arg(va, void *), 16);
+ break;
+ case 's':
+ print_str(&s, va_arg(va, const char *));
+ break;
+ default:
+ addchar(&s, f);
+ break;
+ }
+ }
+ *s.buffer = 0;
+ ++s.added;
+ return s.added;
+}
+
+
+int snprintf(char *buf, int size, const char *fmt, ...)
+{
+ va_list va;
+ int r;
+
+ va_start(va, fmt);
+ r = vsnprintf(buf, size, fmt, va);
+ va_end(va);
+ return r;
+}
+
+int printf(const char *fmt, ...)
+{
+ va_list va;
+ char buf[2000];
+ int r;
+
+ va_start(va, fmt);
+ r = vsnprintf(buf, sizeof buf, fmt, va);
+ va_end(va);
+ puts(buf);
+ return r;
+}
diff --git a/user/test/lib/string.c b/user/test/lib/string.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/string.c
@@ -0,0 +1,21 @@
+#include "libcflat.h"
+
+unsigned long strlen(const char *buf)
+{
+ unsigned long len = 0;
+
+ while (*buf++)
+ ++len;
+ return len;
+}
+
+char *strcat(char *dest, const char *src)
+{
+ char *p = dest;
+
+ while (*p)
+ ++p;
+ while ((*p++ = *src++) != 0)
+ ;
+ return dest;
+}
diff --git a/user/test/lib/x86/apic.h b/user/test/lib/x86/apic.h
new file mode 100644
--- /dev/null
+++ b/user/test/lib/x86/apic.h
@@ -0,0 +1,14 @@
+#ifndef SILLY_APIC_H
+#define SILLY_APIC_H
+
+#define APIC_BASE 0x1000
+#define APIC_SIZE 0x100
+
+#define APIC_REG_NCPU 0x00
+#define APIC_REG_ID 0x04
+#define APIC_REG_SIPI_ADDR 0x08
+#define APIC_REG_SEND_SIPI 0x0c
+#define APIC_REG_IPI_VECTOR 0x10
+#define APIC_REG_SEND_IPI 0x14
+
+#endif
diff --git a/user/test/lib/x86/io.c b/user/test/lib/x86/io.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/x86/io.c
@@ -0,0 +1,23 @@
+#include <libcflat.h>
+#include "smp.h"
+
+static struct spinlock lock;
+
+static void print_serial(const char *buf)
+{
+ unsigned long len = strlen(buf);
+
+ asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
+}
+
+void puts(const char *s)
+{
+ spin_lock(&lock);
+ print_serial(s);
+ spin_unlock(&lock);
+}
+
+void exit(int code)
+{
+ asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
+}
diff --git a/user/test/lib/x86/smp.c b/user/test/lib/x86/smp.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/x86/smp.c
@@ -0,0 +1,150 @@
+
+#include <libcflat.h>
+#include "smp.h"
+#include "apic.h"
+
+#define IPI_VECTOR 0x20
+
+static int apic_read(int reg)
+{
+ unsigned short port = APIC_BASE + reg;
+ unsigned v;
+
+ asm volatile ("in %1, %0" : "=a"(v) : "d"(port));
+ return v;
+}
+
+static void apic_write(int reg, unsigned v)
+{
+ unsigned short port = APIC_BASE + reg;
+
+ asm volatile ("out %0, %1" : : "a"(v), "d"(port));
+}
+
+static int apic_get_cpu_count()
+{
+ return apic_read(APIC_REG_NCPU);
+}
+
+static int apic_get_id()
+{
+ return apic_read(APIC_REG_ID);
+}
+
+static void apic_set_ipi_vector(int vector)
+{
+ apic_write(APIC_REG_IPI_VECTOR, vector);
+}
+
+static void apic_send_ipi(int cpu)
+{
+ apic_write(APIC_REG_SEND_IPI, cpu);
+}
+
+static struct spinlock ipi_lock;
+static void (*ipi_function)(void *data);
+static void *ipi_data;
+static volatile int ipi_done;
+
+static __attribute__((used)) void ipi()
+{
+ ipi_function(ipi_data);
+ ipi_done = 1;
+}
+
+asm (
+ "ipi_entry: \n"
+ " call ipi \n"
+#ifndef __x86_64__
+ " iret"
+#else
+ " iretq"
+#endif
+ );
+
+
+static void set_ipi_descriptor(void (*ipi_entry)(void))
+{
+ unsigned short *desc = (void *)(IPI_VECTOR * sizeof(long) * 2);
+ unsigned short cs;
+ unsigned long ipi = (unsigned long)ipi_entry;
+
+ asm ("mov %%cs, %0" : "=r"(cs));
+ desc[0] = ipi;
+ desc[1] = cs;
+ desc[2] = 0x8e00;
+ desc[3] = ipi >> 16;
+#ifdef __x86_64__
+ desc[4] = ipi >> 32;
+ desc[5] = ipi >> 48;
+ desc[6] = 0;
+ desc[7] = 0;
+#endif
+}
+
+void spin_lock(struct spinlock *lock)
+{
+ int v = 1;
+
+ do {
+ asm volatile ("xchg %1, %0" : "+m"(lock->v), "+r"(v));
+ } while (v);
+ asm volatile ("" : : : "memory");
+}
+
+void spin_unlock(struct spinlock *lock)
+{
+ asm volatile ("" : : : "memory");
+ lock->v = 0;
+}
+
+int cpu_count(void)
+{
+ return apic_get_cpu_count();
+}
+
+int smp_id(void)
+{
+ return apic_get_id();
+}
+
+void on_cpu(int cpu, void (*function)(void *data), void *data)
+{
+ spin_lock(&ipi_lock);
+ if (cpu == apic_get_id())
+ function(data);
+ else {
+ ipi_function = function;
+ ipi_data = data;
+ apic_send_ipi(cpu);
+ while (!ipi_done)
+ ;
+ ipi_done = 0;
+ }
+ spin_unlock(&ipi_lock);
+}
+
+static void (*smp_main_func)(void);
+static volatile int smp_main_running;
+
+asm ("smp_init_entry: \n"
+ "incl smp_main_running \n"
+ "sti \n"
+ "call *smp_main_func");
+
+void smp_init(void (*smp_main)(void))
+{
+ int i;
+ void smp_init_entry(void);
+ void ipi_entry(void);
+
+ apic_set_ipi_vector(IPI_VECTOR);
+ set_ipi_descriptor(smp_init_entry);
+ smp_main_func = smp_main;
+ for (i = 1; i < cpu_count(); ++i) {
+ apic_send_ipi(i);
+ while (smp_main_running < i)
+ ;
+ }
+ set_ipi_descriptor(ipi_entry);
+}
diff --git a/user/test/lib/x86/smp.h b/user/test/lib/x86/smp.h
new file mode 100644
--- /dev/null
+++ b/user/test/lib/x86/smp.h
@@ -0,0 +1,16 @@
+#ifndef __SMP_H
+#define __SMP_H
+
+struct spinlock {
+ int v;
+};
+
+void smp_init(void (*smp_main)(void));
+
+int cpu_count(void);
+int smp_id(void);
+void on_cpu(int cpu, void (*function)(void *data), void *data);
+void spin_lock(struct spinlock *lock);
+void spin_unlock(struct spinlock *lock);
+
+#endif
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 2 of 4] Add Makefile and test changes required for x86 to use libcflat
2008-06-25 20:39 [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Jerone Young
2008-06-25 20:39 ` [PATCH 1 of 4] Consilidate libcflat for x86 to single lib for all archs Jerone Young
@ 2008-06-25 20:39 ` Jerone Young
2008-06-25 20:39 ` [PATCH 3 of 4] Remove old x86 test libs, that are now appart of libcflat Jerone Young
` (3 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Jerone Young @ 2008-06-25 20:39 UTC (permalink / raw)
To: kvm; +Cc: kvm-ppc
6 files changed, 25 insertions(+), 15 deletions(-)
user/Makefile | 11 ++++++++++-
user/config-x86-common.mak | 16 ++++++++++------
user/main.c | 2 +-
user/test/x86/port80.c | 3 +--
user/test/x86/smptest.c | 5 ++---
user/test/x86/tsc.c | 3 +--
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
diff --git a/user/Makefile b/user/Makefile
--- a/user/Makefile
+++ b/user/Makefile
@@ -9,6 +9,12 @@
CFLAGS =
libgcc := $(shell $(CC) --print-libgcc-file-name)
+
+libcflat := test/lib/libcflat.a
+cflatobjs := \
+ test/lib/panic.o \
+ test/lib/printf.o \
+ test/lib/string.o
#include architecure specific make rules
include config-$(ARCH).mak
@@ -41,10 +47,13 @@
kvmtrace: $(kvmtrace_objs)
$(CC) $(LDFLAGS) $^ -o $@
+$(libcflat): $(cflatobjs)
+ ar rcs $@ $^
+
%.o: %.S
$(CC) $(CFLAGS) -c -nostdlib -o $@ $^
-include .*.d
clean: arch_clean
- $(RM) kvmctl kvmtrace *.o *.a .*.d
+ $(RM) kvmctl kvmtrace *.o *.a .*.d $(libcflat) $(cflatobjs)
diff --git a/user/config-x86-common.mak b/user/config-x86-common.mak
--- a/user/config-x86-common.mak
+++ b/user/config-x86-common.mak
@@ -5,7 +5,15 @@
kvmctl_objs= main.o iotable.o ../libkvm/libkvm.a
balloon_ctl: balloon_ctl.o
-FLATLIBS = $(TEST_DIR)/libcflat.a $(libgcc)
+cflatobjs += \
+ test/lib/x86/io.o \
+ test/lib/x86/smp.o
+
+$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): CFLAGS += -ffreestanding -I test/lib
+
+
+FLATLIBS = test/lib/libcflat.a $(libgcc)
%.flat: %.o $(FLATLIBS)
$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^ $(FLATLIBS)
@@ -15,7 +23,7 @@
test_cases: $(tests-common) $(tests)
-$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I$(TEST_DIR)/lib
+$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I test/lib -I test/lib/x86
$(TEST_DIR)/bootstrap: $(TEST_DIR)/bootstrap.o
$(CC) -nostdlib -o $@ -Wl,-T,bootstrap.lds $^
@@ -41,10 +49,6 @@
$(TEST_DIR)/tsc.flat: $(cstart.o) $(TEST_DIR)/tsc.o
-$(TEST_DIR)/libcflat.a: $(TEST_DIR)/lib/exit.o $(TEST_DIR)/lib/printf.o \
- $(TEST_DIR)/lib/smp.o $(TEST_DIR)/lib/string.o
- ar rcs $@ $^
-
arch_clean:
$(RM) $(TEST_DIR)/bootstrap $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
$(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
diff --git a/user/main.c b/user/main.c
--- a/user/main.c
+++ b/user/main.c
@@ -17,7 +17,7 @@
#define _GNU_SOURCE
#include <libkvm.h>
-#include "test/x86/lib/apic.h"
+#include "test/lib/x86/apic.h"
#include "test/x86/ioram.h"
#include <stdio.h>
diff --git a/user/test/x86/port80.c b/user/test/x86/port80.c
--- a/user/test/x86/port80.c
+++ b/user/test/x86/port80.c
@@ -1,5 +1,4 @@
-
-#include "printf.h"
+#include <libcflat.h>
int main()
{
diff --git a/user/test/x86/smptest.c b/user/test/x86/smptest.c
--- a/user/test/x86/smptest.c
+++ b/user/test/x86/smptest.c
@@ -1,6 +1,5 @@
-
-#include "smp.h"
-#include "printf.h"
+#include <libcflat.h>
+#include <smp.h>
static void ipi_test(void *data)
{
diff --git a/user/test/x86/tsc.c b/user/test/x86/tsc.c
--- a/user/test/x86/tsc.c
+++ b/user/test/x86/tsc.c
@@ -1,5 +1,4 @@
-
-#include "printf.h"
+#include <libcflat.h>
typedef unsigned long long u64;
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 3 of 4] Remove old x86 test libs, that are now appart of libcflat
2008-06-25 20:39 [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Jerone Young
2008-06-25 20:39 ` [PATCH 1 of 4] Consilidate libcflat for x86 to single lib for all archs Jerone Young
2008-06-25 20:39 ` [PATCH 2 of 4] Add Makefile and test changes required for x86 to use libcflat Jerone Young
@ 2008-06-25 20:39 ` Jerone Young
2008-06-25 20:39 ` [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes Jerone Young
` (2 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Jerone Young @ 2008-06-25 20:39 UTC (permalink / raw)
To: kvm; +Cc: kvm-ppc
8 files changed, 411 deletions(-)
user/test/x86/lib/apic.h | 14 ---
user/test/x86/lib/exit.c | 5 -
user/test/x86/lib/printf.c | 195 --------------------------------------------
user/test/x86/lib/printf.h | 2
user/test/x86/lib/smp.c | 151 ----------------------------------
user/test/x86/lib/smp.h | 16 ---
user/test/x86/lib/string.c | 21 ----
user/test/x86/lib/string.h | 7 -
Signed-off-by: Jerone Young <jyoung5@.us.ibm.com>
diff --git a/user/test/x86/lib/apic.h b/user/test/x86/lib/apic.h
deleted file mode 100644
--- a/user/test/x86/lib/apic.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef SILLY_APIC_H
-#define SILLY_APIC_H
-
-#define APIC_BASE 0x1000
-#define APIC_SIZE 0x100
-
-#define APIC_REG_NCPU 0x00
-#define APIC_REG_ID 0x04
-#define APIC_REG_SIPI_ADDR 0x08
-#define APIC_REG_SEND_SIPI 0x0c
-#define APIC_REG_IPI_VECTOR 0x10
-#define APIC_REG_SEND_IPI 0x14
-
-#endif
diff --git a/user/test/x86/lib/exit.c b/user/test/x86/lib/exit.c
deleted file mode 100644
--- a/user/test/x86/lib/exit.c
+++ /dev/null
@@ -1,5 +0,0 @@
-
-void exit(int code)
-{
- asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
-}
diff --git a/user/test/x86/lib/printf.c b/user/test/x86/lib/printf.c
deleted file mode 100644
--- a/user/test/x86/lib/printf.c
+++ /dev/null
@@ -1,195 +0,0 @@
-#include "printf.h"
-#include "smp.h"
-#include <stdarg.h>
-#include "string.h"
-
-static struct spinlock lock;
-
-void print(const char *s);
-
-typedef struct pstream {
- char *buffer;
- int remain;
- int added;
-} pstream_t;
-
-static void addchar(pstream_t *p, char c)
-{
- if (p->remain) {
- *p->buffer++ = c;
- --p->remain;
- }
- ++p->added;
-}
-
-void print_str(pstream_t *p, const char *s)
-{
- while (*s)
- addchar(p, *s++);
-}
-
-static char digits[16] = "0123456789abcdef";
-
-void print_int(pstream_t *ps, long long n, int base)
-{
- char buf[sizeof(long) * 3 + 2], *p = buf;
- int s = 0, i;
-
- if (n < 0) {
- n = -n;
- s = 1;
- }
-
- while (n) {
- *p++ = digits[n % base];
- n /= base;
- }
-
- if (s)
- *p++ = '-';
-
- if (p == buf)
- *p++ = '0';
-
- for (i = 0; i < (p - buf) / 2; ++i) {
- char tmp;
-
- tmp = buf[i];
- buf[i] = p[-1-i];
- p[-1-i] = tmp;
- }
-
- *p = 0;
-
- print_str(ps, buf);
-}
-
-void print_unsigned(pstream_t *ps, unsigned long long n, int base)
-{
- char buf[sizeof(long) * 3 + 1], *p = buf;
- int i;
-
- while (n) {
- *p++ = digits[n % base];
- n /= base;
- }
-
- if (p == buf)
- *p++ = '0';
-
- for (i = 0; i < (p - buf) / 2; ++i) {
- char tmp;
-
- tmp = buf[i];
- buf[i] = p[-1-i];
- p[-1-i] = tmp;
- }
-
- *p = 0;
-
- print_str(ps, buf);
-}
-
-int vsnprintf(char *buf, int size, const char *fmt, va_list va)
-{
- pstream_t s;
-
- s.buffer = buf;
- s.remain = size - 1;
- s.added = 0;
- while (*fmt) {
- char f = *fmt++;
- int nlong = 0;
-
- if (f != '%') {
- addchar(&s, f);
- continue;
- }
- morefmt:
- f = *fmt++;
- switch (f) {
- case '%':
- addchar(&s, '%');
- break;
- case '\0':
- --fmt;
- break;
- case 'l':
- ++nlong;
- goto morefmt;
- case 'd':
- switch (nlong) {
- case 0:
- print_int(&s, va_arg(va, int), 10);
- break;
- case 1:
- print_int(&s, va_arg(va, long), 10);
- break;
- default:
- print_int(&s, va_arg(va, long long), 10);
- break;
- }
- break;
- case 'x':
- switch (nlong) {
- case 0:
- print_unsigned(&s, va_arg(va, unsigned), 16);
- break;
- case 1:
- print_unsigned(&s, va_arg(va, unsigned long), 16);
- break;
- default:
- print_unsigned(&s, va_arg(va, unsigned long long), 16);
- break;
- }
- break;
- case 'p':
- print_str(&s, "0x");
- print_unsigned(&s, (unsigned long)va_arg(va, void *), 16);
- break;
- case 's':
- print_str(&s, va_arg(va, const char *));
- break;
- default:
- addchar(&s, f);
- break;
- }
- }
- *s.buffer = 0;
- ++s.added;
- return s.added;
-}
-
-
-int snprintf(char *buf, int size, const char *fmt, ...)
-{
- va_list va;
- int r;
-
- va_start(va, fmt);
- r = vsnprintf(buf, size, fmt, va);
- va_end(va);
- return r;
-}
-
-void print_serial(const char *buf)
-{
- unsigned long len = strlen(buf);
-
- asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
-}
-
-int printf(const char *fmt, ...)
-{
- va_list va;
- char buf[2000];
- int r;
-
- va_start(va, fmt);
- r = vsnprintf(buf, sizeof buf, fmt, va);
- va_end(va);
- spin_lock(&lock);
- print_serial(buf);
- spin_unlock(&lock);
- return r;
-}
diff --git a/user/test/x86/lib/printf.h b/user/test/x86/lib/printf.h
deleted file mode 100644
--- a/user/test/x86/lib/printf.h
+++ /dev/null
@@ -1,2 +0,0 @@
-
-int printf(const char *fmt, ...);
diff --git a/user/test/x86/lib/smp.c b/user/test/x86/lib/smp.c
deleted file mode 100644
--- a/user/test/x86/lib/smp.c
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-#include "smp.h"
-#include "apic.h"
-#include "printf.h"
-
-#define IPI_VECTOR 0x20
-
-static int apic_read(int reg)
-{
- unsigned short port = APIC_BASE + reg;
- unsigned v;
-
- asm volatile ("in %1, %0" : "=a"(v) : "d"(port));
- return v;
-}
-
-static void apic_write(int reg, unsigned v)
-{
- unsigned short port = APIC_BASE + reg;
-
- asm volatile ("out %0, %1" : : "a"(v), "d"(port));
-}
-
-static int apic_get_cpu_count()
-{
- return apic_read(APIC_REG_NCPU);
-}
-
-static int apic_get_id()
-{
- return apic_read(APIC_REG_ID);
-}
-
-static void apic_set_ipi_vector(int vector)
-{
- apic_write(APIC_REG_IPI_VECTOR, vector);
-}
-
-static void apic_send_ipi(int cpu)
-{
- apic_write(APIC_REG_SEND_IPI, cpu);
-}
-
-static struct spinlock ipi_lock;
-static void (*ipi_function)(void *data);
-static void *ipi_data;
-static volatile int ipi_done;
-
-static __attribute__((used)) void ipi()
-{
- ipi_function(ipi_data);
- ipi_done = 1;
-}
-
-asm (
- "ipi_entry: \n"
- " call ipi \n"
-#ifndef __x86_64__
- " iret"
-#else
- " iretq"
-#endif
- );
-
-
-static void set_ipi_descriptor(void (*ipi_entry)(void))
-{
- unsigned short *desc = (void *)(IPI_VECTOR * sizeof(long) * 2);
- unsigned short cs;
- unsigned long ipi = (unsigned long)ipi_entry;
-
- asm ("mov %%cs, %0" : "=r"(cs));
- desc[0] = ipi;
- desc[1] = cs;
- desc[2] = 0x8e00;
- desc[3] = ipi >> 16;
-#ifdef __x86_64__
- desc[4] = ipi >> 32;
- desc[5] = ipi >> 48;
- desc[6] = 0;
- desc[7] = 0;
-#endif
-}
-
-void spin_lock(struct spinlock *lock)
-{
- int v = 1;
-
- do {
- asm volatile ("xchg %1, %0" : "+m"(lock->v), "+r"(v));
- } while (v);
- asm volatile ("" : : : "memory");
-}
-
-void spin_unlock(struct spinlock *lock)
-{
- asm volatile ("" : : : "memory");
- lock->v = 0;
-}
-
-int cpu_count(void)
-{
- return apic_get_cpu_count();
-}
-
-int smp_id(void)
-{
- return apic_get_id();
-}
-
-void on_cpu(int cpu, void (*function)(void *data), void *data)
-{
- spin_lock(&ipi_lock);
- if (cpu == apic_get_id())
- function(data);
- else {
- ipi_function = function;
- ipi_data = data;
- apic_send_ipi(cpu);
- while (!ipi_done)
- ;
- ipi_done = 0;
- }
- spin_unlock(&ipi_lock);
-}
-
-static void (*smp_main_func)(void);
-static volatile int smp_main_running;
-
-asm ("smp_init_entry: \n"
- "incl smp_main_running \n"
- "sti \n"
- "call *smp_main_func");
-
-void smp_init(void (*smp_main)(void))
-{
- int i;
- void smp_init_entry(void);
- void ipi_entry(void);
-
- apic_set_ipi_vector(IPI_VECTOR);
- set_ipi_descriptor(smp_init_entry);
- smp_main_func = smp_main;
- for (i = 1; i < cpu_count(); ++i) {
- apic_send_ipi(i);
- while (smp_main_running < i)
- ;
- }
- set_ipi_descriptor(ipi_entry);
-}
diff --git a/user/test/x86/lib/smp.h b/user/test/x86/lib/smp.h
deleted file mode 100644
--- a/user/test/x86/lib/smp.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __SMP_H
-#define __SMP_H
-
-struct spinlock {
- int v;
-};
-
-void smp_init(void (*smp_main)(void));
-
-int cpu_count(void);
-int smp_id(void);
-void on_cpu(int cpu, void (*function)(void *data), void *data);
-void spin_lock(struct spinlock *lock);
-void spin_unlock(struct spinlock *lock);
-
-#endif
diff --git a/user/test/x86/lib/string.c b/user/test/x86/lib/string.c
deleted file mode 100644
--- a/user/test/x86/lib/string.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "string.h"
-
-unsigned long strlen(const char *buf)
-{
- unsigned long len = 0;
-
- while (*buf++)
- ++len;
- return len;
-}
-
-char *strcat(char *dest, const char *src)
-{
- char *p = dest;
-
- while (*p)
- ++p;
- while ((*p++ = *src++) != 0)
- ;
- return dest;
-}
diff --git a/user/test/x86/lib/string.h b/user/test/x86/lib/string.h
deleted file mode 100644
--- a/user/test/x86/lib/string.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef FLAT_LIB_STRING_H
-#define FLAT_LIB_STRING_H
-
-unsigned long strlen(const char *buf);
-char *strcat(char *dest, const char *src);
-
-#endif
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes
2008-06-25 20:39 [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Jerone Young
` (2 preceding siblings ...)
2008-06-25 20:39 ` [PATCH 3 of 4] Remove old x86 test libs, that are now appart of libcflat Jerone Young
@ 2008-06-25 20:39 ` Jerone Young
2008-06-25 21:28 ` Hollis Blanchard
2008-06-25 21:27 ` [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Hollis Blanchard
2008-06-29 9:10 ` Avi Kivity
5 siblings, 1 reply; 17+ messages in thread
From: Jerone Young @ 2008-06-25 20:39 UTC (permalink / raw)
To: kvm; +Cc: kvm-ppc
4 files changed, 124 insertions(+), 1 deletion(-)
user/config-powerpc.mak | 10 ++++++-
user/test/lib/powerpc/44x/map.c | 51 +++++++++++++++++++++++++++++++++++++
user/test/lib/powerpc/44x/tlbwe.S | 29 +++++++++++++++++++++
user/test/lib/powerpc/io.c | 35 +++++++++++++++++++++++++
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Jerone Young <jyoung5@.us.ibm.com>
diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -3,6 +3,14 @@
CFLAGS += -I $(KERNELDIR)/include
# for some reaons binutils hates tlbsx unless we say we're 405 :(
CFLAGS += -Wa,-mregnames,-m405
+
+cflatobjs += \
+ test/lib/powerpc/io.o \
+ test/lib/powerpc/44x/map.o \
+ test/lib/powerpc/44x/tlbwe.o
+
+$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): CFLAGS += -ffreestanding -I test/lib -I test/lib/powerpc/44x
%.bin: %.o
$(OBJCOPY) -O binary $^ $@
@@ -18,7 +26,7 @@
tests := $(addprefix test/powerpc/, $(testobjs))
-all: kvmtrace kvmctl $(tests)
+all: kvmtrace kvmctl $(libcflat) $(tests)
kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
diff --git a/user/test/lib/powerpc/44x/map.c b/user/test/lib/powerpc/44x/map.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/map.c
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#include "libcflat.h"
+
+#define TLB_SIZE 64
+
+extern void tlbwe(unsigned int index,
+ unsigned char tid,
+ unsigned int word0,
+ unsigned int word1,
+ unsigned int word2);
+
+unsigned int next_free_index;
+
+#define PAGE_SHIFT 12
+#define PAGE_MASK (~((1<<PAGE_SHIFT)-1))
+
+#define V (1<<9)
+
+void map(unsigned long vaddr, unsigned long paddr)
+{
+ unsigned int w0, w1, w2;
+
+ /* We don't install exception handlers, so we can't handle TLB misses,
+ * so we can't loop around and overwrite entry 0. */
+ if (next_free_index++ >= TLB_SIZE)
+ panic("TLB overflow");
+
+ w0 = (vaddr & PAGE_MASK) | V;
+ w1 = paddr & PAGE_MASK;
+ w2 = 0x3;
+
+ tlbwe(next_free_index, 0, w0, w1, w2);
+}
diff --git a/user/test/lib/powerpc/44x/tlbwe.S b/user/test/lib/powerpc/44x/tlbwe.S
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/tlbwe.S
@@ -0,0 +1,29 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#define SPRN_MMUCR 0x3b2
+
+/* tlbwe(uint index, uint8_t tid, uint word0, uint word1, uint word2) */
+.global tlbwe
+tlbwe:
+ mtspr SPRN_MMUCR, r4
+ tlbwe r5, r3, 0
+ tlbwe r6, r3, 1
+ tlbwe r7, r3, 2
+ blr
diff --git a/user/test/lib/powerpc/io.c b/user/test/lib/powerpc/io.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/io.c
@@ -0,0 +1,35 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#include "libcflat.h"
+
+#define BASE 0xf0000000
+#define _putc ((volatile char *)(BASE))
+#define _exit ((volatile char *)(BASE+1))
+
+void puts(const char *s)
+{
+ while (*s != '\0')
+ *_putc = *s++;
+}
+
+void exit(int code)
+{
+ *_exit = code;
+}
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-06-25 20:39 [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Jerone Young
` (3 preceding siblings ...)
2008-06-25 20:39 ` [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes Jerone Young
@ 2008-06-25 21:27 ` Hollis Blanchard
2008-06-26 15:12 ` Jerone Young
2008-06-29 9:10 ` Avi Kivity
5 siblings, 1 reply; 17+ messages in thread
From: Hollis Blanchard @ 2008-06-25 21:27 UTC (permalink / raw)
To: Jerone Young; +Cc: kvm, kvm-ppc
On Wed, 2008-06-25 at 15:39 -0500, Jerone Young wrote:
> This set of patches are to consolidate test libraries into a single
> library archive. This lib archive is libcflat. This will allow common
> code to be shared among archs.
>
> Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
I think patches 1-3 should be combined.
By the way, I assume you've built x86 with these changes, but have you
run it too?
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes
2008-06-25 20:39 ` [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes Jerone Young
@ 2008-06-25 21:28 ` Hollis Blanchard
2008-06-26 15:14 ` Jerone Young
0 siblings, 1 reply; 17+ messages in thread
From: Hollis Blanchard @ 2008-06-25 21:28 UTC (permalink / raw)
To: Jerone Young; +Cc: kvm, kvm-ppc
On Wed, 2008-06-25 at 15:39 -0500, Jerone Young wrote:
> 4 files changed, 124 insertions(+), 1 deletion(-)
> user/config-powerpc.mak | 10 ++++++-
> user/test/lib/powerpc/44x/map.c | 51 +++++++++++++++++++++++++++++++++++++
> user/test/lib/powerpc/44x/tlbwe.S | 29 +++++++++++++++++++++
> user/test/lib/powerpc/io.c | 35 +++++++++++++++++++++++++
Without user/test/powerpc/cstart.S (and exit.c which uses it), most of
this code is totally unused. That should at least be an additional patch
in this series; see
http://marc.info/?l=kvm-ppc-devel&m=120043765909206&w=2
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-06-25 21:27 ` [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Hollis Blanchard
@ 2008-06-26 15:12 ` Jerone Young
2008-06-26 22:01 ` Hollis Blanchard
0 siblings, 1 reply; 17+ messages in thread
From: Jerone Young @ 2008-06-26 15:12 UTC (permalink / raw)
To: Hollis Blanchard; +Cc: kvm, kvm-ppc
On Wed, 2008-06-25 at 16:27 -0500, Hollis Blanchard wrote:
> On Wed, 2008-06-25 at 15:39 -0500, Jerone Young wrote:
> > This set of patches are to consolidate test libraries into a single
> > library archive. This lib archive is libcflat. This will allow common
> > code to be shared among archs.
> >
> > Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
>
> I think patches 1-3 should be combined.
I was told by someone that when these patches were combined .. they
where too big. Also these bisect easily and don't break from patch to
patch. Which is why they are phased in.
>
> By the way, I assume you've built x86 with these changes, but have you
> run it too?
Yes, with these patches x86 tests compile and run fine.
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes
2008-06-25 21:28 ` Hollis Blanchard
@ 2008-06-26 15:14 ` Jerone Young
0 siblings, 0 replies; 17+ messages in thread
From: Jerone Young @ 2008-06-26 15:14 UTC (permalink / raw)
To: Hollis Blanchard; +Cc: kvm, kvm-ppc
On Wed, 2008-06-25 at 16:28 -0500, Hollis Blanchard wrote:
> On Wed, 2008-06-25 at 15:39 -0500, Jerone Young wrote:
> > 4 files changed, 124 insertions(+), 1 deletion(-)
> > user/config-powerpc.mak | 10 ++++++-
> > user/test/lib/powerpc/44x/map.c | 51 +++++++++++++++++++++++++++++++++++++
> > user/test/lib/powerpc/44x/tlbwe.S | 29 +++++++++++++++++++++
> > user/test/lib/powerpc/io.c | 35 +++++++++++++++++++++++++
>
> Without user/test/powerpc/cstart.S (and exit.c which uses it), most of
> this code is totally unused. That should at least be an additional patch
> in this series; see
> http://marc.info/?l=kvm-ppc-devel&m=120043765909206&w=2
>
I held back PowerPC testcase code using these for now. As I have other
patches that are going to come in and do stuff as well. But these
patches introduce the code needed for libcflat to build mainly.
The point of this patch series was mainly for libcflat. I will drop
patches for PowerPC that use libcflat soon.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-06-26 15:12 ` Jerone Young
@ 2008-06-26 22:01 ` Hollis Blanchard
0 siblings, 0 replies; 17+ messages in thread
From: Hollis Blanchard @ 2008-06-26 22:01 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, kvm-ppc, Jerone Young
On Thu, 2008-06-26 at 10:12 -0500, Jerone Young wrote:
> On Wed, 2008-06-25 at 16:27 -0500, Hollis Blanchard wrote:
> > On Wed, 2008-06-25 at 15:39 -0500, Jerone Young wrote:
> > > This set of patches are to consolidate test libraries into a single
> > > library archive. This lib archive is libcflat. This will allow common
> > > code to be shared among archs.
> > >
> > > Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
> >
> > I think patches 1-3 should be combined.
> I was told by someone that when these patches were combined .. they
> where too big. Also these bisect easily and don't break from patch to
> patch. Which is why they are phased in.
>
> >
> > By the way, I assume you've built x86 with these changes, but have you
> > run it too?
> Yes, with these patches x86 tests compile and run fine.
OK, patches 1-4 Acked-by: Hollis Blanchard <hollisb@us.ibm.com>.
Avi, would you apply please?
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-06-25 20:39 [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Jerone Young
` (4 preceding siblings ...)
2008-06-25 21:27 ` [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Hollis Blanchard
@ 2008-06-29 9:10 ` Avi Kivity
2008-06-29 13:24 ` Avi Kivity
5 siblings, 1 reply; 17+ messages in thread
From: Avi Kivity @ 2008-06-29 9:10 UTC (permalink / raw)
To: Jerone Young; +Cc: kvm, kvm-ppc
Jerone Young wrote:
> This set of patches are to consolidate test libraries into a single library archive. This lib archive is libcflat. This will allow common code to be shared among archs.
>
>
Applied all, thanks. I squashed together 1-3 as Hollis suggested, and
with git's rename detection, one can see that you merged exit() puts()
etc into a single file. That usually doesn't work will with libraries
(if you define your own puts() but not your own exit(), you're in
trouble), but we can fix this if/when it starts to hurt.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-06-29 9:10 ` Avi Kivity
@ 2008-06-29 13:24 ` Avi Kivity
2008-07-01 7:33 ` Jerone Young
0 siblings, 1 reply; 17+ messages in thread
From: Avi Kivity @ 2008-06-29 13:24 UTC (permalink / raw)
To: Jerone Young; +Cc: kvm, kvm-ppc
Avi Kivity wrote:
> Jerone Young wrote:
>> This set of patches are to consolidate test libraries into a single
>> library archive. This lib archive is libcflat. This will allow common
>> code to be shared among archs.
>>
>>
>
> Applied all, thanks. I squashed together 1-3 as Hollis suggested, and
> with git's rename detection, one can see that you merged exit() puts()
> etc into a single file. That usually doesn't work will with libraries
> (if you define your own puts() but not your own exit(), you're in
> trouble), but we can fix this if/when it starts to hurt.
>
>
This fails compilation with:
gcc -m64 -D__x86_64__ -I /tmp/BUILDER/kvm/rpmtop/BUILD/kernel/include
-O1 -MMD -MF test/x86/.access.d -g -fomit-frame-pointer -Wa
ll -fno-stack-protector -I ../libkvm -std=gnu99 -ffreestanding -I
test/lib -I test/lib/x86 -c -o test/x86/access.o test/x86/a
ccess.c
test/x86/access.c:153: error: conflicting types for 'memset'
/usr/include/string.h:59: error: previous declaration of 'memset' was here
test/x86/access.c: In function 'ac_test_do_access':
test/x86/access.c:511: warning: implicit declaration of function 'printf'
test/x86/access.c: In function 'main':
test/x86/access.c:578: warning: passing argument 1 of 'smp_init' from
incompatible pointer type
make[1]: *** [test/x86/access.o] Error 1
make[1]: Leaving directory `/tmp/BUILDER/kvm/rpmtop/BUILD/user'
error: Bad exit status from /var/tmp/rpm-tmp.45450 (%build)
So I'm unapplying these patches.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-06-29 13:24 ` Avi Kivity
@ 2008-07-01 7:33 ` Jerone Young
2008-07-05 9:28 ` Avi Kivity
0 siblings, 1 reply; 17+ messages in thread
From: Jerone Young @ 2008-07-01 7:33 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, kvm-ppc, hollisb
On Sun, 2008-06-29 at 16:24 +0300, Avi Kivity wrote:
> Avi Kivity wrote:
> > Jerone Young wrote:
> >> This set of patches are to consolidate test libraries into a single
> >> library archive. This lib archive is libcflat. This will allow common
> >> code to be shared among archs.
> >>
> >>
> >
> > Applied all, thanks. I squashed together 1-3 as Hollis suggested, and
> > with git's rename detection, one can see that you merged exit() puts()
> > etc into a single file. That usually doesn't work will with libraries
> > (if you define your own puts() but not your own exit(), you're in
> > trouble), but we can fix this if/when it starts to hurt.
> >
> >
>
> This fails compilation with:
>
> gcc -m64 -D__x86_64__ -I /tmp/BUILDER/kvm/rpmtop/BUILD/kernel/include
> -O1 -MMD -MF test/x86/.access.d -g -fomit-frame-pointer -Wa
> ll -fno-stack-protector -I ../libkvm -std=gnu99 -ffreestanding -I
> test/lib -I test/lib/x86 -c -o test/x86/access.o test/x86/a
> ccess.c
> test/x86/access.c:153: error: conflicting types for 'memset'
> /usr/include/string.h:59: error: previous declaration of 'memset' was here
> test/x86/access.c: In function 'ac_test_do_access':
> test/x86/access.c:511: warning: implicit declaration of function 'printf'
> test/x86/access.c: In function 'main':
> test/x86/access.c:578: warning: passing argument 1 of 'smp_init' from
> incompatible pointer type
> make[1]: *** [test/x86/access.o] Error 1
> make[1]: Leaving directory `/tmp/BUILDER/kvm/rpmtop/BUILD/user'
> error: Bad exit status from /var/tmp/rpm-tmp.45450 (%build)
>
> So I'm unapplying these patches.
>
Ah. Sorry about that. I was testing on x86 and not x86-64. So I didn't
notice that config-x86_64.mak had other test cases outside of what was
in config-x86-common.
The problem here is access.c needs to include the new libcflat.h , and
not printf.h . In one of my patches.
Since I don't currently have an x86-64 setup to try, can't turn out a
patch. I can give you an idea of what is up so here are the changes
needed for test/x86/access.c:
jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ vi access.c.FIXED
jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ diff -aurp access.c access.c.FIXED
--- access.c 2008-06-09 08:57:25.000000000 -0500
+++ access.c.FIXED 2008-07-01 02:32:41.000000000 -0500
@@ -1,7 +1,6 @@
-#include "smp.h"
-#include "printf.h"
-#include "string.h"
+#include <x86/smp.h>
+#include <libcflat.h>
#define true 1
#define false 0
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-07-01 7:33 ` Jerone Young
@ 2008-07-05 9:28 ` Avi Kivity
2008-07-05 17:32 ` Jerone Young
0 siblings, 1 reply; 17+ messages in thread
From: Avi Kivity @ 2008-07-05 9:28 UTC (permalink / raw)
To: jyoung5; +Cc: kvm, kvm-ppc, hollisb
Jerone Young wrote:
> On Sun, 2008-06-29 at 16:24 +0300, Avi Kivity wrote:
>
>> Avi Kivity wrote:
>>
>>> Jerone Young wrote:
>>>
>>>> This set of patches are to consolidate test libraries into a single
>>>> library archive. This lib archive is libcflat. This will allow common
>>>> code to be shared among archs.
>>>>
>>>>
>>>>
>>> Applied all, thanks. I squashed together 1-3 as Hollis suggested, and
>>> with git's rename detection, one can see that you merged exit() puts()
>>> etc into a single file. That usually doesn't work will with libraries
>>> (if you define your own puts() but not your own exit(), you're in
>>> trouble), but we can fix this if/when it starts to hurt.
>>>
>>>
>>>
>> This fails compilation with:
>>
>> gcc -m64 -D__x86_64__ -I /tmp/BUILDER/kvm/rpmtop/BUILD/kernel/include
>> -O1 -MMD -MF test/x86/.access.d -g -fomit-frame-pointer -Wa
>> ll -fno-stack-protector -I ../libkvm -std=gnu99 -ffreestanding -I
>> test/lib -I test/lib/x86 -c -o test/x86/access.o test/x86/a
>> ccess.c
>> test/x86/access.c:153: error: conflicting types for 'memset'
>> /usr/include/string.h:59: error: previous declaration of 'memset' was here
>> test/x86/access.c: In function 'ac_test_do_access':
>> test/x86/access.c:511: warning: implicit declaration of function 'printf'
>> test/x86/access.c: In function 'main':
>> test/x86/access.c:578: warning: passing argument 1 of 'smp_init' from
>> incompatible pointer type
>> make[1]: *** [test/x86/access.o] Error 1
>> make[1]: Leaving directory `/tmp/BUILDER/kvm/rpmtop/BUILD/user'
>> error: Bad exit status from /var/tmp/rpm-tmp.45450 (%build)
>>
>> So I'm unapplying these patches.
>>
>>
>
> Ah. Sorry about that. I was testing on x86 and not x86-64. So I didn't
> notice that config-x86_64.mak had other test cases outside of what was
> in config-x86-common.
>
> The problem here is access.c needs to include the new libcflat.h , and
> not printf.h . In one of my patches.
>
> Since I don't currently have an x86-64 setup to try, can't turn out a
> patch. I can give you an idea of what is up so here are the changes
> needed for test/x86/access.c:
>
> jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ vi access.c.FIXED
> jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ diff -aurp access.c access.c.FIXED
> --- access.c 2008-06-09 08:57:25.000000000 -0500
> +++ access.c.FIXED 2008-07-01 02:32:41.000000000 -0500
> @@ -1,7 +1,6 @@
>
> -#include "smp.h"
> -#include "printf.h"
> -#include "string.h"
> +#include <x86/smp.h>
> +#include <libcflat.h>
>
>
Er, <> includes are for system headers. Please stick to "" includes.
The previous patches also need to be fixed.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-07-05 9:28 ` Avi Kivity
@ 2008-07-05 17:32 ` Jerone Young
2008-07-05 17:36 ` Avi Kivity
0 siblings, 1 reply; 17+ messages in thread
From: Jerone Young @ 2008-07-05 17:32 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, kvm-ppc, hollisb
On Sat, 2008-07-05 at 12:28 +0300, Avi Kivity wrote:
> Jerone Young wrote:
> > On Sun, 2008-06-29 at 16:24 +0300, Avi Kivity wrote:
> >
> >> Avi Kivity wrote:
> >>
> >>> Jerone Young wrote:
> >>>
> >>>> This set of patches are to consolidate test libraries into a single
> >>>> library archive. This lib archive is libcflat. This will allow common
> >>>> code to be shared among archs.
> >>>>
> >>>>
> >>>>
> >>> Applied all, thanks. I squashed together 1-3 as Hollis suggested, and
> >>> with git's rename detection, one can see that you merged exit() puts()
> >>> etc into a single file. That usually doesn't work will with libraries
> >>> (if you define your own puts() but not your own exit(), you're in
> >>> trouble), but we can fix this if/when it starts to hurt.
> >>>
> >>>
> >>>
> >> This fails compilation with:
> >>
> >> gcc -m64 -D__x86_64__ -I /tmp/BUILDER/kvm/rpmtop/BUILD/kernel/include
> >> -O1 -MMD -MF test/x86/.access.d -g -fomit-frame-pointer -Wa
> >> ll -fno-stack-protector -I ../libkvm -std=gnu99 -ffreestanding -I
> >> test/lib -I test/lib/x86 -c -o test/x86/access.o test/x86/a
> >> ccess.c
> >> test/x86/access.c:153: error: conflicting types for 'memset'
> >> /usr/include/string.h:59: error: previous declaration of 'memset' was here
> >> test/x86/access.c: In function 'ac_test_do_access':
> >> test/x86/access.c:511: warning: implicit declaration of function 'printf'
> >> test/x86/access.c: In function 'main':
> >> test/x86/access.c:578: warning: passing argument 1 of 'smp_init' from
> >> incompatible pointer type
> >> make[1]: *** [test/x86/access.o] Error 1
> >> make[1]: Leaving directory `/tmp/BUILDER/kvm/rpmtop/BUILD/user'
> >> error: Bad exit status from /var/tmp/rpm-tmp.45450 (%build)
> >>
> >> So I'm unapplying these patches.
> >>
> >>
> >
> > Ah. Sorry about that. I was testing on x86 and not x86-64. So I didn't
> > notice that config-x86_64.mak had other test cases outside of what was
> > in config-x86-common.
> >
> > The problem here is access.c needs to include the new libcflat.h , and
> > not printf.h . In one of my patches.
> >
> > Since I don't currently have an x86-64 setup to try, can't turn out a
> > patch. I can give you an idea of what is up so here are the changes
> > needed for test/x86/access.c:
> >
> > jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ vi access.c.FIXED
> > jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ diff -aurp access.c access.c.FIXED
> > --- access.c 2008-06-09 08:57:25.000000000 -0500
> > +++ access.c.FIXED 2008-07-01 02:32:41.000000000 -0500
> > @@ -1,7 +1,6 @@
> >
> > -#include "smp.h"
> > -#include "printf.h"
> > -#include "string.h"
> > +#include <x86/smp.h>
> > +#include <libcflat.h>
> >
> >
>
> Er, <> includes are for system headers. Please stick to "" includes.
> The previous patches also need to be fixed.
Actually the include paths to not use system includes.
Just setup an x86-64 compilation enviroment. Looks like access.c was the
only test that had the problem. Also the pseudo patch I sent ended up
being the solution. I will send a formal patch set shortly so you can
include libcflat.
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-07-05 17:32 ` Jerone Young
@ 2008-07-05 17:36 ` Avi Kivity
2008-07-05 17:59 ` Jerone Young
0 siblings, 1 reply; 17+ messages in thread
From: Avi Kivity @ 2008-07-05 17:36 UTC (permalink / raw)
To: jyoung5; +Cc: kvm, kvm-ppc, hollisb
Jerone Young wrote:
> On Sat, 2008-07-05 at 12:28 +0300, Avi Kivity wrote:
>
>> Jerone Young wrote:
>>
>>> On Sun, 2008-06-29 at 16:24 +0300, Avi Kivity wrote:
>>>
>>>
>>>> Avi Kivity wrote:
>>>>
>>>>
>>>>> Jerone Young wrote:
>>>>>
>>>>>
>>>>>> This set of patches are to consolidate test libraries into a single
>>>>>> library archive. This lib archive is libcflat. This will allow common
>>>>>> code to be shared among archs.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> Applied all, thanks. I squashed together 1-3 as Hollis suggested, and
>>>>> with git's rename detection, one can see that you merged exit() puts()
>>>>> etc into a single file. That usually doesn't work will with libraries
>>>>> (if you define your own puts() but not your own exit(), you're in
>>>>> trouble), but we can fix this if/when it starts to hurt.
>>>>>
>>>>>
>>>>>
>>>>>
>>>> This fails compilation with:
>>>>
>>>> gcc -m64 -D__x86_64__ -I /tmp/BUILDER/kvm/rpmtop/BUILD/kernel/include
>>>> -O1 -MMD -MF test/x86/.access.d -g -fomit-frame-pointer -Wa
>>>> ll -fno-stack-protector -I ../libkvm -std=gnu99 -ffreestanding -I
>>>> test/lib -I test/lib/x86 -c -o test/x86/access.o test/x86/a
>>>> ccess.c
>>>> test/x86/access.c:153: error: conflicting types for 'memset'
>>>> /usr/include/string.h:59: error: previous declaration of 'memset' was here
>>>> test/x86/access.c: In function 'ac_test_do_access':
>>>> test/x86/access.c:511: warning: implicit declaration of function 'printf'
>>>> test/x86/access.c: In function 'main':
>>>> test/x86/access.c:578: warning: passing argument 1 of 'smp_init' from
>>>> incompatible pointer type
>>>> make[1]: *** [test/x86/access.o] Error 1
>>>> make[1]: Leaving directory `/tmp/BUILDER/kvm/rpmtop/BUILD/user'
>>>> error: Bad exit status from /var/tmp/rpm-tmp.45450 (%build)
>>>>
>>>> So I'm unapplying these patches.
>>>>
>>>>
>>>>
>>> Ah. Sorry about that. I was testing on x86 and not x86-64. So I didn't
>>> notice that config-x86_64.mak had other test cases outside of what was
>>> in config-x86-common.
>>>
>>> The problem here is access.c needs to include the new libcflat.h , and
>>> not printf.h . In one of my patches.
>>>
>>> Since I don't currently have an x86-64 setup to try, can't turn out a
>>> patch. I can give you an idea of what is up so here are the changes
>>> needed for test/x86/access.c:
>>>
>>> jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ vi access.c.FIXED
>>> jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ diff -aurp access.c access.c.FIXED
>>> --- access.c 2008-06-09 08:57:25.000000000 -0500
>>> +++ access.c.FIXED 2008-07-01 02:32:41.000000000 -0500
>>> @@ -1,7 +1,6 @@
>>>
>>> -#include "smp.h"
>>> -#include "printf.h"
>>> -#include "string.h"
>>> +#include <x86/smp.h>
>>> +#include <libcflat.h>
>>>
>>>
>>>
>> Er, <> includes are for system headers. Please stick to "" includes.
>> The previous patches also need to be fixed.
>>
>
> Actually the include paths to not use system includes.
>
>
<> means system include file. libcflat.h is not a system include file,
so no pointy brackets.
> Just setup an x86-64 compilation enviroment. Looks like access.c was the
> only test that had the problem. Also the pseudo patch I sent ended up
> being the solution. I will send a formal patch set shortly so you can
> include libcflat.
>
Thanks. Please don't send separate create and delete patches, and use
diff -M, so that we see exactly what's changed rather than a zillion and
a half adds and removes.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat
2008-07-05 17:36 ` Avi Kivity
@ 2008-07-05 17:59 ` Jerone Young
0 siblings, 0 replies; 17+ messages in thread
From: Jerone Young @ 2008-07-05 17:59 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, kvm-ppc, hollisb
Just got this email, after sending the access.c fix.
On Sat, 2008-07-05 at 20:36 +0300, Avi Kivity wrote:
> Jerone Young wrote:
> > On Sat, 2008-07-05 at 12:28 +0300, Avi Kivity wrote:
> >
> >> Jerone Young wrote:
> >>
> >>> On Sun, 2008-06-29 at 16:24 +0300, Avi Kivity wrote:
> >>>
> >>>
> >>>> Avi Kivity wrote:
> >>>>
> >>>>
> >>>>> Jerone Young wrote:
> >>>>>
> >>>>>
> >>>>>> This set of patches are to consolidate test libraries into a single
> >>>>>> library archive. This lib archive is libcflat. This will allow common
> >>>>>> code to be shared among archs.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>> Applied all, thanks. I squashed together 1-3 as Hollis suggested, and
> >>>>> with git's rename detection, one can see that you merged exit() puts()
> >>>>> etc into a single file. That usually doesn't work will with libraries
> >>>>> (if you define your own puts() but not your own exit(), you're in
> >>>>> trouble), but we can fix this if/when it starts to hurt.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> This fails compilation with:
> >>>>
> >>>> gcc -m64 -D__x86_64__ -I /tmp/BUILDER/kvm/rpmtop/BUILD/kernel/include
> >>>> -O1 -MMD -MF test/x86/.access.d -g -fomit-frame-pointer -Wa
> >>>> ll -fno-stack-protector -I ../libkvm -std=gnu99 -ffreestanding -I
> >>>> test/lib -I test/lib/x86 -c -o test/x86/access.o test/x86/a
> >>>> ccess.c
> >>>> test/x86/access.c:153: error: conflicting types for 'memset'
> >>>> /usr/include/string.h:59: error: previous declaration of 'memset' was here
> >>>> test/x86/access.c: In function 'ac_test_do_access':
> >>>> test/x86/access.c:511: warning: implicit declaration of function 'printf'
> >>>> test/x86/access.c: In function 'main':
> >>>> test/x86/access.c:578: warning: passing argument 1 of 'smp_init' from
> >>>> incompatible pointer type
> >>>> make[1]: *** [test/x86/access.o] Error 1
> >>>> make[1]: Leaving directory `/tmp/BUILDER/kvm/rpmtop/BUILD/user'
> >>>> error: Bad exit status from /var/tmp/rpm-tmp.45450 (%build)
> >>>>
> >>>> So I'm unapplying these patches.
> >>>>
> >>>>
> >>>>
> >>> Ah. Sorry about that. I was testing on x86 and not x86-64. So I didn't
> >>> notice that config-x86_64.mak had other test cases outside of what was
> >>> in config-x86-common.
> >>>
> >>> The problem here is access.c needs to include the new libcflat.h , and
> >>> not printf.h . In one of my patches.
> >>>
> >>> Since I don't currently have an x86-64 setup to try, can't turn out a
> >>> patch. I can give you an idea of what is up so here are the changes
> >>> needed for test/x86/access.c:
> >>>
> >>> jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ vi access.c.FIXED
> >>> jerone@thinkpadL:~/work/kvm-userspace/user/test/x86$ diff -aurp access.c access.c.FIXED
> >>> --- access.c 2008-06-09 08:57:25.000000000 -0500
> >>> +++ access.c.FIXED 2008-07-01 02:32:41.000000000 -0500
> >>> @@ -1,7 +1,6 @@
> >>>
> >>> -#include "smp.h"
> >>> -#include "printf.h"
> >>> -#include "string.h"
> >>> +#include <x86/smp.h>
> >>> +#include <libcflat.h>
> >>>
> >>>
> >>>
> >> Er, <> includes are for system headers. Please stick to "" includes.
> >> The previous patches also need to be fixed.
> >>
> >
> > Actually the include paths to not use system includes.
Ok can do this. Will fix up all the test files to use "" instead of <>.
> >
> >
>
> <> means system include file. libcflat.h is not a system include file,
> so no pointy brackets.
>
> > Just setup an x86-64 compilation enviroment. Looks like access.c was the
> > only test that had the problem. Also the pseudo patch I sent ended up
> > being the solution. I will send a formal patch set shortly so you can
> > include libcflat.
> >
>
> Thanks. Please don't send separate create and delete patches, and use
> diff -M, so that we see exactly what's changed rather than a zillion and
> a half adds and removes.
I'll see what I can do. Though I depend on hg to generate the patches.
So I'll see if I can have just have remove for files (but no promises).
I'll just merge everything into one big patch.
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2008-07-05 17:59 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-25 20:39 [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Jerone Young
2008-06-25 20:39 ` [PATCH 1 of 4] Consilidate libcflat for x86 to single lib for all archs Jerone Young
2008-06-25 20:39 ` [PATCH 2 of 4] Add Makefile and test changes required for x86 to use libcflat Jerone Young
2008-06-25 20:39 ` [PATCH 3 of 4] Remove old x86 test libs, that are now appart of libcflat Jerone Young
2008-06-25 20:39 ` [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes Jerone Young
2008-06-25 21:28 ` Hollis Blanchard
2008-06-26 15:14 ` Jerone Young
2008-06-25 21:27 ` [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Hollis Blanchard
2008-06-26 15:12 ` Jerone Young
2008-06-26 22:01 ` Hollis Blanchard
2008-06-29 9:10 ` Avi Kivity
2008-06-29 13:24 ` Avi Kivity
2008-07-01 7:33 ` Jerone Young
2008-07-05 9:28 ` Avi Kivity
2008-07-05 17:32 ` Jerone Young
2008-07-05 17:36 ` Avi Kivity
2008-07-05 17:59 ` Jerone Young
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox