Skip to contentSkip to conversation

Add small pieces for userspace powerpc support

PATCH Applied Jerone Young 2 participants 4 messages Nov 29, 2007 – Nov 30, 2007 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add small pieces for userspace powerpc support

These patches add two things:
libkvm skelton support
powerpc tests (but missing kvmctl main.c)

I'm submitting these patches to start to trickle in code into upstream repository. A lot more patches will follow, but these should start to go in, not just as a refrence. But also to help with some collaboration. Much more to come.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

#1 lore raw

PATCH 1/1 Add powerpc tests

# HG changeset patch
# User Jerone Young <jyoung5-r/[email protected]> # Date 1196367231 21600
# Node ID 6f34b3cd608868c4cc8280ab333aac78a7ba9a6d
# Parent be65ecf21443ddb74f9adbf6aa9778f798b5761b
Add powerpc tests

This patch adds a set of simple powerpc tests

user/config-powerpc.mak new file +14 -0
new file mode 100644
@@ -0,0 +1,14 @@
+TEST_DIR=test/powerpc
+CFLAGS += -m32
+CFLAGS += -D__powerpc__
+CFLAGS += -I $(KERNELDIR)/include
+
+tests= $(TEST_DIR)/io.S \
+	$(TEST_DIR)/spin.S \
+	$(TEST_DIR)/sprg.S \
+	$(TEST_DIR)/44x/tlbsx.S \
+	$(TEST_DIR)/44x/tlbwe_16KB.S \
+	$(TEST_DIR)/44x/tlbwe_hole.S \
+	$(TEST_DIR)/44x/tlbwe.S
+
+kvmctl_objs = main.o ../libkvm/libkvm.a
user/test/powerpc/44x/tlbsx.S new file +33 -0
new file mode 100644
@@ -0,0 +1,33 @@
+#define SPRN_MMUCR 0x3b2
+
+#define TLBWORD0 0x10000210
+#define TLBWORD1 0x10000000
+#define TLBWORD2 0x00000003
+
+.global _start
+_start:
+	li	r4, 0
+	mtspr	SPRN_MMUCR, r4
+
+	li	r3, 23
+
+	lis	r4, TLBWORD0@h
+	ori	r4, r4, TLBWORD0@l
+	tlbwe	r4, r3, 0
+
+	lis	r4, TLBWORD1@h
+	ori	r4, r4, TLBWORD1@l
+	tlbwe	r4, r3, 1
+
+	lis	r4, TLBWORD2@h
+	ori	r4, r4, TLBWORD2@l
+	tlbwe	r4, r3, 2
+
+	lis	r4, 0x1000
+	tlbsx	r5, r4, r0
+	cmpwi	r5, 23
+	beq	good
+	trap
+
+good:
+	b	.
user/test/powerpc/44x/tlbwe.S new file +27 -0
new file mode 100644
@@ -0,0 +1,27 @@
+#define SPRN_MMUCR 0x3b2
+
+/* Create a mapping at 4MB */
+#define TLBWORD0 0x00400210
+#define TLBWORD1 0x00400000
+#define TLBWORD2 0x00000003
+
+.global _start
+_start:
+	li	r4, 0
+	mtspr	SPRN_MMUCR, r4
+
+	li	r3, 23
+
+	lis	r4, TLBWORD0@h
+	ori	r4, r4, TLBWORD0@l
+	tlbwe	r4, r3, 0
+
+	lis	r4, TLBWORD1@h
+	ori	r4, r4, TLBWORD1@l
+	tlbwe	r4, r3, 1
+
+	lis	r4, TLBWORD2@h
+	ori	r4, r4, TLBWORD2@l
+	tlbwe	r4, r3, 2
+
+	b	.
user/test/powerpc/44x/tlbwe_16KB.S new file +35 -0
new file mode 100644
@@ -0,0 +1,35 @@
+#define SPRN_MMUCR 0x3b2
+
+/* 16KB mapping at 4MB */
+#define TLBWORD0 0x00400220
+#define TLBWORD1 0x00400000
+#define TLBWORD2 0x00000003
+
+.global _start
+_start:
+	li	r4, 0
+	mtspr	SPRN_MMUCR, r4
+
+	li	r3, 5
+
+	lis	r4, TLBWORD0@h
+	ori	r4, r4, TLBWORD0@l
+	tlbwe	r4, r3, 0
+
+	lis	r4, TLBWORD1@h
+	ori	r4, r4, TLBWORD1@l
+	tlbwe	r4, r3, 1
+
+	lis	r4, TLBWORD2@h
+	ori	r4, r4, TLBWORD2@l
+	tlbwe	r4, r3, 2
+
+	/* load from 4MB */
+	lis	r3, 0x0040
+	lwz	r4, 0(r3)
+
+	/* load from 4MB+8KB */
+	ori	r3, r3, 0x2000
+	lwz	r4, 0(r3)
+
+	b	.
user/test/powerpc/44x/tlbwe_hole.S new file +27 -0
new file mode 100644
@@ -0,0 +1,27 @@
+#define SPRN_MMUCR 0x3b2
+
+/* Try to map real address 1GB. */
+#define TLBWORD0 0x40000210
+#define TLBWORD1 0x40000000
+#define TLBWORD2 0x00000003
+
+.global _start
+_start:
+	li	r4, 0
+	mtspr	SPRN_MMUCR, r4
+
+	li	r3, 23
+
+	lis	r4, TLBWORD0@h
+	ori	r4, r4, TLBWORD0@l
+	tlbwe	r4, r3, 0
+
+	lis	r4, TLBWORD1@h
+	ori	r4, r4, TLBWORD1@l
+	tlbwe	r4, r3, 1
+
+	lis	r4, TLBWORD2@h
+	ori	r4, r4, TLBWORD2@l
+	tlbwe	r4, r3, 2
+
+	b	.
user/test/powerpc/io.S new file +32 -0
new file mode 100644
@@ -0,0 +1,32 @@
+#define SPRN_MMUCR 0x3b2
+
+#define TLBWORD0 0xf0000210
+#define TLBWORD1 0xf0000000
+#define TLBWORD2 0x00000003
+
+.global _start
+_start:
+	li	r4, 0
+	mtspr	SPRN_MMUCR, r4
+
+	li	r3, 2
+
+	lis	r4, TLBWORD0@h
+	ori	r4, r4, TLBWORD0@l
+	tlbwe	r4, r3, 0
+
+	lis	r4, TLBWORD1@h
+	ori	r4, r4, TLBWORD1@l
+	tlbwe	r4, r3, 1
+
+	lis	r4, TLBWORD2@h
+	ori	r4, r4, TLBWORD2@l
+	tlbwe	r4, r3, 2
+
+	lis	r3, 0xf000
+	lis	r4, 0x1234
+	ori	r4, r4, 0x5678
+	stb	r4, 0(r3)
+	lbz	r5, 0(r3)
+
+	b	.
user/test/powerpc/spin.S new file +4 -0
new file mode 100644
@@ -0,0 +1,4 @@
+
+.global _start
+_start:
+	b	.
user/test/powerpc/sprg.S new file +7 -0
new file mode 100644
@@ -0,0 +1,7 @@
+
+.global _start
+_start:
+	li	r3, 42
+	mtsprg	0, r3
+	mfsprg	r4, 0
+	b	.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

