Skip to contentSkip to conversation

Move all x86 tests to user/tests/x86

PATCH In review Jerone Young 2 participants 3 messages Oct 23, 2007 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Move all x86 tests to user/tests/x86

This patch moves all tests currently in kvm tree to a arch specific directory. So files user/test/* are now in user/test/x86. These tests only relate to x86. Currently this is the case. Later as these share then there should be a "common" directory (tests for apic may be here).

This applies on top of the new makefile consolidation changes for x86 & x86-64.

user/Makefile +3 -22
@@ -15,13 +15,13 @@ cc-option = $(shell if $(CC) $(1) -S -o 
 cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
               > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
 
-CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall 
+CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
 CFLAGS += $(call cc-option, -fno-stack-protector, "")
 CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
 
 LDFLAGS += $(CFLAGS)
 
-CXXFLAGS = $(autodepend-flags) 
+CXXFLAGS = $(autodepend-flags)
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
 
@@ -36,29 +36,10 @@ install:
 %.flat: %.o
 	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^
 
-test/bootstrap: test/bootstrap.o
-	$(CC) -nostdlib -o $@ -Wl,-T,bootstrap.lds $^
-
 %.o: %.S
 	$(CC) $(CFLAGS) -c -nostdlib -o $@ $^
 
-test/irq.flat: test/print.o
-
-test/access.flat: $(cstart.o) test/access.o test/printf.o test/print.o \
-	test/smp.o
-
-test/sieve.flat: $(cstart.o) test/sieve.o test/print.o test/vm.o
-
-test/vmexit.flat: $(cstart.o) test/vmexit.o test/printf.o test/smp.o
-
-test/test32.flat: test/test32.o
-
-test/smp.flat: $(cstart.o) test/smp.o test/printf.o test/smptest.o
-
-test/%.o: CFLAGS += -std=gnu99 -ffreestanding
-
 -include .*.d
 
-clean:
+clean: arch_clean
 	$(RM) kvmctl *.o *.a .*.d
-	$(RM) test/bootstrap test/*.o test/*.flat test/.*.d
user/config-i386.mak +2 -1
@@ -1,5 +1,6 @@ LIBDIR = /lib
 LIBDIR = /lib
-cstart.o = test/cstart.o
+TEST_DIR=test/x86
+cstart.o = $(TEST_DIR)/cstart.o
 bits = 32
 ldarch = elf32-i386
 CFLAGS += -m32
user/config-x86-common.mak +28 -1
@@ -11,6 +11,33 @@ libkvm.a: kvmctl.o
 
 balloon_ctl: balloon_ctl.o
 
-flatfiles-common = test/bootstrap test/vmexit.flat test/smp.flat
+flatfiles-common = $(TEST_DIR)/bootstrap \
+			$(TEST_DIR)/vmexit.flat \
+			$(TEST_DIR)/smp.flat
 
 flatfiles: $(flatfiles-common) $(flatfiles)
+
+$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding
+
+$(TEST_DIR)/bootstrap: $(TEST_DIR)/bootstrap.o
+	$(CC) -nostdlib -o $@ -Wl,-T,bootstrap.lds $^
+
+$(TEST_DIR)/irq.flat: $(TEST_DIR)/test/print.o
+
+$(TEST_DIR)/access.flat: $(cstart.o) $(TEST_DIR)/access.o \
+    	$(TEST_DIR)/printf.o $(TEST_DIR)/print.o $(TEST_DIR)/smp.o
+
+$(TEST_DIR)/sieve.flat: $(cstart.o) $(TEST_DIR)/sieve.o \
+	$(TEST_DIR)/print.o $(TEST_DIR)/vm.o
+
+$(TEST_DIR)/vmexit.flat: $(cstart.o) $(TEST_DIR)/vmexit.o \
+	$(TEST_DIR)/printf.o $(TEST_DIR)/smp.o
+
+$(TEST_DIR)/test32.flat: $(TEST_DIR)/test32.o
+
+$(TEST_DIR)/smp.flat: $(cstart.o) $(TEST_DIR)/smp.o $(TEST_DIR)/printf.o \
+		$(TEST_DIR)/smptest.o
+
+arch_clean:
+	$(RM) $(TEST_DIR)/bootstrap $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
+	      $(TEST_DIR)/.*.d
user/config-x86_64.mak +2 -1
@@ -1,5 +1,6 @@ LIBDIR = /lib64
 LIBDIR = /lib64
-cstart.o = test/cstart64.o
+TEST_DIR=test/x86
+cstart.o = $(TEST_DIR)/cstart64.o
 bits = 64
 ldarch = elf64-x86-64
 CFLAGS += -m64
user/main.c +1 -1
@@ -17,7 +17,7 @@
 #define _GNU_SOURCE
 
 #include "kvmctl.h"
-#include "test/apic.h"
+#include "test/x86/apic.h"
 
 #include <stdio.h>
 #include <unistd.h>
user/test/access.c deleted +0 -367

367 lines not on this page · raw message

user/test/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/bootstrap.S deleted +0 -137

137 lines not on this page · raw message

user/test/cstart.S deleted +0 -10
deleted file mode 100644
@@ -1,10 +0,0 @@
-
-
-.bss
-
-.section .init
-	call main
-1:	hlt
-	jmp 1b
-
-
user/test/cstart64.S deleted +0 -169

169 lines not on this page · raw message

user/test/irq.S deleted +0 -118

118 lines not on this page · raw message

user/test/memtest1.S deleted +0 -44

44 lines not on this page · raw message

user/test/print.S deleted +0 -31
deleted file mode 100644
@@ -1,31 +0,0 @@
-
-#include "print.h"
-
-#define PSEUDO_SERIAL_PORT 0xf1
-
-	
-.text
-	PRINT "boo"
-	hlt
-1:	jmp 1b
-	
-.globl print
-print:
-	push %rax
-	push %rsi
-	push %rdx
-
-	mov %rdi, %rsi
-	mov $(PSEUDO_SERIAL_PORT), %edx
-
-putchar:
-	cmpb $0, (%rsi)
-	jz done
-	outsb
-	jmp putchar
-done:
-	
-	pop %rdx
-	pop %rsi
-	pop %rax
-	ret
user/test/print.h deleted +0 -19
deleted file mode 100644
@@ -1,19 +0,0 @@
-#ifndef PRINT_H
-#define PRINT_H
-
-.macro PRINT text
-
-.data
-
-333: .asciz "\text\n"
-
-.previous
-
-	push %rdi
-	lea 333b, %rdi
-	call print
-	pop %rdi
-
-.endm
-
-#endif
user/test/printf.c deleted +0 -169

169 lines not on this page · raw message

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

89 lines not on this page · raw message

user/test/simple.S deleted +0 -13
deleted file mode 100644
@@ -1,13 +0,0 @@
-
-	.text
-
-	mov $0, %al
-	mov $10000, %ebx
-1:
-	mov %rbx, %rcx
-2:	
-	loop 2b
-	out %al, $0x80
-	inc %al
-	add $10000, %rbx
-	jmp 1b
user/test/smp.c deleted +0 -151

151 lines not on this page · raw message

user/test/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/smptest.c deleted +0 -32
deleted file mode 100644
@@ -1,32 +0,0 @@
-
-#include "smp.h"
-#include "printf.h"
-
-static void ipi_test(void *data)
-{
-    int n = (long)data;
-
-    printf("ipi called, cpu %d\n", n);
-    if (n != smp_id())
-	printf("but wrong cpu %d\n", smp_id());
-}
-
-static void smp_main(void)
-{
-    printf("smp main %d\n", smp_id());
-    while (1)
-	asm volatile ("hlt" : : : "memory");
-}
-
-int main()
-{
-    int ncpus;
-    int i;
-
-    smp_init(smp_main);
-    ncpus = cpu_count();
-    printf("found %d cpus\n", ncpus);
-    for (i = 0; i < ncpus; ++i)
-	on_cpu(i, ipi_test, (void *)(long)i);
-    return 0;
-}
user/test/stringio.S deleted +0 -31
deleted file mode 100644
@@ -1,31 +0,0 @@
-
-.data
-
-.macro str name, value
-
-\name :	.long 1f-2f
-2:	.ascii "\value"
-1:	
-.endm	
-
-	str "forward", "forward"
-	str "backward", "backward"
-		
-.text
-
-
-	cld
-	movl forward, %ecx
-	lea  4+forward, %rsi
-	movw $1, %dx
-	rep outsb
-
-	std
-	movl backward, %ecx
-	lea 4+backward-1(%rcx), %rsi
-	movw $2, %dx
-	rep outsb
-	
-	hlt
-
-
user/test/test32.S deleted +0 -8
deleted file mode 100644
@@ -1,8 +0,0 @@
-.code32
-
-.text
-
-1:
-	mov $0x12, %al
-	out %al, $0x80
-	jmp 1b
user/test/vm.c deleted +0 -249

249 lines not on this page · raw message

user/test/vm.h deleted +0 -9
deleted file mode 100644
@@ -1,9 +0,0 @@
-#ifndef VM_H
-#define VM_H
-
-void setup_vm();
-
-void *vmalloc(unsigned long size);
-void vfree(void *mem);
-
-#endif
user/test/vmexit.c deleted +0 -32
deleted file mode 100644
@@ -1,32 +0,0 @@
-
-#include "printf.h"
-
-static inline unsigned long long rdtsc()
-{
-	long long r;
-
-#ifdef __x86_64__
-	unsigned a, d;
-
-	asm volatile ("rdtsc" : "=a"(a), "=d"(d));
-	r = a | ((long long)d << 32);
-#else
-	asm volatile ("rdtsc" : "=A"(r));
-#endif
-	return r;
-}
-
-#define N (1 << 22)
-
-int main()
-{
-	int i;
-	unsigned long long t1, t2;
-
-	t1 = rdtsc();
-	for (i = 0; i < N; ++i)
-		asm volatile ("cpuid" : : : "eax", "ebx", "ecx", "edx");
-	t2 = rdtsc();
-	printf("vmexit latency: %d\n", (int)((t2 - t1) / N));
-	return 0;
-}
user/test/x86/access.c new file +367 -0

367 lines not on this page · raw message

user/test/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/x86/bootstrap.S new file +137 -0

137 lines not on this page · raw message

user/test/x86/cstart.S new file +10 -0
new file mode 100644
@@ -0,0 +1,10 @@
+
+
+.bss
+
+.section .init
+	call main
+1:	hlt
+	jmp 1b
+
+
user/test/x86/cstart64.S new file +169 -0

169 lines not on this page · raw message

user/test/x86/irq.S new file +118 -0

118 lines not on this page · raw message

user/test/x86/memtest1.S new file +44 -0

44 lines not on this page · raw message

user/test/x86/print.S new file +31 -0
new file mode 100644
@@ -0,0 +1,31 @@
+
+#include "print.h"
+
+#define PSEUDO_SERIAL_PORT 0xf1
+
+	
+.text
+	PRINT "boo"
+	hlt
+1:	jmp 1b
+	
+.globl print
+print:
+	push %rax
+	push %rsi
+	push %rdx
+
+	mov %rdi, %rsi
+	mov $(PSEUDO_SERIAL_PORT), %edx
+
+putchar:
+	cmpb $0, (%rsi)
+	jz done
+	outsb
+	jmp putchar
+done:
+	
+	pop %rdx
+	pop %rsi
+	pop %rax
+	ret
user/test/x86/print.h new file +19 -0
new file mode 100644
@@ -0,0 +1,19 @@
+#ifndef PRINT_H
+#define PRINT_H
+
+.macro PRINT text
+
+.data
+
+333: .asciz "\text\n"
+
+.previous
+
+	push %rdi
+	lea 333b, %rdi
+	call print
+	pop %rdi
+
+.endm
+
+#endif
user/test/x86/printf.c new file +169 -0

169 lines not on this page · raw message

user/test/x86/printf.h new file +2 -0
new file mode 100644
@@ -0,0 +1,2 @@
+
+int printf(const char *fmt, ...);
user/test/x86/sieve.c new file +89 -0

89 lines not on this page · raw message

user/test/x86/simple.S new file +13 -0
new file mode 100644
@@ -0,0 +1,13 @@
+
+	.text
+
+	mov $0, %al
+	mov $10000, %ebx
+1:
+	mov %rbx, %rcx
+2:	
+	loop 2b
+	out %al, $0x80
+	inc %al
+	add $10000, %rbx
+	jmp 1b
user/test/x86/smp.c new file +151 -0

7 lines not on this page · raw message

user/test/x86/smp.h new file +16 -0
new file mode 100644

Lines of this file are not shown. View the raw message.

user/test/x86/smptest.c new file +32 -0
new file mode 100644

Lines of this file are not shown. View the raw message.

user/test/x86/stringio.S new file +31 -0
new file mode 100644

Lines of this file are not shown. View the raw message.

user/test/x86/test32.S new file +8 -0
new file mode 100644

Lines of this file are not shown. View the raw message.

user/test/x86/vm.c new file +249 -0

249 lines not on this page · raw message

user/test/x86/vm.h new file +9 -0
new file mode 100644

Lines of this file are not shown. View the raw message.

user/test/x86/vmexit.c new file +32 -0
new file mode 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 4 lines · Jerone Young

This patch moves all tests currently in kvm tree to a arch specific directory. So files user/test/* are now in user/test/x86. These tests only relate to x86. Currently this is the case. Later as these share then there should be a "common" directory (tests for apic may be here).

...

Quoted 5 lines
user/config-x86-common.mak +0 -0
@@ -11,6 +11,33 @@ libkvm.a: kvmctl.o
 

user/config-x86-common.mak libkvm.a: kvmctl.o · line 20

Quoted 10 lines
user/config-x86-common.mak +5 -1
 balloon_ctl: balloon_ctl.o
 
-flatfiles-common = test/bootstrap test/vmexit.flat test/smp.flat
+flatfiles-common = $(TEST_DIR)/bootstrap \
+			$(TEST_DIR)/vmexit.flat \
+			$(TEST_DIR)/smp.flat
 
 flatfiles: $(flatfiles-common) $(flatfiles)
+
+$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding

You should be able to do something clever with $(patsubst ...) to avoid typing TEST_DIR everywhere.

...

user/config-x86-common.mak libkvm.a: kvmctl.o · line 43

Quoted 4 lines
user/config-x86-common.mak +4 -0
+
+arch_clean:
+	$(RM) $(TEST_DIR)/bootstrap $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
+	      $(TEST_DIR)/.*.d

I think you need a FORCE or .PHONY or whatever. (Otherwise, creating a file named "arch_clean" will keep this from working.)

Signature · 9 lines
Hollis Blanchard
IBM Linux Technology Center


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
#2 lore raw
Quoted 27 lines · Hollis Blanchard
Quoted 4 lines · Jerone Young

This patch moves all tests currently in kvm tree to a arch specific directory. So files user/test/* are now in user/test/x86. These tests only relate to x86. Currently this is the case. Later as these share then there should be a "common" directory (tests for apic may be here).

...

Quoted 5 lines
user/config-x86-common.mak +0 -0
@@ -11,6 +11,33 @@ libkvm.a: kvmctl.o
 

user/config-x86-common.mak libkvm.a: kvmctl.o · line 20

Quoted 10 lines
user/config-x86-common.mak +5 -1
 balloon_ctl: balloon_ctl.o
 
-flatfiles-common = test/bootstrap test/vmexit.flat test/smp.flat
+flatfiles-common = $(TEST_DIR)/bootstrap \
+			$(TEST_DIR)/vmexit.flat \
+			$(TEST_DIR)/smp.flat
 
 flatfiles: $(flatfiles-common) $(flatfiles)
+
+$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding

You should be able to do something clever with $(patsubst ...) to avoid typing TEST_DIR everywhere.

Quoted 8 lines

...

user/config-x86-common.mak libkvm.a: kvmctl.o · line 43

Quoted 4 lines
user/config-x86-common.mak +4 -0
+
+arch_clean:
+	$(RM) $(TEST_DIR)/bootstrap $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
+	      $(TEST_DIR)/.*.d

I think you need a FORCE or .PHONY or whatever. (Otherwise, creating a file named "arch_clean" will keep this from working.)

Your right. Didn't think about that ... but also what are the chances of a someone naming a file arch_clean? Never the less, a .PHONY is needed I'll add that to a separate patch, if no one has any other issues with these patches.

Quoted 1 line

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/