Skip to content

Commit

Permalink
s390x/gdb: add gs registers
Browse files Browse the repository at this point in the history
Let's provide the guarded storage registers via gdb server.

Signed-off-by: Christian Borntraeger <[email protected]>
  • Loading branch information
borntraeger committed Jul 14, 2017
1 parent 21a1069 commit 86158a2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -6231,7 +6231,7 @@ case "$target_name" in
echo "TARGET_ABI32=y" >> $config_target_mak
;;
s390x)
gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
;;
tilegx)
;;
Expand Down
14 changes: 14 additions & 0 deletions gdb-xml/s390-gs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!-- Copyright 2017 IBM Corp.
This work is licensed under the terms of the GNU GPL, version 2 or
(at your option) any later version. See the COPYING file in the
top-level directory. -->

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.s390.gs">
<reg name="gs_reserved" bitsize="64" type="uint64" group="system"/>
<reg name="gsd" bitsize="64" type="uint64" group="system"/>
<reg name="gssm" bitsize="64" type="uint64" group="system"/>
<reg name="gsepla" bitsize="64" type="data_ptr" group="system"/>
</feature>
24 changes: 24 additions & 0 deletions target/s390x/gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,26 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
}
#endif

/* the values represent the positions in s390-gs.xml */
#define S390_GS_RESERVED_REGNUM 0
#define S390_GS_GSD_REGNUM 1
#define S390_GS_GSSM_REGNUM 2
#define S390_GS_GSEPLA_REGNUM 3
/* total number of registers in s390-gs.xml */
#define S390_NUM_GS_REGS 4

static int cpu_read_gs_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
{
return gdb_get_regl(mem_buf, env->gscb[n]);
}

static int cpu_write_gs_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
{
env->gscb[n] = ldtul_p(mem_buf);
cpu_synchronize_post_init(ENV_GET_CPU(env));
return 8;
}

void s390_cpu_gdb_init(CPUState *cs)
{
gdb_register_coprocessor(cs, cpu_read_ac_reg,
Expand All @@ -300,6 +320,10 @@ void s390_cpu_gdb_init(CPUState *cs)
cpu_write_vreg,
S390_NUM_VREGS, "s390-vx.xml", 0);

gdb_register_coprocessor(cs, cpu_read_gs_reg,
cpu_write_gs_reg,
S390_NUM_GS_REGS, "s390-gs.xml", 0);

#ifndef CONFIG_USER_ONLY
gdb_register_coprocessor(cs, cpu_read_c_reg,
cpu_write_c_reg,
Expand Down

0 comments on commit 86158a2

Please sign in to comment.