* [Qemu-devel] [PATCH risu 1/9] Drop the weird modification of a ucontext in the ppc reginfo_is_eq()
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 2/9] Abstract out getting and setting parameter register Peter Maydell
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
From: Peter Maydell <pmaydell@chiark.greenend.org.uk>
The PPC reginfo_is_eq() has some weird code which tries to modify
a ucontext_t in the middle of comparing the two registers.
I don't understand this, but this is definitely not the right
place to do anything like this. Drop the weird code.
Signed-off-by: Peter Maydell <pmaydell@chiark.greenend.org.uk>
---
risu_ppc64le.c | 4 ++--
risu_reginfo_ppc64le.c | 10 +---------
risu_reginfo_ppc64le.h | 2 +-
3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/risu_ppc64le.c b/risu_ppc64le.c
index 9c1fafd..1c986a9 100644
--- a/risu_ppc64le.c
+++ b/risu_ppc64le.c
@@ -89,7 +89,7 @@ int recv_and_compare_register_info(int sock, void *uc)
if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri))) {
packet_mismatch = 1;
resp = 2;
- } else if (!reginfo_is_eq(&master_ri, &apprentice_ri, uc)) {
+ } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
resp = 2;
}
else if (op == OP_TESTEND) {
@@ -134,7 +134,7 @@ int report_match_status(void)
fprintf(stderr, "master reginfo:\n");
reginfo_dump(&master_ri, 0);
}
- if (!reginfo_is_eq(&master_ri, &apprentice_ri, NULL)) {
+ if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
fprintf(stderr, "mismatch on regs!\n");
resp = 1;
}
diff --git a/risu_reginfo_ppc64le.c b/risu_reginfo_ppc64le.c
index e6bc0e0..585d8b7 100644
--- a/risu_reginfo_ppc64le.c
+++ b/risu_reginfo_ppc64le.c
@@ -50,7 +50,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)
}
/* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */
-int reginfo_is_eq(struct reginfo *m, struct reginfo *a, ucontext_t *uc)
+int reginfo_is_eq(struct reginfo *m, struct reginfo *a)
{
int i;
for (i = 0; i < 32; i++) {
@@ -86,14 +86,6 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a, ucontext_t *uc)
m->vrregs.vrregs[i][1] != a->vrregs.vrregs[i][1] ||
m->vrregs.vrregs[i][2] != a->vrregs.vrregs[i][2] ||
m->vrregs.vrregs[i][3] != a->vrregs.vrregs[i][3]) {
-
- if (uc != NULL && (m->gregs[CCR] & 0x10)) {
- uc->uc_mcontext.v_regs->vrregs[i][0] = a->vrregs.vrregs[i][0];
- uc->uc_mcontext.v_regs->vrregs[i][1] = a->vrregs.vrregs[i][1];
- uc->uc_mcontext.v_regs->vrregs[i][2] = a->vrregs.vrregs[i][2];
- uc->uc_mcontext.v_regs->vrregs[i][3] = a->vrregs.vrregs[i][3];
- return 1;
- }
return 0;
}
}
diff --git a/risu_reginfo_ppc64le.h b/risu_reginfo_ppc64le.h
index abe6002..49bb1aa 100644
--- a/risu_reginfo_ppc64le.h
+++ b/risu_reginfo_ppc64le.h
@@ -29,7 +29,7 @@ struct reginfo
void reginfo_init(struct reginfo *ri, ucontext_t *uc);
/* return 1 if structs are equal, 0 otherwise. */
-int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2, ucontext_t *uc);
+int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2);
/* print reginfo state to a stream */
void reginfo_dump(struct reginfo *ri, int is_master);
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH risu 2/9] Abstract out getting and setting parameter register
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 1/9] Drop the weird modification of a ucontext in the ppc reginfo_is_eq() Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 3/9] Make get_risuop() a formal part of the CPU interface Peter Maydell
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
From: Peter Maydell <pmaydell@chiark.greenend.org.uk>
The SETMEMBLOCK operation takes a parameter in a register,
and GETMEMBLOCK returns a result in a register. Abstract
these out into functions provided by the backend, so we
can use common code for send_register_info() and
recv_and_compare_register_info().
Signed-off-by: Peter Maydell <pmaydell@chiark.greenend.org.uk>
---
risu.h | 11 +++++++++++
risu_aarch64.c | 19 +++++++++++++------
risu_arm.c | 20 ++++++++++++++------
risu_m68k.c | 19 +++++++++++++------
risu_ppc64le.c | 19 +++++++++++++------
5 files changed, 64 insertions(+), 24 deletions(-)
diff --git a/risu.h b/risu.h
index 26ed834..4f923b2 100644
--- a/risu.h
+++ b/risu.h
@@ -37,6 +37,8 @@ extern int test_fp_exc;
/* The memory block should be this long */
#define MEMBLOCKLEN 8192
+struct reginfo;
+
/* Interface provided by CPU-specific code: */
/* Send the register information from the struct ucontext down the socket.
@@ -63,4 +65,13 @@ int report_match_status(void);
*/
void advance_pc(void *uc);
+/* Set the parameter register in a ucontext_t to the specified value.
+ * (32-bit targets can ignore high 32 bits.)
+ * vuc is a ucontext_t* cast to void*.
+ */
+void set_ucontext_paramreg(void *vuc, uint64_t value);
+
+/* Return the value of the parameter register from a reginfo. */
+uint64_t get_reginfo_paramreg(struct reginfo *ri);
+
#endif /* RISU_H */
diff --git a/risu_aarch64.c b/risu_aarch64.c
index f150dcd..f13338d 100644
--- a/risu_aarch64.c
+++ b/risu_aarch64.c
@@ -30,10 +30,15 @@ void advance_pc(void *vuc)
uc->uc_mcontext.pc += 4;
}
-static void set_x0(void *vuc, uint64_t x0)
+void set_ucontext_paramreg(void *vuc, uint64_t value)
{
ucontext_t *uc = vuc;
- uc->uc_mcontext.regs[0] = x0;
+ uc->uc_mcontext.regs[0] = value;
+}
+
+uint64_t get_reginfo_paramreg(struct reginfo *ri)
+{
+ return ri->regs[0];
}
static int get_risuop(uint32_t insn)
@@ -63,10 +68,11 @@ int send_register_info(int sock, void *uc)
*/
return send_data_pkt(sock, &ri, sizeof(ri));
case OP_SETMEMBLOCK:
- memblock = (void *)ri.regs[0];
+ memblock = (void *)get_reginfo_paramreg(&ri);
break;
case OP_GETMEMBLOCK:
- set_x0(uc, ri.regs[0] + (uintptr_t)memblock);
+ set_ucontext_paramreg(uc,
+ get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
break;
case OP_COMPAREMEM:
return send_data_pkt(sock, memblock, MEMBLOCKLEN);
@@ -111,10 +117,11 @@ int recv_and_compare_register_info(int sock, void *uc)
send_response_byte(sock, resp);
break;
case OP_SETMEMBLOCK:
- memblock = (void *)master_ri.regs[0];
+ memblock = (void *)get_reginfo_paramreg(&master_ri);
break;
case OP_GETMEMBLOCK:
- set_x0(uc, master_ri.regs[0] + (uintptr_t)memblock);
+ set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
+ (uintptr_t)memblock);
break;
case OP_COMPAREMEM:
mem_used = 1;
diff --git a/risu_arm.c b/risu_arm.c
index bdfb59b..c2b79a5 100644
--- a/risu_arm.c
+++ b/risu_arm.c
@@ -52,10 +52,16 @@ void advance_pc(void *vuc)
uc->uc_mcontext.arm_pc += insnsize(uc);
}
-static void set_r0(void *vuc, uint32_t r0)
+
+void set_ucontext_paramreg(void *vuc, uint64_t value)
{
ucontext_t *uc = vuc;
- uc->uc_mcontext.arm_r0 = r0;
+ uc->uc_mcontext.arm_r0 = value;
+}
+
+uint64_t get_reginfo_paramreg(struct reginfo *ri)
+{
+ return ri->gpreg[0];
}
static int get_risuop(uint32_t insn, int isz)
@@ -87,10 +93,11 @@ int send_register_info(int sock, void *uc)
*/
return send_data_pkt(sock, &ri, sizeof(ri));
case OP_SETMEMBLOCK:
- memblock = (void *)ri.gpreg[0];
+ memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri);
break;
case OP_GETMEMBLOCK:
- set_r0(uc, ri.gpreg[0] + (uintptr_t)memblock);
+ set_ucontext_paramreg(uc,
+ get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
break;
case OP_COMPAREMEM:
return send_data_pkt(sock, memblock, MEMBLOCKLEN);
@@ -139,10 +146,11 @@ int recv_and_compare_register_info(int sock, void *uc)
send_response_byte(sock, resp);
break;
case OP_SETMEMBLOCK:
- memblock = (void *)master_ri.gpreg[0];
+ memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri);
break;
case OP_GETMEMBLOCK:
- set_r0(uc, master_ri.gpreg[0] + (uintptr_t)memblock);
+ set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
+ (uintptr_t)memblock);
break;
case OP_COMPAREMEM:
mem_used = 1;
diff --git a/risu_m68k.c b/risu_m68k.c
index 15e30b1..feb3912 100644
--- a/risu_m68k.c
+++ b/risu_m68k.c
@@ -25,10 +25,15 @@ void advance_pc(void *vuc)
uc->uc_mcontext.gregs[R_PC] += 4;
}
-void set_a0(void *vuc, uint32_t a0)
+void set_ucontext_paramreg(void *vuc, uint64_t value)
{
ucontext_t *uc = vuc;
- uc->uc_mcontext.gregs[R_A0] = a0;
+ uc->uc_mcontext.gregs[R_A0] = value;
+}
+
+uint64_t get_reginfo_paramreg(struct reginfo *ri)
+{
+ return ri->gregs[R_A0];
}
static int get_risuop(uint32_t insn)
@@ -53,10 +58,11 @@ int send_register_info(int sock, void *uc)
default:
return send_data_pkt(sock, &ri, sizeof(ri));
case OP_SETMEMBLOCK:
- memblock = (void*)ri.gregs[R_A0];
+ memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri);
break;
case OP_GETMEMBLOCK:
- set_a0(uc, ri.gregs[R_A0] + (uintptr_t)memblock);
+ set_ucontext_paramreg(uc,
+ get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
break;
case OP_COMPAREMEM:
return send_data_pkt(sock, memblock, MEMBLOCKLEN);
@@ -93,10 +99,11 @@ int recv_and_compare_register_info(int sock, void *uc)
send_response_byte(sock, resp);
break;
case OP_SETMEMBLOCK:
- memblock = (void*)master_ri.gregs[R_A0];
+ memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri);
break;
case OP_GETMEMBLOCK:
- set_a0(uc, master_ri.gregs[R_A0] + (uintptr_t)memblock);
+ set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
+ (uintptr_t)memblock);
break;
case OP_COMPAREMEM:
mem_used = 1;
diff --git a/risu_ppc64le.c b/risu_ppc64le.c
index 1c986a9..05b0294 100644
--- a/risu_ppc64le.c
+++ b/risu_ppc64le.c
@@ -30,10 +30,15 @@ void advance_pc(void *vuc)
uc->uc_mcontext.regs->nip += 4;
}
-void set_x0(void *vuc, uint64_t x0)
+void set_ucontext_paramreg(void *vuc, uint64_t value)
{
ucontext_t *uc = vuc;
- uc->uc_mcontext.gp_regs[0] = x0;
+ uc->uc_mcontext.gp_regs[0] = value;
+}
+
+uint64_t get_reginfo_paramreg(struct reginfo *ri)
+{
+ return ri->gregs[0];
}
static int get_risuop(uint32_t insn)
@@ -58,10 +63,11 @@ int send_register_info(int sock, void *uc)
default:
return send_data_pkt(sock, &ri, sizeof(ri));
case OP_SETMEMBLOCK:
- memblock = (void*)ri.gregs[0];
+ memblock = (void*)get_reginfo_paramreg(&ri);
break;
case OP_GETMEMBLOCK:
- set_x0(uc, ri.gregs[0] + (uintptr_t)memblock);
+ set_ucontext_paramreg(uc,
+ get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
break;
case OP_COMPAREMEM:
return send_data_pkt(sock, memblock, MEMBLOCKLEN);
@@ -98,10 +104,11 @@ int recv_and_compare_register_info(int sock, void *uc)
send_response_byte(sock, resp);
break;
case OP_SETMEMBLOCK:
- memblock = (void*)master_ri.gregs[0];
+ memblock = (void*)get_reginfo_paramreg(&master_ri);
break;
case OP_GETMEMBLOCK:
- set_x0(uc, master_ri.gregs[0] + (uintptr_t)memblock);
+ set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
+ (uintptr_t)memblock);
break;
case OP_COMPAREMEM:
mem_used = 1;
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH risu 3/9] Make get_risuop() a formal part of the CPU interface
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 1/9] Drop the weird modification of a ucontext in the ppc reginfo_is_eq() Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 2/9] Abstract out getting and setting parameter register Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 4/9] ppc64le, m68k: Make reginfo_dump() API match arm, aarch64 Peter Maydell
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
From: Peter Maydell <pmaydell@chiark.greenend.org.uk>
Make get_risuop() a formal part of the CPU interface rather than
just a de-facto common routine.
Signed-off-by: Peter Maydell <pmaydell@chiark.greenend.org.uk>
---
risu.h | 5 +++++
risu_aarch64.c | 7 ++++---
risu_arm.c | 9 +++++----
risu_m68k.c | 7 ++++---
risu_ppc64le.c | 7 ++++---
5 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/risu.h b/risu.h
index 4f923b2..1525b3e 100644
--- a/risu.h
+++ b/risu.h
@@ -74,4 +74,9 @@ void set_ucontext_paramreg(void *vuc, uint64_t value);
/* Return the value of the parameter register from a reginfo. */
uint64_t get_reginfo_paramreg(struct reginfo *ri);
+/* Return the risu operation number we have been asked to do,
+ * or -1 if this was a SIGILL for a non-risuop insn.
+ */
+int get_risuop(struct reginfo *ri);
+
#endif /* RISU_H */
diff --git a/risu_aarch64.c b/risu_aarch64.c
index f13338d..81573e3 100644
--- a/risu_aarch64.c
+++ b/risu_aarch64.c
@@ -41,11 +41,12 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri)
return ri->regs[0];
}
-static int get_risuop(uint32_t insn)
+int get_risuop(struct reginfo *ri)
{
/* Return the risuop we have been asked to do
* (or -1 if this was a SIGILL for a non-risuop insn)
*/
+ uint32_t insn = ri->faulting_insn;
uint32_t op = insn & 0xf;
uint32_t key = insn & ~0xf;
uint32_t risukey = 0x00005af0;
@@ -57,7 +58,7 @@ int send_register_info(int sock, void *uc)
struct reginfo ri;
int op;
reginfo_init(&ri, uc);
- op = get_risuop(ri.faulting_insn);
+ op = get_risuop(&ri);
switch (op) {
case OP_COMPARE:
@@ -94,7 +95,7 @@ int recv_and_compare_register_info(int sock, void *uc)
int resp = 0, op;
reginfo_init(&master_ri, uc);
- op = get_risuop(master_ri.faulting_insn);
+ op = get_risuop(&master_ri);
switch (op) {
case OP_COMPARE:
diff --git a/risu_arm.c b/risu_arm.c
index c2b79a5..36ac3c8 100644
--- a/risu_arm.c
+++ b/risu_arm.c
@@ -64,24 +64,25 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri)
return ri->gpreg[0];
}
-static int get_risuop(uint32_t insn, int isz)
+int get_risuop(struct reginfo *ri)
{
/* Return the risuop we have been asked to do
* (or -1 if this was a SIGILL for a non-risuop insn)
*/
+ uint32_t insn = ri->faulting_insn;
+ int isz = ri->faulting_insn_size;
uint32_t op = insn & 0xf;
uint32_t key = insn & ~0xf;
uint32_t risukey = (isz == 2) ? 0xdee0 : 0xe7fe5af0;
return (key != risukey) ? -1 : op;
}
-
int send_register_info(int sock, void *uc)
{
struct reginfo ri;
int op;
reginfo_init(&ri, uc);
- op = get_risuop(ri.faulting_insn, ri.faulting_insn_size);
+ op = get_risuop(&ri);
switch (op)
{
@@ -119,7 +120,7 @@ int recv_and_compare_register_info(int sock, void *uc)
int resp = 0, op;
reginfo_init(&master_ri, uc);
- op = get_risuop(master_ri.faulting_insn, master_ri.faulting_insn_size);
+ op = get_risuop(&master_ri);
switch (op)
{
diff --git a/risu_m68k.c b/risu_m68k.c
index feb3912..8c138dd 100644
--- a/risu_m68k.c
+++ b/risu_m68k.c
@@ -36,8 +36,9 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri)
return ri->gregs[R_A0];
}
-static int get_risuop(uint32_t insn)
+int get_risuop(struct reginfo *ri)
{
+ uint32_t insn = ri->faulting_insn;
uint32_t op = insn & 0xf;
uint32_t key = insn & ~0xf;
uint32_t risukey = 0x4afc7000;
@@ -50,7 +51,7 @@ int send_register_info(int sock, void *uc)
int op;
reginfo_init(&ri, uc);
- op = get_risuop(ri.faulting_insn);
+ op = get_risuop(&ri);
switch (op) {
case OP_COMPARE:
@@ -81,7 +82,7 @@ int recv_and_compare_register_info(int sock, void *uc)
int op;
reginfo_init(&master_ri, uc);
- op = get_risuop(master_ri.faulting_insn);
+ op = get_risuop(&master_ri);
switch (op) {
case OP_COMPARE:
diff --git a/risu_ppc64le.c b/risu_ppc64le.c
index 05b0294..43170ea 100644
--- a/risu_ppc64le.c
+++ b/risu_ppc64le.c
@@ -41,8 +41,9 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri)
return ri->gregs[0];
}
-static int get_risuop(uint32_t insn)
+int get_risuop(struct reginfo *ri)
{
+ uint32_t insn = ri->faulting_insn;
uint32_t op = insn & 0xf;
uint32_t key = insn & ~0xf;
uint32_t risukey = 0x00005af0;
@@ -55,7 +56,7 @@ int send_register_info(int sock, void *uc)
int op;
reginfo_init(&ri, uc);
- op = get_risuop(ri.faulting_insn);
+ op = get_risuop(&ri);
switch (op) {
case OP_COMPARE:
@@ -86,7 +87,7 @@ int recv_and_compare_register_info(int sock, void *uc)
int op;
reginfo_init(&master_ri, uc);
- op = get_risuop(master_ri.faulting_insn);
+ op = get_risuop(&master_ri);
switch (op) {
case OP_COMPARE:
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH risu 4/9] ppc64le, m68k: Make reginfo_dump() API match arm, aarch64
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
` (2 preceding siblings ...)
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 3/9] Make get_risuop() a formal part of the CPU interface Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 5/9] m68k: Drop unused ucontext_t* argument to reginfo_is_eq() Peter Maydell
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
Make the reginfo_dump() API for ppc64le and m68k match the one used
for ARM and AArch64, which takes a FILE*, doesn't have a flag for
is_master, and returns a success indication.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
risu_m68k.c | 6 +++---
risu_ppc64le.c | 6 +++---
risu_reginfo_m68k.c | 21 +++++++++++----------
risu_reginfo_m68k.h | 4 ++--
risu_reginfo_ppc64le.c | 49 +++++++++++++++++++++++++------------------------
risu_reginfo_ppc64le.h | 4 ++--
6 files changed, 46 insertions(+), 44 deletions(-)
diff --git a/risu_m68k.c b/risu_m68k.c
index 8c138dd..87776ab 100644
--- a/risu_m68k.c
+++ b/risu_m68k.c
@@ -135,7 +135,7 @@ int report_match_status(void)
fprintf(stderr, "packet mismatch (probably disagreement "
"about UNDEF on load/store)\n");
fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, 0);
+ reginfo_dump(&master_ri, stderr);
}
if (!reginfo_is_eq(&master_ri, &apprentice_ri, NULL)) {
fprintf(stderr, "mismatch on regs!\n");
@@ -151,10 +151,10 @@ int report_match_status(void)
}
fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, 1);
+ reginfo_dump(&master_ri, stderr);
fprintf(stderr, "apprentice reginfo:\n");
- reginfo_dump(&apprentice_ri, 0);
+ reginfo_dump(&apprentice_ri, stderr);
reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr);
return resp;
diff --git a/risu_ppc64le.c b/risu_ppc64le.c
index 43170ea..8757712 100644
--- a/risu_ppc64le.c
+++ b/risu_ppc64le.c
@@ -140,7 +140,7 @@ int report_match_status(void)
fprintf(stderr, "packet mismatch (probably disagreement "
"about UNDEF on load/store)\n");
fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, 0);
+ reginfo_dump(&master_ri, stderr);
}
if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
fprintf(stderr, "mismatch on regs!\n");
@@ -156,10 +156,10 @@ int report_match_status(void)
}
fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, 1);
+ reginfo_dump(&master_ri, stderr);
fprintf(stderr, "apprentice reginfo:\n");
- reginfo_dump(&apprentice_ri, 0);
+ reginfo_dump(&apprentice_ri, stderr);
reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr);
return resp;
diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c
index d0d47d9..3988d71 100644
--- a/risu_reginfo_m68k.c
+++ b/risu_reginfo_m68k.c
@@ -75,29 +75,30 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a, ucontext_t *uc)
}
/* reginfo_dump: print state to a stream, returns nonzero on success */
-void reginfo_dump(struct reginfo *ri, int is_master)
+int reginfo_dump(struct reginfo *ri, FILE *f)
{
int i;
- if (is_master) {
- fprintf(stderr, " pc \e[1;101;37m0x%08x\e[0m\n",
- ri->pc);
- }
- fprintf(stderr, "\tPC: %08x\n", ri->gregs[R_PC]);
- fprintf(stderr, "\tPS: %04x\n", ri->gregs[R_PS]);
+ fprintf(f, " pc \e[1;101;37m0x%08x\e[0m\n",
+ ri->pc);
+
+ fprintf(f, "\tPC: %08x\n", ri->gregs[R_PC]);
+ fprintf(f, "\tPS: %04x\n", ri->gregs[R_PS]);
for (i = 0; i < 8; i++) {
- fprintf(stderr, "\tD%d: %8x\tA%d: %8x\n", i, ri->gregs[i],
+ fprintf(f, "\tD%d: %8x\tA%d: %8x\n", i, ri->gregs[i],
i, ri->gregs[i + 8]);
}
for (i = 0; i < 8; i++) {
- fprintf(stderr, "\tFP%d: %08x %08x %08x\n", i,
+ fprintf(f, "\tFP%d: %08x %08x %08x\n", i,
ri->fpregs.f_fpregs[i][0], ri->fpregs.f_fpregs[i][1],
ri->fpregs.f_fpregs[i][2]);
}
- fprintf(stderr, "\n");
+ fprintf(f, "\n");
+
+ return !ferror(f);
}
int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
diff --git a/risu_reginfo_m68k.h b/risu_reginfo_m68k.h
index 9dd8f32..3922bf6 100644
--- a/risu_reginfo_m68k.h
+++ b/risu_reginfo_m68k.h
@@ -23,8 +23,8 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc);
/* return 1 if structs are equal, 0 otherwise. */
int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2, ucontext_t *uc);
-/* print reginfo state to a stream */
-void reginfo_dump(struct reginfo *ri, int is_master);
+/* print reginfo state to a stream, returns 1 on success, 0 on failure */
+int reginfo_dump(struct reginfo *ri, FILE *f);
/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */
int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
diff --git a/risu_reginfo_ppc64le.c b/risu_reginfo_ppc64le.c
index 585d8b7..9e673e1 100644
--- a/risu_reginfo_ppc64le.c
+++ b/risu_reginfo_ppc64le.c
@@ -93,46 +93,47 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a)
}
/* reginfo_dump: print state to a stream, returns nonzero on success */
-void reginfo_dump(struct reginfo *ri, int is_master)
+int reginfo_dump(struct reginfo *ri, FILE *f)
{
int i;
- if (is_master) {
- fprintf(stderr, " faulting insn 0x%x\n", ri->faulting_insn);
- fprintf(stderr, " prev insn 0x%x\n", ri->prev_insn);
- fprintf(stderr, " prev addr 0x%" PRIx64 "\n\n", ri->nip);
- }
+
+ fprintf(f, " faulting insn 0x%x\n", ri->faulting_insn);
+ fprintf(f, " prev insn 0x%x\n", ri->prev_insn);
+ fprintf(f, " prev addr 0x%" PRIx64 "\n\n", ri->nip);
for (i = 0; i < 16; i++) {
- fprintf(stderr, "\tr%2d: %16lx\tr%2d: %16lx\n", i, ri->gregs[i],
+ fprintf(f, "\tr%2d: %16lx\tr%2d: %16lx\n", i, ri->gregs[i],
i + 16, ri->gregs[i + 16]);
}
- fprintf(stderr, "\n");
- fprintf(stderr, "\tnip : %16lx\n", ri->gregs[32]);
- fprintf(stderr, "\tmsr : %16lx\n", ri->gregs[33]);
- fprintf(stderr, "\torig r3: %16lx\n", ri->gregs[34]);
- fprintf(stderr, "\tctr : %16lx\n", ri->gregs[35]);
- fprintf(stderr, "\tlnk : %16lx\n", ri->gregs[36]);
- fprintf(stderr, "\txer : %16lx\n", ri->gregs[37]);
- fprintf(stderr, "\tccr : %16lx\n", ri->gregs[38]);
- fprintf(stderr, "\tmq : %16lx\n", ri->gregs[39]);
- fprintf(stderr, "\ttrap : %16lx\n", ri->gregs[40]);
- fprintf(stderr, "\tdar : %16lx\n", ri->gregs[41]);
- fprintf(stderr, "\tdsisr : %16lx\n", ri->gregs[42]);
- fprintf(stderr, "\tresult : %16lx\n", ri->gregs[43]);
- fprintf(stderr, "\tdscr : %16lx\n\n", ri->gregs[44]);
+ fprintf(f, "\n");
+ fprintf(f, "\tnip : %16lx\n", ri->gregs[32]);
+ fprintf(f, "\tmsr : %16lx\n", ri->gregs[33]);
+ fprintf(f, "\torig r3: %16lx\n", ri->gregs[34]);
+ fprintf(f, "\tctr : %16lx\n", ri->gregs[35]);
+ fprintf(f, "\tlnk : %16lx\n", ri->gregs[36]);
+ fprintf(f, "\txer : %16lx\n", ri->gregs[37]);
+ fprintf(f, "\tccr : %16lx\n", ri->gregs[38]);
+ fprintf(f, "\tmq : %16lx\n", ri->gregs[39]);
+ fprintf(f, "\ttrap : %16lx\n", ri->gregs[40]);
+ fprintf(f, "\tdar : %16lx\n", ri->gregs[41]);
+ fprintf(f, "\tdsisr : %16lx\n", ri->gregs[42]);
+ fprintf(f, "\tresult : %16lx\n", ri->gregs[43]);
+ fprintf(f, "\tdscr : %16lx\n\n", ri->gregs[44]);
for (i = 0; i < 16; i++) {
- fprintf(stderr, "\tf%2d: %.4f\tr%2d: %.4f\n", i, ri->fpregs[i],
+ fprintf(f, "\tf%2d: %.4f\tr%2d: %.4f\n", i, ri->fpregs[i],
i + 16, ri->fpregs[i + 16]);
}
- fprintf(stderr, "\tfpscr: %f\n\n", ri->fpregs[32]);
+ fprintf(f, "\tfpscr: %f\n\n", ri->fpregs[32]);
for (i = 0; i < 32; i++) {
- fprintf(stderr, "vr%02d: %8x, %8x, %8x, %8x\n", i,
+ fprintf(f, "vr%02d: %8x, %8x, %8x, %8x\n", i,
ri->vrregs.vrregs[i][0], ri->vrregs.vrregs[i][1],
ri->vrregs.vrregs[i][2], ri->vrregs.vrregs[i][3]);
}
+
+ return !ferror(f);
}
int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
diff --git a/risu_reginfo_ppc64le.h b/risu_reginfo_ppc64le.h
index 49bb1aa..9f74cd3 100644
--- a/risu_reginfo_ppc64le.h
+++ b/risu_reginfo_ppc64le.h
@@ -31,8 +31,8 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc);
/* return 1 if structs are equal, 0 otherwise. */
int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2);
-/* print reginfo state to a stream */
-void reginfo_dump(struct reginfo *ri, int is_master);
+/* print reginfo state to a stream, returns 1 on success, 0 on failure */
+int reginfo_dump(struct reginfo *ri, FILE *f);
/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */
int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH risu 5/9] m68k: Drop unused ucontext_t* argument to reginfo_is_eq()
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
` (3 preceding siblings ...)
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 4/9] ppc64le, m68k: Make reginfo_dump() API match arm, aarch64 Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 6/9] Make reginfo_{init, is_eq, dump, dump_mismatch} official per-CPU API Peter Maydell
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
Drop the ucontext*t argument to reginfo_is_eq(); we don't
use it.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
risu_m68k.c | 4 ++--
risu_reginfo_m68k.c | 2 +-
risu_reginfo_m68k.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/risu_m68k.c b/risu_m68k.c
index 87776ab..e345b25 100644
--- a/risu_m68k.c
+++ b/risu_m68k.c
@@ -91,7 +91,7 @@ int recv_and_compare_register_info(int sock, void *uc)
if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri))) {
packet_mismatch = 1;
resp = 2;
- } else if (!reginfo_is_eq(&master_ri, &apprentice_ri, uc)) {
+ } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
resp = 2;
}
else if (op == OP_TESTEND) {
@@ -137,7 +137,7 @@ int report_match_status(void)
fprintf(stderr, "master reginfo:\n");
reginfo_dump(&master_ri, stderr);
}
- if (!reginfo_is_eq(&master_ri, &apprentice_ri, NULL)) {
+ if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
fprintf(stderr, "mismatch on regs!\n");
resp = 1;
}
diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c
index 3988d71..45950b1 100644
--- a/risu_reginfo_m68k.c
+++ b/risu_reginfo_m68k.c
@@ -38,7 +38,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)
}
/* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */
-int reginfo_is_eq(struct reginfo *m, struct reginfo *a, ucontext_t *uc)
+int reginfo_is_eq(struct reginfo *m, struct reginfo *a)
{
int i;
diff --git a/risu_reginfo_m68k.h b/risu_reginfo_m68k.h
index 3922bf6..021939d 100644
--- a/risu_reginfo_m68k.h
+++ b/risu_reginfo_m68k.h
@@ -21,7 +21,7 @@ struct reginfo
void reginfo_init(struct reginfo *ri, ucontext_t *uc);
/* return 1 if structs are equal, 0 otherwise. */
-int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2, ucontext_t *uc);
+int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2);
/* print reginfo state to a stream, returns 1 on success, 0 on failure */
int reginfo_dump(struct reginfo *ri, FILE *f);
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH risu 6/9] Make reginfo_{init, is_eq, dump, dump_mismatch} official per-CPU API
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
` (4 preceding siblings ...)
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 5/9] m68k: Drop unused ucontext_t* argument to reginfo_is_eq() Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 7/9] Move send_register_info() to reginfo.c Peter Maydell
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
All CPUs now implement reginfo_{init,is_eq,dump,dump_mismatch} with the
same API and semantics. Make this official by moving the prototypes
into risu.h.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
risu.h | 13 +++++++++++++
risu_reginfo_aarch64.h | 12 ------------
risu_reginfo_arm.h | 12 ------------
risu_reginfo_m68k.h | 12 ------------
risu_reginfo_ppc64le.h | 12 ------------
5 files changed, 13 insertions(+), 48 deletions(-)
diff --git a/risu.h b/risu.h
index 1525b3e..d95dace 100644
--- a/risu.h
+++ b/risu.h
@@ -14,6 +14,7 @@
#include <inttypes.h>
#include <stdint.h>
+#include <ucontext.h>
/* Socket related routines */
int master_connect(int port);
@@ -79,4 +80,16 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri);
*/
int get_risuop(struct reginfo *ri);
+/* initialize structure from a ucontext */
+void reginfo_init(struct reginfo *ri, ucontext_t *uc);
+
+/* return 1 if structs are equal, 0 otherwise. */
+int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2);
+
+/* print reginfo state to a stream, returns 1 on success, 0 on failure */
+int reginfo_dump(struct reginfo *ri, FILE *f);
+
+/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */
+int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
+
#endif /* RISU_H */
diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h
index 166b76c..3d1b2fd 100644
--- a/risu_reginfo_aarch64.h
+++ b/risu_reginfo_aarch64.h
@@ -28,16 +28,4 @@ struct reginfo
__uint128_t vregs[32];
};
-/* initialize structure from a ucontext */
-void reginfo_init(struct reginfo *ri, ucontext_t *uc);
-
-/* return 1 if structs are equal, 0 otherwise. */
-int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2);
-
-/* print reginfo state to a stream, returns 1 on success, 0 on failure */
-int reginfo_dump(struct reginfo *ri, FILE *f);
-
-/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
-
#endif /* RISU_REGINFO_AARCH64_H */
diff --git a/risu_reginfo_arm.h b/risu_reginfo_arm.h
index 80c28c6..96e5791 100644
--- a/risu_reginfo_arm.h
+++ b/risu_reginfo_arm.h
@@ -23,16 +23,4 @@ struct reginfo
uint32_t fpscr;
};
-/* initialize a reginfo structure with data from uc */
-void reginfo_init(struct reginfo *ri, ucontext_t *uc);
-
-/* returns 1 if structs are equal, zero otherwise */
-int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2);
-
-/* print struct values to a stream, return 0 on stream err, 1 on success */
-int reginfo_dump(struct reginfo *ri, FILE *f);
-
-/* print a detailed mismatch report, return 0 on stream err, 1 on success */
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
-
#endif /* RISU_REGINFO_ARM_H */
diff --git a/risu_reginfo_m68k.h b/risu_reginfo_m68k.h
index 021939d..06ea61d 100644
--- a/risu_reginfo_m68k.h
+++ b/risu_reginfo_m68k.h
@@ -17,16 +17,4 @@ struct reginfo
fpregset_t fpregs;
};
-/* initialize structure from a ucontext */
-void reginfo_init(struct reginfo *ri, ucontext_t *uc);
-
-/* return 1 if structs are equal, 0 otherwise. */
-int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2);
-
-/* print reginfo state to a stream, returns 1 on success, 0 on failure */
-int reginfo_dump(struct reginfo *ri, FILE *f);
-
-/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
-
#endif /* RISU_REGINFO_M68K_H */
diff --git a/risu_reginfo_ppc64le.h b/risu_reginfo_ppc64le.h
index 9f74cd3..826143e 100644
--- a/risu_reginfo_ppc64le.h
+++ b/risu_reginfo_ppc64le.h
@@ -25,16 +25,4 @@ struct reginfo
vrregset_t vrregs;
};
-/* initialize structure from a ucontext */
-void reginfo_init(struct reginfo *ri, ucontext_t *uc);
-
-/* return 1 if structs are equal, 0 otherwise. */
-int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2);
-
-/* print reginfo state to a stream, returns 1 on success, 0 on failure */
-int reginfo_dump(struct reginfo *ri, FILE *f);
-
-/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
-
#endif /* RISU_REGINFO_PPC64LE_H */
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH risu 7/9] Move send_register_info() to reginfo.c
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
` (5 preceding siblings ...)
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 6/9] Make reginfo_{init, is_eq, dump, dump_mismatch} official per-CPU API Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 8/9] Move recv_and_compare_register_info() and report_match_status() " Peter Maydell
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
send_register_info() is now essentially the same code for all
target CPUs, so move it into reginfo.c rather than having
duplicated code.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Makefile | 4 ++--
reginfo.c | 43 +++++++++++++++++++++++++++++++++++++++++++
risu.h | 13 ++++++++++++-
risu_aarch64.c | 29 -----------------------------
risu_arm.c | 30 ------------------------------
risu_m68k.c | 27 ---------------------------
risu_ppc64le.c | 27 ---------------------------
7 files changed, 57 insertions(+), 116 deletions(-)
create mode 100644 reginfo.c
diff --git a/Makefile b/Makefile
index d20c4e4..9a29bb4 100644
--- a/Makefile
+++ b/Makefile
@@ -17,10 +17,10 @@ VPATH=$(SRCDIR)
CFLAGS ?= -g
-ALL_CFLAGS = -Wall -D_GNU_SOURCE $(CFLAGS) $(EXTRA_CFLAGS)
+ALL_CFLAGS = -Wall -D_GNU_SOURCE -DARCH=$(ARCH) $(CFLAGS) $(EXTRA_CFLAGS)
PROG=risu
-SRCS=risu.c comms.c risu_$(ARCH).c risu_reginfo_$(ARCH).c
+SRCS=risu.c comms.c reginfo.c risu_$(ARCH).c risu_reginfo_$(ARCH).c
HDRS=risu.h
BINS=test_$(ARCH).bin
diff --git a/reginfo.c b/reginfo.c
new file mode 100644
index 0000000..d62a2ed
--- /dev/null
+++ b/reginfo.c
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * Copyright (c) 2017 Linaro Limited
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Peter Maydell (Linaro) - initial implementation
+ *****************************************************************************/
+
+#include <stdio.h>
+
+#include "risu.h"
+
+int send_register_info(int sock, void *uc)
+{
+ struct reginfo ri;
+ int op;
+ reginfo_init(&ri, uc);
+ op = get_risuop(&ri);
+
+ switch (op) {
+ case OP_COMPARE:
+ case OP_TESTEND:
+ default:
+ /* Do a simple register compare on (a) explicit request
+ * (b) end of test (c) a non-risuop UNDEF
+ */
+ return send_data_pkt(sock, &ri, sizeof(ri));
+ case OP_SETMEMBLOCK:
+ memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri);
+ break;
+ case OP_GETMEMBLOCK:
+ set_ucontext_paramreg(uc,
+ get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
+ break;
+ case OP_COMPAREMEM:
+ return send_data_pkt(sock, memblock, MEMBLOCKLEN);
+ break;
+ }
+ return 0;
+}
diff --git a/risu.h b/risu.h
index d95dace..0f00b5f 100644
--- a/risu.h
+++ b/risu.h
@@ -16,6 +16,15 @@
#include <stdint.h>
#include <ucontext.h>
+/* GCC computed include to pull in the correct risu_reginfo_*.h for
+ * the architecture.
+ */
+#define REGINFO_HEADER2(X) #X
+#define REGINFO_HEADER1(ARCHNAME) REGINFO_HEADER2(risu_reginfo_ ## ARCHNAME.h)
+#define REGINFO_HEADER(ARCH) REGINFO_HEADER1(ARCH)
+
+#include REGINFO_HEADER(ARCH)
+
/* Socket related routines */
int master_connect(int port);
int apprentice_connect(const char *hostname, int port);
@@ -40,7 +49,7 @@ extern int test_fp_exc;
struct reginfo;
-/* Interface provided by CPU-specific code: */
+/* Functions operating on reginfo */
/* Send the register information from the struct ucontext down the socket.
* Return the response code from the master.
@@ -48,6 +57,8 @@ struct reginfo;
*/
int send_register_info(int sock, void *uc);
+/* Interface provided by CPU-specific code: */
+
/* Read register info from the socket and compare it with that from the
* ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
* NB: called from a signal handler.
diff --git a/risu_aarch64.c b/risu_aarch64.c
index 81573e3..7363eb1 100644
--- a/risu_aarch64.c
+++ b/risu_aarch64.c
@@ -53,35 +53,6 @@ int get_risuop(struct reginfo *ri)
return (key != risukey) ? -1 : op;
}
-int send_register_info(int sock, void *uc)
-{
- struct reginfo ri;
- int op;
- reginfo_init(&ri, uc);
- op = get_risuop(&ri);
-
- switch (op) {
- case OP_COMPARE:
- case OP_TESTEND:
- default:
- /* Do a simple register compare on (a) explicit request
- * (b) end of test (c) a non-risuop UNDEF
- */
- return send_data_pkt(sock, &ri, sizeof(ri));
- case OP_SETMEMBLOCK:
- memblock = (void *)get_reginfo_paramreg(&ri);
- break;
- case OP_GETMEMBLOCK:
- set_ucontext_paramreg(uc,
- get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
- break;
- case OP_COMPAREMEM:
- return send_data_pkt(sock, memblock, MEMBLOCKLEN);
- break;
- }
- return 0;
-}
-
/* Read register info from the socket and compare it with that from the
* ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
* NB: called from a signal handler.
diff --git a/risu_arm.c b/risu_arm.c
index 36ac3c8..878b2ee 100644
--- a/risu_arm.c
+++ b/risu_arm.c
@@ -77,36 +77,6 @@ int get_risuop(struct reginfo *ri)
return (key != risukey) ? -1 : op;
}
-int send_register_info(int sock, void *uc)
-{
- struct reginfo ri;
- int op;
- reginfo_init(&ri, uc);
- op = get_risuop(&ri);
-
- switch (op)
- {
- case OP_COMPARE:
- case OP_TESTEND:
- default:
- /* Do a simple register compare on (a) explicit request
- * (b) end of test (c) a non-risuop UNDEF
- */
- return send_data_pkt(sock, &ri, sizeof(ri));
- case OP_SETMEMBLOCK:
- memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri);
- break;
- case OP_GETMEMBLOCK:
- set_ucontext_paramreg(uc,
- get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
- break;
- case OP_COMPAREMEM:
- return send_data_pkt(sock, memblock, MEMBLOCKLEN);
- break;
- }
- return 0;
-}
-
/* Read register info from the socket and compare it with that from the
* ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
* NB: called from a signal handler.
diff --git a/risu_m68k.c b/risu_m68k.c
index e345b25..c0e29ff 100644
--- a/risu_m68k.c
+++ b/risu_m68k.c
@@ -45,33 +45,6 @@ int get_risuop(struct reginfo *ri)
return (key != risukey) ? -1 : op;
}
-int send_register_info(int sock, void *uc)
-{
- struct reginfo ri;
- int op;
-
- reginfo_init(&ri, uc);
- op = get_risuop(&ri);
-
- switch (op) {
- case OP_COMPARE:
- case OP_TESTEND:
- default:
- return send_data_pkt(sock, &ri, sizeof(ri));
- case OP_SETMEMBLOCK:
- memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri);
- break;
- case OP_GETMEMBLOCK:
- set_ucontext_paramreg(uc,
- get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
- break;
- case OP_COMPAREMEM:
- return send_data_pkt(sock, memblock, MEMBLOCKLEN);
- break;
- }
- return 0;
-}
-
/* Read register info from the socket and compare it with that from the
* ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
* NB: called from a signal handler.
diff --git a/risu_ppc64le.c b/risu_ppc64le.c
index 8757712..928f36f 100644
--- a/risu_ppc64le.c
+++ b/risu_ppc64le.c
@@ -50,33 +50,6 @@ int get_risuop(struct reginfo *ri)
return (key != risukey) ? -1 : op;
}
-int send_register_info(int sock, void *uc)
-{
- struct reginfo ri;
- int op;
-
- reginfo_init(&ri, uc);
- op = get_risuop(&ri);
-
- switch (op) {
- case OP_COMPARE:
- case OP_TESTEND:
- default:
- return send_data_pkt(sock, &ri, sizeof(ri));
- case OP_SETMEMBLOCK:
- memblock = (void*)get_reginfo_paramreg(&ri);
- break;
- case OP_GETMEMBLOCK:
- set_ucontext_paramreg(uc,
- get_reginfo_paramreg(&ri) + (uintptr_t)memblock);
- break;
- case OP_COMPAREMEM:
- return send_data_pkt(sock, memblock, MEMBLOCKLEN);
- break;
- }
- return 0;
-}
-
/* Read register info from the socket and compare it with that from the
* ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
* NB: called from a signal handler.
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH risu 8/9] Move recv_and_compare_register_info() and report_match_status() to reginfo.c
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
` (6 preceding siblings ...)
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 7/9] Move send_register_info() to reginfo.c Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 9/9] Tidy up #include lines Peter Maydell
2017-02-24 18:15 ` [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Laurent Vivier
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
Move recv_and_compare_register_info() and report_match_status() to
reginfo.c -- they are essentially the same for all targets so
can be common code. The shared variables they use come with them.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
reginfo.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
risu.h | 4 +-
risu_aarch64.c | 108 -----------------------------------------------------
risu_arm.c | 116 ---------------------------------------------------------
risu_m68k.c | 94 ----------------------------------------------
risu_ppc64le.c | 94 ----------------------------------------------
6 files changed, 110 insertions(+), 414 deletions(-)
diff --git a/reginfo.c b/reginfo.c
index d62a2ed..96c6342 100644
--- a/reginfo.c
+++ b/reginfo.c
@@ -10,9 +10,17 @@
*****************************************************************************/
#include <stdio.h>
+#include <string.h>
#include "risu.h"
+struct reginfo master_ri, apprentice_ri;
+
+uint8_t apprentice_memblock[MEMBLOCKLEN];
+
+static int mem_used = 0;
+static int packet_mismatch = 0;
+
int send_register_info(int sock, void *uc)
{
struct reginfo ri;
@@ -41,3 +49,103 @@ int send_register_info(int sock, void *uc)
}
return 0;
}
+
+/* Read register info from the socket and compare it with that from the
+ * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
+ * NB: called from a signal handler.
+ *
+ * We don't have any kind of identifying info in the incoming data
+ * that says whether it is register or memory data, so if the two
+ * sides get out of sync then we will fail obscurely.
+ */
+int recv_and_compare_register_info(int sock, void *uc)
+{
+ int resp = 0, op;
+
+ reginfo_init(&master_ri, uc);
+ op = get_risuop(&master_ri);
+
+ switch (op) {
+ case OP_COMPARE:
+ case OP_TESTEND:
+ default:
+ /* Do a simple register compare on (a) explicit request
+ * (b) end of test (c) a non-risuop UNDEF
+ */
+ if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri))) {
+ packet_mismatch = 1;
+ resp = 2;
+
+ } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
+ /* register mismatch */
+ resp = 2;
+
+ } else if (op == OP_TESTEND) {
+ resp = 1;
+ }
+ send_response_byte(sock, resp);
+ break;
+ case OP_SETMEMBLOCK:
+ memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri);
+ break;
+ case OP_GETMEMBLOCK:
+ set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
+ (uintptr_t)memblock);
+ break;
+ case OP_COMPAREMEM:
+ mem_used = 1;
+ if (recv_data_pkt(sock, apprentice_memblock, MEMBLOCKLEN)) {
+ packet_mismatch = 1;
+ resp = 2;
+ } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) {
+ /* memory mismatch */
+ resp = 2;
+ }
+ send_response_byte(sock, resp);
+ break;
+ }
+
+ return resp;
+}
+
+/* Print a useful report on the status of the last comparison
+ * done in recv_and_compare_register_info(). This is called on
+ * exit, so need not restrict itself to signal-safe functions.
+ * Should return 0 if it was a good match (ie end of test)
+ * and 1 for a mismatch.
+ */
+int report_match_status(void)
+{
+ int resp = 0;
+ fprintf(stderr, "match status...\n");
+ if (packet_mismatch) {
+ fprintf(stderr, "packet mismatch (probably disagreement "
+ "about UNDEF on load/store)\n");
+ /* We don't have valid reginfo from the apprentice side
+ * so stop now rather than printing anything about it.
+ */
+ fprintf(stderr, "master reginfo:\n");
+ reginfo_dump(&master_ri, stderr);
+ return 1;
+ }
+ if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
+ fprintf(stderr, "mismatch on regs!\n");
+ resp = 1;
+ }
+ if (mem_used && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) {
+ fprintf(stderr, "mismatch on memory!\n");
+ resp = 1;
+ }
+ if (!resp) {
+ fprintf(stderr, "match!\n");
+ return 0;
+ }
+
+ fprintf(stderr, "master reginfo:\n");
+ reginfo_dump(&master_ri, stderr);
+ fprintf(stderr, "apprentice reginfo:\n");
+ reginfo_dump(&apprentice_ri, stderr);
+
+ reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr);
+ return resp;
+}
diff --git a/risu.h b/risu.h
index 0f00b5f..90e4f23 100644
--- a/risu.h
+++ b/risu.h
@@ -57,8 +57,6 @@ struct reginfo;
*/
int send_register_info(int sock, void *uc);
-/* Interface provided by CPU-specific code: */
-
/* Read register info from the socket and compare it with that from the
* ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
* NB: called from a signal handler.
@@ -73,6 +71,8 @@ int recv_and_compare_register_info(int sock, void *uc);
*/
int report_match_status(void);
+/* Interface provided by CPU-specific code: */
+
/* Move the PC past this faulting insn by adjusting ucontext
*/
void advance_pc(void *uc);
diff --git a/risu_aarch64.c b/risu_aarch64.c
index 7363eb1..cdd23d8 100644
--- a/risu_aarch64.c
+++ b/risu_aarch64.c
@@ -17,13 +17,6 @@
#include "risu.h"
#include "risu_reginfo_aarch64.h"
-struct reginfo master_ri, apprentice_ri;
-
-uint8_t apprentice_memblock[MEMBLOCKLEN];
-
-static int mem_used = 0;
-static int packet_mismatch = 0;
-
void advance_pc(void *vuc)
{
ucontext_t *uc = vuc;
@@ -52,104 +45,3 @@ int get_risuop(struct reginfo *ri)
uint32_t risukey = 0x00005af0;
return (key != risukey) ? -1 : op;
}
-
-/* Read register info from the socket and compare it with that from the
- * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
- * NB: called from a signal handler.
- *
- * We don't have any kind of identifying info in the incoming data
- * that says whether it is register or memory data, so if the two
- * sides get out of sync then we will fail obscurely.
- */
-int recv_and_compare_register_info(int sock, void *uc)
-{
- int resp = 0, op;
-
- reginfo_init(&master_ri, uc);
- op = get_risuop(&master_ri);
-
- switch (op) {
- case OP_COMPARE:
- case OP_TESTEND:
- default:
- /* Do a simple register compare on (a) explicit request
- * (b) end of test (c) a non-risuop UNDEF
- */
- if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri))) {
- packet_mismatch = 1;
- resp = 2;
-
- } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
- /* register mismatch */
- resp = 2;
-
- } else if (op == OP_TESTEND) {
- resp = 1;
- }
- send_response_byte(sock, resp);
- break;
- case OP_SETMEMBLOCK:
- memblock = (void *)get_reginfo_paramreg(&master_ri);
- break;
- case OP_GETMEMBLOCK:
- set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
- (uintptr_t)memblock);
- break;
- case OP_COMPAREMEM:
- mem_used = 1;
- if (recv_data_pkt(sock, apprentice_memblock, MEMBLOCKLEN)) {
- packet_mismatch = 1;
- resp = 2;
- } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) {
- /* memory mismatch */
- resp = 2;
- }
- send_response_byte(sock, resp);
- break;
- }
-
- return resp;
-}
-
-/* Print a useful report on the status of the last comparison
- * done in recv_and_compare_register_info(). This is called on
- * exit, so need not restrict itself to signal-safe functions.
- * Should return 0 if it was a good match (ie end of test)
- * and 1 for a mismatch.
- */
-int report_match_status(void)
-{
- int resp = 0;
- fprintf(stderr, "match status...\n");
- if (packet_mismatch) {
- fprintf(stderr, "packet mismatch (probably disagreement "
- "about UNDEF on load/store)\n");
- /* We don't have valid reginfo from the apprentice side
- * so stop now rather than printing anything about it.
- */
- fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, stderr);
- return 1;
- }
- if (memcmp(&master_ri, &apprentice_ri, sizeof(master_ri)) != 0)
- {
- fprintf(stderr, "mismatch on regs!\n");
- resp = 1;
- }
- if (mem_used && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) {
- fprintf(stderr, "mismatch on memory!\n");
- resp = 1;
- }
- if (!resp) {
- fprintf(stderr, "match!\n");
- return 0;
- }
-
- fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, stderr);
- fprintf(stderr, "apprentice reginfo:\n");
- reginfo_dump(&apprentice_ri, stderr);
-
- reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr);
- return resp;
-}
diff --git a/risu_arm.c b/risu_arm.c
index 878b2ee..f570828 100644
--- a/risu_arm.c
+++ b/risu_arm.c
@@ -16,12 +16,6 @@
#include "risu.h"
#include "risu_reginfo_arm.h"
-struct reginfo master_ri, apprentice_ri;
-uint8_t apprentice_memblock[MEMBLOCKLEN];
-
-static int mem_used = 0;
-static int packet_mismatch = 0;
-
int insnsize(ucontext_t *uc)
{
/* Return instruction size in bytes of the
@@ -76,113 +70,3 @@ int get_risuop(struct reginfo *ri)
uint32_t risukey = (isz == 2) ? 0xdee0 : 0xe7fe5af0;
return (key != risukey) ? -1 : op;
}
-
-/* Read register info from the socket and compare it with that from the
- * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
- * NB: called from a signal handler.
- *
- * We don't have any kind of identifying info in the incoming data
- * that says whether it's register or memory data, so if the two
- * sides get out of sync then we will fail obscurely.
- */
-int recv_and_compare_register_info(int sock, void *uc)
-{
- int resp = 0, op;
-
- reginfo_init(&master_ri, uc);
- op = get_risuop(&master_ri);
-
- switch (op)
- {
- case OP_COMPARE:
- case OP_TESTEND:
- default:
- /* Do a simple register compare on (a) explicit request
- * (b) end of test (c) a non-risuop UNDEF
- */
- if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri)))
- {
- packet_mismatch = 1;
- resp = 2;
- }
- else if (memcmp(&master_ri, &apprentice_ri, sizeof(master_ri)) != 0)
- {
- /* register mismatch */
- resp = 2;
- }
- else if (op == OP_TESTEND)
- {
- resp = 1;
- }
- send_response_byte(sock, resp);
- break;
- case OP_SETMEMBLOCK:
- memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri);
- break;
- case OP_GETMEMBLOCK:
- set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
- (uintptr_t)memblock);
- break;
- case OP_COMPAREMEM:
- mem_used = 1;
- if (recv_data_pkt(sock, apprentice_memblock, MEMBLOCKLEN))
- {
- packet_mismatch = 1;
- resp = 2;
- }
- else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0)
- {
- /* memory mismatch */
- resp = 2;
- }
- send_response_byte(sock, resp);
- break;
- }
- return resp;
-}
-
-/* Print a useful report on the status of the last comparison
- * done in recv_and_compare_register_info(). This is called on
- * exit, so need not restrict itself to signal-safe functions.
- * Should return 0 if it was a good match (ie end of test)
- * and 1 for a mismatch.
- */
-int report_match_status(void)
-{
- int resp = 0;
- fprintf(stderr, "match status...\n");
- if (packet_mismatch)
- {
- fprintf(stderr, "packet mismatch (probably disagreement "
- "about UNDEF on load/store)\n");
- /* We don't have valid reginfo from the apprentice side
- * so stop now rather than printing anything about it.
- */
- fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, stderr);
- return 1;
- }
- if (!reginfo_is_eq(&master_ri, &apprentice_ri))
- {
- fprintf(stderr, "mismatch on regs!\n");
- resp = 1;
- }
- if (mem_used && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0)
- {
- fprintf(stderr, "mismatch on memory!\n");
- resp = 1;
- }
- if (!resp)
- {
- fprintf(stderr, "match!\n");
- return 0;
- }
-
- fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, stderr);
- fprintf(stderr, "apprentice reginfo:\n");
- reginfo_dump(&apprentice_ri, stderr);
-
- reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr);
- return resp;
-}
diff --git a/risu_m68k.c b/risu_m68k.c
index c0e29ff..851487b 100644
--- a/risu_m68k.c
+++ b/risu_m68k.c
@@ -13,12 +13,6 @@
#include "risu.h"
#include "risu_reginfo_m68k.h"
-struct reginfo master_ri, apprentice_ri;
-static int mem_used = 0;
-static int packet_mismatch = 0;
-
-uint8_t apprentice_memblock[MEMBLOCKLEN];
-
void advance_pc(void *vuc)
{
ucontext_t *uc = (ucontext_t*)vuc;
@@ -44,91 +38,3 @@ int get_risuop(struct reginfo *ri)
uint32_t risukey = 0x4afc7000;
return (key != risukey) ? -1 : op;
}
-
-/* Read register info from the socket and compare it with that from the
- * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
- * NB: called from a signal handler.
- */
-int recv_and_compare_register_info(int sock, void *uc)
-{
- int resp = 0;
- int op;
-
- reginfo_init(&master_ri, uc);
- op = get_risuop(&master_ri);
-
- switch (op) {
- case OP_COMPARE:
- case OP_TESTEND:
- default:
- if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri))) {
- packet_mismatch = 1;
- resp = 2;
- } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
- resp = 2;
- }
- else if (op == OP_TESTEND) {
- resp = 1;
- }
- send_response_byte(sock, resp);
- break;
- case OP_SETMEMBLOCK:
- memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri);
- break;
- case OP_GETMEMBLOCK:
- set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
- (uintptr_t)memblock);
- break;
- case OP_COMPAREMEM:
- mem_used = 1;
- if (recv_data_pkt(sock, apprentice_memblock, MEMBLOCKLEN)) {
- packet_mismatch = 1;
- resp = 2;
- } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) {
- resp = 2;
- }
- send_response_byte(sock, resp);
- break;
- }
- return resp;
-}
-
-/* Print a useful report on the status of the last comparison
- * done in recv_and_compare_register_info(). This is called on
- * exit, so need not restrict itself to signal-safe functions.
- * Should return 0 if it was a good match (ie end of test)
- * and 1 for a mismatch.
- */
-int report_match_status(void)
-{
- int resp = 0;
- fprintf(stderr, "match status...\n");
-
- if (packet_mismatch) {
- fprintf(stderr, "packet mismatch (probably disagreement "
- "about UNDEF on load/store)\n");
- fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, stderr);
- }
- if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
- fprintf(stderr, "mismatch on regs!\n");
- resp = 1;
- }
- if (mem_used && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) {
- fprintf(stderr, "mismatch on memory!\n");
- resp = 1;
- }
- if (!resp) {
- fprintf(stderr, "match!\n");
- return 0;
- }
-
- fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, stderr);
-
- fprintf(stderr, "apprentice reginfo:\n");
- reginfo_dump(&apprentice_ri, stderr);
-
- reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr);
- return resp;
-}
diff --git a/risu_ppc64le.c b/risu_ppc64le.c
index 928f36f..c15d78e 100644
--- a/risu_ppc64le.c
+++ b/risu_ppc64le.c
@@ -18,12 +18,6 @@
#include "risu.h"
#include "risu_reginfo_ppc64le.h"
-struct reginfo master_ri, apprentice_ri;
-static int mem_used = 0;
-static int packet_mismatch = 0;
-
-uint8_t apprentice_memblock[MEMBLOCKLEN];
-
void advance_pc(void *vuc)
{
ucontext_t *uc = (ucontext_t*)vuc;
@@ -49,91 +43,3 @@ int get_risuop(struct reginfo *ri)
uint32_t risukey = 0x00005af0;
return (key != risukey) ? -1 : op;
}
-
-/* Read register info from the socket and compare it with that from the
- * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch.
- * NB: called from a signal handler.
- */
-int recv_and_compare_register_info(int sock, void *uc)
-{
- int resp = 0;
- int op;
-
- reginfo_init(&master_ri, uc);
- op = get_risuop(&master_ri);
-
- switch (op) {
- case OP_COMPARE:
- case OP_TESTEND:
- default:
- if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri))) {
- packet_mismatch = 1;
- resp = 2;
- } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
- resp = 2;
- }
- else if (op == OP_TESTEND) {
- resp = 1;
- }
- send_response_byte(sock, resp);
- break;
- case OP_SETMEMBLOCK:
- memblock = (void*)get_reginfo_paramreg(&master_ri);
- break;
- case OP_GETMEMBLOCK:
- set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) +
- (uintptr_t)memblock);
- break;
- case OP_COMPAREMEM:
- mem_used = 1;
- if (recv_data_pkt(sock, apprentice_memblock, MEMBLOCKLEN)) {
- packet_mismatch = 1;
- resp = 2;
- } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) {
- resp = 2;
- }
- send_response_byte(sock, resp);
- break;
- }
- return resp;
-}
-
-/* Print a useful report on the status of the last comparison
- * done in recv_and_compare_register_info(). This is called on
- * exit, so need not restrict itself to signal-safe functions.
- * Should return 0 if it was a good match (ie end of test)
- * and 1 for a mismatch.
- */
-int report_match_status(void)
-{
- int resp = 0;
- fprintf(stderr, "match status...\n");
-
- if (packet_mismatch) {
- fprintf(stderr, "packet mismatch (probably disagreement "
- "about UNDEF on load/store)\n");
- fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, stderr);
- }
- if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
- fprintf(stderr, "mismatch on regs!\n");
- resp = 1;
- }
- if (mem_used && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) {
- fprintf(stderr, "mismatch on memory!\n");
- resp = 1;
- }
- if (!resp) {
- fprintf(stderr, "match!\n");
- return 0;
- }
-
- fprintf(stderr, "master reginfo:\n");
- reginfo_dump(&master_ri, stderr);
-
- fprintf(stderr, "apprentice reginfo:\n");
- reginfo_dump(&apprentice_ri, stderr);
-
- reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr);
- return resp;
-}
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH risu 9/9] Tidy up #include lines
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
` (7 preceding siblings ...)
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 8/9] Move recv_and_compare_register_info() and report_match_status() " Peter Maydell
@ 2017-02-24 17:35 ` Peter Maydell
2017-02-24 18:15 ` [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Laurent Vivier
9 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Nikunj A Dadhania, Laurent Vivier
Tidy up unnecessary #includes that risu.h provides.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
risu.h | 1 +
risu_aarch64.c | 5 -----
risu_m68k.c | 5 -----
risu_ppc64le.c | 5 -----
4 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/risu.h b/risu.h
index 90e4f23..883bcf7 100644
--- a/risu.h
+++ b/risu.h
@@ -15,6 +15,7 @@
#include <inttypes.h>
#include <stdint.h>
#include <ucontext.h>
+#include <stdio.h>
/* GCC computed include to pull in the correct risu_reginfo_*.h for
* the architecture.
diff --git a/risu_aarch64.c b/risu_aarch64.c
index cdd23d8..9c6809d 100644
--- a/risu_aarch64.c
+++ b/risu_aarch64.c
@@ -10,12 +10,7 @@
* based on Peter Maydell's risu_arm.c
*****************************************************************************/
-#include <stdio.h>
-#include <ucontext.h>
-#include <string.h>
-
#include "risu.h"
-#include "risu_reginfo_aarch64.h"
void advance_pc(void *vuc)
{
diff --git a/risu_m68k.c b/risu_m68k.c
index 851487b..f84ac7a 100644
--- a/risu_m68k.c
+++ b/risu_m68k.c
@@ -6,12 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************/
-#include <stdio.h>
-#include <ucontext.h>
-#include <string.h>
-
#include "risu.h"
-#include "risu_reginfo_m68k.h"
void advance_pc(void *vuc)
{
diff --git a/risu_ppc64le.c b/risu_ppc64le.c
index c15d78e..b575078 100644
--- a/risu_ppc64le.c
+++ b/risu_ppc64le.c
@@ -11,12 +11,7 @@
* based on Peter Maydell's risu_arm.c
*****************************************************************************/
-#include <stdio.h>
-#include <ucontext.h>
-#include <string.h>
-
#include "risu.h"
-#include "risu_reginfo_ppc64le.h"
void advance_pc(void *vuc)
{
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code
2017-02-24 17:35 [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Peter Maydell
` (8 preceding siblings ...)
2017-02-24 17:35 ` [Qemu-devel] [PATCH risu 9/9] Tidy up #include lines Peter Maydell
@ 2017-02-24 18:15 ` Laurent Vivier
2017-02-24 18:17 ` Peter Maydell
2017-02-28 17:47 ` Peter Maydell
9 siblings, 2 replies; 13+ messages in thread
From: Laurent Vivier @ 2017-02-24 18:15 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Nikunj A Dadhania
Le 24/02/2017 à 18:35, Peter Maydell a écrit :
> This patchset refactors the risu C code to reduce the significant
> amount of duplicated and duplicated-but-not-quite-the-same code
> in the per-CPU files.
>
> I've compile tested this for all architectures, but I'm not in a
> position to do runtime tests for non-ARM (my attempt to use the
> ppc64le risu under QEMU gives mismatch errors even without these
> patches, and the m68k risu makes QEMU crash, presumably because our
> m68k support isn't complete yet). So I wasn't quite prepared to just
Yes, the FPU part is missing.
> push it straight out to master the way I've done with previous
> changes I've been making.
>
> Nikunj, Laurent: if you have time to test this patchset to confirm
> that it hasn't broken anything for you that would be great.
for m68k
Tested-by: Laurent Vivier <laurent@vivier.eu>
>
> My motivation for all this, incidentally, is that I wanted to have
> a go at resurrecting the x86 backend as a test case for how we
> should support variable-length instruction sets.
I think m68k is needing that too.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code
2017-02-24 18:15 ` [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Laurent Vivier
@ 2017-02-24 18:17 ` Peter Maydell
2017-02-28 17:47 ` Peter Maydell
1 sibling, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-24 18:17 UTC (permalink / raw)
To: Laurent Vivier; +Cc: QEMU Developers, Nikunj A Dadhania
On 24 February 2017 at 18:15, Laurent Vivier <laurent@vivier.eu> wrote:
> Le 24/02/2017 à 18:35, Peter Maydell a écrit :
>> My motivation for all this, incidentally, is that I wanted to have
>> a go at resurrecting the x86 backend as a test case for how we
>> should support variable-length instruction sets.
>
> I think m68k is needing that too.
Yep; but I don't have an m68k to hand, whereas I do have
x86-64 ;-)
thanks
-- PMM
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code
2017-02-24 18:15 ` [Qemu-devel] [PATCH risu 0/9] risu: refactor and reduce CPU-specific code Laurent Vivier
2017-02-24 18:17 ` Peter Maydell
@ 2017-02-28 17:47 ` Peter Maydell
1 sibling, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2017-02-28 17:47 UTC (permalink / raw)
To: Laurent Vivier; +Cc: QEMU Developers, Nikunj A Dadhania
On 24 February 2017 at 18:15, Laurent Vivier <laurent@vivier.eu> wrote:
> Le 24/02/2017 à 18:35, Peter Maydell a écrit :
>> This patchset refactors the risu C code to reduce the significant
>> amount of duplicated and duplicated-but-not-quite-the-same code
>> in the per-CPU files.
>>
>> I've compile tested this for all architectures, but I'm not in a
>> position to do runtime tests for non-ARM (my attempt to use the
>> ppc64le risu under QEMU gives mismatch errors even without these
>> patches, and the m68k risu makes QEMU crash, presumably because our
>> m68k support isn't complete yet). So I wasn't quite prepared to just
>
> Yes, the FPU part is missing.
>
>> push it straight out to master the way I've done with previous
>> changes I've been making.
>>
>> Nikunj, Laurent: if you have time to test this patchset to confirm
>> that it hasn't broken anything for you that would be great.
>
> for m68k
> Tested-by: Laurent Vivier <laurent@vivier.eu>
Thanks; I've gone ahead and pushed this series to risu master.
-- PMM
^ permalink raw reply [flat|nested] 13+ messages in thread