From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9PlR-00063o-Ux for qemu-devel@nongnu.org; Wed, 16 Dec 2015 23:02:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9PlO-000296-Nv for qemu-devel@nongnu.org; Wed, 16 Dec 2015 23:02:01 -0500 Date: Thu, 17 Dec 2015 15:02:29 +1100 From: David Gibson Message-ID: <20151217040229.GJ3011@voom.redhat.com> References: <20151216060551.10636.77403.stgit@aravindap> <20151216060847.10636.76722.stgit@aravindap> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="AXxEqdD4tcVTjWte" Content-Disposition: inline In-Reply-To: <20151216060847.10636.76722.stgit@aravindap> Subject: Re: [Qemu-devel] [PATCH v2 4/4] spapr: Introduce FWNMI KVM capability List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aravinda Prasad Cc: benh@au1.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, paulus@samba.org, sam.bobroff@au1.ibm.com --AXxEqdD4tcVTjWte Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 16, 2015 at 11:38:47AM +0530, Aravinda Prasad wrote: > Introduce a new KVM capability to control how KVM > behaves on machine check exception. >=20 > Without this capability, KVM redirects machine check > exceptions to guest's 0x200 vector if the address in > error belongs to guest. With this capability KVM > causes a guest exit with NMI exit reason. >=20 > This is required to avoid problem if a new kernel/KVM > is used with an old QEMU. As old QEMU might not > understand the new NMI exit type and treat it as a > fatal error, even though the guest could have actually > handled the error if the exception was delivered to > guest's 0x200 interrupt vector. >=20 > PS: KVM_CAP_PPC_FWNMI is set to 121 as 119 and 120 are > used by KVM_CAP_GUEST_DEBUG_HW_BPS and KVM_CAP_GUEST_DEBUG_HW_WPS > in KVM code, but still not reflected in QEMU code. The commit message seems to be written as if this were the kernel patch adding the capability there, rather than the qemu patch using it. > Signed-off-by: Aravinda Prasad > --- > hw/ppc/spapr_rtas.c | 17 +++++++++++++++++ > linux-headers/linux/kvm.h | 1 + > target-ppc/kvm.c | 2 ++ > 3 files changed, 20 insertions(+) >=20 > diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c > index 17c4672..53319da 100644 > --- a/hw/ppc/spapr_rtas.c > +++ b/hw/ppc/spapr_rtas.c > @@ -38,6 +38,8 @@ > #include > #include "hw/ppc/spapr_drc.h" > =20 > +extern int cap_fwnmi; > + > /* #define DEBUG_SPAPR */ > =20 > #ifdef DEBUG_SPAPR > @@ -603,9 +605,24 @@ static void rtas_ibm_nmi_register(PowerPCCPU *cpu, > target_ulong args, > uint32_t nret, target_ulong rets) > { > + int ret; > + CPUState *cs =3D CPU(cpu); > + > + if (!cap_fwnmi) { > + rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); > + return; > + } > + > spapr->mc_in_progress =3D false; > qemu_cond_init(&spapr->mc_delivery_cond); > spapr->guest_machine_check_addr =3D rtas_ld(args, 1); > + > + ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_FWNMI, 0); > + if (ret < 0) { > + rtas_st(rets, 0, RTAS_OUT_HW_ERROR); > + return; > + } > + > rtas_st(rets, 0, RTAS_OUT_SUCCESS); > } > =20 > diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h > index 683f713..2db1fba 100644 > --- a/linux-headers/linux/kvm.h > +++ b/linux-headers/linux/kvm.h > @@ -819,6 +819,7 @@ struct kvm_ppc_smmu_info { > #define KVM_CAP_DISABLE_QUIRKS 116 > #define KVM_CAP_X86_SMM 117 > #define KVM_CAP_MULTI_ADDRESS_SPACE 118 > +#define KVM_CAP_PPC_FWNMI 121 > =20 > #ifdef KVM_CAP_IRQ_ROUTING > =20 > diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c > index 2bbb46d..5339c04 100644 > --- a/target-ppc/kvm.c > +++ b/target-ppc/kvm.c > @@ -74,6 +74,7 @@ static int cap_ppc_watchdog; > static int cap_papr; > static int cap_htab_fd; > static int cap_fixup_hcalls; > +int cap_fwnmi; > =20 > static uint32_t debug_inst_opcode; > =20 > @@ -116,6 +117,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) > * only activated after this by kvmppc_set_papr() */ > cap_htab_fd =3D kvm_check_extension(s, KVM_CAP_PPC_HTAB_FD); > cap_fixup_hcalls =3D kvm_check_extension(s, KVM_CAP_PPC_FIXUP_HCALL); > + cap_fwnmi =3D kvm_check_extension(s, KVM_CAP_PPC_FWNMI); > =20 > if (!cap_interrupt_level) { > fprintf(stderr, "KVM: Couldn't find level irq capability. Expect= the " >=20 --=20 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 --AXxEqdD4tcVTjWte Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWcjPVAAoJEGw4ysog2bOSJN4QALMHV0hGR70GePiyaRt9WU96 TPwitGw6G41FMxv/byS0lOZANDseFl0tyZVaAqdbor3oIIkUajPMQjyneh83lYtv jML0vD243uHESN//eIaNGKlPvhpFSMH58BzOLdr37CMZaYH4vEByrIsQFjkmaMT8 R5ByQI0PXyRnMcXOfSyX66zohXTavVZEvtQy/CZIhVYX5DS5nJcwmzDhdVNYYsFS V9YdP/MToinR5ofg8I6yPPtPBs1BJOvHGXXSlcA5VK3UAgxzrNhnVI3emMJSSqUC CJ2H5XEIL541qzaEQz2Ok7cyVI61Ov8eyfvNIDL/cE8Xoy+qNdaLU0NHKZdxdRum f/WbyyynnMS1skuXE4KYkUcRBfYJZR7zQ6uJDZtUesJ46/mRDO2oW5K0DizDdxAw nkZUM1Gh3ABqkyy2+yVn4oYcMPHrsbxGsqsC8ODYH6RgsXPnYnOxwBpqCpYY9YXB q7Whn9+iscHhudyKMEwed+i3CfzJ7iiLQqXgQ6ScXAVumZBkMKiN9UeTxoon7cqV +JTEcn0uuYBf+Cl2lkT3PcEGy373DXfbBjGLckSovmkd7hBfj+HlDVAHs5qD974j OfGBu4l2O9PMz2NSN7+gAnfUMNQ71dETskOjIprSH7VYHpaWLjMxA+aajIOLuw2T zHVhhJFxnfW5R0cB3TaU =v9So -----END PGP SIGNATURE----- --AXxEqdD4tcVTjWte--