Skip to contentSkip to conversation

KVM: Document KVM_NMI

PATCH Applied Avi Kivity 3 participants 8 messages Dec 7, 2011 – Dec 14, 2011

Subsystems (2)
lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 KVM: Document KVM_NMI

---
 Documentation/virtual/kvm/api.txt |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
Documentation/virtual/kvm/api.txt +25 -0
index 7945b0b..38f68ca 100644
@@ -1450,6 +1450,31 @@ is supported; 2 if the processor requires all virtual machines to have
 an RMA, or 1 if the processor can use an RMA but doesn't require it,
 because it supports the Virtual RMA (VRMA) facility.
 
+4.64 KVM_NMI
+
+Capability: KVM_CAP_USER_NMI
+Architectures: x86
+Type: vcpu ioctl
+Parameters: none
+Returns: 0 on success, -1 on error
+
+Queues an NMI on the thread's vcpu.  Note this is well defined only
+when KVM_CREATE_IRQCHIP has not been called, since this is an interface
+between the virtual cpu core and virtual local APIC.  After KVM_CREATE_IRQCHIP
+has been called, this interface is completely emulated within the kernel.
+
+To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the
+following algorithm:
+
+  - pause the vpcu
+  - read the local APIC's state (KVM_GET_LAPIC)
+  - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1)
+  - if so, issue KVM_NMI
+  - resume the vcpu
+
+Some guests configure the LINT1 NMI input to cause a panic, aiding in
+debugging.
+
 5. The kvm_run structure
 
 Application code obtains a pointer to the kvm_run structure by
Signature · 1 line
1.7.7.1
#1 lore raw
Quoted 20 lines · Avi Kivity
---
 Documentation/virtual/kvm/api.txt |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
Documentation/virtual/kvm/api.txt +7 -0
index 7945b0b..38f68ca 100644
@@ -1450,6 +1450,31 @@ is supported; 2 if the processor requires all virtual machines to have
 an RMA, or 1 if the processor can use an RMA but doesn't require it,
 because it supports the Virtual RMA (VRMA) facility.
 
+4.64 KVM_NMI
+
+Capability: KVM_CAP_USER_NMI
+Architectures: x86
+Type: vcpu ioctl
+Parameters: none
+Returns: 0 on success, -1 on error

Documentation/virtual/kvm/api.txt is supported; 2 if the processor requires all virtual machines to have · line 1469

Quoted 10 lines
Documentation/virtual/kvm/api.txt +10 -0
+
+Queues an NMI on the thread's vcpu.  Note this is well defined only
+when KVM_CREATE_IRQCHIP has not been called, since this is an interface
+between the virtual cpu core and virtual local APIC.  After KVM_CREATE_IRQCHIP
+has been called, this interface is completely emulated within the kernel.
+
+To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the
+following algorithm:
+
+  - pause the vpcu

I don't see the QEMU patch doing a stop before grabbing LAPIC state. Or does it happen somewhere before?

Signature · 1 line
Sasha.
author
#2 lore raw
Quoted 2 lines · Sasha Levin

I don't see the QEMU patch doing a stop before grabbing LAPIC state. Or does it happen somewhere before?

It got dropped on the floor; it's now in next.

Signature · 1 line
error compiling committee.c: too many arguments to function
#3 lore raw
Quoted 5 lines · Avi Kivity
Quoted 2 lines · Sasha Levin

I don't see the QEMU patch doing a stop before grabbing LAPIC state. Or does it happen somewhere before?

It got dropped on the floor; it's now in next.

I was talking about that patch you merged. I don't see where the vcpu is being paused before getting the LAPIC state.

Signature · 1 line
Sasha.
author
#4 lore raw
Quoted 10 lines · Sasha Levin
Quoted 5 lines · Avi Kivity
Quoted 2 lines · Sasha Levin

I don't see the QEMU patch doing a stop before grabbing LAPIC state. Or does it happen somewhere before?

It got dropped on the floor; it's now in next.

I was talking about that patch you merged. I don't see where the vcpu is being paused before getting the LAPIC state.

Oh, sorry. Well, once you exit from KVM_RUN, the vcpu is paused.

It's really implied by the fact that vcpu ioctls must be issued from the same thread.

Signature · 1 line
error compiling committee.c: too many arguments to function
#5 lore raw
Quoted 8 lines · Avi Kivity
Quoted 7 lines · Sasha Levin
Quoted 5 lines · Avi Kivity
Quoted 2 lines · Sasha Levin

I don't see the QEMU patch doing a stop before grabbing LAPIC state. Or does it happen somewhere before?

It got dropped on the floor; it's now in next.

Quoted 8 lines
Quoted 3 lines

I was talking about that patch you merged. I don't see where the vcpu is being paused before getting the LAPIC state.

Oh, sorry. Well, once you exit from KVM_RUN, the vcpu is paused.

It's really implied by the fact that vcpu ioctls must be issued from the same thread.

Oh, I totally forgot about that (here, and in my 'kvm nmi' patch).

Thanks!

Signature · 1 line
Sasha.
author
#6 lore raw
Quoted 5 lines · Sasha Levin
Quoted 3 lines

It's really implied by the fact that vcpu ioctls must be issued from the same thread.

Oh, I totally forgot about that (here, and in my 'kvm nmi' patch).

It keeps biting people. We should make the kernel warn about it.

The reason it's important is because we might some day want to move to a syscall based API, rather than ioctl based. In this model a vcpu is bound to the thread that calls kvm_create_vcpu(2), and all vcpu syscalls derive the vcpu from the thread.

This model is more natural than the ioctl model, however it is a lot of work and doesn't solve any real life problems; it only creates a larger compatibility burden. But it's still the right thing.

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