qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: agraf@suse.de
Cc: aliguori@us.ibm.com, qemu-stable@nongnu.org, qemu-ppc@nongnu.org,
	qemu-devel@nongnu.org, David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 5/6] pseries: Don't test for MSR_PR for hypercalls under KVM
Date: Wed, 26 Sep 2012 13:12:20 +1000	[thread overview]
Message-ID: <1348629141-8719-6-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1348629141-8719-1-git-send-email-david@gibson.dropbear.id.au>

PAPR hypercalls should only be invoked from the guest kernel, not guest
user programs, that is, with MSR[PR]=0.  Currently we check this in
spapr_hypercall, returning H_PRIVILEGE if MSR[PR]=1.

However, under KVM the state of MSR[PR] is already checked by the host
kernel before passing the hypercall to qemu, making this check redundant.
Worse, however, we don't generally synchronize KVM and qemu state on the
hypercall path, meaning that qemu could incorrectly reject a hypercall
because it has a stale MSR value.

This patch fixes the problem by moving the privilege test exclusively to
the TCG hypercall path.

Cc: qemu-stable@nongnu.org

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/spapr.c       |    7 ++++++-
 hw/spapr_hcall.c |    5 -----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/spapr.c b/hw/spapr.c
index 079825a..e6bf522 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -573,7 +573,12 @@ static uint64_t translate_kernel_address(void *opaque, uint64_t addr)
 
 static void emulate_spapr_hypercall(CPUPPCState *env)
 {
-    env->gpr[3] = spapr_hypercall(env, env->gpr[3], &env->gpr[4]);
+    if (msr_pr) {
+        hcall_dprintf("Hypercall made with MSR[PR]=1\n");
+        env->gpr[3] = H_PRIVILEGE;
+    } else {
+        env->gpr[3] = spapr_hypercall(env, env->gpr[3], &env->gpr[4]);
+    }
 }
 
 static void spapr_reset_htab(sPAPREnvironment *spapr)
diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index 826ca67..194d9c2 100644
--- a/hw/spapr_hcall.c
+++ b/hw/spapr_hcall.c
@@ -681,11 +681,6 @@ void spapr_register_hypercall(target_ulong opcode, spapr_hcall_fn fn)
 target_ulong spapr_hypercall(CPUPPCState *env, target_ulong opcode,
                              target_ulong *args)
 {
-    if (msr_pr) {
-        hcall_dprintf("Hypercall made with MSR[PR]=1\n");
-        return H_PRIVILEGE;
-    }
-
     if ((opcode <= MAX_HCALL_OPCODE)
         && ((opcode & 0x3) == 0)) {
         spapr_hcall_fn fn = papr_hypercall_table[opcode / 4];
-- 
1.7.10.4

  parent reply	other threads:[~2012-09-26  3:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26  3:12 [Qemu-devel] [0/6] Pending pseries updates David Gibson
2012-09-26  3:12 ` [Qemu-devel] [PATCH 1/6] pseries: Set hash table size based on RAM size David Gibson
2012-09-26  3:12 ` [Qemu-devel] [PATCH 2/6] target-ppc: Remove unused power_mode field from cpu state David Gibson
2012-09-26  3:12 ` [Qemu-devel] [PATCH 3/6] target-ppc: Extend FPU state for newer POWER CPUs David Gibson
2012-09-26  6:36   ` Aurelien Jarno
2012-09-27  0:03     ` [Qemu-devel] [Qemu-ppc] " David Gibson
2012-09-26  3:12 ` [Qemu-devel] [PATCH 4/6] pseries: Implement PAPR NVRAM David Gibson
2012-09-26 12:55   ` Alexander Graf
2012-09-26 21:25     ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
2012-09-26  3:12 ` David Gibson [this message]
2012-09-26  3:12 ` [Qemu-devel] [PATCH 6/6] ppc/pseries: Reset VPA registration on CPU reset David Gibson
2012-09-26 12:59 ` [Qemu-devel] [0/6] Pending pseries updates Alexander Graf
2012-09-26 23:31   ` [Qemu-devel] [Qemu-ppc] " David Gibson
2012-09-27  8:05     ` Alexander Graf
2012-09-27 10:29       ` David Gibson

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=1348629141-8719-6-git-send-email-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --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).