From: "Cédric Le Goater" <clg@kaod.org>
To: Vitaly Cheptsov <cheptsov@ispras.ru>, <qemu-devel@nongnu.org>
Cc: qemu-stable@nongnu.org,
Daniel Henrique Barboza <danielhb413@gmail.com>,
qemu-ppc@nongnu.org, Greg Kurz <groug@kaod.org>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH] target/ppc/mmu_common: Fix SRR1/MSR error code on Book-E
Date: Tue, 25 Jan 2022 12:14:06 +0100 [thread overview]
Message-ID: <b51d7529-8cf2-3cd8-2689-d60cc2c22aab@kaod.org> (raw)
In-Reply-To: <20220121093107.15478-1-cheptsov@ispras.ru>
On 1/21/22 10:31, Vitaly Cheptsov wrote:
> Book-E architecture does not set the error code in 31:27 bits
> of SRR1, but instead uses these bits for custom fields such
> as GS (Guest Supervisor).
>
> Wrongly setting these fields will result in QEMU crashes
> when attempting to execute not executable code due to the attempts
> to use Guest Supervisor mode.
>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Daniel Henrique Barboza <danielhb413@gmail.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: qemu-ppc@nongnu.org
> Cc: qemu-devel@nongnu.org
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
> ---
> target/ppc/mmu_common.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
> index 91270c1f17..6512ee031c 100644
> --- a/target/ppc/mmu_common.c
> +++ b/target/ppc/mmu_common.c
> @@ -1367,22 +1367,34 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,
> case -2:
> /* Access rights violation */
> cs->exception_index = POWERPC_EXCP_ISI;
> - env->error_code = 0x08000000;
> + if ((env->mmu_model == POWERPC_MMU_BOOKE) ||
> + (env->mmu_model == POWERPC_MMU_BOOKE206)) {
> + env->error_code = 0;
> + } else {
> + env->error_code = 0x08000000;
> + }
> break;
> case -3:
> /* No execute protection violation */
> if ((env->mmu_model == POWERPC_MMU_BOOKE) ||
> (env->mmu_model == POWERPC_MMU_BOOKE206)) {
> env->spr[SPR_BOOKE_ESR] = 0x00000000;
> + env->error_code = 0;
> + } else {
> + env->error_code = 0x10000000;
> }
> cs->exception_index = POWERPC_EXCP_ISI;
> - env->error_code = 0x10000000;
> break;
> case -4:
> /* Direct store exception */
> /* No code fetch is allowed in direct-store areas */
> cs->exception_index = POWERPC_EXCP_ISI;
> - env->error_code = 0x10000000;
> + if ((env->mmu_model == POWERPC_MMU_BOOKE) ||
> + (env->mmu_model == POWERPC_MMU_BOOKE206)) {
> + env->error_code = 0;
> + } else {
> + env->error_code = 0x10000000;
> + }
> break;
> }
> } else {
>
next prev parent reply other threads:[~2022-01-25 11:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 9:31 [PATCH] target/ppc/mmu_common: Fix SRR1/MSR error code on Book-E Vitaly Cheptsov
2022-01-25 11:14 ` Cédric Le Goater [this message]
[not found] <BE5775C6-A54F-4443-9752-DBB6587E1F46@ispras.ru>
2022-01-21 8:17 ` Cédric Le Goater
2022-01-21 9:33 ` Vitaly Cheptsov
2022-01-21 17:33 ` Cédric Le Goater
2022-01-23 22:12 ` Vitaly Cheptsov
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=b51d7529-8cf2-3cd8-2689-d60cc2c22aab@kaod.org \
--to=clg@kaod.org \
--cc=cheptsov@ispras.ru \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-stable@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).