From: Paolo Bonzini <pbonzini@redhat.com>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [PATCH] hw/acpi: Set memory regions to native endian as a work around
Date: Tue, 7 Mar 2023 12:26:27 +0100 [thread overview]
Message-ID: <e0a958ec-fa18-0d13-48db-10feea159491@redhat.com> (raw)
In-Reply-To: <c2b19806-db0f-54b8-ed41-2e74c19d029e@eik.bme.hu>
On 3/7/23 11:01, BALATON Zoltan wrote:
>>
>>> I'm not sure I follow what you mean so I'd need a patch to see then I
>>> can
>>> test it with the clients I run on pegasos2.
>>
>> Do you have a spec, or pointer to the morphos kernel sources, to
>> figure out how the hardware works?
>
> No, that's closed source and only available as a demo iso but it's known
> to work on real hardware and freely downloadable so is a good test.
> (AFAIK those who developed MorphOS had close connection to those who
> wrote the firmware for Pegasos II.) Maybe the VT8231 datasheet or
> similar parts (we only emulate VT82C686B and VT8231 in QEMU) has some
> info on this.
I agree it's a good test, but it's not clear what it means to do
sub-word writes to the register.
For example, in the dump I posted you have:
evt 3 1 write 1 // enable timer
evt 0 2 read
evt 0 2 write 1 // just writes again the same value, clearing sts
It's important to note that the comments are just my guess.
Before even looking at the effect of the write, the trace tells us that
your patch is incomplete. With both current QEMU and your patch it
would do nothing because addr is not 0 or 2; but since the firmware of
your machine does use addr == 3, you need to handle it. In other words,
before looking at this trace, I was wary of accepting your patch because
it made no sense to me; but I couldn't exclude that I was missing
something. Now, instead, I am certain it shouldn't be accepted.
I am quite confident that the second guess is correct, because "write
the same value that was read" only makes sense for evt_sts and not for
evt_en. We learnt something: no matter what bus this device sits on, it
does not flip bit 1 of the address for subword writes. As I mentioned
yesterday, we also observe that the load and store use lhbrx and sthbrx.
Assuming this is not a harmless bug in the firmware, this means the
device is indeed little endian.
This means that the first write is almost certainly to evt_en. On a
little-endian machine the write would set bit 8 of evt.en (power
button), but what about a big-endian machine like yours? Should it set
bit 0 or bit 8? If it's bit 0 (which resides at offset 2 according to
the device), who flips the low bit of the address? Why is bit 0 flipped
but not bit 1?
You simply cannot fix the emulation of this machine until you can answer
the above questions. If there is no source and no spec, the two ways to
do it are:
- get a real machine, and figure out whether the write to offset 3
corresponds to the PM timer or the power button.
- continue the trace up to the point the OS runs, and see if you get
some clues similar to the one above that placed evt_sts at offset 2.
Paolo
next prev parent reply other threads:[~2023-03-07 11:26 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 13:05 [PATCH] hw/acpi: Set memory regions to native endian as a work around BALATON Zoltan
2021-11-08 13:32 ` Michael S. Tsirkin
2021-11-08 15:22 ` BALATON Zoltan
2021-12-16 10:27 ` Michael S. Tsirkin
2021-11-08 14:30 ` Paolo Bonzini
2021-11-08 15:04 ` Paolo Bonzini
2021-11-08 15:16 ` BALATON Zoltan
2021-11-13 18:47 ` BALATON Zoltan
2022-01-19 9:19 ` Michael S. Tsirkin
2022-02-22 14:40 ` Michael S. Tsirkin
2023-02-20 18:24 ` BALATON Zoltan
2023-02-20 22:33 ` Michael S. Tsirkin
2023-02-20 23:25 ` BALATON Zoltan
2023-02-21 8:30 ` Paolo Bonzini
2023-02-21 12:48 ` BALATON Zoltan
2023-02-21 12:55 ` BALATON Zoltan
2023-03-06 22:56 ` Paolo Bonzini
2023-03-06 23:11 ` BALATON Zoltan
2023-03-06 23:36 ` Paolo Bonzini
2023-03-07 0:06 ` BALATON Zoltan
2023-03-07 5:58 ` Paolo Bonzini
2023-03-07 10:01 ` BALATON Zoltan
2023-03-07 11:26 ` Paolo Bonzini [this message]
2023-03-07 12:54 ` BALATON Zoltan
2023-03-07 15:14 ` Paolo Bonzini
2023-03-07 15:21 ` BALATON Zoltan
2023-03-07 16:48 ` Paolo Bonzini
2023-04-30 23:10 ` BALATON Zoltan
2023-04-30 23:26 ` BALATON Zoltan
2023-02-21 14:02 ` Paolo Bonzini
2023-03-02 13:42 ` BALATON Zoltan
2023-03-06 18:34 ` Michael S. Tsirkin
2023-03-03 8:22 ` Michael S. Tsirkin
2023-03-11 20:59 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e0a958ec-fa18-0d13-48db-10feea159491@redhat.com \
--to=pbonzini@redhat.com \
--cc=balaton@eik.bme.hu \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).