From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGi2I-00057i-KS for qemu-devel@nongnu.org; Tue, 25 Sep 2012 23:11:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGi2H-0002iI-4c for qemu-devel@nongnu.org; Tue, 25 Sep 2012 23:11:42 -0400 From: David Gibson Date: Wed, 26 Sep 2012 13:12:20 +1000 Message-Id: <1348629141-8719-6-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1348629141-8719-1-git-send-email-david@gibson.dropbear.id.au> References: <1348629141-8719-1-git-send-email-david@gibson.dropbear.id.au> Subject: [Qemu-devel] [PATCH 5/6] pseries: Don't test for MSR_PR for hypercalls under KVM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: agraf@suse.de Cc: aliguori@us.ibm.com, qemu-stable@nongnu.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson 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 --- 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