[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AGHI instruction sets wrong condition code
From: |
Ilya Leoshkevich |
Subject: |
Re: AGHI instruction sets wrong condition code |
Date: |
Wed, 01 Feb 2023 15:55:56 +0100 |
User-agent: |
Evolution 3.46.3 (3.46.3-1.fc37) |
On Wed, 2023-02-01 at 13:37 +0100, Thomas Huth wrote:
>
> Hi Richard,
>
> while looking at an issue that Michael reported in IRC today
> (https://bugs.debian.org/987110) I noticed that the AGHI instructions
> behaves differently in TCG compared to a KVM guest:
>
> With the KVM guest:
>
> (gdb) p/x $r14
> $1 = 0x3ffffffaa48
> (gdb) p/x $pswm
> $2 = 0x705000180000000
> (gdb) x/1i $pc
> => 0x3fff7f99d6e <dl_main+22>: aghi %r14,-32
> (gdb) stepi
> 0x000003fff7f99d72 1357 in rtld.c
> (gdb) p/x $r14
> $3 = 0x3ffffffaa28
> (gdb) p/x $pswm
> $4 = 0x705200180000000
>
> With the TCG guest:
>
> (gdb) p/x $r14
> $1 = 0x3ffffffaa48
> (gdb) p/x $pswm
> $2 = 0x705000180000000
> (gdb) x/1i $pc
> => 0x3fff7f99d6e <dl_main+22>: aghi %r14,-32
> (gdb) stepi
> 0x000003fff7f99d72 1357 in rtld.c
> (gdb) p/x $r14
> $3 = 0x3ffffffaa28
> (gdb) p/x $pswm
> $4 = 0x705000180000000
>
> As you can see, the PSW mask is different after the AGHI instruction,
> real
> hardware sets CC to 2, while TCG keeps it a 0.
>
> I stared at the translate.c and cc_helper.c code for a while, but I
> can't
> quite figure it out ... if you've got some spare minutes, could you
> maybe
> have a look at this, too?
>
> Thanks,
> Thomas
>
>
> PS: I guess it's not the bug causing the issue reported by Michael,
> since
> there is no instruction looking at the CC right after that AGHI
Interestingly enough, the following works fine with linux-user:
#include <assert.h>
#include <stdlib.h>
int main(void) {
long val = 0x3ffffffaa48;
int cc;
asm("aghi %[val],-32\n"
"ipm %[cc]" : [val] "+r" (val), [cc] "=r" (cc) : : "cc");
cc >>= 28;
assert(val == 0x3ffffffaa28);
assert(cc == 2);
return EXIT_SUCCESS;
}
I wonder if this could be a PER/singlestep issue?