All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
Cc: gleb@kernel.org, agraf@suse.de, kvm-ppc@vger.kernel.org,
	paulus@ozlabs.org, linuxppc-dev@ozlabs.org, pbonzini@redhat.com,
	mahesh@linux.vnet.ibm.com, kvm@vger.kernel.org,
	mpe@ellerman.id.au
Subject: Re: [PATCH v3 1/2] KVM: PPC: New capability to control MCE behaviour
Date: Thu, 14 Jan 2016 00:05:54 +0000	[thread overview]
Message-ID: <20160114000554.GC22925@voom.redhat.com> (raw)
In-Reply-To: <20160114000239.GB22925@voom.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4455 bytes --]

On Thu, Jan 14, 2016 at 11:02:39AM +1100, David Gibson wrote:
> On Wed, Jan 13, 2016 at 12:37:59PM +0530, Aravinda Prasad wrote:
> > This patch introduces a new KVM capability to control
> > how KVM behaves on machine check exception (MCE).
> > Without this capability, KVM redirects machine check
> > exceptions to guest's 0x200 vector if the address in
> > error belongs to the guest. With this capability KVM
> > causes a guest exit with NMI exit reason.
> > 
> > This is required to avoid problems if a new kernel/KVM
> > is used with an old QEMU for guests that don't issue
> > "ibm,nmi-register". As old QEMU does not understand the
> > NMI exit type, it treats it as a fatal error. However,
> > the guest could have handled the machine check error
> > if the exception was delivered to guest's 0x200 interrupt
> > vector instead of NMI exit in case of old QEMU.
> > 
> > QEMU part can be found at:
> > http://lists.nongnu.org/archive/html/qemu-ppc/2015-12/msg00199.html
> > 
> > Change Log v3:
> >   - Split the patch into 2. First patch introduces the
> >     new capability while the second one enhances KVM to
> >     redirect MCE.
> >   - Fix access width bug
> >   - Rebased to v4.4-rc7
> > 
> > Change Log v2:
> >   - Added KVM capability
> > 
> > Signed-off-by: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
> > ---
> >  arch/powerpc/include/asm/kvm_host.h |    1 +
> >  arch/powerpc/kernel/asm-offsets.c   |    1 +
> >  arch/powerpc/kvm/powerpc.c          |    7 +++++++
> >  include/uapi/linux/kvm.h            |    1 +
> >  4 files changed, 10 insertions(+)
> > 
> > diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> > index cfa758c..9ac2b84 100644
> > --- a/arch/powerpc/include/asm/kvm_host.h
> > +++ b/arch/powerpc/include/asm/kvm_host.h
> > @@ -243,6 +243,7 @@ struct kvm_arch {
> >  	int hpt_cma_alloc;
> >  	struct dentry *debugfs_dir;
> >  	struct dentry *htab_dentry;
> > +	u8 fwnmi_enabled;
> 
> Um.. I don't see anything in this patch or 2/2 which actually tests
> this flag...

Sorry, I missed it in the asm, spotted it now.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> 
> >  #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
> >  #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
> >  	struct mutex hpt_mutex;
> > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> > index 221d584..6a4e81a 100644
> > --- a/arch/powerpc/kernel/asm-offsets.c
> > +++ b/arch/powerpc/kernel/asm-offsets.c
> > @@ -506,6 +506,7 @@ int main(void)
> >  	DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls));
> >  	DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr));
> >  	DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v));
> > +	DEFINE(KVM_FWNMI, offsetof(struct kvm, arch.fwnmi_enabled));
> >  	DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr));
> >  	DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar));
> >  	DEFINE(VCPU_VPA, offsetof(struct kvm_vcpu, arch.vpa.pinned_addr));
> > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> > index 6fd2405..a8399b5 100644
> > --- a/arch/powerpc/kvm/powerpc.c
> > +++ b/arch/powerpc/kvm/powerpc.c
> > @@ -570,6 +570,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
> >  		r = 1;
> >  		break;
> >  #endif
> > +	case KVM_CAP_PPC_FWNMI:
> > +		r = 1;
> > +		break;
> >  	default:
> >  		r = 0;
> >  		break;
> > @@ -1132,6 +1135,10 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
> >  		break;
> >  	}
> >  #endif /* CONFIG_KVM_XICS */
> > +	case KVM_CAP_PPC_FWNMI:
> > +		r = 0;
> > +		vcpu->kvm->arch.fwnmi_enabled = true;
> > +		break;
> >  	default:
> >  		r = -EINVAL;
> >  		break;
> > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> > index 03f3618..d8a07b5 100644
> > --- a/include/uapi/linux/kvm.h
> > +++ b/include/uapi/linux/kvm.h
> > @@ -831,6 +831,7 @@ struct kvm_ppc_smmu_info {
> >  #define KVM_CAP_GUEST_DEBUG_HW_WPS 120
> >  #define KVM_CAP_SPLIT_IRQCHIP 121
> >  #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122
> > +#define KVM_CAP_PPC_FWNMI 123
> >  
> >  #ifdef KVM_CAP_IRQ_ROUTING
> >  
> > 
> 



-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: David Gibson <david@gibson.dropbear.id.au>
To: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
Cc: gleb@kernel.org, agraf@suse.de, kvm-ppc@vger.kernel.org,
	paulus@ozlabs.org, linuxppc-dev@ozlabs.org, pbonzini@redhat.com,
	mahesh@linux.vnet.ibm.com, kvm@vger.kernel.org,
	mpe@ellerman.id.au
Subject: Re: [PATCH v3 1/2] KVM: PPC: New capability to control MCE behaviour
Date: Thu, 14 Jan 2016 11:05:54 +1100	[thread overview]
Message-ID: <20160114000554.GC22925@voom.redhat.com> (raw)
In-Reply-To: <20160114000239.GB22925@voom.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4455 bytes --]

