Skip to contentSkip to conversation

kvm: notify host when guest paniced

PATCH Superseded Wen Congyang 7 participants 36 messages Feb 27, 2012 – Mar 2, 2012

Subsystems (4)

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: notify host when guest paniced

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +12 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +6 -2
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;
 }
 
 static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
arch/x86/kvm/vmx.c +6 -2
index 66147ca..1b57ebb 100644
@@ -4582,9 +4582,13 @@ static int handle_halt(struct kvm_vcpu *vcpu)
 
 static int handle_vmcall(struct kvm_vcpu *vcpu)
 {
+	int ret;
+
 	skip_emulated_instruction(vcpu);
-	kvm_emulate_hypercall(vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;
 }
 
 static int handle_invd(struct kvm_vcpu *vcpu)
arch/x86/kvm/x86.c +11 -2
index c9d99e5..3fc2853 100644
@@ -4923,7 +4923,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	u64 param, ingpa, outgpa, ret;
 	uint16_t code, rep_idx, rep_cnt, res = HV_STATUS_SUCCESS, rep_done = 0;
 	bool fast, longmode;
-	int cs_db, cs_l;
+	int cs_db, cs_l, r = 1;
 
 	/*
 	 * hypercall generates UD from non zero cpl and real mode
@@ -4964,6 +4964,10 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	case HV_X64_HV_NOTIFY_LONG_SPIN_WAIT:
 		kvm_vcpu_on_spin(vcpu);
 		break;
+	case KVM_HC_GUEST_PANIC:
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;
 	default:
 		res = HV_STATUS_INVALID_HYPERCALL_CODE;
 		break;
@@ -4977,7 +4981,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 		kvm_register_write(vcpu, VCPU_REGS_RAX, ret & 0xffffffff);
 	}
 
-	return 1;
+	return r;
 }
 
 int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
@@ -5013,6 +5017,11 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
 	case KVM_HC_VAPIC_POLL_IRQ:
 		ret = 0;
 		break;
+	case KVM_HC_GUEST_PANIC:
+		ret = 0;
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;
 	default:
 		ret = -KVM_ENOSYS;
 		break;
include/linux/kvm.h +1 -0
index acbe429..8f0e31b 100644
@@ -163,6 +163,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_OSI              18
 #define KVM_EXIT_PAPR_HCALL	  19
 #define KVM_EXIT_S390_UCONTROL	  20
+#define KVM_EXIT_GUEST_PANIC	  21
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 #define KVM_INTERNAL_ERROR_EMULATION 1
include/linux/kvm_para.h +1 -0
index ff476dd..cf94023 100644
@@ -19,6 +19,7 @@
 #define KVM_HC_MMU_OP			2
 #define KVM_HC_FEATURES			3
 #define KVM_HC_PPC_MAP_MAGIC_PAGE	4
+#define KVM_HC_GUEST_PANIC		5
 
 /*
  * hypercalls use architecture specific
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 qemu: deal with guest paniced event

When the host knows the guest is paniced, it will set exit_reason to KVM_EXIT_GUEST_PANIC. So if qemu receive this exit_reason, we can send a event to tell management application that the guest is paniced.

---
 kvm-all.c                 |    3 +++
 linux-headers/linux/kvm.h |    1 +
 monitor.c                 |    3 +++
 monitor.h                 |    1 +
 4 files changed, 8 insertions(+), 0 deletions(-)
kvm-all.c +3 -0
index c4babda..ae428ab 100644
@@ -1190,6 +1190,9 @@ int kvm_cpu_exec(CPUState *env)
                     (uint64_t)run->hw.hardware_exit_reason);
             ret = -1;
             break;
+        case KVM_EXIT_GUEST_PANIC:
+            monitor_protocol_event(QEVENT_GUEST_PANICED, NULL);
+            break;
         case KVM_EXIT_INTERNAL_ERROR:
             ret = kvm_handle_internal_error(env, run);
             break;
linux-headers/linux/kvm.h +1 -0
index f6b5343..45dd031 100644
@@ -163,6 +163,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_OSI              18
 #define KVM_EXIT_PAPR_HCALL	  19
 #define KVM_EXIT_S390_UCONTROL	  20
+#define KVM_EXIT_GUEST_PANIC	  21
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 #define KVM_INTERNAL_ERROR_EMULATION 1
monitor.c +3 -0
index 953e748..9802792 100644
@@ -494,6 +494,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
         case QEVENT_WAKEUP:
             event_name = "WAKEUP";
             break;
+        case QEVENT_GUEST_PANICED:
+            event_name = "GUEST_PANICED";
+            break;
         default:
             abort();
             break;
monitor.h +1 -0
index 0d49800..a62da93 100644
@@ -41,6 +41,7 @@ typedef enum MonitorEvent {
     QEVENT_DEVICE_TRAY_MOVED,
     QEVENT_SUSPEND,
     QEVENT_WAKEUP,
+    QEVENT_GUEST_PANICED,
     QEVENT_MAX,
 } MonitorEvent;
 
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH]qemu: deal with guest paniced event

Quoted 32 lines · Wen Congyang

When the host knows the guest is paniced, it will set exit_reason to KVM_EXIT_GUEST_PANIC. So if qemu receive this exit_reason, we can send a event to tell management application that the guest is paniced.

---
 kvm-all.c                 |    3 +++
 linux-headers/linux/kvm.h |    1 +
 monitor.c                 |    3 +++
 monitor.h                 |    1 +
 4 files changed, 8 insertions(+), 0 deletions(-)
kvm-all.c +3 -0
index c4babda..ae428ab 100644
@@ -1190,6 +1190,9 @@ int kvm_cpu_exec(CPUState *env)
                     (uint64_t)run->hw.hardware_exit_reason);
             ret = -1;
             break;
+        case KVM_EXIT_GUEST_PANIC:
+            monitor_protocol_event(QEVENT_GUEST_PANICED, NULL);
+            break;
         case KVM_EXIT_INTERNAL_ERROR:
             ret = kvm_handle_internal_error(env, run);
             break;
linux-headers/linux/kvm.h +0 -0
index f6b5343..45dd031 100644

linux-headers/linux/kvm.h struct kvm_pit_config { · line 169

Quoted 7 lines
linux-headers/linux/kvm.h +1 -0
@@ -163,6 +163,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_OSI              18
 #define KVM_EXIT_PAPR_HCALL	  19
 #define KVM_EXIT_S390_UCONTROL	  20
+#define KVM_EXIT_GUEST_PANIC	  21
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 #define KVM_INTERNAL_ERROR_EMULATION 1

linux-headers are supposed to be synchronized in a separate patch, naming the upstream or kvm.git hash they pull in. IOW: the KVM ABI change has to be applied first.

Jan

#3 lore raw

Re: [Qemu-devel] [PATCH]qemu: deal with guest paniced event

In reply to Wen Congyang
Quoted 18 lines · On Mon, 27 Feb 2012 11:05:58 +0800 Wen Congyang <[email protected]> wrote:

When the host knows the guest is paniced, it will set exit_reason to KVM_EXIT_GUEST_PANIC. So if qemu receive this exit_reason, we can send a event to tell management application that the guest is paniced.

---
 kvm-all.c                 |    3 +++
 linux-headers/linux/kvm.h |    1 +
 monitor.c                 |    3 +++
 monitor.h                 |    1 +
 4 files changed, 8 insertions(+), 0 deletions(-)
kvm-all.c +0 -0
index c4babda..ae428ab 100644

kvm-all.c int kvm_cpu_exec(CPUState *env) · line 1195

Quoted 6 lines
kvm-all.c +3 -0
@@ -1190,6 +1190,9 @@ int kvm_cpu_exec(CPUState *env)
                     (uint64_t)run->hw.hardware_exit_reason);
             ret = -1;
             break;
+        case KVM_EXIT_GUEST_PANIC:
+            monitor_protocol_event(QEVENT_GUEST_PANICED, NULL);
+            break;

The event alone is not enough, because the mngt app may miss it (eg. the panic happens before the mngt app connected to qemu).

A simple way to solve this would be to also add a new RunState called guest-panic and make the transition to it (besides sending the event).

A more general way would be to model this after -drive's werror/rerror options, say guest-error=report|ignore|stop. When guest-error=stop, the mngt app will get a STOP event and can check the VM runstate to know if it's guest-panic.

#4 lore raw

Re: [Qemu-devel] [PATCH]qemu: deal with guest paniced event

At 03/02/2012 12:51 AM, Luiz Capitulino Wrote:

Quoted 31 lines
Quoted 18 lines · On Mon, 27 Feb 2012 11:05:58 +0800 Wen Congyang <[email protected]> wrote:

When the host knows the guest is paniced, it will set exit_reason to KVM_EXIT_GUEST_PANIC. So if qemu receive this exit_reason, we can send a event to tell management application that the guest is paniced.

---
 kvm-all.c                 |    3 +++
 linux-headers/linux/kvm.h |    1 +
 monitor.c                 |    3 +++
 monitor.h                 |    1 +
 4 files changed, 8 insertions(+), 0 deletions(-)
kvm-all.c +0 -0
index c4babda..ae428ab 100644

kvm-all.c int kvm_cpu_exec(CPUState *env) · line 1195

Quoted 6 lines
kvm-all.c +3 -0
@@ -1190,6 +1190,9 @@ int kvm_cpu_exec(CPUState *env)
                     (uint64_t)run->hw.hardware_exit_reason);
             ret = -1;
             break;
+        case KVM_EXIT_GUEST_PANIC:
+            monitor_protocol_event(QEVENT_GUEST_PANICED, NULL);
+            break;

The event alone is not enough, because the mngt app may miss it (eg. the panic happens before the mngt app connected to qemu).

Quoted 6 lines

A simple way to solve this would be to also add a new RunState called guest-panic and make the transition to it (besides sending the event).

A more general way would be to model this after -drive's werror/rerror options, say guest-error=report|ignore|stop. When guest-error=stop, the mngt app will get a STOP event and can check the VM runstate to know if it's guest-panic.

OK, I will fix it.

Thanks
Wen Congyang

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#5 lore raw
In reply to Wen Congyang
Quoted 25 lines · Wen Congyang

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 19 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
 static int vmmcall_interception(struct vcpu_svm *svm)
 {

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 10 lines
arch/x86/kvm/svm.c +6 -2
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 37 lines
arch/x86/kvm/svm.c +0 -0
 }
 
 static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
arch/x86/kvm/vmx.c +6 -2
index 66147ca..1b57ebb 100644
@@ -4582,9 +4582,13 @@ static int handle_halt(struct kvm_vcpu *vcpu)
 
 static int handle_vmcall(struct kvm_vcpu *vcpu)
 {
+	int ret;
+
 	skip_emulated_instruction(vcpu);
-	kvm_emulate_hypercall(vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;
 }
 
 static int handle_invd(struct kvm_vcpu *vcpu)
arch/x86/kvm/x86.c +1 -1
index c9d99e5..3fc2853 100644
@@ -4923,7 +4923,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	u64 param, ingpa, outgpa, ret;
 	uint16_t code, rep_idx, rep_cnt, res = HV_STATUS_SUCCESS, rep_done = 0;
 	bool fast, longmode;
-	int cs_db, cs_l;
+	int cs_db, cs_l, r = 1;
 
 	/*
 	 * hypercall generates UD from non zero cpl and real mode

arch/x86/kvm/x86.c int kvm_hv_hypercall(struct kvm_vcpu *vcpu) · line 4970

Quoted 7 lines
arch/x86/kvm/x86.c +4 -0
@@ -4964,6 +4964,10 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	case HV_X64_HV_NOTIFY_LONG_SPIN_WAIT:
 		kvm_vcpu_on_spin(vcpu);
 		break;
+	case KVM_HC_GUEST_PANIC:
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;

That's the wrong place. This is a KVM hypercall, not a HyperV one.

Quoted 41 lines
arch/x86/kvm/x86.c +6 -1
 	default:
 		res = HV_STATUS_INVALID_HYPERCALL_CODE;
 		break;
@@ -4977,7 +4981,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 		kvm_register_write(vcpu, VCPU_REGS_RAX, ret & 0xffffffff);
 	}
 
-	return 1;
+	return r;
 }
 
 int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
@@ -5013,6 +5017,11 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
 	case KVM_HC_VAPIC_POLL_IRQ:
 		ret = 0;
 		break;
+	case KVM_HC_GUEST_PANIC:
+		ret = 0;
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;
 	default:
 		ret = -KVM_ENOSYS;
 		break;
include/linux/kvm.h +1 -0
index acbe429..8f0e31b 100644
@@ -163,6 +163,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_OSI              18
 #define KVM_EXIT_PAPR_HCALL	  19
 #define KVM_EXIT_S390_UCONTROL	  20
+#define KVM_EXIT_GUEST_PANIC	  21
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 #define KVM_INTERNAL_ERROR_EMULATION 1
include/linux/kvm_para.h +0 -0
index ff476dd..cf94023 100644

include/linux/kvm_para.h line 25

Quoted 7 lines
include/linux/kvm_para.h +1 -0
@@ -19,6 +19,7 @@
 #define KVM_HC_MMU_OP			2
 #define KVM_HC_FEATURES			3
 #define KVM_HC_PPC_MAP_MAGIC_PAGE	4
+#define KVM_HC_GUEST_PANIC		5
 
 /*
  * hypercalls use architecture specific

Jan

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

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 25 lines · Wen Congyang
Quoted 24 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +0 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
Quoted 13 lines

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 11 lines
arch/x86/kernel/kvm.c +11 -0
+static int
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

OK

Quoted 18 lines
Quoted 18 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Because before this patch, kvm always ignores the error.

After rereading the code, kvm_emulate_hypercall() will return -KVM_EPERM when vcpu's CPL is not 0. I think we should deal with this exception in kvm_emulate_hypercall(), and return 1. But I donot know how to do it. kvm_queue_exception(vcpu, UD_VECTOR)?

Quoted 35 lines
Quoted 35 lines
arch/x86/kvm/svm.c +0 -0
 }
 
 static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
arch/x86/kvm/vmx.c +6 -2
index 66147ca..1b57ebb 100644
@@ -4582,9 +4582,13 @@ static int handle_halt(struct kvm_vcpu *vcpu)
 
 static int handle_vmcall(struct kvm_vcpu *vcpu)
 {
+	int ret;
+
 	skip_emulated_instruction(vcpu);
-	kvm_emulate_hypercall(vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;
 }
 
 static int handle_invd(struct kvm_vcpu *vcpu)
arch/x86/kvm/x86.c +1 -1
index c9d99e5..3fc2853 100644
@@ -4923,7 +4923,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	u64 param, ingpa, outgpa, ret;
 	uint16_t code, rep_idx, rep_cnt, res = HV_STATUS_SUCCESS, rep_done = 0;
 	bool fast, longmode;
-	int cs_db, cs_l;
+	int cs_db, cs_l, r = 1;
 
Quoted 12 lines

arch/x86/kvm/x86.c int kvm_hv_hypercall(struct kvm_vcpu *vcpu) · line 4970

Quoted 10 lines
arch/x86/kvm/x86.c +4 -0
 	/*
 	 * hypercall generates UD from non zero cpl and real mode
@@ -4964,6 +4964,10 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	case HV_X64_HV_NOTIFY_LONG_SPIN_WAIT:
 		kvm_vcpu_on_spin(vcpu);
 		break;
+	case KVM_HC_GUEST_PANIC:
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;

That's the wrong place. This is a KVM hypercall, not a HyperV one.

OK, I will remove it.

Thanks
Wen Congyang

Quoted 52 lines
Quoted 42 lines
arch/x86/kvm/x86.c +6 -1
 	default:
 		res = HV_STATUS_INVALID_HYPERCALL_CODE;
 		break;
@@ -4977,7 +4981,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 		kvm_register_write(vcpu, VCPU_REGS_RAX, ret & 0xffffffff);
 	}
 
-	return 1;
+	return r;
 }
 
 int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
@@ -5013,6 +5017,11 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
 	case KVM_HC_VAPIC_POLL_IRQ:
 		ret = 0;
 		break;
+	case KVM_HC_GUEST_PANIC:
+		ret = 0;
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;
 	default:
 		ret = -KVM_ENOSYS;
 		break;
include/linux/kvm.h +1 -0
index acbe429..8f0e31b 100644
@@ -163,6 +163,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_OSI              18
 #define KVM_EXIT_PAPR_HCALL	  19
 #define KVM_EXIT_S390_UCONTROL	  20
+#define KVM_EXIT_GUEST_PANIC	  21
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 #define KVM_INTERNAL_ERROR_EMULATION 1
include/linux/kvm_para.h +0 -0
index ff476dd..cf94023 100644

include/linux/kvm_para.h line 25

Quoted 7 lines
include/linux/kvm_para.h +1 -0
@@ -19,6 +19,7 @@
 #define KVM_HC_MMU_OP			2
 #define KVM_HC_FEATURES			3
 #define KVM_HC_PPC_MAP_MAGIC_PAGE	4
+#define KVM_HC_GUEST_PANIC		5
 
 /*
  * hypercalls use architecture specific

Jan

#7 lore raw

At 02/28/2012 01:26 PM, Wen Congyang Wrote:

Quoted 75 lines

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 25 lines · Wen Congyang
Quoted 24 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +0 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
Quoted 13 lines

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 11 lines
arch/x86/kernel/kvm.c +11 -0
+static int
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

OK

Quoted 18 lines
Quoted 18 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 3 lines

Because before this patch, kvm always ignores the error.

After rereading the code, kvm_emulate_hypercall() will return -KVM_EPERM

Sorry for my miss. kvm_emulate_hypercall() does not return -KVM_EPERM.

Quoted 116 lines

when vcpu's CPL is not 0. I think we should deal with this exception in kvm_emulate_hypercall(), and return 1. But I donot know how to do it. kvm_queue_exception(vcpu, UD_VECTOR)?

Quoted 35 lines
Quoted 35 lines
arch/x86/kvm/svm.c +0 -0
 }
 
 static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
arch/x86/kvm/vmx.c +6 -2
index 66147ca..1b57ebb 100644
@@ -4582,9 +4582,13 @@ static int handle_halt(struct kvm_vcpu *vcpu)
 
 static int handle_vmcall(struct kvm_vcpu *vcpu)
 {
+	int ret;
+
 	skip_emulated_instruction(vcpu);
-	kvm_emulate_hypercall(vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;
 }
 
 static int handle_invd(struct kvm_vcpu *vcpu)
arch/x86/kvm/x86.c +1 -1
index c9d99e5..3fc2853 100644
@@ -4923,7 +4923,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	u64 param, ingpa, outgpa, ret;
 	uint16_t code, rep_idx, rep_cnt, res = HV_STATUS_SUCCESS, rep_done = 0;
 	bool fast, longmode;
-	int cs_db, cs_l;
+	int cs_db, cs_l, r = 1;
 
Quoted 12 lines

arch/x86/kvm/x86.c int kvm_hv_hypercall(struct kvm_vcpu *vcpu) · line 4970

Quoted 10 lines
arch/x86/kvm/x86.c +4 -0
 	/*
 	 * hypercall generates UD from non zero cpl and real mode
@@ -4964,6 +4964,10 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	case HV_X64_HV_NOTIFY_LONG_SPIN_WAIT:
 		kvm_vcpu_on_spin(vcpu);
 		break;
+	case KVM_HC_GUEST_PANIC:
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;

That's the wrong place. This is a KVM hypercall, not a HyperV one.

OK, I will remove it.

Thanks
Wen Congyang

Quoted 47 lines
Quoted 47 lines
arch/x86/kvm/x86.c +6 -1
 	default:
 		res = HV_STATUS_INVALID_HYPERCALL_CODE;
 		break;
@@ -4977,7 +4981,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 		kvm_register_write(vcpu, VCPU_REGS_RAX, ret & 0xffffffff);
 	}
 
-	return 1;
+	return r;
 }
 
 int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
@@ -5013,6 +5017,11 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
 	case KVM_HC_VAPIC_POLL_IRQ:
 		ret = 0;
 		break;
+	case KVM_HC_GUEST_PANIC:
+		ret = 0;
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;
 	default:
 		ret = -KVM_ENOSYS;
 		break;
include/linux/kvm.h +1 -0
index acbe429..8f0e31b 100644
@@ -163,6 +163,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_OSI              18
 #define KVM_EXIT_PAPR_HCALL	  19
 #define KVM_EXIT_S390_UCONTROL	  20
+#define KVM_EXIT_GUEST_PANIC	  21
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 #define KVM_INTERNAL_ERROR_EMULATION 1
include/linux/kvm_para.h +1 -0
index ff476dd..cf94023 100644
@@ -19,6 +19,7 @@
 #define KVM_HC_MMU_OP			2
 #define KVM_HC_FEATURES			3
 #define KVM_HC_PPC_MAP_MAGIC_PAGE	4
+#define KVM_HC_GUEST_PANIC		5
 
Quoted 5 lines

include/linux/kvm_para.h line 25

Quoted 2 lines
include/linux/kvm_para.h +0 -0
 /*
  * hypercalls use architecture specific

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#8 lore raw
In reply to Jan Kiszka

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 56 lines · Wen Congyang
Quoted 25 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 17 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

kvm_emulate_hypercall() will call kvm_hv_hypercall(), and kvm_hv_hypercall() will return 0 when vcpu's CPL > 0. If vcpu's CPL > 0, does kvm need to exit and tell it to qemu?

Thanks
Wen Congyang

Quoted 99 lines
Quoted 38 lines
arch/x86/kvm/svm.c +0 -0
 }
 
 static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
arch/x86/kvm/vmx.c +6 -2
index 66147ca..1b57ebb 100644
@@ -4582,9 +4582,13 @@ static int handle_halt(struct kvm_vcpu *vcpu)
 
 static int handle_vmcall(struct kvm_vcpu *vcpu)
 {
+	int ret;
+
 	skip_emulated_instruction(vcpu);
-	kvm_emulate_hypercall(vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;
 }
 
 static int handle_invd(struct kvm_vcpu *vcpu)
arch/x86/kvm/x86.c +1 -1
index c9d99e5..3fc2853 100644
@@ -4923,7 +4923,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	u64 param, ingpa, outgpa, ret;
 	uint16_t code, rep_idx, rep_cnt, res = HV_STATUS_SUCCESS, rep_done = 0;
 	bool fast, longmode;
-	int cs_db, cs_l;
+	int cs_db, cs_l, r = 1;
 
 	/*
 	 * hypercall generates UD from non zero cpl and real mode

arch/x86/kvm/x86.c int kvm_hv_hypercall(struct kvm_vcpu *vcpu) · line 4970

Quoted 7 lines
arch/x86/kvm/x86.c +4 -0
@@ -4964,6 +4964,10 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	case HV_X64_HV_NOTIFY_LONG_SPIN_WAIT:
 		kvm_vcpu_on_spin(vcpu);
 		break;
+	case KVM_HC_GUEST_PANIC:
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;

That's the wrong place. This is a KVM hypercall, not a HyperV one.

Quoted 41 lines
arch/x86/kvm/x86.c +6 -1
 	default:
 		res = HV_STATUS_INVALID_HYPERCALL_CODE;
 		break;
@@ -4977,7 +4981,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 		kvm_register_write(vcpu, VCPU_REGS_RAX, ret & 0xffffffff);
 	}
 
-	return 1;
+	return r;
 }
 
 int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
@@ -5013,6 +5017,11 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
 	case KVM_HC_VAPIC_POLL_IRQ:
 		ret = 0;
 		break;
+	case KVM_HC_GUEST_PANIC:
+		ret = 0;
+		vcpu->run->exit_reason = KVM_EXIT_GUEST_PANIC;
+		r = 0;
+		break;
 	default:
 		ret = -KVM_ENOSYS;
 		break;
include/linux/kvm.h +1 -0
index acbe429..8f0e31b 100644
@@ -163,6 +163,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_OSI              18
 #define KVM_EXIT_PAPR_HCALL	  19
 #define KVM_EXIT_S390_UCONTROL	  20
+#define KVM_EXIT_GUEST_PANIC	  21
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 #define KVM_INTERNAL_ERROR_EMULATION 1
include/linux/kvm_para.h +0 -0
index ff476dd..cf94023 100644

include/linux/kvm_para.h line 25

Quoted 7 lines
include/linux/kvm_para.h +1 -0
@@ -19,6 +19,7 @@
 #define KVM_HC_MMU_OP			2
 #define KVM_HC_FEATURES			3
 #define KVM_HC_PPC_MAP_MAGIC_PAGE	4
+#define KVM_HC_GUEST_PANIC		5
 
 /*
  * hypercalls use architecture specific

Jan

#9 lore raw
Quoted 72 lines · Wen Congyang

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 56 lines · Wen Congyang
Quoted 25 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 17 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 4 lines

kvm_emulate_hypercall() will call kvm_hv_hypercall(), and kvm_hv_hypercall() will return 0 when vcpu's CPL > 0. If vcpu's CPL > 0, does kvm need to exit and tell it to qemu?

No, there is currently no exit to userspace due to hypercalls, neither of HV nor KVM kind.

The point is that the return code of kvm_emulate_hypercall is unused so far, so you can easily redefine it to encode continue vs. exit to userspace. Once someone has different needs, this could still be refactored again.

Jan

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

At 02/28/2012 05:34 PM, Jan Kiszka Wrote:

Quoted 78 lines · Wen Congyang
Quoted 72 lines

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 56 lines · Wen Congyang
Quoted 25 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 17 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 4 lines

kvm_emulate_hypercall() will call kvm_hv_hypercall(), and kvm_hv_hypercall() will return 0 when vcpu's CPL > 0. If vcpu's CPL > 0, does kvm need to exit and tell it to qemu?

Quoted 7 lines

No, there is currently no exit to userspace due to hypercalls, neither of HV nor KVM kind.

The point is that the return code of kvm_emulate_hypercall is unused so far, so you can easily redefine it to encode continue vs. exit to userspace. Once someone has different needs, this could still be refactored again.

So, it is OK to change the return value of kvm_hv_hypercall() if vcpu's CPL > 0?

Thanks
Wen Congyang

Quoted 3 lines

Jan

#11 lore raw
Quoted 82 lines · Wen Congyang

At 02/28/2012 05:34 PM, Jan Kiszka Wrote:

Quoted 81 lines · Wen Congyang
Quoted 72 lines

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 56 lines · Wen Congyang
Quoted 25 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 17 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 4 lines

kvm_emulate_hypercall() will call kvm_hv_hypercall(), and kvm_hv_hypercall() will return 0 when vcpu's CPL > 0. If vcpu's CPL > 0, does kvm need to exit and tell it to qemu?

No, there is currently no exit to userspace due to hypercalls, neither of HV nor KVM kind.

Quoted 7 lines
Quoted 4 lines

The point is that the return code of kvm_emulate_hypercall is unused so far, so you can easily redefine it to encode continue vs. exit to userspace. Once someone has different needs, this could still be refactored again.

So, it is OK to change the return value of kvm_hv_hypercall() if vcpu's CPL > 0?

Yes, change it to encode what vendor modules need to return to their callers.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#12 lore raw
Quoted 88 lines · Jan Kiszka
Quoted 87 lines · Wen Congyang

At 02/28/2012 05:34 PM, Jan Kiszka Wrote:

Quoted 85 lines · Wen Congyang
Quoted 72 lines

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 56 lines · Wen Congyang
Quoted 25 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 17 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 4 lines

kvm_emulate_hypercall() will call kvm_hv_hypercall(), and kvm_hv_hypercall() will return 0 when vcpu's CPL > 0. If vcpu's CPL > 0, does kvm need to exit and tell it to qemu?

No, there is currently no exit to userspace due to hypercalls, neither of HV nor KVM kind.

The point is that the return code of kvm_emulate_hypercall is unused so far, so you can easily redefine it to encode continue vs. exit to userspace. Once someone has different needs, this could still be refactored again.

Quoted 6 lines
Quoted 2 lines

So, it is OK to change the return value of kvm_hv_hypercall() if vcpu's CPL > 0?

Yes, change it to encode what vendor modules need to return to their callers.

Better introduce new request flag and set it in your hypercall emulation. See how triple fault is handled.

--
Gleb.

#13 lore raw

At 02/28/2012 06:45 PM, Gleb Natapov Wrote:

Quoted 89 lines · Jan Kiszka
Quoted 88 lines · Wen Congyang
Quoted 87 lines

At 02/28/2012 05:34 PM, Jan Kiszka Wrote:

Quoted 85 lines · Wen Congyang
Quoted 72 lines

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 56 lines · Wen Congyang
Quoted 25 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 17 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 4 lines

kvm_emulate_hypercall() will call kvm_hv_hypercall(), and kvm_hv_hypercall() will return 0 when vcpu's CPL > 0. If vcpu's CPL > 0, does kvm need to exit and tell it to qemu?

No, there is currently no exit to userspace due to hypercalls, neither of HV nor KVM kind.

The point is that the return code of kvm_emulate_hypercall is unused so far, so you can easily redefine it to encode continue vs. exit to userspace. Once someone has different needs, this could still be refactored again.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

So, it is OK to change the return value of kvm_hv_hypercall() if vcpu's CPL > 0?

Yes, change it to encode what vendor modules need to return to their callers.

Better introduce new request flag and set it in your hypercall emulation. See how triple fault is handled.

triple fault sets KVM_EXIT_SHUTDOWN and exits to userspace. Do you mean introduce a new value(like KVM_EXIT_SHUTDOWN)?

Thanks
Wen Congyang

Quoted 9 lines

--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#14 lore raw
Quoted 93 lines · Wen Congyang

At 02/28/2012 06:45 PM, Gleb Natapov Wrote:

Quoted 92 lines · Jan Kiszka
Quoted 91 lines · Wen Congyang
Quoted 89 lines

At 02/28/2012 05:34 PM, Jan Kiszka Wrote:

Quoted 78 lines · Wen Congyang
Quoted 72 lines

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 56 lines · Wen Congyang
Quoted 25 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 17 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 4 lines

kvm_emulate_hypercall() will call kvm_hv_hypercall(), and kvm_hv_hypercall() will return 0 when vcpu's CPL > 0. If vcpu's CPL > 0, does kvm need to exit and tell it to qemu?

Quoted 7 lines

No, there is currently no exit to userspace due to hypercalls, neither of HV nor KVM kind.

The point is that the return code of kvm_emulate_hypercall is unused so far, so you can easily redefine it to encode continue vs. exit to userspace. Once someone has different needs, this could still be refactored again.

So, it is OK to change the return value of kvm_hv_hypercall() if vcpu's CPL > 0?

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Yes, change it to encode what vendor modules need to return to their callers.

Better introduce new request flag and set it in your hypercall emulation. See how triple fault is handled.

triple fault sets KVM_EXIT_SHUTDOWN and exits to userspace. Do you mean introduce a new value(like KVM_EXIT_SHUTDOWN)?

I mean introduce new request bit (like KVM_REQ_TRIPLE_FAULT) and set it in your hypercall if exit to userspace is needed instead of changing return values.

--
Gleb.

#15 lore raw

At 02/29/2012 05:36 PM, Gleb Natapov Wrote:

Quoted 100 lines · Wen Congyang
Quoted 99 lines

At 02/28/2012 06:45 PM, Gleb Natapov Wrote:

Quoted 97 lines · Jan Kiszka
Quoted 88 lines · Wen Congyang
Quoted 87 lines

At 02/28/2012 05:34 PM, Jan Kiszka Wrote:

Quoted 85 lines · Wen Congyang
Quoted 72 lines

At 02/27/2012 11:08 PM, Jan Kiszka Wrote:

Quoted 56 lines · Wen Congyang
Quoted 25 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

---
 arch/x86/kernel/kvm.c    |   12 ++++++++++++
 arch/x86/kvm/svm.c       |    8 ++++++--
 arch/x86/kvm/vmx.c       |    8 ++++++--
 arch/x86/kvm/x86.c       |   13 +++++++++++--
 include/linux/kvm.h      |    1 +
 include/linux/kvm_para.h |    1 +
 6 files changed, 37 insertions(+), 6 deletions(-)
arch/x86/kernel/kvm.c +1 -0
index f0c6fd6..b928d1d 100644
@@ -331,6 +331,17 @@ static struct notifier_block kvm_pv_reboot_nb = {
 	.notifier_call = kvm_pv_reboot_notify,
 };
 
+static int

arch/x86/kernel/kvm.c static struct notifier_block kvm_pv_reboot_nb = { · line 344

Quoted 10 lines
arch/x86/kernel/kvm.c +10 -0
+kvm_pv_panic_notify(struct notifier_block *nb, unsigned long code, void *unused)
+{
+	kvm_hypercall0(KVM_HC_GUEST_PANIC);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block kvm_pv_panic_nb = {
+	.notifier_call = kvm_pv_panic_notify,
+};
+

You should split up host and guest-side changes.

Quoted 17 lines
arch/x86/kernel/kvm.c +1 -0
 static u64 kvm_steal_clock(int cpu)
 {
 	u64 steal;
@@ -417,6 +428,7 @@ void __init kvm_guest_init(void)
 
 	paravirt_ops_setup();
 	register_reboot_notifier(&kvm_pv_reboot_nb);
+	atomic_notifier_chain_register(&panic_notifier_list, &kvm_pv_panic_nb);
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
 		spin_lock_init(&async_pf_sleepers[i].lock);
 	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
arch/x86/kvm/svm.c +0 -0
index 0b7690e..38b4705 100644
@@ -1900,10 +1900,14 @@ static int halt_interception(struct vcpu_svm *svm)
 
Quoted 14 lines

arch/x86/kvm/svm.c static int halt_interception(struct vcpu_svm *svm) · line 1910

Quoted 12 lines
arch/x86/kvm/svm.c +6 -2
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
+	int ret;
+
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	ret = kvm_emulate_hypercall(&svm->vcpu);
+
+	/* Ignore the error? */
+	return ret == 0 ? 0 : 1;

Why can't kvm_emulate_hypercall return the right value?

Quoted 4 lines

kvm_emulate_hypercall() will call kvm_hv_hypercall(), and kvm_hv_hypercall() will return 0 when vcpu's CPL > 0. If vcpu's CPL > 0, does kvm need to exit and tell it to qemu?

No, there is currently no exit to userspace due to hypercalls, neither of HV nor KVM kind.

The point is that the return code of kvm_emulate_hypercall is unused so far, so you can easily redefine it to encode continue vs. exit to userspace. Once someone has different needs, this could still be refactored again.

Quoted 6 lines
Quoted 2 lines

So, it is OK to change the return value of kvm_hv_hypercall() if vcpu's CPL > 0?

Yes, change it to encode what vendor modules need to return to their callers.

Better introduce new request flag and set it in your hypercall emulation. See how triple fault is handled.

Quoted 6 lines
Quoted 3 lines

triple fault sets KVM_EXIT_SHUTDOWN and exits to userspace. Do you mean introduce a new value(like KVM_EXIT_SHUTDOWN)?

I mean introduce new request bit (like KVM_REQ_TRIPLE_FAULT) and set it in your hypercall if exit to userspace is needed instead of changing return values.

I donot notice it. Thanks for you suggestion. I will modify my patch.

Thanks
Wen Congyang

Quoted 4 lines

--
Gleb.

#16 lore raw
In reply to Wen Congyang
Quoted 5 lines · Wen Congyang

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

What's the motivation for this? "Xen does this" is insufficient.

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

At 02/28/2012 07:23 PM, Avi Kivity Wrote:

Quoted 8 lines · Wen Congyang
Quoted 5 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

What's the motivation for this? "Xen does this" is insufficient.

Another purpose is: management app(for example: libvirt) can do auto dump when the guest is crashed. If management app does not do auto dump, the guest's user can do dump by hand if he sees the guest is paniced.

I am thinking about another status: dumping. This status tells the guest's user that the guest is paniced, and the OS's dump function is working.

These two status can tell the guest's user whether the guest is pancied, and what should he do if the guest is paniced.

Thanks
Wen Congyang

#18 lore raw
Quoted 15 lines · Wen Congyang

At 02/28/2012 07:23 PM, Avi Kivity Wrote:

Quoted 8 lines · Wen Congyang
Quoted 5 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

What's the motivation for this? "Xen does this" is insufficient.

Another purpose is: management app(for example: libvirt) can do auto dump when the guest is crashed. If management app does not do auto dump, the guest's user can do dump by hand if he sees the guest is paniced.

Quoted 7 lines

I am thinking about another status: dumping. This status tells the guest's user that the guest is paniced, and the OS's dump function is working.

These two status can tell the guest's user whether the guest is pancied, and what should he do if the guest is paniced.

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

Signature · 1 line
error compiling committee.c: too many arguments to function
#19 lore raw
Quoted 20 lines · Avi Kivity
Quoted 19 lines · Wen Congyang

At 02/28/2012 07:23 PM, Avi Kivity Wrote:

Quoted 8 lines · Wen Congyang
Quoted 5 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

What's the motivation for this? "Xen does this" is insufficient.

Another purpose is: management app(for example: libvirt) can do auto dump when the guest is crashed. If management app does not do auto dump, the guest's user can do dump by hand if he sees the guest is paniced.

I am thinking about another status: dumping. This status tells the guest's user that the guest is paniced, and the OS's dump function is working.

Quoted 7 lines
Quoted 3 lines

These two status can tell the guest's user whether the guest is pancied, and what should he do if the guest is paniced.

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

Isn't it unreliable after the guest panicked? Having special kdump kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

--
Gleb.

#20 lore raw
Quoted 6 lines · Gleb Natapov
Quoted 5 lines
Quoted 1 line

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

Isn't it unreliable after the guest panicked?

So is calling hypercalls, or dumping, or writing to the screen. Of course calling a hypercall is simpler and so is more reliable.

Quoted 3 lines

Having special kdump
kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

Yes. The "panic, starting dump" signal should be initiated by the panicking kernel though, in case the dump fails.

Signature · 1 line
error compiling committee.c: too many arguments to function
#21 lore raw
Quoted 11 lines · Avi Kivity
Quoted 6 lines · Gleb Natapov
Quoted 5 lines
Quoted 1 line

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

Isn't it unreliable after the guest panicked?

So is calling hypercalls, or dumping, or writing to the screen. Of course calling a hypercall is simpler and so is more reliable.

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Quoted 7 lines
Quoted 3 lines

Having special kdump
kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

Yes. The "panic, starting dump" signal should be initiated by the panicking kernel though, in case the dump fails.

Then panic hypercall sounds like a reasonable solution.

--
Gleb.

#22 lore raw
Quoted 9 lines · Gleb Natapov
Quoted 8 lines · Avi Kivity
Quoted 6 lines · Gleb Natapov
Quoted 5 lines
Quoted 1 line

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

Isn't it unreliable after the guest panicked?

Quoted 7 lines
Quoted 3 lines

So is calling hypercalls, or dumping, or writing to the screen. Of course calling a hypercall is simpler and so is more reliable.

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Why not print the oops to virtio-serial? Or even just a regular serial port? That's what bare metal does.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Having special kdump
kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

Yes. The "panic, starting dump" signal should be initiated by the panicking kernel though, in case the dump fails.

Then panic hypercall sounds like a reasonable solution.

It is, but I'm trying to see if we can get away with doing nothing.

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

At 02/29/2012 06:08 PM, Avi Kivity Wrote:

Quoted 13 lines · Gleb Natapov
Quoted 12 lines · Avi Kivity
Quoted 11 lines · Gleb Natapov
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

Isn't it unreliable after the guest panicked?

So is calling hypercalls, or dumping, or writing to the screen. Of course calling a hypercall is simpler and so is more reliable.

Quoted 7 lines
Quoted 4 lines

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Why not print the oops to virtio-serial? Or even just a regular serial port? That's what bare metal does.

If virtio-serial's driver has bug or the guest doesn't have such device...

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Having special kdump
kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

Yes. The "panic, starting dump" signal should be initiated by the panicking kernel though, in case the dump fails.

Then panic hypercall sounds like a reasonable solution.

It is, but I'm trying to see if we can get away with doing nothing.

If we have a reliable way with doing nothing, it is better. But I donot find such way.

Thanks
Wen Congyang

#24 lore raw
Quoted 10 lines · Wen Congyang
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Why not print the oops to virtio-serial? Or even just a regular serial port? That's what bare metal does.

If virtio-serial's driver has bug or the guest doesn't have such device...

We have the same issue with the hypercall; and virtio-serial is available on many deployed versions.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Having special kdump
kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

Yes. The "panic, starting dump" signal should be initiated by the panicking kernel though, in case the dump fails.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Then panic hypercall sounds like a reasonable solution.

It is, but I'm trying to see if we can get away with doing nothing.

If we have a reliable way with doing nothing, it is better. But I donot find such way.

We won't have a 100% reliable way. But I think a variant of the driver that doesn't use interrupts, or just using the ordinary serial driver, should be reliable enough.

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

At 02/29/2012 06:39 PM, Avi Kivity Wrote:

Quoted 7 lines · Wen Congyang
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Why not print the oops to virtio-serial? Or even just a regular serial port? That's what bare metal does.

If virtio-serial's driver has bug or the guest doesn't have such device...

We have the same issue with the hypercall; and virtio-serial is available on many deployed versions.

How to know whether a guest has virtio-serial?

Thanks
Wen Congyang

Quoted 21 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Having special kdump
kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

Yes. The "panic, starting dump" signal should be initiated by the panicking kernel though, in case the dump fails.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Then panic hypercall sounds like a reasonable solution.

It is, but I'm trying to see if we can get away with doing nothing.

If we have a reliable way with doing nothing, it is better. But I donot find such way.

We won't have a 100% reliable way. But I think a variant of the driver that doesn't use interrupts, or just using the ordinary serial driver, should be reliable enough.

#26 lore raw
In reply to Avi Kivity

At 02/29/2012 06:39 PM, Avi Kivity Wrote:

Quoted 7 lines · Wen Congyang
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Why not print the oops to virtio-serial? Or even just a regular serial port? That's what bare metal does.

If virtio-serial's driver has bug or the guest doesn't have such device...

We have the same issue with the hypercall; and virtio-serial is available on many deployed versions.

virtio-serial is available, but it is an optional device. If the guest does not have this device, the guest cannot tell the host that is is paniced. So I still prefer to touch the hypervisor.

Thanks
Wen Congyang

Quoted 21 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Having special kdump
kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

Yes. The "panic, starting dump" signal should be initiated by the panicking kernel though, in case the dump fails.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Then panic hypercall sounds like a reasonable solution.

It is, but I'm trying to see if we can get away with doing nothing.

If we have a reliable way with doing nothing, it is better. But I donot find such way.

We won't have a 100% reliable way. But I think a variant of the driver that doesn't use interrupts, or just using the ordinary serial driver, should be reliable enough.

#27 lore raw
In reply to Avi Kivity
Quoted 13 lines · Avi Kivity
Quoted 12 lines · Gleb Natapov
Quoted 11 lines · Avi Kivity
Quoted 6 lines · Gleb Natapov
Quoted 5 lines
Quoted 1 line

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

Isn't it unreliable after the guest panicked?

So is calling hypercalls, or dumping, or writing to the screen. Of course calling a hypercall is simpler and so is more reliable.

Quoted 8 lines
Quoted 4 lines

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Why not print the oops to virtio-serial? Or even just a regular serial port? That's what bare metal does.

The more interface is complex the more chances it will fail during panic. Regular serial is likely more reliable than virtio-serial. Hypercall is likely more reliable than uart. On serial user can fake panic notification. Can this be problematic?

Quoted 11 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Having special kdump
kernel that transfers dump to a host via virtio-serial channel though sounds interesting. May be that's what you mean.

Yes. The "panic, starting dump" signal should be initiated by the panicking kernel though, in case the dump fails.

Then panic hypercall sounds like a reasonable solution.

It is, but I'm trying to see if we can get away with doing nothing.

Fair enough.

--
Gleb.

#28 lore raw
Quoted 6 lines · Gleb Natapov
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Quoted 7 lines
Quoted 3 lines

Why not print the oops to virtio-serial? Or even just a regular serial port? That's what bare metal does.

The more interface is complex the more chances it will fail during panic. Regular serial is likely more reliable than virtio-serial. Hypercall is likely more reliable than uart. On serial user can fake panic notification.

The serial device is under control of the kernel, so the user can only access it if the kernel so allows.

Quoted 3 lines

Can this be problematic?

From the point of view of the guest, yes, it can generate support calls

in fill up the admin's dump quota. From the point of view of the host, there's no difference between the guest's admin and a random user.

Signature · 1 line
error compiling committee.c: too many arguments to function
#29 lore raw
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Gleb Natapov
Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Yes, crash can be so severe that it is not even detected by a kernel itself, so not OOPS message even printed. But in most cases if kernel is functional enough to print OOPS it is functional enough to call single hypercall instruction.

Why not print the oops to virtio-serial? Or even just a regular serial port? That's what bare metal does.

Quoted 8 lines
Quoted 4 lines

The more interface is complex the more chances it will fail during panic. Regular serial is likely more reliable than virtio-serial. Hypercall is likely more reliable than uart. On serial user can fake panic notification.

The serial device is under control of the kernel, so the user can only access it if the kernel so allows.

Yes, but if we will hijack UART for panic notification VM user will not be able to use it for anything else. virtio-serial have many channels, but AFAIK it does not work at early stages of boot process.

--
Gleb.

#30 lore raw
In reply to Avi Kivity
Quoted 20 lines · Avi Kivity
Quoted 19 lines · Wen Congyang

At 02/28/2012 07:23 PM, Avi Kivity Wrote:

Quoted 8 lines · Wen Congyang
Quoted 5 lines

We can know the guest is paniced when the guest runs on xen. But we do not have such feature on kvm. This patch implemnts this feature, and the implementation is the same as xen:
register panic notifier, and call hypercall when the guest is paniced.

What's the motivation for this? "Xen does this" is insufficient.

Another purpose is: management app(for example: libvirt) can do auto dump when the guest is crashed. If management app does not do auto dump, the guest's user can do dump by hand if he sees the guest is paniced.

I am thinking about another status: dumping. This status tells the guest's user that the guest is paniced, and the OS's dump function is working.

Quoted 6 lines
Quoted 3 lines

These two status can tell the guest's user whether the guest is pancied, and what should he do if the guest is paniced.

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

When the guest OS has crashed, any dumps will be done from the host OS using libvirt's core dump mechanism. The guest OS isn't involved and is likely too dead to be of any use anyway. Likewise it is quite probably too dead to work a virtio-serial channel or any similarly complex device. We're really just after the simplest possible notification that the guest kernel has paniced.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#31 lore raw
Quoted 10 lines · Daniel P. Berrange
Quoted 3 lines

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

When the guest OS has crashed, any dumps will be done from the host OS using libvirt's core dump mechanism. The guest OS isn't involved and is likely too dead to be of any use anyway. Likewise it is quite probably too dead to work a virtio-serial channel or any similarly complex device. We're really just after the simplest possible notification that the guest kernel has paniced.

If it's alive enough to panic, it's alive enough to kexec its kdump kernel. After that it can do anything.

Guest-internal dumps are more useful IMO that host-initiated dumps. In a cloud, the host-initiated dump is left on the host, outside the reach of the guest admin, outside the guest image where all the symbols are, and sometimes not even on the same host if a live migration occurred. It's more useful in small setups, or if the problem is in the hypervisor, not the guest.

Signature · 1 line
error compiling committee.c: too many arguments to function
#32 lore raw
Quoted 15 lines · Avi Kivity
Quoted 10 lines · Daniel P. Berrange
Quoted 3 lines

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

When the guest OS has crashed, any dumps will be done from the host OS using libvirt's core dump mechanism. The guest OS isn't involved and is likely too dead to be of any use anyway. Likewise it is quite probably too dead to work a virtio-serial channel or any similarly complex device. We're really just after the simplest possible notification that the guest kernel has paniced.

If it's alive enough to panic, it's alive enough to kexec its kdump kernel. After that it can do anything.

Quoted 6 lines

Guest-internal dumps are more useful IMO that host-initiated dumps. In a cloud, the host-initiated dump is left on the host, outside the reach of the guest admin, outside the guest image where all the symbols are, and sometimes not even on the same host if a live migration occurred. It's more useful in small setups, or if the problem is in the hypervisor, not the guest.

I don't think guest vs host dumps should be considered mutually exclusive, they both have pluses+minuses.

Configuring kexec+kdump requires non-negligable guest admin configuration work before it's usable, and this work is guest OS specific, if it is possible at all. A permanent panic notifier that's built in the kernel by default requires zero guest admin config, and can allow host admin to automate collection of dumps across all their hosts/guests. The KVM hypercall notification is fairly trivially ported to any OS kernel, by comparison with a full virtio + virtio-serial impl.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#33 lore raw
Quoted 23 lines · Daniel P. Berrange
Quoted 15 lines · Avi Kivity
Quoted 10 lines · Daniel P. Berrange
Quoted 3 lines

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

When the guest OS has crashed, any dumps will be done from the host OS using libvirt's core dump mechanism. The guest OS isn't involved and is likely too dead to be of any use anyway. Likewise it is quite probably too dead to work a virtio-serial channel or any similarly complex device. We're really just after the simplest possible notification that the guest kernel has paniced.

If it's alive enough to panic, it's alive enough to kexec its kdump kernel. After that it can do anything.

Quoted 6 lines

Guest-internal dumps are more useful IMO that host-initiated dumps. In a cloud, the host-initiated dump is left on the host, outside the reach of the guest admin, outside the guest image where all the symbols are, and sometimes not even on the same host if a live migration occurred. It's more useful in small setups, or if the problem is in the hypervisor, not the guest.

Quoted 2 lines

I don't think guest vs host dumps should be considered mutually exclusive, they both have pluses+minuses.

True.

Quoted 3 lines

Configuring kexec+kdump requires non-negligable guest admin configuration work before it's usable, and this work is guest OS specific, if it is possible at all.

I think it's on by default on Windows and requires installing a package on Linux, which may be part of the default configuration on many distros.

Quoted 5 lines

A permanent panic notifier that's built in the kernel by default requires zero guest admin config, and can allow host admin to automate collection of dumps across all their hosts/guests. The KVM hypercall notification is fairly trivially ported to any OS kernel, by comparison with a full virtio + virtio-serial impl.

That's the path of least resistance. But it's not necessarily the best path. We end up with a wide set of disconnected ABIs instead of a narrow set that is more flexible.

Signature · 1 line
error compiling committee.c: too many arguments to function
#34 lore raw
In reply to Avi Kivity

At 02/29/2012 06:05 PM, Avi Kivity Wrote:

Quoted 12 lines · Daniel P. Berrange
Quoted 10 lines
Quoted 3 lines

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

When the guest OS has crashed, any dumps will be done from the host OS using libvirt's core dump mechanism. The guest OS isn't involved and is likely too dead to be of any use anyway. Likewise it is quite probably too dead to work a virtio-serial channel or any similarly complex device. We're really just after the simplest possible notification that the guest kernel has paniced.

Quoted 4 lines

If it's alive enough to panic, it's alive enough to kexec its kdump kernel. After that it can do anything.

Guest-internal dumps are more useful IMO that host-initiated dumps. In

Yes, guest-internal dump is better than host dump. But the user may not start guest-internal dump or guest-internal dump failed. So we need the following feature:
1. If the guest-internal dump does not work, the guest's status is 'crashed'. And then the user does the host dump.
2. If the guest-internal dump is working, the guest's status should be 'dumping'. The user see this status and know the guest has paniced, and the guest-internal dump is working.

Thanks
Wen Congyang

Quoted 6 lines

a cloud, the host-initiated dump is left on the host, outside the reach of the guest admin, outside the guest image where all the symbols are, and sometimes not even on the same host if a live migration occurred. It's more useful in small setups, or if the problem is in the hypervisor, not the guest.

#35 lore raw
Quoted 18 lines · Wen Congyang

At 02/29/2012 06:05 PM, Avi Kivity Wrote:

Quoted 12 lines · Daniel P. Berrange
Quoted 10 lines
Quoted 3 lines

How about using a virtio-serial channel for this? You can transfer any amount of information (including the dump itself).

When the guest OS has crashed, any dumps will be done from the host OS using libvirt's core dump mechanism. The guest OS isn't involved and is likely too dead to be of any use anyway. Likewise it is quite probably too dead to work a virtio-serial channel or any similarly complex device. We're really just after the simplest possible notification that the guest kernel has paniced.

Quoted 4 lines

If it's alive enough to panic, it's alive enough to kexec its kdump kernel. After that it can do anything.

Guest-internal dumps are more useful IMO that host-initiated dumps. In

Quoted 8 lines

Yes, guest-internal dump is better than host dump. But the user may not start guest-internal dump or guest-internal dump failed. So we need the following feature:
1. If the guest-internal dump does not work, the guest's status is 'crashed'. And then the user does the host dump.
2. If the guest-internal dump is working, the guest's status should be 'dumping'. The user see this status and know the guest has paniced, and the guest-internal dump is working.

I agree. There is room for host dump, and we do want notification about what the guest is doing. The question is whether we should reuse virtio-serial for guest-host communication in this case. It's more complicated, but allows us to avoid touching the hypervisor.

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