Skip to contentSkip to conversation

ppc: Enforce setting MSR:EE, IR and DR when MSR:PR is set

GIT PULL G 3 4 participants 13 messages Jul 9, 2016 – Jul 12, 2016

lore
Share & tools
lore

G 3

author
#0 lore raw
Quoted 59 lines · Mark Cave-Ayland
Quoted 29 lines · David Gibson
Quoted 27 lines

From: Benjamin Herrenschmidt <b378bb0948277d71c78bc6d0c1ef80a253aafc80>

The architecture specifies that any instruction that sets MSR:PR will also set MSR:EE, IR and DR.

---
 target-ppc/helper_regs.h | 4 ++++
 1 file changed, 4 insertions(+)
target-ppc/helper_regs.h +4 -0
index 8fc0934..8fdfa5c 100644
@@ -136,6 +136,10 @@ static inline int hreg_store_msr(CPUPPCState  
 *env, target_ulong value,
         /* Change the exception prefix on PowerPC 601 */
         env->excp_prefix = ((value >> MSR_EP) & 1) * 0xFFF00000;
     }
+    /* If PR=1 then EE, IR and DR must be 1 */
+    if ((value >> MSR_PR) & 1) {
+        value |= (1 << MSR_EE) | (1 << MSR_DR) | (1 << MSR_IR);
+    }
Quoted 9 lines
Quoted 5 lines
target-ppc/helper_regs.h +0 -0
 #endif
     env->msr = value;
     hreg_compute_hflags(env);

Unfortunately this patch causes a regression and breaks booting OS 9 and OS X under qemu-system-ppc.

Ah This is curious.

I used :

qemu-system-ppc -M g3beige -cdrom darwinppc-602.cdr -boot d qemu-system-ppc -M mac99 -cdrom darwinppc-602.cdr -boot d qemu-system-ppc64 -M g3beige -cdrom darwinppc-602.cdr -boot d

which "work" as they reach the installation prompt :

The following devices are available for installation.

This one hangs :

qemu-system-ppc64 -M mac99 -cdrom darwinppc-602.cdr -boot d

But that is expected for a 970 cpu.

Quoted 7 lines

The login prompt is reached with a full Darwin disk image.

So I must be missing a scenario :/

Thanks,

C.

I suggest you use a more up-to-date version of Darwin for PowerPC 64-bit support:

https://opensource.apple.com/static/iso/darwinppc-801.cdr.gz

#1 lore raw
Quoted 62 lines · On 07/09/2016 07:42 PM, G 3 wrote:
Quoted 62 lines · Mark Cave-Ayland
Quoted 28 lines · David Gibson
Quoted 26 lines

From: Benjamin Herrenschmidt <b378bb0948277d71c78bc6d0c1ef80a253aafc80>

The architecture specifies that any instruction that sets MSR:PR will also set MSR:EE, IR and DR.

---
 target-ppc/helper_regs.h | 4 ++++
 1 file changed, 4 insertions(+)
target-ppc/helper_regs.h +4 -0
index 8fc0934..8fdfa5c 100644
@@ -136,6 +136,10 @@ static inline int hreg_store_msr(CPUPPCState *env, target_ulong value,
         /* Change the exception prefix on PowerPC 601 */
         env->excp_prefix = ((value >> MSR_EP) & 1) * 0xFFF00000;
     }
+    /* If PR=1 then EE, IR and DR must be 1 */
+    if ((value >> MSR_PR) & 1) {
+        value |= (1 << MSR_EE) | (1 << MSR_DR) | (1 << MSR_IR);
+    }
Quoted 9 lines