On Thu, Jan 14, 2016 at 11:02:39AM +1100, David Gibson wrote:
> On Wed, Jan 13, 2016 at 12:37:59PM +0530, Aravinda Prasad wrote:
> > This patch introduces a new KVM capability to control
> > how KVM behaves on machine check exception (MCE).
> > Without this capability, KVM redirects machine check
> > exceptions to guest's 0x200 vector if the address in
> > error belongs to the guest. With this capability KVM
> > causes a guest exit with NMI exit reason.
> > 
> > This is required to avoid problems if a new kernel/KVM
> > is used with an old QEMU for guests that don't issue
> > "ibm,nmi-register". As old QEMU does not understand the
> > NMI exit type, it treats it as a fatal error. However,
> > the guest could have handled the machine check error
> > if the exception was delivered to guest's 0x200 interrupt
> > vector instead of NMI exit in case of old QEMU.
> > 
> > QEMU part can be found at:
> > http://lists.nongnu.org/archive/html/qemu-ppc/2015-12/msg00199.html
> > 
> > Change Log v3:
> >   - Split the patch into 2. First patch introduces the
> >     new capability while the second one enhances KVM to
> >     redirect MCE.
> >   - Fix access width bug
> >   - Rebased to v4.4-rc7
> > 
> > Change Log v2:
> >   - Added KVM capability
> > 
> > Signed-off-by: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
> > ---
> >  arch/powerpc/include/asm/kvm_host.h |    1 +
> >  arch/powerpc/kernel/asm-offsets.c   |    1 +
> >  arch/powerpc/kvm/powerpc.c          |    7 +++++++
> >  include/uapi/linux/kvm.h            |    1 +
> >  4 files changed, 10 insertions(+)
> > 
> > diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> > index cfa758c..9ac2b84 100644
> > --- a/arch/powerpc/include/asm/kvm_host.h
> > +++ b/arch/powerpc/include/asm/kvm_host.h
> > @@ -243,6 +243,7 @@ struct kvm_arch {
> >  	int hpt_cma_alloc;
> >  	struct dentry *debugfs_dir;
> >  	struct dentry *htab_dentry;
> > +	u8 fwnmi_enabled;
> 
> Um.. I don't see anything in this patch or 2/2 which actually tests
> this flag...

Sorry, I missed it in the asm, spotted it now.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> 
> >  #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
> >  #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
> >  	struct mutex hpt_mutex;
> > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> > index 221d584..6a4e81a 100644
> > --- a/arch/powerpc/kernel/asm-offsets.c
> > +++ b/arch/powerpc/kernel/asm-offsets.c
> > @@ -506,6 +506,7 @@ int main(void)
> >  	DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls));
> >  	DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr));
> >  	DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v));
> > +	DEFINE(KVM_FWNMI, offsetof(struct kvm, arch.fwnmi_enabled));
> >  	DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr));
> >  	DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar));
> >  	DEFINE(VCPU_VPA, offsetof(struct kvm_vcpu, arch.vpa.pinned_addr));
> > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> > index 6fd2405..a8399b5 100644
> > --- a/arch/powerpc/kvm/powerpc.c
> > +++ b/arch/powerpc/kvm/powerpc.c
> > @@ -570,6 +570,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
> >  		r = 1;
> >  		break;
> >  #endif
> > +	case KVM_CAP_PPC_FWNMI:
> > +		r = 1;
> > +		break;
> >  	default:
> >  		r = 0;
> >  		break;
> > @@ -1132,6 +1135,10 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
> >  		break;
> >  	}
> >  #endif /* CONFIG_KVM_XICS */
> > +	case KVM_CAP_PPC_FWNMI:
> > +		r = 0;
> > +		vcpu->kvm->arch.fwnmi_enabled = true;
> > +		break;
> >  	default:
> >  		r = -EINVAL;
> >  		break;
> > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> > index 03f3618..d8a07b5 100644
> > --- a/include/uapi/linux/kvm.h
> > +++ b/include/uapi/linux/kvm.h
> > @@ -831,6 +831,7 @@ struct kvm_ppc_smmu_info {
> >  #define KVM_CAP_GUEST_DEBUG_HW_WPS 120
> >  #define KVM_CAP_SPLIT_IRQCHIP 121
> >  #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122
> > +#define KVM_CAP_PPC_FWNMI 123
> >  
> >  #ifdef KVM_CAP_IRQ_ROUTING
> >  
> > 
> 



-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-01-14  0:05 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-13  7:07 [PATCH v3 1/2] KVM: PPC: New capability to control MCE behaviour Aravinda Prasad
2016-01-13  7:19 ` Aravinda Prasad
2016-01-13  7:08 ` [PATCH v3 2/2] KVM: PPC: Exit guest upon MCE when FWNMI capability is enabled Aravinda Prasad
2016-01-13  7:20   ` Aravinda Prasad
2016-01-14  0:06   ` David Gibson
2016-01-14  0:06     ` David Gibson
2016-01-23 10:28   ` Paul Mackerras
2016-01-23 10:28     ` Paul Mackerras
2016-01-23 12:53     ` Aravinda Prasad
2016-01-23 12:53       ` Aravinda Prasad
2016-01-23 21:24       ` Paul Mackerras
2016-01-23 21:24         ` Paul Mackerras
2016-01-23 21:24         ` Paul Mackerras
2016-01-25  8:39         ` Aravinda Prasad
2016-01-25  8:51           ` Aravinda Prasad
2016-01-27  5:02         ` Mahesh Jagannath Salgaonkar
2016-01-27  5:14           ` Mahesh Jagannath Salgaonkar
2016-01-27  5:02           ` Mahesh Jagannath Salgaonkar
2016-06-20  5:18   ` Paul Mackerras
2016-06-20  5:18     ` Paul Mackerras
2016-06-20  5:18     ` Paul Mackerras
2016-06-21 21:01     ` Aravinda Prasad
2016-06-21 21:13       ` Aravinda Prasad
2016-01-14  0:02 ` [PATCH v3 1/2] KVM: PPC: New capability to control MCE behaviour David Gibson
2016-01-14  0:02   ` David Gibson
2016-01-14  0:05   ` David Gibson [this message]
2016-01-14  0:05     ` David Gibson
2016-01-23 10:20 ` Paul Mackerras
2016-01-23 10:20   ` Paul Mackerras
2016-01-23 12:28   ` Aravinda Prasad
2016-01-23 12:40     ` Aravinda Prasad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160114000554.GC22925@voom.redhat.com \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=aravinda@linux.vnet.ibm.com \
    --cc=gleb@kernel.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@ozlabs.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.