From patchwork Fri Mar 25 03:21:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 88301 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4827EB6F7E for ; Fri, 25 Mar 2011 14:23:25 +1100 (EST) Received: from localhost ([127.0.0.1]:45343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2xcP-0001Xp-VV for incoming@patchwork.ozlabs.org; Thu, 24 Mar 2011 23:23:22 -0400 Received: from [140.186.70.92] (port=59771 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2xat-0001UP-Vb for qemu-devel@nongnu.org; Thu, 24 Mar 2011 23:21:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q2xas-0006bs-Jd for qemu-devel@nongnu.org; Thu, 24 Mar 2011 23:21:47 -0400 Received: from ozlabs.org ([203.10.76.45]:56749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q2xas-0006ba-6B for qemu-devel@nongnu.org; Thu, 24 Mar 2011 23:21:46 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 882A1B6F98; Fri, 25 Mar 2011 14:21:41 +1100 (EST) From: David Gibson To: agraf@suse.de, qemu-devel@nongnu.org Date: Fri, 25 Mar 2011 14:21:08 +1100 Message-Id: <1301023292-24977-4-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1301023292-24977-1-git-send-email-david@gibson.dropbear.id.au> References: <1301023292-24977-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 203.10.76.45 Cc: paulus@samba.org, anton@samba.org Subject: [Qemu-devel] [PATCH 03/27] Add a hook to allow hypercalls to be emulated on PowerPC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org PowerPC and POWER chips since the POWER4 and 970 have a special hypervisor mode, and a corresponding form of the system call instruction which traps to the hypervisor. qemu currently has stub implementations of hypervisor mode. That is, the outline is there to allow qemu to run a PowerPC hypervisor under emulation. There are a number of details missing so this won't actually work at present, but the idea is there. What there is no provision at all, is for qemu to instead emulate the hypervisor itself. That is to have hypercalls trap into qemu and their result be emulated from qemu, rather than running hypervisor code within the emulated system. Hypervisor hardware aware KVM implementations are in the works and it would be useful for debugging and development to also allow full emulation of the same para-virtualized guests as such a KVM. Therefore, this patch adds a hook which will allow a machine to set up emulation of hypervisor calls. Signed-off-by: David Gibson --- target-ppc/cpu.h | 2 ++ target-ppc/helper.c | 8 ++++++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 124bbbf..36ca342 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -1646,4 +1646,6 @@ static inline void cpu_set_tls(CPUState *env, target_ulong newtls) #endif } +extern void (*cpu_ppc_hypercall)(CPUState *); + #endif /* !defined (__CPU_PPC_H__) */ diff --git a/target-ppc/helper.c b/target-ppc/helper.c index 2094ca3..452a35c 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -70,6 +70,10 @@ # define LOG_EXCP(...) do { } while (0) #endif +/*****************************************************************************/ +/* PowerPC Hypercall emulation */ + +void (*cpu_ppc_hypercall)(CPUState *); /*****************************************************************************/ /* PowerPC MMU emulation */ @@ -2152,6 +2156,10 @@ static inline void powerpc_excp(CPUState *env, int excp_model, int excp) case POWERPC_EXCP_SYSCALL: /* System call exception */ dump_syscall(env); lev = env->error_code; + if ((lev == 1) && cpu_ppc_hypercall) { + cpu_ppc_hypercall(env); + return; + } if (lev == 1 || (lpes0 == 0 && lpes1 == 0)) new_msr |= (target_ulong)MSR_HVB; goto store_next;