Skip to contentSkip to conversation

consolidate test libs to libcflat

PATCH In review Jerone Young 3 participants 17 messages Jun 25, 2008 – Jul 5, 2008 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 consolidate test libs to libcflat

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.

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 
#1 lore raw

PATCH 1/1 Consilidate libcflat for x86 to single lib for all archs

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.

user/test/lib/libcflat.h new file +37 -0
new file mode 100644
@@ -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 <[email protected]>
+ */
+
+#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
user/test/lib/panic.c new file +13 -0
new file mode 100644
@@ -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);
+}
user/test/lib/printf.c new file +179 -0

179 lines not on this page · raw message

user/test/lib/string.c new file +21 -0
new file mode 100644
@@ -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;
+}
user/test/lib/x86/apic.h new file +14 -0
new file mode 100644
@@ -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
user/test/lib/x86/io.c new file +23 -0
new file mode 100644
@@ -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));
+}
user/test/lib/x86/smp.c new file +150 -0

150 lines not on this page · raw message

user/test/lib/x86/smp.h new file +16 -0
new file mode 100644
@@ -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
#2 lore raw

PATCH 1/1 Add Makefile and test changes required for x86 to use libcflat

In reply to Jerone Young
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 +--
user/Makefile +10 -1
@@ -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)
user/config-x86-common.mak +10 -6
@@ -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
user/main.c +1 -1
@@ -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>
user/test/x86/port80.c +1 -2
@@ -1,5 +1,4 @@
-
-#include "printf.h"
+#include <libcflat.h>
 
 int main()
 {
user/test/x86/smptest.c +2 -3
@@ -1,6 +1,5 @@
-
-#include "smp.h"
-#include "printf.h"
+#include <libcflat.h>
+#include <smp.h>
 
 static void ipi_test(void *data)
 {
user/test/x86/tsc.c +1 -2
@@ -1,5 +1,4 @@
-
-#include "printf.h"
+#include <libcflat.h>
 
 typedef unsigned long long u64;
 
#3 lore raw

PATCH 1/1 Remove old x86 test libs, that are now appart of libcflat

In reply to Jerone Young
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 -
user/test/x86/lib/apic.h deleted +0 -14
deleted file mode 100644
@@ -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
user/test/x86/lib/exit.c deleted +0 -5
deleted file mode 100644
@@ -1,5 +0,0 @@
-
-void exit(int code)
-{
-	asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
-}
user/test/x86/lib/printf.c deleted +0 -195

195 lines not on this page · raw message

user/test/x86/lib/printf.h deleted +0 -2
deleted file mode 100644
@@ -1,2 +0,0 @@
-
-int printf(const char *fmt, ...);
user/test/x86/lib/smp.c deleted +0 -151

151 lines not on this page · raw message

user/test/x86/lib/smp.h deleted +0 -16
deleted file mode 100644
@@ -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
user/test/x86/lib/string.c deleted +0 -21
deleted file mode 100644
@@ -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;
-}
user/test/x86/lib/string.h deleted +0 -7
deleted file mode 100644
@@ -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
#4 lore raw

PATCH 1/1 Add initial PowerPC libcflat files & make file changes

In reply to Jerone Young
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 +++++++++++++++++++++++++
user/config-powerpc.mak +9 -1
@@ -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
 
user/test/lib/powerpc/44x/map.c new file +51 -0

51 lines not on this page · raw message

user/test/lib/powerpc/44x/tlbwe.S new file +29 -0
new file mode 100644
@@ -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 <[email protected]>
+ */
+
+#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
user/test/lib/powerpc/io.c new file +35 -0
new file mode 100644
@@ -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 <[email protected]>
+ */
+
+#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;
+}
#5 lore raw

Re: [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes

Quoted 5 lines · Jerone Young
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

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#6 lore raw

Re: [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes

Quoted 7 lines · Hollis Blanchard
Quoted 5 lines · Jerone Young
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 +++++++++++++++++++++++++
Quoted 5 lines

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&m0043765909206&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.

#7 lore raw
In reply to Jerone Young
Quoted 5 lines · Jerone Young

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.

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?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#8 lore raw
Quoted 8 lines · Hollis Blanchard
Quoted 5 lines · Jerone Young

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.

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.

Quoted 3 lines

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.

Quoted 1 line
#9 lore raw
Quoted 9 lines · Jerone Young
Quoted 8 lines · Hollis Blanchard
Quoted 5 lines · Jerone Young

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.

I think patches 1-3 should be combined.

Quoted 8 lines

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.

Quoted 3 lines

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 <[email protected]>.

Avi, would you apply please?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#10 lore raw
In reply to Jerone Young
Quoted 3 lines · Jerone Young

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.

Signature · 1 line
error compiling committee.c: too many arguments to function
#11 lore raw
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Jerone Young

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.

Quoted 7 lines

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.

Signature · 1 line
error compiling committee.c: too many arguments to function
#12 lore raw
Quoted 34 lines · Avi Kivity
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Jerone Young

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.

Quoted 7 lines

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)

Quoted 2 lines

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

#13 lore raw
Quoted 58 lines · Jerone Young
Quoted 36 lines · Avi Kivity
Quoted 8 lines · Avi Kivity
Quoted 6 lines · Jerone Young

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.

Quoted 8 lines

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)

Quoted 3 lines

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.FIXED line 5

Quoted 8 lines
access.c.FIXED renamed from access.c +2 -3
@@ -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.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#14 lore raw
Quoted 60 lines · Avi Kivity
Quoted 59 lines · Jerone Young
Quoted 36 lines · Avi Kivity
Quoted 8 lines · Avi Kivity
Quoted 6 lines · Jerone Young

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.

Quoted 8 lines

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)

Quoted 3 lines

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.FIXED renamed from access.c +0 -0
@@ -1,7 +1,6 @@
 
Quoted 10 lines

access.c.FIXED line 5

Quoted 7 lines
access.c.FIXED renamed from access.c +2 -3
-#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.

Quoted 2 lines
#15 lore raw
Quoted 70 lines · Jerone Young
Quoted 57 lines · Avi Kivity
Quoted 55 lines · Jerone Young
Quoted 32 lines · Avi Kivity
Quoted 13 lines · Avi Kivity
Quoted 5 lines · Jerone Young

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)

Quoted 4 lines

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.FIXED renamed from access.c +0 -0
@@ -1,7 +1,6 @@
 
Quoted 10 lines

access.c.FIXED line 6

Quoted 8 lines
access.c.FIXED renamed from access.c +2 -3
-#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.

Quoted 3 lines

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.

Quoted 5 lines

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.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#16 lore raw

Just got this email, after sending the access.c fix.

Quoted 81 lines · Avi Kivity
Quoted 80 lines · Jerone Young
Quoted 77 lines · Avi Kivity
Quoted 63 lines · Jerone Young
Quoted 40 lines · Avi Kivity
Quoted 10 lines · Avi Kivity
Quoted 7 lines · Jerone Young

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.

Quoted 9 lines

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)

Quoted 4 lines

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.FIXED line 6

Quoted 9 lines
access.c.FIXED renamed from access.c +2 -3
@@ -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.

Quoted 1 line
Quoted 1 line

Actually the include paths to not use system includes.

Ok can do this. Will fix up all the test files to use "" instead of <>.

Quoted 12 lines
Quoted 2 lines

<> means system include file. libcflat.h is not a system include file, so no pointy brackets.

Quoted 5 lines

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.

Quoted 3 lines

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.

Quoted 2 lines