Skip to contentSkip to conversation

kvm-userspace: support multiple processors in the same architecture

PATCH In review Hollis Blanchard 3 participants 11 messages Oct 29, 2008 – Nov 2, 2008 2 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm-userspace: support multiple processors in the same architecture

These patches allow the kvmctl bits (including testcases and libcflat) to be built for multiple processor types within the same architecture (e.g. 440 and e500). This is important because PowerPC supervisor mode can contain significant differences between processors (it's user mode that's more or less identical).

For example, the data in a TLB entry and how to manipulate the TLB are a major difference between 440 and e500, which is critical here because libcflat must create its own mappings and so must know which method to use.

Some of the complexity comes from user/Makefile *not* using the top-level config.mak, so we have to add some of the same logic to both configure scripts to generate both config.mak files.

Too much makefile logic depends on ARCH containing only the architecture name, so it was simpler to create and export a separate PROCESSOR variable.

-Hollis

#1 lore raw

PATCH 1/1 kvmctl: ppc: use $PROCESSOR to set configuration options

PowerPC variants are different enough that they require a different libcflat build and different testcases.

user/config-powerpc.mak +1 -3
@@ -1,5 +1,3 @@ platform := 440
-platform := 440
-
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
@@ -23,7 +21,7 @@ tests := \
 tests := \
 	test/powerpc/exit.bin
 
-include config-powerpc-$(platform).mak
+include config-powerpc-$(PROCESSOR).mak
 
 
 all: kvmtrace kvmctl $(libcflat) $(simpletests) $(tests)
#2 lore raw

PATCH 1/1 user: set $PROCESSOR from configure --arch=<arch>-<processor>

In reply to Hollis Blanchard

Export PROCESSOR in config.mak, and call user/configure with the --processor option.

configure +5 -1
@@ -103,6 +103,9 @@ case $arch in
         ;;
 esac
 
