* [Qemu-devel] [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB @ 2018-03-14 13:28 Abdallah Bouassida 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 1/3] target/arm: Add "ARM_CP_NO_GDB" as a new bit field for ARMCPRegInfo type Abdallah Bouassida ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: Abdallah Bouassida @ 2018-03-14 13:28 UTC (permalink / raw) To: qemu-devel, peter.maydell; +Cc: qemu-arm, khaled.jmal, Abdallah Bouassida The previous version: http://patchwork.ozlabs.org/project/qemu-devel/list/?series=33190 Abdallah Bouassida (3): target/arm: Add "ARM_CP_NO_GDB" as a new bit field for ARMCPRegInfo type target/arm: Add "_S" suffix to the secure version of a sysreg target/arm: Add the XML dynamic generation gdbstub.c | 10 ++++++++ include/qom/cpu.h | 5 +++- target/arm/cpu.c | 1 + target/arm/cpu.h | 29 ++++++++++++++++++++- target/arm/gdbstub.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ target/arm/helper.c | 58 +++++++++++++++++++++++++++++++++--------- 6 files changed, 160 insertions(+), 14 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH v5 1/3] target/arm: Add "ARM_CP_NO_GDB" as a new bit field for ARMCPRegInfo type 2018-03-14 13:28 [Qemu-devel] [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida @ 2018-03-14 13:28 ` Abdallah Bouassida 2018-04-04 10:50 ` [Qemu-devel] [Qemu-arm] " Alex Bennée 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 2/3] target/arm: Add "_S" suffix to the secure version of a sysreg Abdallah Bouassida ` (2 subsequent siblings) 3 siblings, 1 reply; 12+ messages in thread From: Abdallah Bouassida @ 2018-03-14 13:28 UTC (permalink / raw) To: qemu-devel, peter.maydell; +Cc: qemu-arm, khaled.jmal, Abdallah Bouassida This is a preparation for the coming feature of creating dynamically an XML description for the ARM sysregs. A register has ARM_CP_NO_GDB enabled will not be shown in the dynamic XML. This bit is enabled automatically when creating CP_ANY wildcard aliases. This bit could be enabled manually for any register we want to remove from the dynamic XML description. Signed-off-by: Abdallah Bouassida <abdallah.bouassida@lauterbach.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> --- target/arm/cpu.h | 3 ++- target/arm/helper.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1e7e1f8..5a6ea24 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1815,10 +1815,11 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) #define ARM_LAST_SPECIAL ARM_CP_DC_ZVA #define ARM_CP_FPU 0x1000 #define ARM_CP_SVE 0x2000 +#define ARM_CP_NO_GDB 0x4000 /* Used only as a terminator for ARMCPRegInfo lists */ #define ARM_CP_SENTINEL 0xffff /* Mask of only the flag bits in a type field */ -#define ARM_CP_FLAG_MASK 0x30ff +#define ARM_CP_FLAG_MASK 0x70ff /* Valid values for ARMCPRegInfo state field, indicating which of * the AArch32 and AArch64 execution states this register is visible in. diff --git a/target/arm/helper.c b/target/arm/helper.c index 09893e3..db8c925 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5664,7 +5664,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, if (((r->crm == CP_ANY) && crm != 0) || ((r->opc1 == CP_ANY) && opc1 != 0) || ((r->opc2 == CP_ANY) && opc2 != 0)) { - r2->type |= ARM_CP_ALIAS; + r2->type |= ARM_CP_ALIAS | ARM_CP_NO_GDB; } /* Check that raw accesses are either forbidden or handled. Note that -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [Qemu-arm] [PATCH v5 1/3] target/arm: Add "ARM_CP_NO_GDB" as a new bit field for ARMCPRegInfo type 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 1/3] target/arm: Add "ARM_CP_NO_GDB" as a new bit field for ARMCPRegInfo type Abdallah Bouassida @ 2018-04-04 10:50 ` Alex Bennée 0 siblings, 0 replies; 12+ messages in thread From: Alex Bennée @ 2018-04-04 10:50 UTC (permalink / raw) To: Abdallah Bouassida; +Cc: qemu-devel, peter.maydell, khaled.jmal, qemu-arm Abdallah Bouassida <abdallah.bouassida@lauterbach.com> writes: > This is a preparation for the coming feature of creating dynamically an XML > description for the ARM sysregs. > A register has ARM_CP_NO_GDB enabled will not be shown in the dynamic XML. > This bit is enabled automatically when creating CP_ANY wildcard aliases. > This bit could be enabled manually for any register we want to remove from the > dynamic XML description. > > Signed-off-by: Abdallah Bouassida <abdallah.bouassida@lauterbach.com> > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> > --- > target/arm/cpu.h | 3 ++- > target/arm/helper.c | 2 +- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/target/arm/cpu.h b/target/arm/cpu.h > index 1e7e1f8..5a6ea24 100644 > --- a/target/arm/cpu.h > +++ b/target/arm/cpu.h > @@ -1815,10 +1815,11 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) > #define ARM_LAST_SPECIAL ARM_CP_DC_ZVA > #define ARM_CP_FPU 0x1000 > #define ARM_CP_SVE 0x2000 > +#define ARM_CP_NO_GDB 0x4000 > /* Used only as a terminator for ARMCPRegInfo lists */ > #define ARM_CP_SENTINEL 0xffff > /* Mask of only the flag bits in a type field */ > -#define ARM_CP_FLAG_MASK 0x30ff > +#define ARM_CP_FLAG_MASK 0x70ff > > /* Valid values for ARMCPRegInfo state field, indicating which of > * the AArch32 and AArch64 execution states this register is visible in. > diff --git a/target/arm/helper.c b/target/arm/helper.c > index 09893e3..db8c925 100644 > --- a/target/arm/helper.c > +++ b/target/arm/helper.c > @@ -5664,7 +5664,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, > if (((r->crm == CP_ANY) && crm != 0) || > ((r->opc1 == CP_ANY) && opc1 != 0) || > ((r->opc2 == CP_ANY) && opc2 != 0)) { > - r2->type |= ARM_CP_ALIAS; > + r2->type |= ARM_CP_ALIAS | ARM_CP_NO_GDB; > } > > /* Check that raw accesses are either forbidden or handled. Note that -- Alex Bennée ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH v5 2/3] target/arm: Add "_S" suffix to the secure version of a sysreg 2018-03-14 13:28 [Qemu-devel] [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 1/3] target/arm: Add "ARM_CP_NO_GDB" as a new bit field for ARMCPRegInfo type Abdallah Bouassida @ 2018-03-14 13:28 ` Abdallah Bouassida 2018-04-04 10:51 ` [Qemu-devel] [Qemu-arm] " Alex Bennée 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 3/3] target/arm: Add the XML dynamic generation Abdallah Bouassida 2018-03-22 15:08 ` [Qemu-devel] ping Re: [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida 3 siblings, 1 reply; 12+ messages in thread From: Abdallah Bouassida @ 2018-03-14 13:28 UTC (permalink / raw) To: qemu-devel, peter.maydell; +Cc: qemu-arm, khaled.jmal, Abdallah Bouassida This is a preparation for the coming feature of creating dynamically an XML description for the ARM sysregs. Add "_S" suffix to the secure version of sysregs that have both S and NS views Replace (S) and (NS) by _S and _NS for the register that are manually defined, so all the registers follow the same convention. Signed-off-by: Abdallah Bouassida <abdallah.bouassida@lauterbach.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> --- target/arm/helper.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index db8c925..1360a14 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -695,12 +695,12 @@ static const ARMCPRegInfo cp_reginfo[] = { * the secure register to be properly reset and migrated. There is also no * v8 EL1 version of the register so the non-secure instance stands alone. */ - { .name = "FCSEIDR(NS)", + { .name = "FCSEIDR", .cp = 15, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 0, .access = PL1_RW, .secure = ARM_CP_SECSTATE_NS, .fieldoffset = offsetof(CPUARMState, cp15.fcseidr_ns), .resetvalue = 0, .writefn = fcse_write, .raw_writefn = raw_write, }, - { .name = "FCSEIDR(S)", + { .name = "FCSEIDR_S", .cp = 15, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 0, .access = PL1_RW, .secure = ARM_CP_SECSTATE_S, .fieldoffset = offsetof(CPUARMState, cp15.fcseidr_s), @@ -716,7 +716,7 @@ static const ARMCPRegInfo cp_reginfo[] = { .access = PL1_RW, .secure = ARM_CP_SECSTATE_NS, .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[1]), .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, - { .name = "CONTEXTIDR(S)", .state = ARM_CP_STATE_AA32, + { .name = "CONTEXTIDR_S", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 1, .access = PL1_RW, .secure = ARM_CP_SECSTATE_S, .fieldoffset = offsetof(CPUARMState, cp15.contextidr_s), @@ -1967,7 +1967,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { cp15.c14_timer[GTIMER_PHYS].ctl), .writefn = gt_phys_ctl_write, .raw_writefn = raw_write, }, - { .name = "CNTP_CTL(S)", + { .name = "CNTP_CTL_S", .cp = 15, .crn = 14, .crm = 2, .opc1 = 0, .opc2 = 1, .secure = ARM_CP_SECSTATE_S, .type = ARM_CP_IO | ARM_CP_ALIAS, .access = PL1_RW | PL0_R, @@ -2006,7 +2006,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { .accessfn = gt_ptimer_access, .readfn = gt_phys_tval_read, .writefn = gt_phys_tval_write, }, - { .name = "CNTP_TVAL(S)", + { .name = "CNTP_TVAL_S", .cp = 15, .crn = 14, .crm = 2, .opc1 = 0, .opc2 = 0, .secure = ARM_CP_SECSTATE_S, .type = ARM_CP_NO_RAW | ARM_CP_IO, .access = PL1_RW | PL0_R, @@ -2060,7 +2060,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { .accessfn = gt_ptimer_access, .writefn = gt_phys_cval_write, .raw_writefn = raw_write, }, - { .name = "CNTP_CVAL(S)", .cp = 15, .crm = 14, .opc1 = 2, + { .name = "CNTP_CVAL_S", .cp = 15, .crm = 14, .opc1 = 2, .secure = ARM_CP_SECSTATE_S, .access = PL1_RW | PL0_R, .type = ARM_CP_64BIT | ARM_CP_IO | ARM_CP_ALIAS, @@ -5563,7 +5563,8 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, void *opaque, int state, int secstate, - int crm, int opc1, int opc2) + int crm, int opc1, int opc2, + const char *name) { /* Private utility function for define_one_arm_cp_reg_with_opaque(): * add a single reginfo struct to the hash table. @@ -5573,6 +5574,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; + r2->name = g_strdup(name); /* Reset the secure state to the specific incoming state. This is * necessary as the register may have been defined with both states. */ @@ -5804,19 +5806,24 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, /* Under AArch32 CP registers can be common * (same for secure and non-secure world) or banked. */ + char *name; + switch (r->secure) { case ARM_CP_SECSTATE_S: case ARM_CP_SECSTATE_NS: add_cpreg_to_hashtable(cpu, r, opaque, state, - r->secure, crm, opc1, opc2); + r->secure, crm, opc1, opc2, + r->name); break; default: + name = g_strdup_printf("%s_S", r->name); add_cpreg_to_hashtable(cpu, r, opaque, state, ARM_CP_SECSTATE_S, - crm, opc1, opc2); + crm, opc1, opc2, name); + g_free(name); add_cpreg_to_hashtable(cpu, r, opaque, state, ARM_CP_SECSTATE_NS, - crm, opc1, opc2); + crm, opc1, opc2, r->name); break; } } else { @@ -5824,7 +5831,7 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, * of AArch32 */ add_cpreg_to_hashtable(cpu, r, opaque, state, ARM_CP_SECSTATE_NS, - crm, opc1, opc2); + crm, opc1, opc2, r->name); } } } -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [Qemu-arm] [PATCH v5 2/3] target/arm: Add "_S" suffix to the secure version of a sysreg 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 2/3] target/arm: Add "_S" suffix to the secure version of a sysreg Abdallah Bouassida @ 2018-04-04 10:51 ` Alex Bennée 0 siblings, 0 replies; 12+ messages in thread From: Alex Bennée @ 2018-04-04 10:51 UTC (permalink / raw) To: Abdallah Bouassida; +Cc: qemu-devel, peter.maydell, khaled.jmal, qemu-arm Abdallah Bouassida <abdallah.bouassida@lauterbach.com> writes: > This is a preparation for the coming feature of creating dynamically an XML > description for the ARM sysregs. > Add "_S" suffix to the secure version of sysregs that have both S and NS views > Replace (S) and (NS) by _S and _NS for the register that are manually defined, > so all the registers follow the same convention. > > Signed-off-by: Abdallah Bouassida <abdallah.bouassida@lauterbach.com> > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> > --- > target/arm/helper.c | 29 ++++++++++++++++++----------- > 1 file changed, 18 insertions(+), 11 deletions(-) > > diff --git a/target/arm/helper.c b/target/arm/helper.c > index db8c925..1360a14 100644 > --- a/target/arm/helper.c > +++ b/target/arm/helper.c > @@ -695,12 +695,12 @@ static const ARMCPRegInfo cp_reginfo[] = { > * the secure register to be properly reset and migrated. There is also no > * v8 EL1 version of the register so the non-secure instance stands alone. > */ > - { .name = "FCSEIDR(NS)", > + { .name = "FCSEIDR", > .cp = 15, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 0, > .access = PL1_RW, .secure = ARM_CP_SECSTATE_NS, > .fieldoffset = offsetof(CPUARMState, cp15.fcseidr_ns), > .resetvalue = 0, .writefn = fcse_write, .raw_writefn = raw_write, }, > - { .name = "FCSEIDR(S)", > + { .name = "FCSEIDR_S", > .cp = 15, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 0, > .access = PL1_RW, .secure = ARM_CP_SECSTATE_S, > .fieldoffset = offsetof(CPUARMState, cp15.fcseidr_s), > @@ -716,7 +716,7 @@ static const ARMCPRegInfo cp_reginfo[] = { > .access = PL1_RW, .secure = ARM_CP_SECSTATE_NS, > .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[1]), > .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, > - { .name = "CONTEXTIDR(S)", .state = ARM_CP_STATE_AA32, > + { .name = "CONTEXTIDR_S", .state = ARM_CP_STATE_AA32, > .cp = 15, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 1, > .access = PL1_RW, .secure = ARM_CP_SECSTATE_S, > .fieldoffset = offsetof(CPUARMState, cp15.contextidr_s), > @@ -1967,7 +1967,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { > cp15.c14_timer[GTIMER_PHYS].ctl), > .writefn = gt_phys_ctl_write, .raw_writefn = raw_write, > }, > - { .name = "CNTP_CTL(S)", > + { .name = "CNTP_CTL_S", > .cp = 15, .crn = 14, .crm = 2, .opc1 = 0, .opc2 = 1, > .secure = ARM_CP_SECSTATE_S, > .type = ARM_CP_IO | ARM_CP_ALIAS, .access = PL1_RW | PL0_R, > @@ -2006,7 +2006,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { > .accessfn = gt_ptimer_access, > .readfn = gt_phys_tval_read, .writefn = gt_phys_tval_write, > }, > - { .name = "CNTP_TVAL(S)", > + { .name = "CNTP_TVAL_S", > .cp = 15, .crn = 14, .crm = 2, .opc1 = 0, .opc2 = 0, > .secure = ARM_CP_SECSTATE_S, > .type = ARM_CP_NO_RAW | ARM_CP_IO, .access = PL1_RW | PL0_R, > @@ -2060,7 +2060,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { > .accessfn = gt_ptimer_access, > .writefn = gt_phys_cval_write, .raw_writefn = raw_write, > }, > - { .name = "CNTP_CVAL(S)", .cp = 15, .crm = 14, .opc1 = 2, > + { .name = "CNTP_CVAL_S", .cp = 15, .crm = 14, .opc1 = 2, > .secure = ARM_CP_SECSTATE_S, > .access = PL1_RW | PL0_R, > .type = ARM_CP_64BIT | ARM_CP_IO | ARM_CP_ALIAS, > @@ -5563,7 +5563,8 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) > > static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, > void *opaque, int state, int secstate, > - int crm, int opc1, int opc2) > + int crm, int opc1, int opc2, > + const char *name) > { > /* Private utility function for define_one_arm_cp_reg_with_opaque(): > * add a single reginfo struct to the hash table. > @@ -5573,6 +5574,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, > int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; > int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; > > + r2->name = g_strdup(name); > /* Reset the secure state to the specific incoming state. This is > * necessary as the register may have been defined with both states. > */ > @@ -5804,19 +5806,24 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, > /* Under AArch32 CP registers can be common > * (same for secure and non-secure world) or banked. > */ > + char *name; > + > switch (r->secure) { > case ARM_CP_SECSTATE_S: > case ARM_CP_SECSTATE_NS: > add_cpreg_to_hashtable(cpu, r, opaque, state, > - r->secure, crm, opc1, opc2); > + r->secure, crm, opc1, opc2, > + r->name); > break; > default: > + name = g_strdup_printf("%s_S", r->name); > add_cpreg_to_hashtable(cpu, r, opaque, state, > ARM_CP_SECSTATE_S, > - crm, opc1, opc2); > + crm, opc1, opc2, name); > + g_free(name); > add_cpreg_to_hashtable(cpu, r, opaque, state, > ARM_CP_SECSTATE_NS, > - crm, opc1, opc2); > + crm, opc1, opc2, r->name); > break; > } > } else { > @@ -5824,7 +5831,7 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, > * of AArch32 */ > add_cpreg_to_hashtable(cpu, r, opaque, state, > ARM_CP_SECSTATE_NS, > - crm, opc1, opc2); > + crm, opc1, opc2, r->name); > } > } > } -- Alex Bennée ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH v5 3/3] target/arm: Add the XML dynamic generation 2018-03-14 13:28 [Qemu-devel] [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 1/3] target/arm: Add "ARM_CP_NO_GDB" as a new bit field for ARMCPRegInfo type Abdallah Bouassida 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 2/3] target/arm: Add "_S" suffix to the secure version of a sysreg Abdallah Bouassida @ 2018-03-14 13:28 ` Abdallah Bouassida 2018-04-04 12:26 ` [Qemu-devel] [Qemu-arm] " Alex Bennée 2018-03-22 15:08 ` [Qemu-devel] ping Re: [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida 3 siblings, 1 reply; 12+ messages in thread From: Abdallah Bouassida @ 2018-03-14 13:28 UTC (permalink / raw) To: qemu-devel, peter.maydell; +Cc: qemu-arm, khaled.jmal, Abdallah Bouassida Generate an XML description for the cp-regs. Register these regs with the gdb_register_coprocessor(). Add arm_gdb_get_sysreg() to use it as a callback to read those regs. Add a dummy arm_gdb_set_sysreg(). Signed-off-by: Abdallah Bouassida <abdallah.bouassida@lauterbach.com> --- gdbstub.c | 10 ++++++++ include/qom/cpu.h | 5 +++- target/arm/cpu.c | 1 + target/arm/cpu.h | 26 +++++++++++++++++++ target/arm/gdbstub.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ target/arm/helper.c | 27 ++++++++++++++++++++ 6 files changed, 139 insertions(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index f1d5148..09065bc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -674,6 +674,16 @@ static const char *get_feature_xml(const char *p, const char **newp, } return target_xml; } + if (cc->gdb_get_dynamic_xml) { + CPUState *cpu = first_cpu; + char *xmlname = g_strndup(p, len); + const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); + + free(xmlname); + if (xml) { + return xml; + } + } for (i = 0; ; i++) { name = xml_builtin[i][0]; if (!name || (strncmp(name, p, len) == 0 && strlen(name) == len)) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index dc6d495..be6d84d 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -132,6 +132,9 @@ struct TranslationBlock; * before the insn which triggers a watchpoint rather than after it. * @gdb_arch_name: Optional callback that returns the architecture name known * to GDB. The caller must free the returned string with g_free. + * @gdb_get_dynamic_xml: Callback to return dynamically generated XML for the + * gdb stub. Returns a pointer to the XML contents for the specified XML file + * or NULL if the CPU doesn't have a dynamically generated content for it. * @cpu_exec_enter: Callback for cpu_exec preparation. * @cpu_exec_exit: Callback for cpu_exec cleanup. * @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec. @@ -198,7 +201,7 @@ typedef struct CPUClass { const struct VMStateDescription *vmsd; const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu); - + const char *(*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname); void (*cpu_exec_enter)(CPUState *cpu); void (*cpu_exec_exit)(CPUState *cpu); bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 022d8c5..38b8b1c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1879,6 +1879,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs = 26; cc->gdb_core_xml_file = "arm-core.xml"; cc->gdb_arch_name = arm_gdb_arch_name; + cc->gdb_get_dynamic_xml = arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint = true; cc->debug_excp_handler = arm_debug_excp_handler; cc->debug_check_watchpoint = arm_debug_check_watchpoint; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5a6ea24..5664f58 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -133,6 +133,19 @@ enum { s<2n+1> maps to the most significant half of d<n> */ +/** + * DynamicGDBXMLInfo: + * @desc: Contains the XML descriptions. + * @num_cpregs: Number of the Coprocessor registers seen by GDB. + * @cpregs_keys: Array that contains the corresponding Key of + * a given cpreg with the same order of the cpreg in the XML description. + */ +typedef struct DynamicGDBXMLInfo { + char *desc; + int num_cpregs; + uint32_t *cpregs_keys; +} DynamicGDBXMLInfo; + /* CPU state for each instance of a generic timer (in cp15 c14) */ typedef struct ARMGenericTimer { uint64_t cval; /* Timer CompareValue register */ @@ -682,6 +695,8 @@ struct ARMCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; + DynamicGDBXMLInfo dyn_xml; + /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; /* GPIO outputs for generic timer */ @@ -863,6 +878,17 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, int arm_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +/* Dynamically generates for gdb stub an XML description of the sysregs from + * the cp_regs hashtable. Returns the registered sysregs number. + */ +int arm_gen_dynamic_xml(CPUState *cpu); + +/* Returns the dynamically generated XML for the gdb stub. + * Returns a pointer to the XML contents for the specified XML file or NULL + * if the XML name doesn't match the predefined one. + */ +const char *arm_gdb_get_dynamic_xml(CPUState *cpu, const char *xmlname); + int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, void *opaque); int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 04c1208..fafc08b 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -101,3 +101,74 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) /* Unknown register. */ return 0; } + +static void arm_gen_one_xml_reg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, + ARMCPRegInfo *ri, uint32_t ri_key, + int bitsize) +{ + g_string_append_printf(s, "<reg name=\"%s\"", ri->name); + g_string_append_printf(s, " bitsize=\"%d\"", bitsize); + g_string_append_printf(s, " group=\"cp_regs\"/>"); + dyn_xml->num_cpregs++; + dyn_xml->cpregs_keys[dyn_xml->num_cpregs - 1] = ri_key; +} + +static void arm_register_sysreg_for_xml(gpointer key, gpointer value, + gpointer p) +{ + uint32_t ri_key = *(uint32_t *)key; + ARMCPRegInfo *ri = value; + void **p_array = p; + ARMCPU *cpu = ARM_CPU((CPUState *)(p_array[0])); + CPUARMState *env = &cpu->env; + DynamicGDBXMLInfo *dyn_xml = &cpu->dyn_xml; + GString *s = (GString *)(p_array[1]); + + if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { + if (arm_feature(env, ARM_FEATURE_AARCH64)) { + if (ri->state == ARM_CP_STATE_AA64) { + arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); + } + } else { + if (ri->state == ARM_CP_STATE_AA32) { + if (!arm_feature(env, ARM_FEATURE_EL3) && + (ri->secure & ARM_CP_SECSTATE_S)) { + return; + } + if (ri->type & ARM_CP_64BIT) { + arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); + } else { + arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 32); + } + } + } + } +} + +int arm_gen_dynamic_xml(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + GString *s = g_string_new(NULL); + void *p_array[] = {cs, s}; + + cpu->dyn_xml.num_cpregs = 0; + cpu->dyn_xml.cpregs_keys = g_malloc(sizeof(uint32_t *) * + g_hash_table_size(cpu->cp_regs)); + g_string_printf(s, "<?xml version=\"1.0\"?>"); + g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); + g_string_append_printf(s, "<feature name=\"org.qemu.gdb.arm.sys.regs\">"); + g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, p_array); + g_string_append_printf(s, "</feature>"); + cpu->dyn_xml.desc = g_string_free(s, false); + return cpu->dyn_xml.num_cpregs; +} + +const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) +{ + ARMCPU *cpu = ARM_CPU(cs); + + if (strcmp(xmlname, "system-registers.xml") == 0) { + return cpu->dyn_xml.desc; + } + return NULL; +} diff --git a/target/arm/helper.c b/target/arm/helper.c index 1360a14..d3c40b7 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -220,6 +220,29 @@ static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri, } } +static int arm_gdb_get_sysreg(CPUARMState *env, uint8_t *buf, int reg) +{ + ARMCPU *cpu = arm_env_get_cpu(env); + const ARMCPRegInfo *ri; + uint32_t key; + + key = cpu->dyn_xml.cpregs_keys[reg]; + ri = get_arm_cp_reginfo(cpu->cp_regs, key); + if (ri) { + if (cpreg_field_is_64bit(ri)) { + return gdb_get_reg64(buf, (uint64_t)read_raw_cp_reg(env, ri)); + } else { + return gdb_get_reg32(buf, (uint32_t)read_raw_cp_reg(env, ri)); + } + } + return 0; +} + +static int arm_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) +{ + return 0; +} + static bool raw_accessors_invalid(const ARMCPRegInfo *ri) { /* Return true if the regdef would cause an assertion if you called @@ -5459,6 +5482,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) { CPUState *cs = CPU(cpu); CPUARMState *env = &cpu->env; + int n; if (arm_feature(env, ARM_FEATURE_AARCH64)) { gdb_register_coprocessor(cs, aarch64_fpu_gdb_get_reg, @@ -5474,6 +5498,9 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, 19, "arm-vfp.xml", 0); } + n = arm_gen_dynamic_xml(cs); + gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, + n, "system-registers.xml", 0); } /* Sort alphabetically by type name, except for "any". */ -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [Qemu-arm] [PATCH v5 3/3] target/arm: Add the XML dynamic generation 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 3/3] target/arm: Add the XML dynamic generation Abdallah Bouassida @ 2018-04-04 12:26 ` Alex Bennée 2018-04-06 17:28 ` Abdallah Bouassida 2018-04-12 9:55 ` Peter Maydell 0 siblings, 2 replies; 12+ messages in thread From: Alex Bennée @ 2018-04-04 12:26 UTC (permalink / raw) To: Abdallah Bouassida; +Cc: qemu-devel, peter.maydell, khaled.jmal, qemu-arm Abdallah Bouassida <abdallah.bouassida@lauterbach.com> writes: > Generate an XML description for the cp-regs. > Register these regs with the gdb_register_coprocessor(). > Add arm_gdb_get_sysreg() to use it as a callback to read those regs. > Add a dummy arm_gdb_set_sysreg(). > > Signed-off-by: Abdallah Bouassida <abdallah.bouassida@lauterbach.com> > --- > gdbstub.c | 10 ++++++++ > include/qom/cpu.h | 5 +++- > target/arm/cpu.c | 1 + > target/arm/cpu.h | 26 +++++++++++++++++++ > target/arm/gdbstub.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > target/arm/helper.c | 27 ++++++++++++++++++++ > 6 files changed, 139 insertions(+), 1 deletion(-) > > diff --git a/gdbstub.c b/gdbstub.c > index f1d5148..09065bc 100644 > --- a/gdbstub.c > +++ b/gdbstub.c > @@ -674,6 +674,16 @@ static const char *get_feature_xml(const char *p, const char **newp, > } > return target_xml; > } > + if (cc->gdb_get_dynamic_xml) { > + CPUState *cpu = first_cpu; > + char *xmlname = g_strndup(p, len); > + const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); > + > + free(xmlname); g_free for a g_strndup'ed string please - although I'm confused as to why you need to g_strdup the string. You already have p and its not like gdb_get_dynamic_xml couldn't dup the string if it needed to (which it doesn't seem to). > + if (xml) { > + return xml; > + } > + } > for (i = 0; ; i++) { > name = xml_builtin[i][0]; > if (!name || (strncmp(name, p, len) == 0 && strlen(name) == len)) > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index dc6d495..be6d84d 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -132,6 +132,9 @@ struct TranslationBlock; > * before the insn which triggers a watchpoint rather than after it. > * @gdb_arch_name: Optional callback that returns the architecture name known > * to GDB. The caller must free the returned string with g_free. > + * @gdb_get_dynamic_xml: Callback to return dynamically generated XML for the > + * gdb stub. Returns a pointer to the XML contents for the specified XML file > + * or NULL if the CPU doesn't have a dynamically generated content for it. > * @cpu_exec_enter: Callback for cpu_exec preparation. > * @cpu_exec_exit: Callback for cpu_exec cleanup. > * @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec. > @@ -198,7 +201,7 @@ typedef struct CPUClass { > const struct VMStateDescription *vmsd; > const char *gdb_core_xml_file; > gchar * (*gdb_arch_name)(CPUState *cpu); > - > + const char *(*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname); > void (*cpu_exec_enter)(CPUState *cpu); > void (*cpu_exec_exit)(CPUState *cpu); > bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); > diff --git a/target/arm/cpu.c b/target/arm/cpu.c > index 022d8c5..38b8b1c 100644 > --- a/target/arm/cpu.c > +++ b/target/arm/cpu.c > @@ -1879,6 +1879,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) > cc->gdb_num_core_regs = 26; > cc->gdb_core_xml_file = "arm-core.xml"; > cc->gdb_arch_name = arm_gdb_arch_name; > + cc->gdb_get_dynamic_xml = arm_gdb_get_dynamic_xml; > cc->gdb_stop_before_watchpoint = true; > cc->debug_excp_handler = arm_debug_excp_handler; > cc->debug_check_watchpoint = arm_debug_check_watchpoint; > diff --git a/target/arm/cpu.h b/target/arm/cpu.h > index 5a6ea24..5664f58 100644 > --- a/target/arm/cpu.h > +++ b/target/arm/cpu.h > @@ -133,6 +133,19 @@ enum { > s<2n+1> maps to the most significant half of d<n> > */ > > +/** > + * DynamicGDBXMLInfo: > + * @desc: Contains the XML descriptions. > + * @num_cpregs: Number of the Coprocessor registers seen by GDB. > + * @cpregs_keys: Array that contains the corresponding Key of > + * a given cpreg with the same order of the cpreg in the XML description. > + */ > +typedef struct DynamicGDBXMLInfo { > + char *desc; > + int num_cpregs; > + uint32_t *cpregs_keys; > +} DynamicGDBXMLInfo; > + > /* CPU state for each instance of a generic timer (in cp15 c14) */ > typedef struct ARMGenericTimer { > uint64_t cval; /* Timer CompareValue register */ > @@ -682,6 +695,8 @@ struct ARMCPU { > uint64_t *cpreg_vmstate_values; > int32_t cpreg_vmstate_array_len; > > + DynamicGDBXMLInfo dyn_xml; > + > /* Timers used by the generic (architected) timer */ > QEMUTimer *gt_timer[NUM_GTIMERS]; > /* GPIO outputs for generic timer */ > @@ -863,6 +878,17 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, > int arm_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); > int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); > > +/* Dynamically generates for gdb stub an XML description of the sysregs from > + * the cp_regs hashtable. Returns the registered sysregs number. > + */ > +int arm_gen_dynamic_xml(CPUState *cpu); > + > +/* Returns the dynamically generated XML for the gdb stub. > + * Returns a pointer to the XML contents for the specified XML file or NULL > + * if the XML name doesn't match the predefined one. > + */ > +const char *arm_gdb_get_dynamic_xml(CPUState *cpu, const char *xmlname); > + > int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, > int cpuid, void *opaque); > int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, > diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c > index 04c1208..fafc08b 100644 > --- a/target/arm/gdbstub.c > +++ b/target/arm/gdbstub.c > @@ -101,3 +101,74 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) > /* Unknown register. */ > return 0; > } > + > +static void arm_gen_one_xml_reg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, > + ARMCPRegInfo *ri, uint32_t ri_key, > + int bitsize) > +{ > + g_string_append_printf(s, "<reg name=\"%s\"", ri->name); > + g_string_append_printf(s, " bitsize=\"%d\"", bitsize); > + g_string_append_printf(s, " group=\"cp_regs\"/>"); > + dyn_xml->num_cpregs++; > + dyn_xml->cpregs_keys[dyn_xml->num_cpregs - 1] = ri_key; > +} > + > +static void arm_register_sysreg_for_xml(gpointer key, gpointer value, > + gpointer p) > +{ > + uint32_t ri_key = *(uint32_t *)key; > + ARMCPRegInfo *ri = value; > + void **p_array = p; > + ARMCPU *cpu = ARM_CPU((CPUState *)(p_array[0])); This comes across as a little clumsy compared to casting p to a structure that contains the correctly typed parameters. > + CPUARMState *env = &cpu->env; > + DynamicGDBXMLInfo *dyn_xml = &cpu->dyn_xml; > + GString *s = (GString *)(p_array[1]); > + > + if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { > + if (arm_feature(env, ARM_FEATURE_AARCH64)) { > + if (ri->state == ARM_CP_STATE_AA64) { > + arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); > + } > + } else { > + if (ri->state == ARM_CP_STATE_AA32) { > + if (!arm_feature(env, ARM_FEATURE_EL3) && > + (ri->secure & ARM_CP_SECSTATE_S)) { > + return; > + } > + if (ri->type & ARM_CP_64BIT) { > + arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); > + } else { > + arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 32); > + } > + } > + } > + } > +} > + > +int arm_gen_dynamic_xml(CPUState *cs) > +{ > + ARMCPU *cpu = ARM_CPU(cs); > + GString *s = g_string_new(NULL); > + void *p_array[] = {cs, s}; > + > + cpu->dyn_xml.num_cpregs = 0; > + cpu->dyn_xml.cpregs_keys = g_malloc(sizeof(uint32_t *) * > + g_hash_table_size(cpu->cp_regs)); > + g_string_printf(s, "<?xml version=\"1.0\"?>"); > + g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); > + g_string_append_printf(s, "<feature name=\"org.qemu.gdb.arm.sys.regs\">"); > + g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, p_array); > + g_string_append_printf(s, "</feature>"); > + cpu->dyn_xml.desc = g_string_free(s, false); > + return cpu->dyn_xml.num_cpregs; > +} > + > +const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) > +{ > + ARMCPU *cpu = ARM_CPU(cs); > + > + if (strcmp(xmlname, "system-registers.xml") == 0) { > + return cpu->dyn_xml.desc; > + } > + return NULL; > +} > diff --git a/target/arm/helper.c b/target/arm/helper.c > index 1360a14..d3c40b7 100644 > --- a/target/arm/helper.c > +++ b/target/arm/helper.c > @@ -220,6 +220,29 @@ static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri, > } > } > > +static int arm_gdb_get_sysreg(CPUARMState *env, uint8_t *buf, int reg) > +{ > + ARMCPU *cpu = arm_env_get_cpu(env); > + const ARMCPRegInfo *ri; > + uint32_t key; > + > + key = cpu->dyn_xml.cpregs_keys[reg]; > + ri = get_arm_cp_reginfo(cpu->cp_regs, key); > + if (ri) { > + if (cpreg_field_is_64bit(ri)) { > + return gdb_get_reg64(buf, (uint64_t)read_raw_cp_reg(env, ri)); > + } else { > + return gdb_get_reg32(buf, (uint32_t)read_raw_cp_reg(env, ri)); > + } > + } > + return 0; There is something odd going on here because if I run a simple little features binary (https://github.com/stsquad/testcases/blob/master/aarch64/features.c) I get: ID_AA64ISAR0_EL1 : 0x0000000000011120 ID_AA64ISAR1_EL1 : 0x0000000000000000 ID_AA64MMFR0_EL1 : 0x00000000ff000000 ID_AA64MMFR1_EL1 : 0x0000000000000000 ID_AA64PFR0_EL1 : 0x0000000000000011 ID_AA64PFR1_EL1 : 0x0000000000000000 ID_AA64DFR0_EL1 : 0x0000000000000006 ID_AA64DFR1_EL1 : 0x0000000000000000 MIDR_EL1 : 0x00000000411fd070 MPIDR_EL1 : 0x0000000080000000 REVIDR_EL1 : 0x0000000000000000 However in the gdb output we see: ID_AA64ISAR0_EL1 0x11120 69920 ID_AA64ISAR1_EL1 0x0 0 ID_AA64MMFR0_EL1 0x1124 4388 <-? ID_AA64MMFR1_EL1 0x0 0 ID_PFR0 0x131 305 <-name and value? ID_AA64PFR1_EL1 0x0 0 ID_AA64DFR0_EL1 0x10305106 271601926 <-? ID_AA64DFR1_EL1 0x0 0 REVIDR_EL1 0x0 0 So why the discrepancies? > +} > + > +static int arm_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) > +{ > + return 0; > +} > + > static bool raw_accessors_invalid(const ARMCPRegInfo *ri) > { > /* Return true if the regdef would cause an assertion if you called > @@ -5459,6 +5482,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) > { > CPUState *cs = CPU(cpu); > CPUARMState *env = &cpu->env; > + int n; > > if (arm_feature(env, ARM_FEATURE_AARCH64)) { > gdb_register_coprocessor(cs, aarch64_fpu_gdb_get_reg, > @@ -5474,6 +5498,9 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) > gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, > 19, "arm-vfp.xml", 0); > } > + n = arm_gen_dynamic_xml(cs); > + gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, > + n, "system-registers.xml", 0); You could call arm_gen_dynamic_xml() direct when calling the register function to save the intermediate n. > } > > /* Sort alphabetically by type name, except for "any". */ -- Alex Bennée ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [Qemu-arm] [PATCH v5 3/3] target/arm: Add the XML dynamic generation 2018-04-04 12:26 ` [Qemu-devel] [Qemu-arm] " Alex Bennée @ 2018-04-06 17:28 ` Abdallah Bouassida 2018-04-12 10:14 ` Peter Maydell 2018-04-12 9:55 ` Peter Maydell 1 sibling, 1 reply; 12+ messages in thread From: Abdallah Bouassida @ 2018-04-06 17:28 UTC (permalink / raw) To: Alex Bennée, peter.maydell; +Cc: qemu-devel, khaled.jmal, qemu-arm Hi Alex, First of all, thanks for the review! >> +static int arm_gdb_get_sysreg(CPUARMState *env, uint8_t *buf, int reg) >> +{ >> + ARMCPU *cpu = arm_env_get_cpu(env); >> + const ARMCPRegInfo *ri; >> + uint32_t key; >> + >> + key = cpu->dyn_xml.cpregs_keys[reg]; >> + ri = get_arm_cp_reginfo(cpu->cp_regs, key); >> + if (ri) { >> + if (cpreg_field_is_64bit(ri)) { >> + return gdb_get_reg64(buf, (uint64_t)read_raw_cp_reg(env, ri)); >> + } else { >> + return gdb_get_reg32(buf, (uint32_t)read_raw_cp_reg(env, ri)); >> + } >> + } >> + return 0; > There is something odd going on here because if I run a simple little > features binary > (https://github.com/stsquad/testcases/blob/master/aarch64/features.c) I > get: > > ID_AA64ISAR0_EL1 : 0x0000000000011120 > ID_AA64ISAR1_EL1 : 0x0000000000000000 > ID_AA64MMFR0_EL1 : 0x00000000ff000000 > ID_AA64MMFR1_EL1 : 0x0000000000000000 > ID_AA64PFR0_EL1 : 0x0000000000000011 > ID_AA64PFR1_EL1 : 0x0000000000000000 > ID_AA64DFR0_EL1 : 0x0000000000000006 > ID_AA64DFR1_EL1 : 0x0000000000000000 > MIDR_EL1 : 0x00000000411fd070 > MPIDR_EL1 : 0x0000000080000000 > REVIDR_EL1 : 0x0000000000000000 > > However in the gdb output we see: > > ID_AA64ISAR0_EL1 0x11120 69920 > ID_AA64ISAR1_EL1 0x0 0 > ID_AA64MMFR0_EL1 0x1124 4388 <-? > ID_AA64MMFR1_EL1 0x0 0 > ID_PFR0 0x131 305 <-name and value? > ID_AA64PFR1_EL1 0x0 0 > ID_AA64DFR0_EL1 0x10305106 271601926 <-? > ID_AA64DFR1_EL1 0x0 0 > REVIDR_EL1 0x0 0 > > So why the discrepancies? > ID_AA64MMFR0_EL1 0x1124 4388 <-? > ID_AA64DFR0_EL1 0x10305106 271601926 <-? I get the same value in x1 (= 0x1124) and x2 (= 0x10305106) when I execute the following instructions on the guest: MRS x1, ID_AA64MMFR0_EL1 MRS x2, ID_AA64DFR0_EL1 So, I think that there is no problem on how GDB is reading these registers! > ID_PFR0 0x131 305 <-name and value? This is not ID_AA64PFR0_EL1 - the ID_AA64PFR0_EL1 is not registered in our dynamic XML as it has "ARM_CP_NO_RAW" type. So should we add some modifications to handle this special case? Best regards, Abdallah ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [Qemu-arm] [PATCH v5 3/3] target/arm: Add the XML dynamic generation 2018-04-06 17:28 ` Abdallah Bouassida @ 2018-04-12 10:14 ` Peter Maydell 0 siblings, 0 replies; 12+ messages in thread From: Peter Maydell @ 2018-04-12 10:14 UTC (permalink / raw) To: Abdallah Bouassida Cc: Alex Bennée, QEMU Developers, Khaled Jmal, qemu-arm On 6 April 2018 at 18:28, Abdallah Bouassida <abdallah.bouassida@lauterbach.com> wrote: > Alex wrote: >> There is something odd going on here because if I run a simple little >> features binary >> (https://github.com/stsquad/testcases/blob/master/aarch64/features.c) I >> get: >> >> ID_AA64ISAR0_EL1 : 0x0000000000011120 >> ID_AA64ISAR1_EL1 : 0x0000000000000000 >> ID_AA64MMFR0_EL1 : 0x00000000ff000000 >> ID_AA64MMFR1_EL1 : 0x0000000000000000 >> ID_AA64PFR0_EL1 : 0x0000000000000011 >> ID_AA64PFR1_EL1 : 0x0000000000000000 >> ID_AA64DFR0_EL1 : 0x0000000000000006 >> ID_AA64DFR1_EL1 : 0x0000000000000000 >> MIDR_EL1 : 0x00000000411fd070 >> MPIDR_EL1 : 0x0000000080000000 >> REVIDR_EL1 : 0x0000000000000000 >> >> However in the gdb output we see: >> >> ID_AA64ISAR0_EL1 0x11120 69920 >> ID_AA64ISAR1_EL1 0x0 0 >> ID_AA64MMFR0_EL1 0x1124 4388 <-? >> ID_AA64MMFR1_EL1 0x0 0 >> ID_PFR0 0x131 305 <-name and value? >> ID_AA64PFR1_EL1 0x0 0 >> ID_AA64DFR0_EL1 0x10305106 271601926 <-? >> ID_AA64DFR1_EL1 0x0 0 >> REVIDR_EL1 0x0 0 >> >> So why the discrepancies? > >> ID_AA64MMFR0_EL1 0x1124 4388 <-? >> ID_AA64DFR0_EL1 0x10305106 271601926 <-? > I get the same value in x1 (= 0x1124) and x2 (= 0x10305106) when I execute > the following instructions on the guest: > MRS x1, ID_AA64MMFR0_EL1 > MRS x2, ID_AA64DFR0_EL1 Alex's test program looks like a Linux userspace one -- in which case it will be reading whatever faked-up values the guest kernel is providing, rather than directly accessing the registers (since they're not EL0-readable in hardware). That may be the cause of the discrepancies. (As an aside, we probably need to add support for userspace accessing of ID regs to our linux-user code at some point.) >> ID_PFR0 0x131 305 <-name and value? > This is not ID_AA64PFR0_EL1 - the ID_AA64PFR0_EL1 is not registered in our > dynamic XML as it has "ARM_CP_NO_RAW" type. > So should we add some modifications to handle this special case? Hmm, this is an interesting case. I'm not entirely sure this register absolutely needs to be NO_RAW. Deciding whether we could drop the NO_RAW requires more thought than I have time for right now, though. In any case, it's quite plausible we may have registers which we want to be not migrated (so NO_RAW) but which we do want to allow the gdb stub to read (and perhaps write). I think that handling those special cases with a .gdbreadfn and .gdbwritefn as and when we need to would be the best approach. For the moment, this patchset is intended to be a "reasonable effort" reflection of the system registers into the gdbstub, so I don't think we need to do that now. If users have genuine need to read particular registers we can add the special casing code then. thanks -- PMM ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [Qemu-arm] [PATCH v5 3/3] target/arm: Add the XML dynamic generation 2018-04-04 12:26 ` [Qemu-devel] [Qemu-arm] " Alex Bennée 2018-04-06 17:28 ` Abdallah Bouassida @ 2018-04-12 9:55 ` Peter Maydell 1 sibling, 0 replies; 12+ messages in thread From: Peter Maydell @ 2018-04-12 9:55 UTC (permalink / raw) To: Alex Bennée Cc: Abdallah Bouassida, QEMU Developers, Khaled Jmal, qemu-arm On 4 April 2018 at 13:26, Alex Bennée <alex.bennee@linaro.org> wrote: > > Abdallah Bouassida <abdallah.bouassida@lauterbach.com> writes: > >> Generate an XML description for the cp-regs. >> Register these regs with the gdb_register_coprocessor(). >> Add arm_gdb_get_sysreg() to use it as a callback to read those regs. >> Add a dummy arm_gdb_set_sysreg(). >> >> Signed-off-by: Abdallah Bouassida <abdallah.bouassida@lauterbach.com> >> --- >> gdbstub.c | 10 ++++++++ >> include/qom/cpu.h | 5 +++- >> target/arm/cpu.c | 1 + >> target/arm/cpu.h | 26 +++++++++++++++++++ >> target/arm/gdbstub.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >> target/arm/helper.c | 27 ++++++++++++++++++++ >> 6 files changed, 139 insertions(+), 1 deletion(-) >> >> diff --git a/gdbstub.c b/gdbstub.c >> index f1d5148..09065bc 100644 >> --- a/gdbstub.c >> +++ b/gdbstub.c >> @@ -674,6 +674,16 @@ static const char *get_feature_xml(const char *p, const char **newp, >> } >> return target_xml; >> } >> + if (cc->gdb_get_dynamic_xml) { >> + CPUState *cpu = first_cpu; >> + char *xmlname = g_strndup(p, len); >> + const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); >> + >> + free(xmlname); > > g_free for a g_strndup'ed string please - although I'm confused as to > why you need to g_strdup the string. You already have p and its not like > gdb_get_dynamic_xml couldn't dup the string if it needed to (which it > doesn't seem to). This is strndup, not strdup. p is not a NUL-terminated string, so we're creating one to hand to the hook function rather than requiring it to deal with a non-terminated string. thanks -- PMM ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] ping Re: [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB 2018-03-14 13:28 [Qemu-devel] [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida ` (2 preceding siblings ...) 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 3/3] target/arm: Add the XML dynamic generation Abdallah Bouassida @ 2018-03-22 15:08 ` Abdallah Bouassida 2018-03-22 15:13 ` Peter Maydell 3 siblings, 1 reply; 12+ messages in thread From: Abdallah Bouassida @ 2018-03-22 15:08 UTC (permalink / raw) To: qemu-devel, peter.maydell; +Cc: qemu-arm, khaled.jmal ping http://patchwork.ozlabs.org/project/qemu-devel/list/?series=33714 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] ping Re: [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB 2018-03-22 15:08 ` [Qemu-devel] ping Re: [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida @ 2018-03-22 15:13 ` Peter Maydell 0 siblings, 0 replies; 12+ messages in thread From: Peter Maydell @ 2018-03-22 15:13 UTC (permalink / raw) To: Abdallah Bouassida; +Cc: QEMU Developers, qemu-arm, Khaled Jmal On 22 March 2018 at 15:08, Abdallah Bouassida <abdallah.bouassida@lauterbach.com> wrote: > ping > http://patchwork.ozlabs.org/project/qemu-devel/list/?series=33714 Hi. This patchset is on my to-review queue, but it may take me a little while to get back to it because we're currently in freeze for the 2.12 release and so things that are bugfixes for 2.12 are higher priority. thanks -- PMM ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2018-04-12 10:15 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-03-14 13:28 [Qemu-devel] [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 1/3] target/arm: Add "ARM_CP_NO_GDB" as a new bit field for ARMCPRegInfo type Abdallah Bouassida 2018-04-04 10:50 ` [Qemu-devel] [Qemu-arm] " Alex Bennée 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 2/3] target/arm: Add "_S" suffix to the secure version of a sysreg Abdallah Bouassida 2018-04-04 10:51 ` [Qemu-devel] [Qemu-arm] " Alex Bennée 2018-03-14 13:28 ` [Qemu-devel] [PATCH v5 3/3] target/arm: Add the XML dynamic generation Abdallah Bouassida 2018-04-04 12:26 ` [Qemu-devel] [Qemu-arm] " Alex Bennée 2018-04-06 17:28 ` Abdallah Bouassida 2018-04-12 10:14 ` Peter Maydell 2018-04-12 9:55 ` Peter Maydell 2018-03-22 15:08 ` [Qemu-devel] ping Re: [PATCH v5 0/3] target/arm: Add a dynamic XML-description of the cp-registers to GDB Abdallah Bouassida 2018-03-22 15:13 ` Peter Maydell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).