Skip to contentSkip to conversation

move hlt exit to arch-specific code, and use upstream version.

PATCH In review Glauber Costa 2 participants 4 messages Oct 20, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 move hlt exit to arch-specific code, and use upstream version.

HLT exit calls directly an arch-specific function. Furthermore, upstream qemu already places it on arch specific code, so let's follow it.

The function that handles halt itself is almost equal between them. So let's use it.

---
 qemu-kvm-x86.c    |   14 +++-----------
 qemu-kvm.c        |    3 ---
 target-i386/kvm.c |    2 ++
 3 files changed, 5 insertions(+), 14 deletions(-)
qemu-kvm-x86.c +3 -11
index c1d0ae9..6573dc5 100644
@@ -199,6 +199,9 @@ int kvm_arch_run(CPUState *env)
 			r = kvm_handle_tpr_access(env);
 			break;
 #endif
+        case KVM_EXIT_HLT:
+            r = kvm_handle_halt(env);
+            break;
 		default:
 			r = 1;
 			break;
@@ -1377,17 +1380,6 @@ int kvm_arch_init_vcpu(CPUState *cenv)
     return 0;
 }
 
-int kvm_arch_halt(CPUState *env)
-{
-
-    if (!((env->interrupt_request & CPU_INTERRUPT_HARD) &&
-	  (env->eflags & IF_MASK)) &&
-	!(env->interrupt_request & CPU_INTERRUPT_NMI)) {
-            env->halted = 1;
-    }
-    return 1;
-}
-
 void kvm_arch_pre_kvm_run(void *opaque, CPUState *env)
 {
     if (!kvm_irqchip_in_kernel())
qemu-kvm.c +0 -3
index b8ae4d8..42ead38 100644
@@ -1002,9 +1002,6 @@ int kvm_run(CPUState *env)
         case KVM_EXIT_MMIO:
             r = handle_mmio(env);
             break;
-        case KVM_EXIT_HLT:
-            r = kvm_arch_halt(env);
-            break;
         case KVM_EXIT_IRQ_WINDOW_OPEN:
             break;
         case KVM_EXIT_SHUTDOWN:
target-i386/kvm.c +2 -0
index 1cf0dc3..de10ef1 100644
@@ -761,6 +761,7 @@ int kvm_arch_post_run(CPUState *env, struct kvm_run *run)
 
     return 0;
 }
+#endif
 
 static int kvm_handle_halt(CPUState *env)
 {
@@ -775,6 +776,7 @@ static int kvm_handle_halt(CPUState *env)
     return 1;
 }
 
+#ifdef KVM_UPSTREAM
 int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run)
 {
     int ret = 0;
Signature · 1 line
1.6.2.5
#1 lore raw
Quoted 6 lines · Glauber Costa

HLT exit calls directly an arch-specific function. Furthermore, upstream qemu already places it on arch specific code, so let's follow it.

The function that handles halt itself is almost equal between them. So let's use it.

kvm_handle_halt() may return 1. If it does kvm_arch_run() will return 1 too and kvm_run() will abort.

Quoted 80 lines
---
 qemu-kvm-x86.c    |   14 +++-----------
 qemu-kvm.c        |    3 ---
 target-i386/kvm.c |    2 ++
 3 files changed, 5 insertions(+), 14 deletions(-)
qemu-kvm-x86.c +3 -11
index c1d0ae9..6573dc5 100644
@@ -199,6 +199,9 @@ int kvm_arch_run(CPUState *env)
 			r = kvm_handle_tpr_access(env);
 			break;
 #endif
+        case KVM_EXIT_HLT:
+            r = kvm_handle_halt(env);
+            break;
 		default:
 			r = 1;
 			break;
@@ -1377,17 +1380,6 @@ int kvm_arch_init_vcpu(CPUState *cenv)
     return 0;
 }
 
-int kvm_arch_halt(CPUState *env)
-{
-
-    if (!((env->interrupt_request & CPU_INTERRUPT_HARD) &&
-	  (env->eflags & IF_MASK)) &&
-	!(env->interrupt_request & CPU_INTERRUPT_NMI)) {
-            env->halted = 1;
-    }
-    return 1;
-}
-
 void kvm_arch_pre_kvm_run(void *opaque, CPUState *env)
 {
     if (!kvm_irqchip_in_kernel())
qemu-kvm.c +0 -3
index b8ae4d8..42ead38 100644
@@ -1002,9 +1002,6 @@ int kvm_run(CPUState *env)
         case KVM_EXIT_MMIO:
             r = handle_mmio(env);
             break;
-        case KVM_EXIT_HLT:
-            r = kvm_arch_halt(env);
-            break;
         case KVM_EXIT_IRQ_WINDOW_OPEN:
             break;
         case KVM_EXIT_SHUTDOWN:
target-i386/kvm.c +2 -0
index 1cf0dc3..de10ef1 100644
@@ -761,6 +761,7 @@ int kvm_arch_post_run(CPUState *env, struct kvm_run *run)
 
     return 0;
 }
+#endif
 
 static int kvm_handle_halt(CPUState *env)
 {
@@ -775,6 +776,7 @@ static int kvm_handle_halt(CPUState *env)
     return 1;
 }
 
+#ifdef KVM_UPSTREAM
 int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run)
 {
     int ret = 0;
Signature · 6 lines
1.6.2.5

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

--
Gleb.

#2 lore raw
Quoted 9 lines · Gleb Natapov
Quoted 6 lines · Glauber Costa

HLT exit calls directly an arch-specific function. Furthermore, upstream qemu already places it on arch specific code, so let's follow it.

The function that handles halt itself is almost equal between them. So let's use it.

kvm_handle_halt() may return 1. If it does kvm_arch_run() will return 1 too and kvm_run() will abort.

kvm_arch_halt() may return 1 as well.

#3 lore raw
Quoted 5 lines · Glauber Costa
Quoted 4 lines · Gleb Natapov
Quoted 3 lines · Glauber Costa

HLT exit calls directly an arch-specific function. Furthermore, upstream qemu already places it on arch specific code, so let's follow it.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The function that handles halt itself is almost equal between them. So let's use it.

kvm_handle_halt() may return 1. If it does kvm_arch_run() will return 1 too and kvm_run() will abort.

kvm_arch_halt() may return 1 as well.

But it's called from another place and its return value is handled differently.

--
Gleb.