qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	Cedric Le Goater <clg@kaod.org>
Subject: [Qemu-devel] [PATCH 1/3] ppc: Fix hreg_store_msr() so that non-HV mode cannot alter MSR:HV
Date: Fri,  3 Jun 2016 14:11:18 +0200	[thread overview]
Message-ID: <1464955880-10176-2-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1464955880-10176-1-git-send-email-clg@kaod.org>

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

This helper is only used by the various instructions that can alter
MSR and not interrupts. Add a comment to that effect to the interrupt
code as well in case somebody wants to change this

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 target-ppc/excp_helper.c | 8 ++++++--
 target-ppc/helper_regs.h | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c
index a37009eb2560..30e960e30b63 100644
--- a/target-ppc/excp_helper.c
+++ b/target-ppc/excp_helper.c
@@ -709,8 +709,12 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
         }
     }
 #endif
-    /* XXX: we don't use hreg_store_msr here as already have treated
-     *      any special case that could occur. Just store MSR and update hflags
+    /* We don't use hreg_store_msr here as already have treated
+     * any special case that could occur. Just store MSR and update hflags
+     *
+     * Note: We *MUST* not use hreg_store_msr() as-is anyway because it
+     * will prevent setting of the HV bit which some exceptions might need
+     * to do.
      */
     env->msr = new_msr & env->msr_mask;
     hreg_compute_hflags(env);
diff --git a/target-ppc/helper_regs.h b/target-ppc/helper_regs.h
index 57da931e3c4d..12af61cbf19b 100644
--- a/target-ppc/helper_regs.h
+++ b/target-ppc/helper_regs.h
@@ -114,8 +114,8 @@ static inline int hreg_store_msr(CPUPPCState *env, target_ulong value,
     excp = 0;
     value &= env->msr_mask;
 #if !defined(CONFIG_USER_ONLY)
-    if (!alter_hv) {
-        /* mtmsr cannot alter the hypervisor state */
+    /* Neither mtmsr nor guest state can alter HV */
+    if (!alter_hv || !(env->msr & MSR_HVB)) {
         value &= ~MSR_HVB;
         value |= env->msr & MSR_HVB;
     }
-- 
2.1.4

  reply	other threads:[~2016-06-03 12:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03 12:11 [Qemu-devel] [PATCH 0/3] ppc: complete the new HV mode Cédric Le Goater
2016-06-03 12:11 ` Cédric Le Goater [this message]
2016-06-03 12:11 ` [Qemu-devel] [PATCH 2/3] ppc: Better figure out if processor has " Cédric Le Goater
2016-06-03 12:11 ` [Qemu-devel] [PATCH 3/3] ppc: fix hrfid, tlbia and slbia privilege Cédric Le Goater
2016-06-04  8:24   ` Thomas Huth
2016-06-06  1:10     ` David Gibson
2016-06-03 13:52 ` [Qemu-devel] [PATCH 0/3] ppc: complete the new HV mode Mark Cave-Ayland
2016-06-03 14:00   ` Cédric Le Goater
2016-06-03 14:06     ` Mark Cave-Ayland
2016-06-03 14:06     ` Cedric Le Goater
2016-06-03 14:14       ` Mark Cave-Ayland
2016-06-03 15:47         ` Mark Cave-Ayland
2016-06-03 17:54           ` Cédric Le Goater
2016-06-05 17:41   ` Cédric Le Goater
2016-06-05 22:26     ` Mark Cave-Ayland
2016-06-06  6:27       ` Cédric Le Goater
2016-06-06  6:30         ` Cedric Le Goater
2016-06-06  6:38           ` Mark Cave-Ayland
2016-06-07  7:04             ` Cédric Le Goater
2016-06-07  8:24               ` Mark Cave-Ayland
2016-06-06  1:47     ` David Gibson
2016-06-06  4:17     ` [Qemu-devel] [Qemu-ppc] " Benjamin Herrenschmidt
2016-06-06  7:28       ` Cédric Le Goater
2016-06-06  1:17 ` [Qemu-devel] " David Gibson
2016-06-06  3:55   ` Benjamin Herrenschmidt
2016-06-06  4:20     ` [Qemu-devel] [Qemu-ppc] " Benjamin Herrenschmidt
2016-06-06  6:29       ` Mark Cave-Ayland
2016-06-06  7:04         ` Benjamin Herrenschmidt
2016-06-06  7:06           ` Benjamin Herrenschmidt

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=1464955880-10176-2-git-send-email-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=benh@kernel.crashing.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).