#2 lore raw

PATCH 1/1 Initial skeleton for libkvm powerpc support

In reply to Jerone Young

# HG changeset patch
# User Jerone Young <jyoung5-r/[email protected]> # Date 1196367361 21600
# Node ID edbd1102ce114df80ea0f17bffb5bb98129c37f8
# Parent 6f34b3cd608868c4cc8280ab333aac78a7ba9a6d
Initial skeleton for libkvm powerpc support

This patch is to add initial skelton code for powerpc. No big implimentations as kernel code is still being worked out. But it can be a good template for other architectures. Once kernel code makes it upstream (and is for the most part finalized) then implimentaions will follow.

libkvm/config-powerpc.mak new file +6 -0
new file mode 100644
@@ -0,0 +1,6 @@
+
+LIBDIR := /lib
+CFLAGS += -m32
+CFLAGS += -D__powerpc__
+
+libkvm-$(ARCH)-objs := libkvm-powerpc.o
libkvm/kvm-powerpc.h new file +23 -0
new file mode 100644
@@ -0,0 +1,23 @@
+/* 
+ * This header is for functions & variables that will ONLY be
+ * used inside libkvm for powerpc. 
+ * THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE 
+ * WITHIN LIBKVM.
+ *
+ * Copyright (C) 2007 IBM
+ *
+ * Authors:
+ *	Jerone Young <jyoung5-r/[email protected]>	
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#ifndef KVM_POWERPC_H
+#define KVM_POWERPC_H
+
+#include "kvm-common.h"
+
+#define PAGE_SIZE 4096ul
+#define PAGE_MASK (~(PAGE_SIZE - 1))
+
+#endif
libkvm/libkvm-powerpc.c new file +34 -0
new file mode 100644
@@ -0,0 +1,34 @@
+#include "libkvm.h"
+#include "kvm-powerpc.h"
+#include <errno.h>
+
+int kvm_run_abi10(kvm_context_t kvm, int vcpu)
+{
+	return -ENOSYS;
+}
+
+void kvm_show_code(kvm_context_t kvm, int vcpu)
+{
+}
+
+void kvm_show_regs(kvm_context_t kvm, int vcpu)
+{
+}
+
+int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
+			 void **vm_mem)
+{
+	return 0;
+}
+
+int kvm_arch_create_default_phys_mem(kvm_context_t kvm,
+					unsigned long phys_mem_bytes,
+					void **vm_mem)
+{
+	return 0;
+}
+
+int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu)
+{
+	return 0;
+}
libkvm/libkvm.c +4 -0
@@ -39,6 +39,10 @@
 
 #if defined(__x86_64__) || defined(__i386__)
 #include "kvm-x86.h"
+#endif
+
+#if defined(__powerpc__)
+#include "kvm-powerpc.h"
 #endif
 
 int kvm_abi = EXPECTED_KVM_API_VERSION;

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

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

These patches add two things:
libkvm skelton support
powerpc tests (but missing kvmctl main.c)

Applied, thanks.

Signature · 8 lines
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4