Skip to contentSkip to conversation

misc uq/master updates (v2)

PATCH Applied Marcelo Tosatti 3 participants 14 messages Mar 23, 2010 – Jun 23, 2010 KVM

lore
Share & tools
lore
#0 lore raw

cover misc uq/master updates (v2)

See individual patches for details.

#1 lore raw

PATCH 1/6 target-i386: print EFER in cpu_dump_state

target-i386/helper.c +1 -0
Index: qemu-uq/target-i386/helper.c
===================================================================
@@ -355,6 +355,7 @@ void cpu_dump_state(CPUState *env, FILE 
                         cc_op_name);
         }
     }
+    cpu_fprintf(f, "EFER=%016" PRIx64 "\n", env->efer);
     if (flags & X86_DUMP_FPU) {
         int fptag;
         fptag = 0;
#2 lore raw

PATCH 2/6 kvm: handle internal error

In reply to Marcelo Tosatti

Port qemu-kvm's KVM_EXIT_INTERNAL_ERROR handling to upstream.

kvm-all.c +31 -0
Index: qemu-uq/kvm-all.c
===================================================================
@@ -721,6 +721,32 @@ static int kvm_handle_io(uint16_t port, 
     return 1;
 }
 
+#ifdef KVM_CAP_INTERNAL_ERROR_DATA
+static void kvm_handle_internal_error(CPUState *env, struct kvm_run *run)
+{
+
+    if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {
+        int i;
+
+        fprintf(stderr, "KVM internal error. Suberror: %d\n",
+                run->internal.suberror);
+
+        for (i = 0; i < run->internal.ndata; ++i) {
+            fprintf(stderr, "extra data[%d]: %"PRIx64"\n",
+                    i, (uint64_t)run->internal.data[i]);
+        }
+    }
+    cpu_dump_state(env, stderr, fprintf, 0);
+    if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {
+        fprintf(stderr, "emulation failure\n");
+    }
+    /* FIXME: Should trigger a qmp message to let management know
+     * something went wrong.
+     */
+    vm_stop(0);
+}
+#endif
+
 void kvm_flush_coalesced_mmio_buffer(void)
 {
 #ifdef KVM_CAP_COALESCED_MMIO
@@ -836,6 +862,11 @@ int kvm_cpu_exec(CPUState *env)
         case KVM_EXIT_EXCEPTION:
             dprintf("kvm_exit_exception\n");
             break;
+#ifdef KVM_CAP_INTERNAL_ERROR_DATA
+        case KVM_EXIT_INTERNAL_ERROR:
+            kvm_handle_internal_error(env, run);
+            break;
+#endif
         case KVM_EXIT_DEBUG:
             dprintf("kvm_exit_debug\n");
 #ifdef KVM_CAP_SET_GUEST_DEBUG
#3 lore raw

PATCH 3/6 kvm: allow qemu to set EPT identity mapping address

In reply to Marcelo Tosatti

From: Sheng Yang <[email protected]>

If we use larger BIOS image than current 256KB, we would need move reserved TSS and EPT identity mapping pages. Currently TSS support this, but not EPT.

target-i386/kvm.c +25 -1
Index: qemu-uq/target-i386/kvm.c
===================================================================
@@ -326,6 +326,25 @@ static int kvm_has_msr_star(CPUState *en
     return 0;
 }
 
+static int kvm_init_identity_map_page(KVMState *s)
+{
+#ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR
+    int ret;
+    uint64_t addr = 0xfffbc000;
+
+    if (!kvm_check_extension(s, KVM_CAP_SET_IDENTITY_MAP_ADDR)) {
+        return 0;
+    }
+
+    ret = kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, &addr);
+    if (ret < 0) {
+        fprintf(stderr, "kvm_set_identity_map_addr: %s\n", strerror(ret));
+        return ret;
+    }
+#endif
+    return 0;
+}
+
 int kvm_arch_init(KVMState *s, int smp_cpus)
 {
     int ret;
@@ -353,7 +372,12 @@ int kvm_arch_init(KVMState *s, int smp_c
         perror("e820_add_entry() table is full");
         exit(1);
     }
-    return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, 0xfffbd000);
+    ret = kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, 0xfffbd000);
+    if (ret < 0) {
+        return ret;
+    }
+
+    return kvm_init_identity_map_page(s);
 }
                     
 static void set_v8086_seg(struct kvm_segment *lhs, const SegmentCache *rhs)
