diff mbox

[3/6] pseries: Add real mode debugging hcalls

Message ID 1312441339-22477-4-git-send-email-david@gibson.dropbear.id.au
State New
Headers show

Commit Message

David Gibson Aug. 4, 2011, 7:02 a.m. UTC
From: Ben Herrenschmidt <benh@kernel.crashing.org>

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 <benh@kernel.crashing.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
---
 hw/spapr_hcall.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)

Comments

Alexander Graf Aug. 10, 2011, 3:19 p.m. UTC | #1
On 08/04/2011 09:02 AM, David Gibson wrote:
> From: Ben Herrenschmidt<benh@kernel.crashing.org>
>
> 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<benh@kernel.crashing.org>
> Signed-off-by: David Gibson<dwg@au1.ibm.com>

agraf@lychee:/home/agraf/release/qemu> git pw am 108355
ERROR: code indent should never use tabs
#40: FILE: hw/spapr_hcall.c:453:
+^I^I^I^I   target_ulong opcode, target_ulong *args)$

ERROR: code indent should never use tabs
#42: FILE: hw/spapr_hcall.c:455:
+^Itarget_ulong size = args[0];$

ERROR: code indent should never use tabs
#43: FILE: hw/spapr_hcall.c:456:
+^Itarget_ulong addr = args[1];$

ERROR: code indent should never use tabs
#45: FILE: hw/spapr_hcall.c:458:
+^Iswitch(size) {$

ERROR: space required before the open parenthesis '('
#45: FILE: hw/spapr_hcall.c:458:
+    switch(size) {

ERROR: code indent should never use tabs
#46: FILE: hw/spapr_hcall.c:459:
+^Icase 1:$

ERROR: code indent should never use tabs
#47: FILE: hw/spapr_hcall.c:460:
+^I^Iargs[0] = ldub_phys(addr);$

ERROR: code indent should never use tabs
#48: FILE: hw/spapr_hcall.c:461:
+^I^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#49: FILE: hw/spapr_hcall.c:462:
+^Icase 2:$

ERROR: code indent should never use tabs
#50: FILE: hw/spapr_hcall.c:463:
+^I^Iargs[0] = lduw_phys(addr);$

ERROR: code indent should never use tabs
#51: FILE: hw/spapr_hcall.c:464:
+^I^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#52: FILE: hw/spapr_hcall.c:465:
+^Icase 4:$

ERROR: code indent should never use tabs
#53: FILE: hw/spapr_hcall.c:466:
+^I^Iargs[0] = ldl_phys(addr);$

ERROR: code indent should never use tabs
#54: FILE: hw/spapr_hcall.c:467:
+^I^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#55: FILE: hw/spapr_hcall.c:468:
+^Icase 8:$

ERROR: code indent should never use tabs
#56: FILE: hw/spapr_hcall.c:469:
+^I^Iargs[0] = ldq_phys(addr);$

ERROR: code indent should never use tabs
#57: FILE: hw/spapr_hcall.c:470:
+^I^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#58: FILE: hw/spapr_hcall.c:471:
+^I}$

ERROR: code indent should never use tabs
#59: FILE: hw/spapr_hcall.c:472:
+^Ireturn H_PARAMETER;$

ERROR: code indent should never use tabs
#63: FILE: hw/spapr_hcall.c:476:
+^I^I^I^I   target_ulong opcode, target_ulong *args)$

ERROR: code indent should never use tabs
#65: FILE: hw/spapr_hcall.c:478:
+^Itarget_ulong size = args[0];$

ERROR: code indent should never use tabs
#66: FILE: hw/spapr_hcall.c:479:
+^Itarget_ulong addr = args[1];$

ERROR: code indent should never use tabs
#67: FILE: hw/spapr_hcall.c:480:
+^Itarget_ulong val  = args[2];$

ERROR: code indent should never use tabs
#69: FILE: hw/spapr_hcall.c:482:
+^Iswitch(size) {$

ERROR: space required before the open parenthesis '('
#69: FILE: hw/spapr_hcall.c:482:
+    switch(size) {

ERROR: code indent should never use tabs
#70: FILE: hw/spapr_hcall.c:483:
+^Icase 1:$

ERROR: code indent should never use tabs
#71: FILE: hw/spapr_hcall.c:484:
+^I^Istb_phys(addr, val);$

ERROR: code indent should never use tabs
#72: FILE: hw/spapr_hcall.c:485:
+^I^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#73: FILE: hw/spapr_hcall.c:486:
+^Icase 2:$

ERROR: code indent should never use tabs
#74: FILE: hw/spapr_hcall.c:487:
+^I^Istw_phys(addr, val);$

ERROR: code indent should never use tabs
#75: FILE: hw/spapr_hcall.c:488:
+^I^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#76: FILE: hw/spapr_hcall.c:489:
+^Icase 4:$

ERROR: code indent should never use tabs
#77: FILE: hw/spapr_hcall.c:490:
+^I^Istl_phys(addr, val);$

ERROR: code indent should never use tabs
#78: FILE: hw/spapr_hcall.c:491:
+^I^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#79: FILE: hw/spapr_hcall.c:492:
+^Icase 8:$

ERROR: trailing whitespace
#80: FILE: hw/spapr_hcall.c:493:
+^I^Istq_phys(addr, val);^I$

ERROR: code indent should never use tabs
#80: FILE: hw/spapr_hcall.c:493:
+^I^Istq_phys(addr, val);^I$

ERROR: code indent should never use tabs
#81: FILE: hw/spapr_hcall.c:494:
+^I^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#82: FILE: hw/spapr_hcall.c:495:
+^I}$

ERROR: code indent should never use tabs
#83: FILE: hw/spapr_hcall.c:496:
+^Ireturn H_PARAMETER;$

ERROR: code indent should never use tabs
#87: FILE: hw/spapr_hcall.c:500:
+^I^I^I^I   target_ulong opcode, target_ulong *args)$

ERROR: code indent should never use tabs
#89: FILE: hw/spapr_hcall.c:502:
+^I/* Nothing to do on emulation, KVM will trap this in the kernel */$

ERROR: code indent should never use tabs
#90: FILE: hw/spapr_hcall.c:503:
+^Ireturn H_SUCCESS;$

ERROR: code indent should never use tabs
#94: FILE: hw/spapr_hcall.c:507:
+^I^I^I^I   target_ulong opcode, target_ulong *args)$

ERROR: code indent should never use tabs
#96: FILE: hw/spapr_hcall.c:509:
+^I/* Nothing to do on emulation, KVM will trap this in the kernel */$

ERROR: code indent should never use tabs
#97: FILE: hw/spapr_hcall.c:510:
+^Ireturn H_SUCCESS;$

ERROR: trailing whitespace
#118: FILE: hw/spapr_hcall.c:588:
+    $

total: 47 errors, 0 warnings, 86 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
diff mbox

Patch

diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index f7ead04..89d80d3 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,19 @@  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);
 }