+processor=${arch#*-}
+arch=${arch%%-*}
+
 # see if we have split build and source directories
 if [ -d "$kerneldir/include2" ]; then
     kernelsourcedir=${kerneldir%/*}/source
@@ -110,7 +113,7 @@ fi
 
 #configure user dir
 (cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
-          --arch="$arch" \
+          --arch="$arch" --processor="$processor" \
           ${cross_prefix:+"--cross-prefix=$cross_prefix"})
 
 #configure qemu
@@ -128,6 +131,7 @@ fi
 
 cat <<EOF > config.mak
 ARCH=$arch
+PROCESSOR=$processor
 PREFIX=$prefix
 KERNELDIR=$kerneldir
 KERNELSOURCEDIR=$kernelsourcedir
#3 lore raw

PATCH 1/1 kvmctl: add --processor option to user/configure

In reply to Hollis Blanchard

Use that to export PROCESSOR in user/config.mak.

user/configure +5 -0
@@ -6,6 +6,7 @@ ld=ld
 ld=ld
 objcopy=objcopy
 arch=`uname -m | sed -e s/i.86/i386/`
+processor="$arch"
 cross_prefix=
 
 usage() {
@@ -40,6 +41,9 @@ while [[ "$1" = -* ]]; do
         --arch)
 	    arch="$arg"
 	    ;;
+        --processor)
+	    processor="$arg"
+	    ;;
 	--cross-prefix)
 	    cross_prefix="$arg"
 	    ;;
@@ -62,6 +66,7 @@ PREFIX=$prefix
 PREFIX=$prefix
 KERNELDIR=$(readlink -f $kerneldir)
 ARCH=$arch
+PROCESSOR=$processor
 CC=$cross_prefix$cc
 LD=$cross_prefix$ld
 OBJCOPY=$cross_prefix$objcopy
#4 lore raw

PATCH 1/1 user: ppc: remove build flags

In reply to Hollis Blanchard

Remove -m32 build flag. Although necessary when building for a 32-bit target with a biarch toolchain that defaults to 64-bit output, it naturally breaks 64-bit builds.

Also remove -D__powerpc__. I'm not sure why I added that in the first place; that is automatically defined by GCC (for both 32- and 64-bit targets).

libkvm/config-powerpc.mak +0 -2
@@ -1,6 +1,4 @@
 
 LIBDIR := /lib
-CFLAGS += -m32
-CFLAGS += -D__powerpc__
 
 libkvm-$(ARCH)-objs := libkvm-powerpc.o
user/config-powerpc.mak +0 -2
@@ -1,5 +1,3 @@ CFLAGS += -m32
-CFLAGS += -m32
-CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
 CFLAGS += -Wa,-mregnames -I test/lib
 
#5 lore raw

PATCH 1/1 user: consolidate $arch tests and allow $arch to be "<arch>-<processor>"

In reply to Hollis Blanchard

Use case/esac instead of multiple if/fi tests, allowing us to use wildcards.

configure +15 -20
@@ -87,26 +87,21 @@ done
 #set kenel directory
 libkvm_kerneldir=$(readlink -f kernel)
 
-#if arch is an x86 arch set to i386
-if [[ $arch = i?86 ]]; then
-  arch="i386"
-fi
-
-#set parameters compiling
-if [ "$arch" = "i386" -o "$arch" = "x86_64" ]; then
-    target_exec="x86_64-softmmu"
-    qemu_cflags="$qemu_cflags -DCONFIG_X86"
-fi
-
-if [ "$arch" = "ia64" ]; then
-    target_exec="ia64-softmmu"
-fi
-
-if [ "$arch" = "powerpc" ]; then
-    target_exec="ppcemb-softmmu"
-    qemu_cflags="$qemu_cflags -I $PWD/libfdt"
-    qemu_ldflags="$qemu_ldflags -L $PWD/libfdt"
-fi
+case $arch in
+    i?86*|x86_64*)
+        arch=${arch/#i?86/i386}
+        target_exec="x86_64-softmmu"
+        qemu_cflags="$qemu_cflags -DCONFIG_X86"
+        ;;
+    ia64*)
+        target_exec="ia64-softmmu"
+        ;;
+    powerpc*)
+        target_exec="ppcemb-softmmu"
+        qemu_cflags="$qemu_cflags -I $PWD/libfdt"
+        qemu_ldflags="$qemu_ldflags -L $PWD/libfdt"
+        ;;
+esac
 
 # see if we have split build and source directories
 if [ -d "$kerneldir/include2" ]; then

A message that is not in the archive (sent off-list or not yet received): f9e70364f32892700c73.1225304869-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#7 lore raw

Re: [PATCH 1 of 7] user: consolidate $arch tests and allow $arch to be "<arch>-<processor>"

Quoted 2 lines · Hollis Blanchard

Use case/esac instead of multiple if/fi tests, allowing us to use wildcards.

Just a note:

if/fi allows wildcards as well:

if "$reply" = y*; then

    # assume user can't spell
    ...
 fi

though case is better in this esac.

(I can't believe I used the word 'better' in the context of bash)

Signature · 6 lines
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

PATCH 1/1 kvmctl: rename config-powerpc-44x.mak

In reply to Hollis Blanchard

This will make for a more user-friendly "configure --arch=powerpc-440" instead of "configure --arch=powerpc-44x". There aren't any other PowerPC 44x anyways (model numbers are already in the 460s).

user/config-powerpc-440.mak renamed from user/config-powerpc-44x.mak +0 -0
rename from user/config-powerpc-44x.mak
rename to user/config-powerpc-440.mak
user/config-powerpc.mak +1 -1
@@ -1,4 +1,4 @@ platform := 44x
-platform := 44x
+platform := 440
 
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
#9 lore raw

PATCH 1/1 user: define and use AR in configure scripts and Makefiles

In reply to Hollis Blanchard

libkvm/Makefile uses $(AR), but it's not defined by the top-level configure. The problem is that when cross-compiling for a 64-bit target on a 32-bit host, 32-bit ar will be used and the 64-bit code will fail to link.

user/Makefile has the same problem, and even uses plain "ar".

Add AR to configure and user/configure, and use it in the Makefiles.

configure +2 -0
@@ -6,6 +6,7 @@ cc=gcc
 cc=gcc
 ld=ld
 objcopy=objcopy
+ar=ar
 want_module=1
 qemu_cflags=
 qemu_ldflags=
@@ -141,6 +142,7 @@ CC=$cross_prefix$cc
 CC=$cross_prefix$cc
 LD=$cross_prefix$ld
 OBJCOPY=$cross_prefix$objcopy
+AR=$cross_prefix$ar
 EOF
 
 cat <<EOF > kernel/config.kbuild
user/Makefile +1 -1
@@ -48,7 +48,7 @@ kvmtrace: $(kvmtrace_objs)
 	$(CC) $(LDFLAGS) $^ -o $@
 
 $(libcflat): $(cflatobjs)
-	ar rcs $@ $^
+	$(AR) rcs $@ $^
 
 %.o: %.S
 	$(CC) $(CFLAGS) -c -nostdlib -o $@ $^
user/configure +2 -0
@@ -5,6 +5,7 @@ cc=gcc
 cc=gcc
 ld=ld
 objcopy=objcopy
+ar=ar
 arch=`uname -m | sed -e s/i.86/i386/`
 processor="$arch"
 cross_prefix=
@@ -70,4 +71,5 @@ CC=$cross_prefix$cc
 CC=$cross_prefix$cc
 LD=$cross_prefix$ld
 OBJCOPY=$cross_prefix$objcopy
+AR=$cross_prefix$ar
 EOF
Acked-by on v1 1/1
#10 lore raw
In reply to Hollis Blanchard
Quoted 14 lines · Hollis Blanchard

These patches allow the kvmctl bits (including testcases and libcflat) to be built for multiple processor types within the same architecture (e.g. 440 and e500). This is important because PowerPC supervisor mode can contain significant differences between processors (it's user mode that's more or less identical).

For example, the data in a TLB entry and how to manipulate the TLB are a major difference between 440 and e500, which is critical here because libcflat must create its own mappings and so must know which method to use.

Some of the complexity comes from user/Makefile *not* using the top-level config.mak, so we have to add some of the same logic to both configure scripts to generate both config.mak files.

Quoted 9 lines

Too much makefile logic depends on ARCH containing only the architecture name, so it was simpler to create and export a separate PROCESSOR variable.

-Hollis
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Unfortunately there is too often no "really nice" way to do Makefile magic :-)
I know you started with the arch-platform-os-compiler after our discussion, but I like the $PROCESSOR solution for our *powerpc* Makefiles too. And a good catch with that AR usage in patch 7.

(full series)

Signature · 3 lines
Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

A message that is not in the archive (sent off-list or not yet received): patchbomb.1225304868-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#12 lore raw
Quoted 10 lines · Hollis Blanchard

These patches allow the kvmctl bits (including testcases and libcflat) to be built for multiple processor types within the same architecture (e.g. 440 and e500). This is important because PowerPC supervisor mode can contain significant differences between processors (it's user mode that's more or less identical).

For example, the data in a TLB entry and how to manipulate the TLB are a major difference between 440 and e500, which is critical here because libcflat must create its own mappings and so must know which method to use.

Quoted 7 lines

Some of the complexity comes from user/Makefile *not* using the top-level config.mak, so we have to add some of the same logic to both configure scripts to generate both config.mak files.

Too much makefile logic depends on ARCH containing only the architecture name, so it was simpler to create and export a separate PROCESSOR variable.

All applied, thanks.

Signature · 6 lines
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html