From patchwork Thu Aug 11 00:44:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 109481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 65B31B6F57 for ; Thu, 11 Aug 2011 10:45:17 +1000 (EST) Received: from localhost ([::1]:48875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrJOc-0004gB-0h for incoming@patchwork.ozlabs.org; Wed, 10 Aug 2011 20:45:14 -0400 Received: from eggs.gnu.org ([140.186.70.92]:45034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrJOE-0003m1-Ci for qemu-devel@nongnu.org; Wed, 10 Aug 2011 20:44:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrJO9-0006HZ-7F for qemu-devel@nongnu.org; Wed, 10 Aug 2011 20:44:50 -0400 Received: from ozlabs.org ([203.10.76.45]:33165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrJO8-0006HJ-Ld for qemu-devel@nongnu.org; Wed, 10 Aug 2011 20:44:45 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 1AAF0B7091; Thu, 11 Aug 2011 10:44:42 +1000 (EST) Date: Thu, 11 Aug 2011 10:44:20 +1000 From: David Gibson To: Alexander Graf Message-ID: <20110811004420.GD6342@yookeroo.fritz.box> Mail-Followup-To: Alexander Graf , qemu-devel@nongnu.org References: <1312441339-22477-1-git-send-email-david@gibson.dropbear.id.au> <4E42A0D3.1000203@suse.de> <4E42A2CB.2070905@suse.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4E42A2CB.2070905@suse.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-devel] pseries machine updates X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Wed, Aug 10, 2011 at 05:24:59PM +0200, Alexander Graf wrote: > On 08/10/2011 05:16 PM, Alexander Graf wrote: > >On 08/04/2011 09:02 AM, David Gibson wrote: > >>Hi Alex, > >> > >>Here's another batch of assorted updates for the pseries machine. > > > >Looks pretty nice. Please update patch 2/6 with the bug you found > >and the whitespace problems. I'll put the others into my tree > >already. > > Sorry, patch 3 failed checkpatch. Please respin that one too. Done. Here you go. I'll blame Ben again :) From 6d5418b479852edfe93c40b8ddb707dde5128e32 Mon Sep 17 00:00:00 2001 From: Ben Herrenschmidt Date: Fri, 29 Jul 2011 12:06:33 +1000 Subject: [PATCH] pseries: Add real mode debugging hcalls PAPR systems support several hypercalls intended for use in real mode debugging tools. These implement reads and writes to arbitrary guest physical addresses. This is useful for real mode software because it allows access to IO addresses and memory outside the RMA without going through the somewhat involved process of setting up the hash page table and enabling translation. We want these so that when we add real IO devices, the SLOF firmware can boot from them without having to enter virtual mode. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: David Gibson --- hw/spapr_hcall.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-) diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c index f7ead04..05d6c54 100644 --- a/hw/spapr_hcall.c +++ b/hw/spapr_hcall.c @@ -449,6 +449,67 @@ static target_ulong h_rtas(CPUState *env, sPAPREnvironment *spapr, nret, rtas_r3 + 12 + 4*nargs); } +static target_ulong h_logical_load(CPUState *env, sPAPREnvironment *spapr, + target_ulong opcode, target_ulong *args) +{ + target_ulong size = args[0]; + target_ulong addr = args[1]; + + switch (size) { + case 1: + args[0] = ldub_phys(addr); + return H_SUCCESS; + case 2: + args[0] = lduw_phys(addr); + return H_SUCCESS; + case 4: + args[0] = ldl_phys(addr); + return H_SUCCESS; + case 8: + args[0] = ldq_phys(addr); + return H_SUCCESS; + } + return H_PARAMETER; +} + +static target_ulong h_logical_store(CPUState *env, sPAPREnvironment *spapr, + target_ulong opcode, target_ulong *args) +{ + target_ulong size = args[0]; + target_ulong addr = args[1]; + target_ulong val = args[2]; + + switch (size) { + case 1: + stb_phys(addr, val); + return H_SUCCESS; + case 2: + stw_phys(addr, val); + return H_SUCCESS; + case 4: + stl_phys(addr, val); + return H_SUCCESS; + case 8: + stq_phys(addr, val); + return H_SUCCESS; + } + return H_PARAMETER; +} + +static target_ulong h_logical_icbi(CPUState *env, sPAPREnvironment *spapr, + target_ulong opcode, target_ulong *args) +{ + /* Nothing to do on emulation, KVM will trap this in the kernel */ + return H_SUCCESS; +} + +static target_ulong h_logical_dcbf(CPUState *env, sPAPREnvironment *spapr, + target_ulong opcode, target_ulong *args) +{ + /* Nothing to do on emulation, KVM will trap this in the kernel */ + return H_SUCCESS; +} + static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1]; static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - KVMPPC_HCALL_BASE + 1]; @@ -513,6 +574,18 @@ static void hypercall_init(void) spapr_register_hypercall(H_REGISTER_VPA, h_register_vpa); spapr_register_hypercall(H_CEDE, h_cede); + /* "debugger" hcalls (also used by SLOF). Note: We do -not- differenciate + * here between the "CI" and the "CACHE" variants, they will use whatever + * mapping attributes qemu is using. When using KVM, the kernel will + * enforce the attributes more strongly + */ + spapr_register_hypercall(H_LOGICAL_CI_LOAD, h_logical_load); + spapr_register_hypercall(H_LOGICAL_CI_STORE, h_logical_store); + spapr_register_hypercall(H_LOGICAL_CACHE_LOAD, h_logical_load); + spapr_register_hypercall(H_LOGICAL_CACHE_STORE, h_logical_store); + spapr_register_hypercall(H_LOGICAL_ICBI, h_logical_icbi); + spapr_register_hypercall(H_LOGICAL_DCBF, h_logical_dcbf); + /* qemu/KVM-PPC specific hcalls */ spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas); }