#4 lore raw

PATCH 4/6 kvm_init_vcpu requires global lock held

In reply to Marcelo Tosatti

Since it accesses data protected by the lock.

vl.c +1 -1
Index: qemu-uq/vl.c
===================================================================
@@ -2447,6 +2447,7 @@ static void *kvm_cpu_thread_fn(void *arg
 {
     CPUState *env = arg;
 
+    qemu_mutex_lock(&qemu_global_mutex);
     qemu_thread_self(env->thread);
     if (kvm_enabled())
         kvm_init_vcpu(env);
@@ -2454,7 +2455,6 @@ static void *kvm_cpu_thread_fn(void *arg
     kvm_block_io_signals(env);
 
     /* signal CPU creation */
-    qemu_mutex_lock(&qemu_global_mutex);
     env->created = 1;
     qemu_cond_signal(&qemu_cpu_cond);
 
#5 lore raw

PATCH 5/6 kvm: init mp_state

In reply to Marcelo Tosatti
target-i386/kvm.c +6 -0
Index: qemu-uq/target-i386/kvm.c
===================================================================
@@ -279,6 +279,12 @@ void kvm_arch_reset_vcpu(CPUState *env)
     env->interrupt_injected = -1;
     env->nmi_injected = 0;
     env->nmi_pending = 0;
+    if (kvm_irqchip_in_kernel()) {
+        env->mp_state = cpu_is_bsp(env) ? KVM_MP_STATE_RUNNABLE :
+                                          KVM_MP_STATE_UNINITIALIZED;
+    } else {
+        env->mp_state = KVM_MP_STATE_RUNNABLE;
+    }
 }
 
 static int kvm_has_msr_star(CPUState *env)
#6 lore raw

PATCH 6/6 kvm: remove explicit kvm_arch_reset_vcpu from kvm_init_vcpu

In reply to Marcelo Tosatti

This is now done via the initialization's qemu_system_reset call.

kvm-all.c +0 -1
Index: qemu-uq/kvm-all.c
===================================================================
@@ -209,7 +209,6 @@ int kvm_init_vcpu(CPUState *env)
     ret = kvm_arch_init_vcpu(env);
     if (ret == 0) {
         qemu_register_reset(kvm_reset_vcpu, env);
-        kvm_arch_reset_vcpu(env);
     }
 err:
     return ret;
#7 lore raw

Re: [patch 6/6] kvm: remove explicit kvm_arch_reset_vcpu from kvm_init_vcpu

Quoted 11 lines · Marcelo Tosatti

This is now done via the initialization's qemu_system_reset call.

Index: qemu-uq/kvm-all.c
===================================================================

kvm-all.c int kvm_init_vcpu(CPUState *env) · line 214

Quoted 7 lines
kvm-all.c +0 -1
@@ -209,7 +209,6 @@ int kvm_init_vcpu(CPUState *env)
      ret = kvm_arch_init_vcpu(env);
      if (ret == 0) {
          qemu_register_reset(kvm_reset_vcpu, env);
-        kvm_arch_reset_vcpu(env);
      }
  err:
      return ret;

I'm testing uq/master, and I see this breaks it. qemu freezes immediately on startup.

(might be due to a rebase?)

Signature · 1 line
error compiling committee.c: too many arguments to function
#8 lore raw

Re: [patch 6/6] kvm: remove explicit kvm_arch_reset_vcpu from kvm_init_vcpu

Quoted 21 lines · Avi Kivity
Quoted 10 lines · Marcelo Tosatti

This is now done via the initialization's qemu_system_reset call.

Index: qemu-uq/kvm-all.c
===================================================================

kvm-all.c int kvm_init_vcpu(CPUState *env) · line 214

Quoted 7 lines
kvm-all.c +0 -1
@@ -209,7 +209,6 @@ int kvm_init_vcpu(CPUState *env)
      ret = kvm_arch_init_vcpu(env);
      if (ret == 0) {
          qemu_register_reset(kvm_reset_vcpu, env);
-        kvm_arch_reset_vcpu(env);
      }
  err:
      return ret;

I'm testing uq/master, and I see this breaks it. qemu freezes immediately on startup.

Quoted 2 lines

(might be due to a rebase?)

The symptoms, btw, are a vcpu started from 0:0 instead of 0xf000:0xfff0.

Signature · 1 line
error compiling committee.c: too many arguments to function
#9 lore raw

Re: [patch 6/6] kvm: remove explicit kvm_arch_reset_vcpu from kvm_init_vcpu

Quoted 23 lines · Avi Kivity
Quoted 22 lines · Avi Kivity
Quoted 10 lines · Marcelo Tosatti

This is now done via the initialization's qemu_system_reset call.

Index: qemu-uq/kvm-all.c
===================================================================

kvm-all.c int kvm_init_vcpu(CPUState *env) · line 214

Quoted 7 lines
kvm-all.c +0 -1
@@ -209,7 +209,6 @@ int kvm_init_vcpu(CPUState *env)
      ret = kvm_arch_init_vcpu(env);
      if (ret == 0) {
          qemu_register_reset(kvm_reset_vcpu, env);
-        kvm_arch_reset_vcpu(env);
      }
  err:
      return ret;

I'm testing uq/master, and I see this breaks it. qemu freezes immediately on startup.

Quoted 5 lines
Quoted 2 lines

(might be due to a rebase?)

The symptoms, btw, are a vcpu started from 0:0 instead of 0xf000:0xfff0.

Might be unrelated, still: Does [1] make any difference? (Upsream is a bit hairy ATM.)

Jan

[1] http://thread.gmane.org/gmane.comp.emulators.qemu/75087

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#10 lore raw

Re: [patch 6/6] kvm: remove explicit kvm_arch_reset_vcpu from kvm_init_vcpu

Quoted 11 lines · Jan Kiszka
Quoted 10 lines
Quoted 7 lines

I'm testing uq/master, and I see this breaks it. qemu freezes immediately on startup.

(might be due to a rebase?)

The symptoms, btw, are a vcpu started from 0:0 instead of 0xf000:0xfff0.

Might be unrelated, still: Does [1] make any difference?

No, and this is not surprising - looks like reset is completely bypassed.

Quoted 3 lines

(Upsream is a
bit hairy ATM.)

Well, it boots at least, which uq/master doesn't with this patch.

Signature · 1 line
error compiling committee.c: too many arguments to function
#11 lore raw

Re: [patch 6/6] kvm: remove explicit kvm_arch_reset_vcpu from kvm_init_vcpu

Quoted 7 lines · Avi Kivity
Quoted 6 lines · Jan Kiszka
Quoted 6 lines
Quoted 6 lines

I'm testing uq/master, and I see this breaks it. qemu freezes immediately on startup.

(might be due to a rebase?)

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

The symptoms, btw, are a vcpu started from 0:0 instead of 0xf000:0xfff0.

Might be unrelated, still: Does [1] make any difference?

No, and this is not surprising - looks like reset is completely bypassed.

You mean there is no system reset during init in kvm mode? Well, then...

Quoted 7 lines
Quoted 4 lines

(Upsream is a
bit hairy ATM.)

Well, it boots at least, which uq/master doesn't with this patch.

Also depends on the number of CPUs.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#12 lore raw

Re: [patch 6/6] kvm: remove explicit kvm_arch_reset_vcpu from kvm_init_vcpu

Quoted 5 lines · Jan Kiszka
Quoted 3 lines

No, and this is not surprising - looks like reset is completely bypassed.

You mean there is no system reset during init in kvm mode? Well, then...

Yes. The cpu executes until it hits 0xa0000, then stops.

Signature · 1 line
error compiling committee.c: too many arguments to function
Applied
#13 lore raw
In reply to Marcelo Tosatti
Quoted 4 lines · Marcelo Tosatti

See individual patches for details.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function