Skip to contentSkip to conversation

misc uq/master updates

PATCH In review Marcelo Tosatti 2 participants 9 messages Mar 9, 2010 – Mar 14, 2010 KVM

lore
Share & tools
lore
#0 lore raw

cover misc uq/master updates

See individual patches for details.

#1 lore raw

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

target-i386/helper.c +1 -0
Index: qemu-kvm-uq/target-i386/helper.c
===================================================================
@@ -1176,6 +1176,7 @@ void cpu_dump_state(CPUState *env, FILE 
     cpu_x86_dump_seg_cache(env, f, cpu_fprintf, "TR", &env->tr);
 
 #ifdef TARGET_X86_64
+    cpu_fprintf(f, "EFER=    %016" PRIx64 "\n", env->efer);
     if (env->hflags & HF_LMA_MASK) {
         cpu_fprintf(f, "GDT=     %016" PRIx64 " %08x\n",
                     env->gdt.base, env->gdt.limit);
#2 lore raw

Re: [patch 1/3] target-i386: print EFER in cpu_dump_state

Quoted 9 lines · Marcelo Tosatti

Index: qemu-kvm-uq/target-i386/helper.c
===================================================================

target-i386/helper.c void cpu_dump_state(CPUState *env, FILE · line 1182

Quoted 7 lines
target-i386/helper.c +1 -0
@@ -1176,6 +1176,7 @@ void cpu_dump_state(CPUState *env, FILE
      cpu_x86_dump_seg_cache(env, f, cpu_fprintf, "TR",&env->tr);
 
  #ifdef TARGET_X86_64
+    cpu_fprintf(f, "EFER=    %016" PRIx64 "\n", env->efer);
      if (env->hflags&  HF_LMA_MASK) {
          cpu_fprintf(f, "GDT=     %016" PRIx64 " %08x\n",
                      env->gdt.base, env->gdt.limit);

Better to do this for i386 too, no?

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

Re: [patch 1/3] target-i386: print EFER in cpu_dump_state

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

Index: qemu-kvm-uq/target-i386/helper.c
===================================================================

target-i386/helper.c +0 -0
@@ -1176,6 +1176,7 @@ void cpu_dump_state(CPUState *env, FILE
     cpu_x86_dump_seg_cache(env, f, cpu_fprintf, "TR",&env->tr);
 
Quoted 8 lines

target-i386/helper.c void cpu_dump_state(CPUState *env, FILE · line 1182

Quoted 6 lines
target-i386/helper.c +1 -0
 #ifdef TARGET_X86_64
+    cpu_fprintf(f, "EFER=    %016" PRIx64 "\n", env->efer);
     if (env->hflags&  HF_LMA_MASK) {
         cpu_fprintf(f, "GDT=     %016" PRIx64 " %08x\n",
                     env->gdt.base, env->gdt.limit);

Better to do this for i386 too, no?

"On systems that support IA-32e mode, the extended feature enable register (IA32_EFER) is available. This model-specific register controls activation of IA-32e mode and other IA-32e mode operations."

Can it be useful for i386 too?

#4 lore raw

Re: [patch 1/3] target-i386: print EFER in cpu_dump_state

Quoted 22 lines · Marcelo Tosatti
Quoted 11 lines · Avi Kivity
Quoted 9 lines · Marcelo Tosatti

Index: qemu-kvm-uq/target-i386/helper.c
===================================================================

target-i386/helper.c +0 -0
@@ -1176,6 +1176,7 @@ void cpu_dump_state(CPUState *env, FILE
      cpu_x86_dump_seg_cache(env, f, cpu_fprintf, "TR",&env->tr);
 
Quoted 9 lines

target-i386/helper.c void cpu_dump_state(CPUState *env, FILE · line 1182

Quoted 7 lines
target-i386/helper.c +1 -0
  #ifdef TARGET_X86_64
+    cpu_fprintf(f, "EFER=    %016" PRIx64 "\n", env->efer);
      if (env->hflags&   HF_LMA_MASK) {
          cpu_fprintf(f, "GDT=     %016" PRIx64 " %08x\n",
                      env->gdt.base, env->gdt.limit);

Better to do this for i386 too, no?

Quoted 6 lines

"On systems that support IA-32e mode, the extended feature enable register (IA32_EFER) is available. This model-specific register controls activation of IA-32e mode and other IA-32e mode operations."

Can it be useful for i386 too?

That's on Intel. AMDs had EFER before 64-bit support (for syscall support, and nx), IIRC.

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

PATCH 2/3 kvm: handle internal error

In reply to Marcelo Tosatti

Port qemu-kvm's KVM_EXIT_INTERNAL_ERROR handling to upstream.

kvm-all.c +27 -0
Index: qemu-kvm/kvm-all.c
===================================================================
@@ -721,6 +721,28 @@ 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");
+    vm_stop(0);
+}
+#endif
+
 void kvm_flush_coalesced_mmio_buffer(void)
 {
 #ifdef KVM_CAP_COALESCED_MMIO
@@ -836,6 +858,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
#6 lore raw

Re: [patch 2/3] kvm: handle internal error

Quoted 21 lines · Marcelo Tosatti

Port qemu-kvm's KVM_EXIT_INTERNAL_ERROR handling to upstream.

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

kvm-all.c +9 -0
@@ -721,6 +721,28 @@ 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);

kvm-all.c static int kvm_handle_io(uint16_t port, · line 742

Quoted 10 lines
kvm-all.c +9 -0
+
+        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");
 

{ braces }

kvm-all.c static int kvm_handle_io(uint16_t port,

Quoted 4 lines
kvm-all.c +3 -0
+    vm_stop(0);
+}
+#endif
 

Should trigger a qmp message to let management know something went wrong (can come later).

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

PATCH 3/3 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 +23 -1
Index: qemu-kvm/target-i386/kvm.c
===================================================================
@@ -341,6 +341,24 @@ 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;
@@ -368,7 +386,11 @@ 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)
#8 lore raw

Re: [patch 3/3] kvm: allow qemu to set EPT identity mapping address

Quoted 15 lines · 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.

Index: qemu-kvm/target-i386/kvm.c
===================================================================

target-i386/kvm.c +0 -0
@@ -341,6 +341,24 @@ static int kvm_has_msr_star(CPUState *en
      return 0;
  }

target-i386/kvm.c static int kvm_has_msr_star(CPUState *en · line 352

Quoted 10 lines
target-i386/kvm.c +8 -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;
 

{ braces }

Quoted 14 lines
target-i386/kvm.c +10 -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;

target-i386/kvm.c int kvm_arch_init(KVMState *s, int smp_c · line 392

Quoted 8 lines
target-i386/kvm.c +3 -1
@@ -368,7 +386,11 @@ 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;
 

{ }

Quoted 12 lines
target-i386/kvm.c +2 -0
+
+    return kvm_init_identity_map_page(s);
  }
 

static void set_v8086_seg(struct kvm_segment *lhs, const SegmentCache *rhs)

--
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

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