Skip to contentSkip to conversation

Fix loading of registers preboot for PowerPC

PATCH Superseded Jerone Young 2 participants 5 messages Apr 10, 2008 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix loading of registers preboot for PowerPC

These patches fix issue with brining up bamboo board model for PowerPC. We need to load certain registers in the first vcp preboot.

I have not tested this on x86, but it should work without issue. Does anyone not like this being where it is?

2 files changed, 5 insertions(+), 3 deletions(-)
qemu/hw/ppc440_bamboo.c |    3 ---
qemu/qemu-kvm.c         |    5 +++++

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

#1 lore raw

PATCH 1/1 Add kvm_load_registers after first vcpu creation

1 file changed, 5 insertions(+)

qemu/qemu-kvm.c | 5 +++++

This patch adds a call to load_kvm_registers after creation of vcpu. This is required for ppc since we are required to set certain registers before boot. This should not have any effect on the curren x86 code (though I need to test this to make sure).

What I would like though are some comments on the fix. Is this the right place for this? We had this in our platform setup code, but with recent code changes it will not work there anymore).

qemu/qemu-kvm.c +5 -0
@@ -353,6 +353,11 @@ static void *ap_main_loop(void *_env)
     sigdelset(&signals, SIG_IPI);
     sigprocmask(SIG_BLOCK, &signals, NULL);
     kvm_create_vcpu(kvm_context, env->cpu_index);
+    if (env->cpu_index == 0) {
+         /* load any registers set in env into 
+            kvm  for the first guest vcpu */ 
+        kvm_load_registers(env);
+    }
     kvm_qemu_init_env(env);
     if (kvm_irqchip_in_kernel(kvm_context))
 	env->hflags &= ~HF_HALTED_MASK;

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

#4 lore raw

PATCH 1/1 Remove kvm_load_registers from ppc440_bamboo board model

In reply to Jerone Young
1 file changed, 3 deletions(-)

qemu/hw/ppc440_bamboo.c | 3 ---

This patch removes the call to kvm_load_registers while in board platform setup code. This must now be done later in vcpu initialization.

qemu/hw/ppc440_bamboo.c +0 -3
@@ -174,9 +174,6 @@ void bamboo_init(ram_addr_t ram_size, in
 		env->gpr[3] = dt_base;
 #endif
 		env->nip = ep;
-
-		printf("%s: loading kvm registers\n", __func__);
-		kvm_load_registers(env);
 	}
 
 	for (i = 0; i < nb_nics; i++) {

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

#2 lore raw

Re: [PATCH 1 of 2] Add kvm_load_registers after first vcpu creation

In reply to Jerone Young
Quoted 20 lines · Jerone Young
1 file changed, 5 insertions(+)

qemu/qemu-kvm.c | 5 +++++

This patch adds a call to load_kvm_registers after creation of vcpu. This is required for ppc since we are required to set certain registers before boot. This should not have any effect on the curren x86 code (though I need to test this to make sure).

What I would like though are some comments on the fix. Is this the right place for this? We had this in our platform setup code, but with recent code changes it will not work there anymore).

qemu/qemu-kvm.c +0 -0
@@ -353,6 +353,11 @@ static void *ap_main_loop(void *_env)
     sigdelset(&signals, SIG_IPI);

qemu/qemu-kvm.c static void *ap_main_loop(void *_env) · line 363

Quoted 10 lines
qemu/qemu-kvm.c +5 -0
     sigprocmask(SIG_BLOCK, &signals, NULL);
     kvm_create_vcpu(kvm_context, env->cpu_index);
+    if (env->cpu_index == 0) {
+         /* load any registers set in env into 
+            kvm  for the first guest vcpu */ 
+        kvm_load_registers(env);
+    }
     kvm_qemu_init_env(env);
     if (kvm_irqchip_in_kernel(kvm_context))
 	env->hflags &= ~HF_HALTED_MASK;

Hi Jerone,

You can hook into PPC's kvm_arch_qemu_init_env().

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

#3 lore raw

Re: [PATCH 1 of 2] Add kvm_load_registers after first vcpu creation

Quoted 34 lines · Marcelo Tosatti
Quoted 20 lines · Jerone Young
1 file changed, 5 insertions(+)

qemu/qemu-kvm.c | 5 +++++

This patch adds a call to load_kvm_registers after creation of vcpu. This is required for ppc since we are required to set certain registers before boot. This should not have any effect on the curren x86 code (though I need to test this to make sure).

What I would like though are some comments on the fix. Is this the right place for this? We had this in our platform setup code, but with recent code changes it will not work there anymore).

qemu/qemu-kvm.c +0 -0
@@ -353,6 +353,11 @@ static void *ap_main_loop(void *_env)
     sigdelset(&signals, SIG_IPI);

qemu/qemu-kvm.c static void *ap_main_loop(void *_env) · line 363

Quoted 10 lines
qemu/qemu-kvm.c +5 -0
     sigprocmask(SIG_BLOCK, &signals, NULL);
     kvm_create_vcpu(kvm_context, env->cpu_index);
+    if (env->cpu_index == 0) {
+         /* load any registers set in env into 
+            kvm  for the first guest vcpu */ 
+        kvm_load_registers(env);
+    }
     kvm_qemu_init_env(env);
     if (kvm_irqchip_in_kernel(kvm_context))
 	env->hflags &= ~HF_HALTED_MASK;

Hi Jerone,

Quoted 1 line

You can hook into PPC's kvm_arch_qemu_init_env().

That would be a much better place.

I also noticed that kvm_qemu_init_env() is called in ap_main_loop and the kvm_main_loop_cpu. ap_main_loop calls kvm_main_loop_cpu, so one them should be removed. I'll submit another patch for that.

Quoted 1 line

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone