target/s390x/translate: Fix RNSBG instruction
PATCH 1/1 target/s390x/translate: Fix RNSBG instruction
RNSBG is handled via the op_rosbg() helper function. But RNSBG has the opcode 0xEC54, i.e. 0x54 as second byte, while op_rosbg() currently checks for 0x55. This seems to be a typo, fix it to use 0x54 instead, so that op_rosbg() does not abort() anymore if a program uses RNSBG.
I've checked with a simply test function that I now get the same results with KVM and with TCG:
static void test_rnsbg(void)
{
uint64_t r1, r2;
r2 = 0xffff000000000000UL;
r1 = 0x123456789bdfaaaaUL;
asm volatile (" rnsbg %0,%1,12,61,16 " : "+r"(r1) : "r"(r2));
printf("r1 afterwards: 0x%lx\n", r1);}
--- target/s390x/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/translate.c +1 -1
@@ -3874,7 +3874,7 @@ static DisasJumpType op_rosbg(DisasContext *s, DisasOps *o)/* Operate. */ switch (s->fields.op2) { -case 0x55 :/* AND */ +case 0x54 :/* AND */ tcg_gen_ori_i64 (o->in2, o->in2, ~mask);tcg_gen_and_i64 (o->out, o->out, o->in2);break ;
Signature · 1 line
2.18.1
Quoted 17 lines · Thomas Huth
RNSBG is handled via the
op_rosbg()helper function. But RNSBG has the opcode0xEC54, i.e.0x54as second byte, whileop_rosbg()currently checks for0x55. This seems to be a typo, fix it to use0x54instead, so thatop_rosbg()does notabort()anymore if a program uses RNSBG.I've checked with a simply test function that I now get the same results with KVM and with TCG:
static void
test_rnsbg(void){ uint64_t r1, r2; r2 = 0xffff000000000000UL; r1 = 0x123456789bdfaaaaUL; asm volatile (" rnsbg %0,%1,12,61,16 " : "+r"(r1) : "r"(r2)); printf("r1 afterwards: 0x%lx\n", r1);
Quoted 1 line
}
You could add a tcg test case for that :)
Quoted 13 lines
Signed-off-by Thomas Huth <[email protected]>--- target/s390x/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/s390x/translate.c +0
-0
target/s390x/translate.c static DisasJumpType op_rosbg(DisasContext *s, DisasOps *o) · line 3880
Quoted 8 lines
target/s390x/translate.c +1
-1@@ -3874,7 +3874,7 @@ static DisasJumpType op_rosbg(DisasContext *s, DisasOps *o)/* Operate. */ switch (s->fields.op2) { -case 0x55 :/* AND */ +case 0x54 :/* AND */ tcg_gen_ori_i64 (o->in2, o->in2, ~mask);tcg_gen_and_i64 (o->out, o->out, o->in2);break ;
Thanks!
Signature · 3 lines
Thanks, David / dhildenb
Quoted 13 lines · David Hildenbrand
Quoted 12 lines · Thomas Huth
RNSBG is handled via the
op_rosbg()helper function. But RNSBG has the opcode0xEC54, i.e.0x54as second byte, whileop_rosbg()currently checks for0x55. This seems to be a typo, fix it to use0x54instead, so thatop_rosbg()does notabort()anymore if a program uses RNSBG.I've checked with a simply test function that I now get the same results with KVM and with TCG:
static void
test_rnsbg(void){ uint64_t r1, r2;
Quoted 8 lines
Quoted 6 lines
r2 = 0xffff000000000000UL; r1 = 0x123456789bdfaaaaUL; asm volatile (" rnsbg %0,%1,12,61,16 " : "+r"(r1) : "r"(r2)); printf("r1 afterwards: 0x%lx\n", r1);}
You could add a tcg test case for that :)
I already thought about it ... I'll have a try when I've got some spare time.
Thomas
Cornelia Huck
AppliedQuoted 6 lines · On Thu, 30 Jan 2020 14:34:17 +0100 Thomas Huth <[email protected]> wrote:
RNSBG is handled via the
op_rosbg()helper function. But RNSBG has the opcode0xEC54, i.e.0x54as second byte, whileop_rosbg()currently checks for0x55. This seems to be a typo, fix it to use0x54instead, so thatop_rosbg()does notabort()anymore if a program uses RNSBG.I've checked with a simply test function that I now get the same results
s/simply/simple/
Quoted 24 lines
with KVM and with TCG:
static void
test_rnsbg(void){ uint64_t r1, r2; r2 = 0xffff000000000000UL; r1 = 0x123456789bdfaaaaUL; asm volatile (" rnsbg %0,%1,12,61,16 " : "+r"(r1) : "r"(r2)); printf("r1 afterwards: 0x%lx\n", r1);}
Signed-off-by Thomas Huth <[email protected]>--- target/s390x/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/s390x/translate.c +0
-0
target/s390x/translate.c static DisasJumpType op_rosbg(DisasContext *s, DisasOps *o) · line 3880
Quoted 8 lines
target/s390x/translate.c +1
-1@@ -3874,7 +3874,7 @@ static DisasJumpType op_rosbg(DisasContext *s, DisasOps *o)/* Operate. */ switch (s->fields.op2) { -case 0x55 :/* AND */ +case 0x54 :/* AND */ tcg_gen_ori_i64 (o->in2, o->in2, ~mask);tcg_gen_and_i64 (o->out, o->out, o->in2);break ;
Thanks, applied.