Re: [RFC] nmi watchdog in kvm

Joerg Roedel
2008-01-28T12:29:25Z

On Mon, Jan 28, 2008 at 01:48:40PM +0530, Balaji Rao wrote:
> Hello,
>
> I was trying to enable the use of nmi watchdog within a linux guest running in kvm. I have done it
> by allowing direct access to perfmon msrs using the MSR_BITMAP field in vmcs region.

Is there a proper virtualization of the performance counter MSRs on
Intel? If not this patch will destroy any host side performance
monitoring.

> Most of the times the NMI Watchdog Test in the guest fails, but with a finite number of NMI's
> received by the guest. But randomly it does work! Whenever it fails, i get this vmwrite error :
>
> vmwrite error: reg 4016 value 80000202 (err 164061)
>
> I have a few questions.
>
> 1. How are NMI's supposed to be delivered to the guest ? I did this by adding a new op to
> kvm_x86_ops.
> 2. How am I supposed to handle perfmon MSRs ? Direct access may pose problems during migration. But
> am not sure how costly emulation by abstraction would be..
> I have not yet considered saving the MSRS upon vmexits to allow multiple VMs use the MSRs. I think i
> can do them easily when i get this working.

This patch kills the ability of KVM to migrate between AMD and Intel
because the Intel performance counters are not available on AMD and vice
verca.

> diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
> index 67ae307..f17248d 100644
> --- a/include/asm-x86/kvm_host.h
> +++ b/include/asm-x86/kvm_host.h
> @@ -387,6 +387,7 @@ struct kvm_x86_ops {
> void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr,
> bool has_error_code, u32 error_code);
> bool (*exception_injected)(struct kvm_vcpu *vcpu);
> + void (*inject_nmi)(struct kvm_vcpu *vcpu);

The implementation of this new callback for SVM is missing.

> void (*inject_pending_irq)(struct kvm_vcpu *vcpu);
> void (*inject_pending_vectors)(struct kvm_vcpu *vcpu,
> struct kvm_run *run);
> ---

--
| AMD Saxony Limited Liability Company & Co. KG
Operating | Wilschdorfer Landstr. 101, 01109 Dresden, Germany
System | Register Court Dresden: HRA 4896
Research | General Partner authorized to represent:
Center | AMD Saxony LLC (Wilmington, Delaware, US)
| General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy