Skip to contentSkip to conversation

PPC KVM bringup patches round 2 v2

PATCH In review Alexander Graf 3 participants 10 messages Jul 24, 2009 – Jul 27, 2009

lore
Share & tools
lore
#0 lore raw

cover PPC KVM bringup patches round 2 v2

Thanks a lot for commiting the previous patches. I still needed these to get a guest booted almost as broken as with TCG ;-).

Please test the dirty log patch thoroughly!

V2 changes

- remove debug printf
- make dirty log handling generic again (thx to Jan)
- add patch to make -kernel reserved space bigger on ppc

Alexander Graf (4):
Move mp_state to CPU_COMMON
Use 64bit pointer for dirty log
PPC: Round VGA BIOS size to page boundary
Give the kernel more room

 cpu-defs.h        |    3 ++-
 hw/ppc_mac.h      |    4 ++--
 hw/ppc_newworld.c |    3 +++
 hw/ppc_oldworld.c |    3 +++
 kvm-all.c         |    2 +-
 target-i386/cpu.h |    1 -
 6 files changed, 11 insertions(+), 5 deletions(-)
#1 lore raw

PATCH 1/4 Move mp_state to CPU_COMMON

MP State is implemented in the generic code, so let's move the variable it accesses to generic code as well.

Unbreaks PPC w/ KVM.

---
 cpu-defs.h        |    3 ++-
 target-i386/cpu.h |    1 -
 2 files changed, 2 insertions(+), 2 deletions(-)
