qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

s390x/gdb: support reading/writing of control registers

Let's support reading and writing of control registers for kvm and tcg.

We have to take care of flushing the tlb (tcg) and pushing the changed
registers into kvm.

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>

authored by

David Hildenbrand and committed by
Cornelia Huck
5b9f6345 c0194a00

+66 -1
+1 -1
configure
··· 5392 5392 echo "TARGET_ABI32=y" >> $config_target_mak 5393 5393 ;; 5394 5394 s390x) 5395 - gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml" 5395 + gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml" 5396 5396 ;; 5397 5397 tricore) 5398 5398 ;;
+26
gdb-xml/s390-cr.xml
··· 1 + <?xml version="1.0"?> 2 + <!-- Copyright 2015 IBM Corp. 3 + 4 + This work is licensed under the terms of the GNU GPL, version 2 or 5 + (at your option) any later version. See the COPYING file in the 6 + top-level directory. --> 7 + 8 + <!DOCTYPE feature SYSTEM "gdb-target.dtd"> 9 + <feature name="org.gnu.gdb.s390.cr"> 10 + <reg name="cr0" bitsize="64" type="uint64" group="control"/> 11 + <reg name="cr1" bitsize="64" type="uint64" group="control"/> 12 + <reg name="cr2" bitsize="64" type="uint64" group="control"/> 13 + <reg name="cr3" bitsize="64" type="uint64" group="control"/> 14 + <reg name="cr4" bitsize="64" type="uint64" group="control"/> 15 + <reg name="cr5" bitsize="64" type="uint64" group="control"/> 16 + <reg name="cr6" bitsize="64" type="uint64" group="control"/> 17 + <reg name="cr7" bitsize="64" type="uint64" group="control"/> 18 + <reg name="cr8" bitsize="64" type="uint64" group="control"/> 19 + <reg name="cr9" bitsize="64" type="uint64" group="control"/> 20 + <reg name="cr10" bitsize="64" type="uint64" group="control"/> 21 + <reg name="cr11" bitsize="64" type="uint64" group="control"/> 22 + <reg name="cr12" bitsize="64" type="uint64" group="control"/> 23 + <reg name="cr13" bitsize="64" type="uint64" group="control"/> 24 + <reg name="cr14" bitsize="64" type="uint64" group="control"/> 25 + <reg name="cr15" bitsize="64" type="uint64" group="control"/> 26 + </feature>
+39
target-s390x/gdbstub.c
··· 174 174 } 175 175 } 176 176 177 + /* the values represent the positions in s390-cr.xml */ 178 + #define S390_C0_REGNUM 0 179 + #define S390_C15_REGNUM 15 180 + /* total number of registers in s390-cr.xml */ 181 + #define S390_NUM_C_REGS 16 182 + 183 + #ifndef CONFIG_USER_ONLY 184 + static int cpu_read_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) 185 + { 186 + switch (n) { 187 + case S390_C0_REGNUM ... S390_C15_REGNUM: 188 + return gdb_get_regl(mem_buf, env->cregs[n]); 189 + default: 190 + return 0; 191 + } 192 + } 193 + 194 + static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) 195 + { 196 + switch (n) { 197 + case S390_C0_REGNUM ... S390_C15_REGNUM: 198 + env->cregs[n] = ldtul_p(mem_buf); 199 + if (tcg_enabled()) { 200 + tlb_flush(ENV_GET_CPU(env), 1); 201 + } 202 + cpu_synchronize_post_init(ENV_GET_CPU(env)); 203 + return 8; 204 + default: 205 + return 0; 206 + } 207 + } 208 + #endif 209 + 177 210 void s390_cpu_gdb_init(CPUState *cs) 178 211 { 179 212 gdb_register_coprocessor(cs, cpu_read_ac_reg, ··· 187 220 gdb_register_coprocessor(cs, cpu_read_vreg, 188 221 cpu_write_vreg, 189 222 S390_NUM_VREGS, "s390-vx.xml", 0); 223 + 224 + #ifndef CONFIG_USER_ONLY 225 + gdb_register_coprocessor(cs, cpu_read_c_reg, 226 + cpu_write_c_reg, 227 + S390_NUM_C_REGS, "s390-cr.xml", 0); 228 + #endif 190 229 }