From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 04/35] Add "broadcast" option for mce command Date: Sun, 09 Jan 2011 19:51:20 +0100 Message-ID: <4D2A03A8.9080600@web.de> References: <497ea69043289b0421a8265f32e9b1a80a3c9481.1294336601.git.mtosatti@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig2F5C112F4F895B68E668958C" Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Jin Dongming To: Marcelo Tosatti , Anthony Liguori Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:34661 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751237Ab1AISv0 (ORCPT ); Sun, 9 Jan 2011 13:51:26 -0500 In-Reply-To: <497ea69043289b0421a8265f32e9b1a80a3c9481.1294336601.git.mtosatti@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2F5C112F4F895B68E668958C Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Am 06.01.2011 18:56, Marcelo Tosatti wrote: > From: Jin Dongming >=20 > When the following test case is injected with mce command, maybe user c= ould not > get the expected result. > DATA > command cpu bank status mcg_status addr m= isc > (qemu) mce 1 1 0xbd00000000000000 0x05 0x1234 0= x8c >=20 > Expected Result > panic type: "Fatal Machine check" >=20 > That is because each mce command can only inject the given cpu and coul= d not > inject mce interrupt to other cpus. So user will get the following resu= lt: > panic type: "Fatal machine check on current CPU" >=20 > "broadcast" option is used for injecting dummy data into other cpus. In= jecting > mce with this option the expected result could be gotten. >=20 > Usage: > Broadcast[on] > command broadcast cpu bank status mcg_status ad= dr misc > (qemu) mce -b 1 1 0xbd00000000000000 0x05 0x= 1234 0x8c >=20 > Broadcast[off] > command cpu bank status mcg_status addr misc > (qemu) mce 1 1 0xbd00000000000000 0x05 0x1234 0x8c >=20 > Signed-off-by: Jin Dongming > Signed-off-by: Marcelo Tosatti > --- > cpu-all.h | 3 ++- > hmp-commands.hx | 6 +++--- > monitor.c | 7 +++++-- > target-i386/helper.c | 20 ++++++++++++++++++-- > target-i386/kvm.c | 16 ++++++++++++---- > target-i386/kvm_x86.h | 5 ++++- > 6 files changed, 44 insertions(+), 13 deletions(-) >=20 > diff --git a/cpu-all.h b/cpu-all.h > index 30ae17d..4ce4e83 100644 > --- a/cpu-all.h > +++ b/cpu-all.h > @@ -964,6 +964,7 @@ int cpu_memory_rw_debug(CPUState *env, target_ulong= addr, > uint8_t *buf, int len, int is_write); > =20 > void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, > - uint64_t mcg_status, uint64_t addr, uint64_t m= isc); > + uint64_t mcg_status, uint64_t addr, uint64_t m= isc, > + int broadcast); > =20 > #endif /* CPU_ALL_H */ > diff --git a/hmp-commands.hx b/hmp-commands.hx > index df134f8..c82fb10 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -1091,9 +1091,9 @@ ETEXI > =20 > { > .name =3D "mce", > - .args_type =3D "cpu_index:i,bank:i,status:l,mcg_status:l,addr= :l,misc:l", > - .params =3D "cpu bank status mcgstatus addr misc", > - .help =3D "inject a MCE on the given CPU", > + .args_type =3D "broadcast:-b,cpu_index:i,bank:i,status:l,mcg_= status:l,addr:l,misc:l", > + .params =3D "[-b] cpu bank status mcgstatus addr misc", > + .help =3D "inject a MCE on the given CPU [and broadcast = to other CPUs with -b option]", > .mhandler.cmd =3D do_inject_mce, > }, > =20 > diff --git a/monitor.c b/monitor.c > index f258000..f4f624b 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -2671,12 +2671,15 @@ static void do_inject_mce(Monitor *mon, const Q= Dict *qdict) > uint64_t mcg_status =3D qdict_get_int(qdict, "mcg_status"); > uint64_t addr =3D qdict_get_int(qdict, "addr"); > uint64_t misc =3D qdict_get_int(qdict, "misc"); > + int broadcast =3D qdict_get_try_bool(qdict, "broadcast", 0); > =20 > - for (cenv =3D first_cpu; cenv !=3D NULL; cenv =3D cenv->next_cpu) > + for (cenv =3D first_cpu; cenv !=3D NULL; cenv =3D cenv->next_cpu) = { > if (cenv->cpu_index =3D=3D cpu_index && cenv->mcg_cap) { > - cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, m= isc); > + cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, m= isc, > + broadcast); > break; > } > + } > } > #endif > =20 > diff --git a/target-i386/helper.c b/target-i386/helper.c > index 2c94130..2cfb4a4 100644 > --- a/target-i386/helper.c > +++ b/target-i386/helper.c > @@ -1069,18 +1069,34 @@ static void qemu_inject_x86_mce(CPUState *cenv,= int bank, uint64_t status, > } > =20 > void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, > - uint64_t mcg_status, uint64_t addr, uint64_t m= isc) > + uint64_t mcg_status, uint64_t addr, uint64_t m= isc, > + int broadcast) > { > unsigned bank_num =3D cenv->mcg_cap & 0xff; > + CPUState *env; > + int flag =3D 0; > =20 > if (bank >=3D bank_num || !(status & MCI_STATUS_VAL)) { > return; > } > =20 > if (kvm_enabled()) { > - kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc,= 0); > + if (broadcast) { > + flag |=3D MCE_BROADCAST; > + } > + > + kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc,= flag); > } else { > qemu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc= ); > + if (broadcast) { > + for (env =3D first_cpu; env !=3D NULL; env =3D env->next_c= pu) { > + if (cenv =3D=3D env) { > + continue; > + } > + > + qemu_inject_x86_mce(env, 1, 0xa000000000000000, 0, 0, = 0); Constant lacks "ULL". Can probably be fixed up on commit. Jan > + } > + } > } > } > #endif /* !CONFIG_USER_ONLY */ > diff --git a/target-i386/kvm.c b/target-i386/kvm.c > index 4004de7..8b868ad 100644 > --- a/target-i386/kvm.c > +++ b/target-i386/kvm.c > @@ -264,11 +264,13 @@ static void kvm_do_inject_x86_mce(void *_data) > } > } > } > + > +static void kvm_mce_broadcast_rest(CPUState *env); > #endif > =20 > void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, > uint64_t mcg_status, uint64_t addr, uint64_t m= isc, > - int abort_on_error) > + int flag) > { > #ifdef KVM_CAP_MCE > struct kvm_x86_mce mce =3D { > @@ -288,10 +290,15 @@ void kvm_inject_x86_mce(CPUState *cenv, int bank,= uint64_t status, > return; > } > =20 > + if (flag & MCE_BROADCAST) { > + kvm_mce_broadcast_rest(cenv); > + } > + > run_on_cpu(cenv, kvm_do_inject_x86_mce, &data); > #else > - if (abort_on_error) > + if (flag & ABORT_ON_ERROR) { > abort(); > + } > #endif > } > =20 > @@ -1716,7 +1723,8 @@ static void kvm_mce_broadcast_rest(CPUState *env)= > continue; > } > kvm_inject_x86_mce(cenv, 1, MCI_STATUS_VAL | MCI_STATUS_UC= , > - MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0= , 1); > + MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0= , > + ABORT_ON_ERROR); > } > } > } > @@ -1816,7 +1824,7 @@ int kvm_on_sigbus(int code, void *addr) > | 0xc0; > kvm_inject_x86_mce(first_cpu, 9, status, > MCG_STATUS_MCIP | MCG_STATUS_RIPV, paddr, > - (MCM_ADDR_PHYS << 6) | 0xc, 1); > + (MCM_ADDR_PHYS << 6) | 0xc, ABORT_ON_ERROR)= ; > kvm_mce_broadcast_rest(first_cpu); > } else > #endif > diff --git a/target-i386/kvm_x86.h b/target-i386/kvm_x86.h > index 04932cf..9d7b584 100644 > --- a/target-i386/kvm_x86.h > +++ b/target-i386/kvm_x86.h > @@ -15,8 +15,11 @@ > #ifndef __KVM_X86_H__ > #define __KVM_X86_H__ > =20 > +#define ABORT_ON_ERROR 0x01 > +#define MCE_BROADCAST 0x02 > + > void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, > uint64_t mcg_status, uint64_t addr, uint64_t m= isc, > - int abort_on_error); > + int flag); > =20 > #endif --------------enig2F5C112F4F895B68E668958C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk0qA6wACgkQitSsb3rl5xTCygCeNjQhwloIuyQnps8udKZM4ke6 tfIAoKp9vML+BwGMlN71F0Xpk2tV4fgq =mauB -----END PGP SIGNATURE----- --------------enig2F5C112F4F895B68E668958C-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=46590 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pc0MS-0001rO-KO for qemu-devel@nongnu.org; Sun, 09 Jan 2011 13:51:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pc0MR-0006aE-2n for qemu-devel@nongnu.org; Sun, 09 Jan 2011 13:51:28 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:34662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pc0MQ-0006ZU-IX for qemu-devel@nongnu.org; Sun, 09 Jan 2011 13:51:27 -0500 Message-ID: <4D2A03A8.9080600@web.de> Date: Sun, 09 Jan 2011 19:51:20 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <497ea69043289b0421a8265f32e9b1a80a3c9481.1294336601.git.mtosatti@redhat.com> In-Reply-To: <497ea69043289b0421a8265f32e9b1a80a3c9481.1294336601.git.mtosatti@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig2F5C112F4F895B68E668958C" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH 04/35] Add "broadcast" option for mce command List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti , Anthony Liguori Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Jin Dongming This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2F5C112F4F895B68E668958C Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Am 06.01.2011 18:56, Marcelo Tosatti wrote: > From: Jin Dongming >=20 > When the following test case is injected with mce command, maybe user c= ould not > get the expected result. > DATA > command cpu bank status mcg_status addr m= isc > (qemu) mce 1 1 0xbd00000000000000 0x05 0x1234 0= x8c >=20 > Expected Result > panic type: "Fatal Machine check" >=20 > That is because each mce command can only inject the given cpu and coul= d not > inject mce interrupt to other cpus. So user will get the following resu= lt: > panic type: "Fatal machine check on current CPU" >=20 > "broadcast" option is used for injecting dummy data into other cpus. In= jecting > mce with this option the expected result could be gotten. >=20 > Usage: > Broadcast[on] > command broadcast cpu bank status mcg_status ad= dr misc > (qemu) mce -b 1 1 0xbd00000000000000 0x05 0x= 1234 0x8c >=20 > Broadcast[off] > command cpu bank status mcg_status addr misc > (qemu) mce 1 1 0xbd00000000000000 0x05 0x1234 0x8c >=20 > Signed-off-by: Jin Dongming > Signed-off-by: Marcelo Tosatti > --- > cpu-all.h | 3 ++- > hmp-commands.hx | 6 +++--- > monitor.c | 7 +++++-- > target-i386/helper.c | 20 ++++++++++++++++++-- > target-i386/kvm.c | 16 ++++++++++++---- > target-i386/kvm_x86.h | 5 ++++- > 6 files changed, 44 insertions(+), 13 deletions(-) >=20 > diff --git a/cpu-all.h b/cpu-all.h > index 30ae17d..4ce4e83 100644 > --- a/cpu-all.h > +++ b/cpu-all.h > @@ -964,6 +964,7 @@ int cpu_memory_rw_debug(CPUState *env, target_ulong= addr, > uint8_t *buf, int len, int is_write); > =20 > void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, > - uint64_t mcg_status, uint64_t addr, uint64_t m= isc); > + uint64_t mcg_status, uint64_t addr, uint64_t m= isc, > + int broadcast); > =20 > #endif /* CPU_ALL_H */ > diff --git a/hmp-commands.hx b/hmp-commands.hx > index df134f8..c82fb10 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -1091,9 +1091,9 @@ ETEXI > =20 > { > .name =3D "mce", > - .args_type =3D "cpu_index:i,bank:i,status:l,mcg_status:l,addr= :l,misc:l", > - .params =3D "cpu bank status mcgstatus addr misc", > - .help =3D "inject a MCE on the given CPU", > + .args_type =3D "broadcast:-b,cpu_index:i,bank:i,status:l,mcg_= status:l,addr:l,misc:l", > + .params =3D "[-b] cpu bank status mcgstatus addr misc", > + .help =3D "inject a MCE on the given CPU [and broadcast = to other CPUs with -b option]", > .mhandler.cmd =3D do_inject_mce, > }, > =20 > diff --git a/monitor.c b/monitor.c > index f258000..f4f624b 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -2671,12 +2671,15 @@ static void do_inject_mce(Monitor *mon, const Q= Dict *qdict) > uint64_t mcg_status =3D qdict_get_int(qdict, "mcg_status"); > uint64_t addr =3D qdict_get_int(qdict, "addr"); > uint64_t misc =3D qdict_get_int(qdict, "misc"); > + int broadcast =3D qdict_get_try_bool(qdict, "broadcast", 0); > =20 > - for (cenv =3D first_cpu; cenv !=3D NULL; cenv =3D cenv->next_cpu) > + for (cenv =3D first_cpu; cenv !=3D NULL; cenv =3D cenv->next_cpu) = { > if (cenv->cpu_index =3D=3D cpu_index && cenv->mcg_cap) { > - cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, m= isc); > + cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, m= isc, > + broadcast); > break; > } > + } > } > #endif > =20 > diff --git a/target-i386/helper.c b/target-i386/helper.c > index 2c94130..2cfb4a4 100644 > --- a/target-i386/helper.c > +++ b/target-i386/helper.c > @@ -1069,18 +1069,34 @@ static void qemu_inject_x86_mce(CPUState *cenv,= int bank, uint64_t status, > } > =20 > void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, > - uint64_t mcg_status, uint64_t addr, uint64_t m= isc) > + uint64_t mcg_status, uint64_t addr, uint64_t m= isc, > + int broadcast) > { > unsigned bank_num =3D cenv->mcg_cap & 0xff; > + CPUState *env; > + int flag =3D 0; > =20 > if (bank >=3D bank_num || !(status & MCI_STATUS_VAL)) { > return; > } > =20 > if (kvm_enabled()) { > - kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc,= 0); > + if (broadcast) { > + flag |=3D MCE_BROADCAST; > + } > + > + kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc,= flag); > } else { > qemu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc= ); > + if (broadcast) { > + for (env =3D first_cpu; env !=3D NULL; env =3D env->next_c= pu) { > + if (cenv =3D=3D env) { > + continue; > + } > + > + qemu_inject_x86_mce(env, 1, 0xa000000000000000, 0, 0, = 0); Constant lacks "ULL". Can probably be fixed up on commit. Jan > + } > + } > } > } > #endif /* !CONFIG_USER_ONLY */ > diff --git a/target-i386/kvm.c b/target-i386/kvm.c > index 4004de7..8b868ad 100644 > --- a/target-i386/kvm.c > +++ b/target-i386/kvm.c > @@ -264,11 +264,13 @@ static void kvm_do_inject_x86_mce(void *_data) > } > } > } > + > +static void kvm_mce_broadcast_rest(CPUState *env); > #endif > =20 > void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, > uint64_t mcg_status, uint64_t addr, uint64_t m= isc, > - int abort_on_error) > + int flag) > { > #ifdef KVM_CAP_MCE > struct kvm_x86_mce mce =3D { > @@ -288,10 +290,15 @@ void kvm_inject_x86_mce(CPUState *cenv, int bank,= uint64_t status, > return; > } > =20 > + if (flag & MCE_BROADCAST) { > + kvm_mce_broadcast_rest(cenv); > + } > + > run_on_cpu(cenv, kvm_do_inject_x86_mce, &data); > #else > - if (abort_on_error) > + if (flag & ABORT_ON_ERROR) { > abort(); > + } > #endif > } > =20 > @@ -1716,7 +1723,8 @@ static void kvm_mce_broadcast_rest(CPUState *env)= > continue; > } > kvm_inject_x86_mce(cenv, 1, MCI_STATUS_VAL | MCI_STATUS_UC= , > - MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0= , 1); > + MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0= , > + ABORT_ON_ERROR); > } > } > } > @@ -1816,7 +1824,7 @@ int kvm_on_sigbus(int code, void *addr) > | 0xc0; > kvm_inject_x86_mce(first_cpu, 9, status, > MCG_STATUS_MCIP | MCG_STATUS_RIPV, paddr, > - (MCM_ADDR_PHYS << 6) | 0xc, 1); > + (MCM_ADDR_PHYS << 6) | 0xc, ABORT_ON_ERROR)= ; > kvm_mce_broadcast_rest(first_cpu); > } else > #endif > diff --git a/target-i386/kvm_x86.h b/target-i386/kvm_x86.h > index 04932cf..9d7b584 100644 > --- a/target-i386/kvm_x86.h > +++ b/target-i386/kvm_x86.h > @@ -15,8 +15,11 @@ > #ifndef __KVM_X86_H__ > #define __KVM_X86_H__ > =20 > +#define ABORT_ON_ERROR 0x01 > +#define MCE_BROADCAST 0x02 > + > void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, > uint64_t mcg_status, uint64_t addr, uint64_t m= isc, > - int abort_on_error); > + int flag); > =20 > #endif --------------enig2F5C112F4F895B68E668958C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk0qA6wACgkQitSsb3rl5xTCygCeNjQhwloIuyQnps8udKZM4ke6 tfIAoKp9vML+BwGMlN71F0Xpk2tV4fgq =mauB -----END PGP SIGNATURE----- --------------enig2F5C112F4F895B68E668958C--