cpu-defs.h +2 -1
index d73ec0a..2482398 100644
@@ -195,6 +195,7 @@ typedef struct CPUWatchpoint {
     const char *cpu_model_str;                                          \
     struct KVMState *kvm_state;                                         \
     struct kvm_run *kvm_run;                                            \
-    int kvm_fd;
+    int kvm_fd;                                                         \
+    int mp_state;
 
 #endif
target-i386/cpu.h +0 -1
index 08200ed..ce3fbc1 100644
@@ -689,7 +689,6 @@ typedef struct CPUX86State {
 
     /* For KVM */
     uint64_t interrupt_bitmap[256 / 64];
-    uint32_t mp_state;
 
     /* in order to simplify APIC support, we leave this pointer to the
        user */
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/4 Use 64bit pointer for dirty log

Dirty logs currently get written with native "long" size. On little endian it doesn't matter if we use uint64_t instead though, because we'd still end up using the right bytes.

On big endian, this does become a bigger problem, so we need to ensure that kernel and userspace talk the same language, which means getting rid of "long" and using a defined size instead.

So I decided to use 64 bit types at all times. This doesn't break existing targets but will in conjunction with a patch I'll send to the KVM ML make dirty logs work with 32 bit userspace on 64 kernel with big endian.

---
 kvm-all.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kvm-all.c +1 -1
index 824bb4c..9d02ce3 100644
@@ -357,7 +357,7 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
         for (phys_addr = mem->start_addr, addr = mem->phys_offset;
              phys_addr < mem->start_addr + mem->memory_size;
              phys_addr += TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {
-            unsigned long *bitmap = (unsigned long *)d.dirty_bitmap;
+            uint64_t *bitmap = (uint64_t *)d.dirty_bitmap;
             unsigned nr = (phys_addr - mem->start_addr) >> TARGET_PAGE_BITS;
             unsigned word = nr / (sizeof(*bitmap) * 8);
             unsigned bit = nr % (sizeof(*bitmap) * 8);
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/4 PPC: Round VGA BIOS size to page boundary

When giving KVM a slot of a size not on page boundary, it chokes. So let's just round up the VGA BIOS size so nobody complains anymore and we don't need to implement sub-page slots.

Required for booting a PPC guest in KVM.

---

V2 removes a left over debug message

---
 hw/ppc_newworld.c |    3 +++
 hw/ppc_oldworld.c |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)
hw/ppc_newworld.c +3 -0
index 4e5043c..b28a23d 100644
@@ -179,6 +179,9 @@ static void ppc_core99_init (ram_addr_t ram_size,
         vga_bios_ptr[3] = 'V';
         cpu_to_be32w((uint32_t *)(vga_bios_ptr + 4), vga_bios_size);
         vga_bios_size += 8;
+
+        /* Round to page boundary */
+        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK;
     }
 
     if (linux_boot) {
hw/ppc_oldworld.c +3 -0
index b26e407..0bd6376 100644
@@ -212,6 +212,9 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
         vga_bios_ptr[3] = 'V';
         cpu_to_be32w((uint32_t *)(vga_bios_ptr + 4), vga_bios_size);
         vga_bios_size += 8;
+
+        /* Round to page boundary */
+        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK;
     }
 
     if (linux_boot) {
Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/4 Give the kernel more room

My self-built PPC kernel doesn't fit in the region reserved for the kernel, so I can't use -kernel with it.

Let's just extend the region.

---
 hw/ppc_mac.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/ppc_mac.h +2 -2
index dc39338..bcc4aaf 100644
@@ -36,8 +36,8 @@
 #define PROM_ADDR         0xfff00000
 
 #define KERNEL_LOAD_ADDR 0x01000000
-#define CMDLINE_ADDR     0x017ff000
-#define INITRD_LOAD_ADDR 0x01800000
+#define CMDLINE_ADDR     0x027ff000
+#define INITRD_LOAD_ADDR 0x02800000
 
 #define ESCC_CLOCK 3686400
 
Signature · 1 line
1.6.0.2
#5 lore raw

Re: [Qemu-devel] [PATCH 3/4] PPC: Round VGA BIOS size to page boundary

In reply to Alexander Graf

hw/ppc_newworld.c static void ppc_core99_init (ram_addr_t ram_size,

Quoted 11 lines · Alexander Graf

When giving KVM a slot of a size not on page boundary, it chokes. So let's just round up the VGA BIOS size so nobody complains anymore and we don't need to implement sub-page slots.

hw/ppc_newworld.c +6 -0
+
+        /* Round to page boundary */
+        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK;
 
+
+        /* Round to page boundary */
+        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK;

This wrongly increases the size by extra TARGET_PAGE_SIZE, when vga_bios_size mod TARGET_PAGE_SIZE == 0. Please use (vga_bios_size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK.

#6 lore raw

Re: [Qemu-devel] [PATCH 3/4] PPC: Round VGA BIOS size to page boundary

Quoted 10 lines · Blue Swirl
Quoted 8 lines · Alexander Graf

When giving KVM a slot of a size not on page boundary, it chokes. So let's just round up the VGA BIOS size so nobody complains anymore and we don't need to implement sub-page slots.

hw/ppc_newworld.c +3 -0
+
+        /* Round to page boundary */
+        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE) &  

TARGET_PAGE_MASK;

Quoted 8 lines
Quoted 4 lines
hw/ppc_newworld.c +3 -0
+
+        /* Round to page boundary */
+        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE) &  

TARGET_PAGE_MASK;

This wrongly increases the size by extra TARGET_PAGE_SIZE, when vga_bios_size mod TARGET_PAGE_SIZE == 0. Please use (vga_bios_size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK.

Right, that's what Jan said too. Mind to change it when applying the patch or would you prefer me to do a respin?

Alex

#7 lore raw

Re: [Qemu-devel] [PATCH 3/4] PPC: Round VGA BIOS size to page boundary

Quoted 21 lines · Alexander Graf
Quoted 18 lines · Blue Swirl
Quoted 16 lines · Alexander Graf

When giving KVM a slot of a size not on page boundary, it chokes. So let's
just round up the VGA BIOS size so nobody complains anymore and we don't need
to implement sub-page slots.

+
+        /* Round to page boundary */
+        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK;

+
+        /* Round to page boundary */
+        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK;

Quoted 6 lines
Quoted 3 lines

This wrongly increases the size by extra TARGET_PAGE_SIZE, when vga_bios_size mod TARGET_PAGE_SIZE == 0. Please use (vga_bios_size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK.

Right, that's what Jan said too. Mind to change it when applying the patch or would you prefer me to do a respin?

I changed it and applied, also applied 4/4.

#8 lore raw

Re: [Qemu-devel] [PATCH 1/4] Move mp_state to CPU_COMMON

In reply to Alexander Graf
Quoted 5 lines · Alexander Graf

MP State is implemented in the generic code, so let's move the variable it accesses to generic code as well.

Unbreaks PPC w/ KVM.

And breaks the build for everyone else.

You change mp_state from a uint32_t to a int, but then there's:

target-i386/machine.c:

   qemu_put_be32s(f, &env->mp_state);

Which expects a uint32_t.

Regards,

Anthony Liguori

#9 lore raw

Re: [Qemu-devel] [PATCH 1/4] Move mp_state to CPU_COMMON

Quoted 9 lines · Anthony Liguori
Quoted 5 lines · Alexander Graf

MP State is implemented in the generic code, so let's move the variable it accesses to generic code as well.

Unbreaks PPC w/ KVM.

And breaks the build for everyone else.

Quoted 7 lines

You change mp_state from a uint32_t to a int, but then there's:

target-i386/machine.c:

  qemu_put_be32s(f, &env->mp_state);

Which expects a uint32_t.

Oh right - -Werror. I have to disable that on every machine I was on so far because it always breaks somewhere.

Want to do the one-liner change yourself or would you like me to send a new patch?

Alex