target-ppc/helper_regs.h static inline int hreg_store_msr(CPUPPCState *env, target_ulong value, · line 145

Quoted 5 lines
target-ppc/helper_regs.h +0 -0
 #endif
     env->msr = value;
     hreg_compute_hflags(env);

Unfortunately this patch causes a regression and breaks booting OS 9 and OS X under qemu-system-ppc.

Ah This is curious.

I used :

qemu-system-ppc -M g3beige -cdrom darwinppc-602.cdr -boot d qemu-system-ppc -M mac99 -cdrom darwinppc-602.cdr -boot d qemu-system-ppc64 -M g3beige -cdrom darwinppc-602.cdr -boot d

which "work" as they reach the installation prompt :

The following devices are available for installation.

This one hangs :

qemu-system-ppc64 -M mac99 -cdrom darwinppc-602.cdr -boot d

But that is expected for a 970 cpu.

The login prompt is reached with a full Darwin disk image.

So I must be missing a scenario :/

Quoted 8 lines
Quoted 3 lines

Thanks,

C.

I suggest you use a more up-to-date version of Darwin for PowerPC 64-bit support:

https://opensource.apple.com/static/iso/darwinppc-801.cdr.gz

ok. Will do.

Mark,

For OS 9, do you plan to commit these openbios patches soon ?

	https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg02824.html

as we just gave them a good test. Or may be, include them under a github branch to make them easier to find.

Also, I found out that some OS 9 isos are not supported by qemu. These are ok :

	http://www.emaculation.com/forum/viewtopic.php?f=34&t=7047&sid=0ef8922b24a51d2a9d546300aea69c64&start=250

But the one under :

	http://c-obrien.org/qemu-os9/testing/

does not boot. It loops on some CUDA commands and then hangs. I did not dig further. Is that a known issue ?

Thanks,

C.

#2 lore raw

I removed OpenTransport and other extensions and control panels as well as patched the System Suitcase on some of those iso's on the emaculation.com
forum. They are not stock images. Perhaps we still need further work. As
far as 9.0.4 booting, I have never succeeded in booting that, awesome!

Mark: do you have a link to the latest working openbios-ppc?

Regards,
Alfonso

Quoted 8 lines · On 07/09/2016 07:42 PM, G 3 wrote:
Quoted 8 lines · Mark Cave-Ayland
Quoted 7 lines · David Gibson
Quoted 5 lines

From: Benjamin Herrenschmidt <b378bb0948277d71c78bc6d0c1ef80a253aafc80>

The architecture specifies that any instruction that sets MSR:PR will

also

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

set MSR:EE, IR and DR.

---
 target-ppc/helper_regs.h | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

target-ppc/helper_regs.h static inline int hreg_store_msr(CPUPPCState

Quoted 5 lines
target-ppc/helper_regs.h +0 -0
index 8fc0934..8fdfa5c 100644
@@ -136,6 +136,10 @@ static inline int hreg_store_msr(CPUPPCState

*env, target_ulong value,

Quoted 38 lines
Quoted 38 lines
Quoted 13 lines

target-ppc/helper_regs.h static inline int hreg_store_msr(CPUPPCState · line 145

Quoted 12 lines
target-ppc/helper_regs.h +4 -0
         /* Change the exception prefix on PowerPC 601 */
         env->excp_prefix = ((value >> MSR_EP) & 1) * 0xFFF00000;
     }
+    /* If PR=1 then EE, IR and DR must be 1 */
+    if ((value >> MSR_PR) & 1) {
+        value |= (1 << MSR_EE) | (1 << MSR_DR) | (1 << MSR_IR);
+    }
 #endif
     env->msr = value;
     hreg_compute_hflags(env);
Quoted 3 lines

Unfortunately this patch causes a regression and breaks booting OS 9 and OS X under qemu-system-ppc.

Ah This is curious.

I used :

qemu-system-ppc -M g3beige -cdrom darwinppc-602.cdr -boot d qemu-system-ppc -M mac99 -cdrom darwinppc-602.cdr -boot d qemu-system-ppc64 -M g3beige -cdrom darwinppc-602.cdr -boot d

which "work" as they reach the installation prompt :

The following devices are available for installation.

This one hangs :

qemu-system-ppc64 -M mac99 -cdrom darwinppc-602.cdr -boot d

But that is expected for a 970 cpu.

The login prompt is reached with a full Darwin disk image.

Quoted 8 lines
Quoted 5 lines

So I must be missing a scenario :/

Thanks,

C.

I suggest you use a more up-to-date version of Darwin for PowerPC 64-bit

support:

Quoted 2 lines

https://opensource.apple.com/static/iso/darwinppc-801.cdr.gz

ok. Will do.

Mark,

For OS 9, do you plan to commit these openbios patches soon ?

https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg02824.html

as we just gave them a good test. Or may be, include them under a github branch to make them easier to find.

Also, I found out that some OS 9 isos are not supported by qemu. These are ok :

http://www.emaculation.com/forum/viewtopic.php?f=34&t=7047&sid=0ef8922b24a51d2a9d546300aea69c64&start=250

But the one under :

        http://c-obrien.org/qemu-os9/testing/

does not boot. It loops on some CUDA commands and then hangs. I did not dig further. Is that a known issue ?

Thanks,

C.

#3 lore raw
Quoted 4 lines · Alfonso Gamboa

I removed OpenTransport and other extensions and control panels as well as patched the System Suitcase on some of those iso's on the emaculation.com
forum. They are not stock images. Perhaps we still need further work. As
far as 9.0.4 booting, I have never succeeded in booting that, awesome!

Quickly browsing through mails this morning, you should be able to boot/install unmodified OS 9 ISOs with David's ppc-for-2.7 branch and a slightly modified OpenBIOS. Note that the DBDMA code simply reports back to OpenTransport that nothing is connected to the ESCC port, so it's not as if you'll be able to run LocalTalk over emulated serial ports yet. But it should be enough for people to test with OS 9 LAN drivers.

Quoted 1 line

Mark: do you have a link to the latest working openbios-ppc?

https://www.ilande.co.uk/tmp/openbios/openbios-ppc

ATB,

Mark.

#4 lore raw
In reply to Cédric Le Goater
Quoted 8 lines · Cédric Le Goater

Mark,

For OS 9, do you plan to commit these openbios patches soon ?

	https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg02824.html

as we just gave them a good test. Or may be, include them under a github branch to make them easier to find.

All of the OS 9 patches for QEMU and OpenBIOS have been upstreamed, except this one for OpenBIOS:
https://www.coreboot.org/pipermail/openbios/2015-June/008722.html. I currently keep a manually build binary at
https://www.ilande.co.uk/tmp/openbios/openbios-ppc for people who can't build their own.

Quoted 11 lines

Also, I found out that some OS 9 isos are not supported by qemu. These are ok :

	http://www.emaculation.com/forum/viewtopic.php?f=34&t=7047&sid=0ef8922b24a51d2a9d546300aea69c64&start=250

But the one under :

	http://c-obrien.org/qemu-os9/testing/

does not boot. It loops on some CUDA commands and then hangs. I did not dig further. Is that a known issue ?

Hmmm if that's the same 9.2.1 image we were using for last year's GSoC then it has been working fine here? From what I've seen both 9.2.1 and 9.2.2 now boot fine, but please test and report if that's not the case.

ATB,

Mark.

#5 lore raw
Quoted 25 lines · Mark Cave-Ayland
Quoted 8 lines · Cédric Le Goater

Mark,

For OS 9, do you plan to commit these openbios patches soon ?

	https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg02824.html

as we just gave them a good test. Or may be, include them under a github branch to make them easier to find.

All of the OS 9 patches for QEMU and OpenBIOS have been upstreamed, except this one for OpenBIOS:
https://www.coreboot.org/pipermail/openbios/2015-June/008722.html. I currently keep a manually build binary at
https://www.ilande.co.uk/tmp/openbios/openbios-ppc for people who can't build their own.

Quoted 7 lines

Also, I found out that some OS 9 isos are not supported by qemu. These are ok :

	http://www.emaculation.com/forum/viewtopic.php?f=34&t=7047&sid=0ef8922b24a51d2a9d546300aea69c64&start=250

But the one under :

Quoted 8 lines
Quoted 4 lines
	http://c-obrien.org/qemu-os9/testing/

does not boot. It loops on some CUDA commands and then hangs. I did not dig further. Is that a known issue ?

Hmmm if that's the same 9.2.1 image we were using for last year's GSoC then it has been working fine here? From what I've seen both 9.2.1 and 9.2.2 now boot fine, but please test and report if that's not the case.

Hello Mark,

I managed to boot and install a 9.2.1. Here is what I have used for that :

* qemu, David's 2.7 branch, plus Ben's patch "v2 ppc: Fix support for odd MSR combinations".

* openbios, github's HEAD + the patch your patch from :

	https://www.coreboot.org/pipermail/openbios/2015-June/008722.html

* iso, the os9.osi from

	http://c-obrien.org/qemu-os9/testing/

There are a couple of qemu errors :

dbdma_unassigned_rw: use of unassigned channel 14
dbdma_unassigned_flush: use of unassigned channel 14
CUDA: unknown command 0x24

and invalids read/write on SPRs but it didn't cause any issue in the guest at installation time or later at runtime. I did not try network though.

So mainline only misses your forth patch. Looking really good !

Thanks,

C.

#6 lore raw
Quoted 43 lines · Cédric Le Goater
Quoted 25 lines · Mark Cave-Ayland
Quoted 8 lines · Cédric Le Goater

Mark,

For OS 9, do you plan to commit these openbios patches soon ?

	https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg02824.html

as we just gave them a good test. Or may be, include them under a github branch to make them easier to find.

All of the OS 9 patches for QEMU and OpenBIOS have been upstreamed, except this one for OpenBIOS:
https://www.coreboot.org/pipermail/openbios/2015-June/008722.html. I currently keep a manually build binary at
https://www.ilande.co.uk/tmp/openbios/openbios-ppc for people who can't build their own.

Quoted 7 lines

Also, I found out that some OS 9 isos are not supported by qemu. These are ok :

	http://www.emaculation.com/forum/viewtopic.php?f=34&t=7047&sid=0ef8922b24a51d2a9d546300aea69c64&start=250

But the one under :

Quoted 8 lines
Quoted 4 lines
	http://c-obrien.org/qemu-os9/testing/

does not boot. It loops on some CUDA commands and then hangs. I did not dig further. Is that a known issue ?

Hmmm if that's the same 9.2.1 image we were using for last year's GSoC then it has been working fine here? From what I've seen both 9.2.1 and 9.2.2 now boot fine, but please test and report if that's not the case.

Hello Mark,

I managed to boot and install a 9.2.1. Here is what I have used for that :

* qemu, David's 2.7 branch, plus Ben's patch "v2 ppc: Fix support for odd MSR combinations".

Quoted 7 lines

* openbios, github's HEAD + the patch your patch from :

	https://www.coreboot.org/pipermail/openbios/2015-June/008722.html

* iso, the os9.osi from

	http://c-obrien.org/qemu-os9/testing/

That is a 9.2.1. Status is the same with a 9.2.2 I found on the net.

Cheers,

C.

Quoted 15 lines

There are a couple of qemu errors :

dbdma_unassigned_rw: use of unassigned channel 14
dbdma_unassigned_flush: use of unassigned channel 14
CUDA: unknown command 0x24

and invalids read/write on SPRs but it didn't cause any issue in the guest at installation time or later at runtime. I did not try network though.

So mainline only misses your forth patch. Looking really good !

Thanks,

C.

#7 lore raw
In reply to Cédric Le Goater
Quoted 22 lines · Cédric Le Goater
Quoted 3 lines

Hmmm if that's the same 9.2.1 image we were using for last year's GSoC then it has been working fine here? From what I've seen both 9.2.1 and 9.2.2 now boot fine, but please test and report if that's not the case.

Hello Mark,

I managed to boot and install a 9.2.1. Here is what I have used for that :

* qemu, David's 2.7 branch, plus Ben's patch "v2 ppc: Fix support for odd MSR combinations".

* openbios, github's HEAD + the patch your patch from :

	https://www.coreboot.org/pipermail/openbios/2015-June/008722.html

* iso, the os9.osi from

	http://c-obrien.org/qemu-os9/testing/

There are a couple of qemu errors :

Quoted 8 lines

dbdma_unassigned_rw: use of unassigned channel 14
dbdma_unassigned_flush: use of unassigned channel 14
CUDA: unknown command 0x24

and invalids read/write on SPRs but it didn't cause any issue in the guest at installation time or later at runtime. I did not try network though.

So mainline only misses your forth patch. Looking really good !

Hi Cédric,

That's exactly what I see here, thanks for testing. For the unassigned channels there is potentially scope for doing something better for ESCC, however the aim for this patchset was to merge the minimal changes required to enable testing.

ATB,

Mark.

#8 lore raw

Hello Mark,

Quoted 31 lines · Mark Cave-Ayland
Quoted 29 lines · Cédric Le Goater
Quoted 3 lines

Hmmm if that's the same 9.2.1 image we were using for last year's GSoC then it has been working fine here? From what I've seen both 9.2.1 and 9.2.2 now boot fine, but please test and report if that's not the case.

Hello Mark,

I managed to boot and install a 9.2.1. Here is what I have used for that :

* qemu, David's 2.7 branch, plus Ben's patch "v2 ppc: Fix support for odd MSR combinations".

* openbios, github's HEAD + the patch your patch from :

	https://www.coreboot.org/pipermail/openbios/2015-June/008722.html

* iso, the os9.osi from

	http://c-obrien.org/qemu-os9/testing/

There are a couple of qemu errors :

dbdma_unassigned_rw: use of unassigned channel 14
dbdma_unassigned_flush: use of unassigned channel 14
CUDA: unknown command 0x24

and invalids read/write on SPRs but it didn't cause any issue in the guest at installation time or later at runtime. I did not try network though.

Quoted 8 lines
Quoted 1 line

So mainline only misses your forth patch. Looking really good !

Hi Cédric,

That's exactly what I see here, thanks for testing. For the unassigned channels there is potentially scope for doing something better for ESCC, however the aim for this patchset was to merge the minimal changes required to enable testing.

So, what are the release plans for OpenBIOS ? It would be good to have the macos9 support available in qemu-2.7.

Thanks,

C.

#9 lore raw
Quoted 7 lines · Cédric Le Goater
Quoted 4 lines

That's exactly what I see here, thanks for testing. For the unassigned channels there is potentially scope for doing something better for ESCC, however the aim for this patchset was to merge the minimal changes required to enable testing.

So, what are the release plans for OpenBIOS ? It would be good to have the macos9 support available in qemu-2.7.

Hopefully the repository migration will be finished over the next couple of days, at which point I'll retest the current github master and if it looks good, send a pull request to update the binaries.

The OS 9 issue is a bit tricky, the OS 9 bootloader is buggy in that it fiddles with the r-stack which means it corrupts its own return address. Hopefully I'll find some time over the next week or so to start looking at this again.

ATB,

Mark.

#10 lore raw
In reply to Mark Cave-Ayland
Quoted 25 lines · Mark Cave-Ayland
Quoted 8 lines · Cédric Le Goater

Mark,

For OS 9, do you plan to commit these openbios patches soon ?

	https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg02824.html

as we just gave them a good test. Or may be, include them under a github branch to make them easier to find.

All of the OS 9 patches for QEMU and OpenBIOS have been upstreamed, except this one for OpenBIOS:
https://www.coreboot.org/pipermail/openbios/2015-June/008722.html. I currently keep a manually build binary at
https://www.ilande.co.uk/tmp/openbios/openbios-ppc for people who can't build their own.

Quoted 7 lines

Also, I found out that some OS 9 isos are not supported by qemu. These are ok :

	http://www.emaculation.com/forum/viewtopic.php?f=34&t=7047&sid=0ef8922b24a51d2a9d546300aea69c64&start=250

But the one under :

Quoted 9 lines
Quoted 4 lines
	http://c-obrien.org/qemu-os9/testing/

does not boot. It loops on some CUDA commands and then hangs. I did not dig further. Is that a known issue ?

Hmmm if that's the same 9.2.1 image we were using for last year's GSoC then it has been working fine here? From what I've seen both 9.2.1 and 9.2.2 now boot fine, but please test and report if that's not the case.

I tried the Mac OS 9.2.1 iso and it does not boot. I used only your patch set.

I would also like to report that I could not make networking work on Mac OS 9.0.4. I tried both the usb-net and rtl8139 nics. This is the command-line I used: -netdev user,id=mynet0 -device usb-net,netdev=mynet0 and -netdev user,id=mynet0 -device rtl8139,netdev=mynet0.

#11 lore raw
Quoted 5 lines · Programmingkid
Quoted 4 lines

Hmmm if that's the same 9.2.1 image we were using for last year's GSoC then it has been working fine here? From what I've seen both 9.2.1 and 9.2.2 now boot fine, but please test and report if that's not the case.

I tried the Mac OS 9.2.1 iso and it does not boot. I used only your patch set.

On top of git master? In that case you still need Ben's patch to fix odd MSR combinations:
http://lists.nongnu.org/archive/html/qemu-devel/2016-07/msg02066.html.

Quoted 1 line

I would also like to report that I could not make networking work on Mac OS 9.0.4. I tried both the usb-net and rtl8139 nics. This is the command-line I used: -netdev user,id=mynet0 -device usb-net,netdev=mynet0 and -netdev user,id=mynet0 -device rtl8139,netdev=mynet0.

This seems to be slightly lacking as a bug report - does the NIC appear in the device tree, which drivers have you used, any relevant logs etc.? Anyhow it's probably worth spinning this out to a separate thread.

ATB,

Mark.

#12 lore raw
Quoted 11 lines · Mark Cave-Ayland
Quoted 5 lines · Programmingkid
Quoted 4 lines

Hmmm if that's the same 9.2.1 image we were using for last year's GSoC then it has been working fine here? From what I've seen both 9.2.1 and 9.2.2 now boot fine, but please test and report if that's not the case.

I tried the Mac OS 9.2.1 iso and it does not boot. I used only your patch set.

On top of git master? In that case you still need Ben's patch to fix odd MSR combinations:
http://lists.nongnu.org/archive/html/qemu-devel/2016-07/msg02066.html.

Thank you for this.

Quoted 6 lines
Quoted 2 lines

I would also like to report that I could not make networking work on Mac OS 9.0.4. I tried both the usb-net and rtl8139 nics. This is the command-line I used: -netdev user,id=mynet0 -device usb-net,netdev=mynet0 and -netdev user,id=mynet0 -device rtl8139,netdev=mynet0.

This seems to be slightly lacking as a bug report - does the NIC appear in the device tree, which drivers have you used, any relevant logs etc.? Anyhow it's probably worth spinning this out to a separate thread.

The USB NIC is not recognized by Mac OS 9.0.4. The RTL8139 is recognized but does not appear to be fully functional. DHCP does not work.

I am pleased to announce that this patch set fixes the problem of Mac OS 9 preventing QEMU from shutting down. Restarting Mac OS 9 does still cause QEMU to display a blank black screen.