Skip to contentSkip to conversation

PreP kernels boot using Qemu

Qemu-devel J. Mayer 5 participants 18 messages Oct 22, 2007 – Oct 31, 2007 Network drivers

lore
Share & tools
lore

J. Mayer

author
#0 lore raw

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.
The issues I found in the kernel are:
- the OpenFirmware video console driver is broken in recent 2.4 kernels and have been removed from recent 2.6 kernel
- I then decided to use the vga16fb console driver but needed to do some patches in order to make it compile properly
- the CMOS RTC driver is not available for PPC architecture in 2.6 kernels and need some patches in order to be usable
- I discovered that the mkprep utility is bugged in 2.4.35 and 2.6.12 kernels. The bugs are visible only when cross-compiling from a little-endian and/or 64 bits host.
- I got issues (ie process freezing) when using the 2.6.22 kernel with HZ > 100. It seems to run properly when the system timer is set to 100 Hz but this needs more tests for confirmation.
- I got the 2.6.22 kernel crashing (ie kernel Oops in workqueue code) when it has no RTC available. There is no problem when the RTC is present. This is likely to be a kernel bug: when no RTC is available, it cannot calibrate its timers properly and the kernel timer seems to run very fast. Forcing (with hacks...) the timer to run at nearly real-time seems to prevent the bug to happen.

I then generated some kernels that allow me to boot and use those 3 kernels.
Here are 3 tarballs with:
- a patch to be applied to the vanilla kernel sources to fix the mentionned bugs
- the .config file I used to build the kernel
- the zImage.prep image
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.4.35-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.12-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.22-prep.tar.bz2>

I then run Qemu with the following command line template:
./ppc-softmmu/qemu-system-ppc -serial stdio -net nic,model=ne2k_isa -net tap -net nic,model=ne2k_pci -net tap -net nic,model=rtl8139 -net tap -cpu 604 -M prep -L pc-bios/ -hda <my_first_disk> -cdrom <my_cdrom> -kernel <src_base>/linux-<kversion>.patched/arch/ppc/boot/images/zImage.prep

Hope this helps.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#1 lore raw
Quoted 43 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.
The issues I found in the kernel are:
- the OpenFirmware video console driver is broken in recent 2.4 kernels and have been removed from recent 2.6 kernel
- I then decided to use the vga16fb console driver but needed to do some patches in order to make it compile properly
- the CMOS RTC driver is not available for PPC architecture in 2.6 kernels and need some patches in order to be usable
- I discovered that the mkprep utility is bugged in 2.4.35 and 2.6.12 kernels. The bugs are visible only when cross-compiling from a little-endian and/or 64 bits host.
- I got issues (ie process freezing) when using the 2.6.22 kernel with HZ > 100. It seems to run properly when the system timer is set to 100 Hz but this needs more tests for confirmation.
- I got the 2.6.22 kernel crashing (ie kernel Oops in workqueue code) when it has no RTC available. There is no problem when the RTC is present. This is likely to be a kernel bug: when no RTC is available, it cannot calibrate its timers properly and the kernel timer seems to run very fast. Forcing (with hacks...) the timer to run at nearly real-time seems to prevent the bug to happen.

I then generated some kernels that allow me to boot and use those 3 kernels.
Here are 3 tarballs with:
- a patch to be applied to the vanilla kernel sources to fix the mentionned bugs
- the .config file I used to build the kernel
- the zImage.prep image
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.4.35-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.12-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.22-prep.tar.bz2>

I then run Qemu with the following command line template:
./ppc-softmmu/qemu-system-ppc -serial stdio -net nic,model=ne2k_isa -net tap -net nic,model=ne2k_pci -net tap -net nic,model=rtl8139 -net tap

(quoted diff) +0 -2
-cpu 604 -M prep -L pc-bios/ -hda <my_first_disk> -cdrom <my_cdrom>
-kernel

<src_base>/linux-<kversion>.patched/arch/ppc/boot/images/zImage.prep

Quoted 1 line

Hope this helps.

Two points I forgot:
- there is no way to make Qemu stop when the PreP kernel displays "Power down" because the prep_halt routine just does an infinite loop.
- the board reset would not work with the current code. I will fix this soon.

Signature · 1 line
Jocelyn Mayer <[email protected]>
#2 lore raw
Quoted 5 lines · Jocelyn Mayer
Quoted 5 lines

I then generated some kernels that allow me to boot and use those 3 kernels.
Here are 3 tarballs with:
- a patch to be applied to the vanilla kernel sources to fix the mentionned bugs

Quoted 8 lines
Quoted 8 lines

- the .config file I used to build the kernel
- the zImage.prep image
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.4.35-prep.ta
r.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.12-prep.ta
r.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.22-prep.ta
r.bz2>

The thing is, that's done with ARCH=ppc and the Linux kernel is migrating to ARCH=powerpc. (This is apparently fallout from merging the 32-bit and 64-bit PowerPC architecture sources.)

ARCH=ppc is deprecated and going away some time next year, they're migrating everything over to the new infrastructure in ARCH=powerpc.

From an immediate practical standpoint, I can't use ARCH=ppc to build a system because that architecture doesn't support the "make headers_install" target so I can extract appropriate architecture-specific Linux kernel headers defining the system calls I can build a C library against.

There's a series of 20+ patches to add proper prep support to arch=powerpc, but when those are applied the result runs on real prep hardware but not under qemu (due to the prep residual data in qemu not matching the Linux kernel's expectations).

Rather than update the residual data qemu is generating so the linux kernel can parse it to add entries to a device tree, Milton just created a "qemu target" with the same set of hardware as a prep system but minus the boot logic. Instead he created a device tree data structure in the format Linux wants it, and a boot room that could feed that device tree to the Linux kernel directly. This was much simpler and mostly involved removing code rather than adding any.

Getting the kernel to build a "qemu target" that runs on prep but doesn't have the prep packaging, boot wrapper, or residual data parsing logic, was 1 patch instead of 20+.

Rob

Signature · 2 lines
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.
#3 lore raw
In reply to J. Mayer
Quoted 43 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.
The issues I found in the kernel are:
- the OpenFirmware video console driver is broken in recent 2.4 kernels and have been removed from recent 2.6 kernel
- I then decided to use the vga16fb console driver but needed to do some patches in order to make it compile properly
- the CMOS RTC driver is not available for PPC architecture in 2.6 kernels and need some patches in order to be usable
- I discovered that the mkprep utility is bugged in 2.4.35 and 2.6.12 kernels. The bugs are visible only when cross-compiling from a little-endian and/or 64 bits host.
- I got issues (ie process freezing) when using the 2.6.22 kernel with HZ > 100. It seems to run properly when the system timer is set to 100 Hz but this needs more tests for confirmation.
- I got the 2.6.22 kernel crashing (ie kernel Oops in workqueue code) when it has no RTC available. There is no problem when the RTC is present. This is likely to be a kernel bug: when no RTC is available, it cannot calibrate its timers properly and the kernel timer seems to run very fast. Forcing (with hacks...) the timer to run at nearly real-time seems to prevent the bug to happen.

I then generated some kernels that allow me to boot and use those 3 kernels.
Here are 3 tarballs with:
- a patch to be applied to the vanilla kernel sources to fix the mentionned bugs
- the .config file I used to build the kernel
- the zImage.prep image
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.4.35-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.12-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.22-prep.tar.bz2>

I then run Qemu with the following command line template:
./ppc-softmmu/qemu-system-ppc -serial stdio -net nic,model=ne2k_isa -net tap -net nic,model=ne2k_pci -net tap -net nic,model=rtl8139 -net tap

(quoted diff) +0 -2
-cpu 604 -M prep -L pc-bios/ -hda <my_first_disk> -cdrom <my_cdrom>
-kernel

<src_base>/linux-<kversion>.patched/arch/ppc/boot/images/zImage.prep

Quoted 2 lines

Hope this helps.

Yes, this help a lot, thanks! With your config file, I have been able to build and boot a 2.6.22 kernel. I have used a Debian sid chroot.

Here are a few remarks:
- The NE2000 card doesn't work for the same reason as with the powerpc architecture. The kernel patch below fixes the problem. I will send it later along with the ppc patch.
- The "floating point" problem I reported during the week-end does not exists, probably because of the switch from powerpc to ppc. I still don't know if it is a kernel problem or a QEMU problem (or both).
- PCI is broken. PCI IDs are reported in the wrong endianness:
00:00.0 Non-VGA unclassified device: Unknown device 0148:5710 (rev 06) 00:01.0 Non-VGA unclassified device: Santa Cruz Operation Unknown device 3412 (rev 03)

Otherwise everything works fine for me, it looks a bit faster than MIPS(el) emulation (which is faster than ARM and SPARC). I still haven't done that much tests though.

arch/ppc/syslib/i8259.c +1 -0
index 1e5a00a..559f27c 100644
@@ -127,6 +127,7 @@ static void i8259_unmask_irq(unsigned int irq_nr)
 static struct irq_chip i8259_pic = {
 	.typename	= " i8259    ",
 	.mask		= i8259_mask_irq,
+	.disable	= i8259_mask_irq,
 	.unmask		= i8259_unmask_irq,
 	.mask_ack	= i8259_mask_and_ack_irq,
 };
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
author
#4 lore raw
Quoted 50 lines · Aurelien Jarno
Quoted 43 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.
The issues I found in the kernel are:
- the OpenFirmware video console driver is broken in recent 2.4 kernels and have been removed from recent 2.6 kernel
- I then decided to use the vga16fb console driver but needed to do some patches in order to make it compile properly
- the CMOS RTC driver is not available for PPC architecture in 2.6 kernels and need some patches in order to be usable
- I discovered that the mkprep utility is bugged in 2.4.35 and 2.6.12 kernels. The bugs are visible only when cross-compiling from a little-endian and/or 64 bits host.
- I got issues (ie process freezing) when using the 2.6.22 kernel with HZ > 100. It seems to run properly when the system timer is set to 100 Hz but this needs more tests for confirmation.
- I got the 2.6.22 kernel crashing (ie kernel Oops in workqueue code) when it has no RTC available. There is no problem when the RTC is present. This is likely to be a kernel bug: when no RTC is available, it cannot calibrate its timers properly and the kernel timer seems to run very fast. Forcing (with hacks...) the timer to run at nearly real-time seems to prevent the bug to happen.

I then generated some kernels that allow me to boot and use those 3 kernels.
Here are 3 tarballs with:
- a patch to be applied to the vanilla kernel sources to fix the mentionned bugs
- the .config file I used to build the kernel
- the zImage.prep image
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.4.35-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.12-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.22-prep.tar.bz2>

I then run Qemu with the following command line template:
./ppc-softmmu/qemu-system-ppc -serial stdio -net nic,model=ne2k_isa -net tap -net nic,model=ne2k_pci -net tap -net nic,model=rtl8139 -net tap

(quoted diff) +0 -2
-cpu 604 -M prep -L pc-bios/ -hda <my_first_disk> -cdrom <my_cdrom>
-kernel

<src_base>/linux-<kversion>.patched/arch/ppc/boot/images/zImage.prep

Quoted 2 lines

Hope this helps.

Yes, this help a lot, thanks! With your config file, I have been able to build and boot a 2.6.22 kernel. I have used a Debian sid chroot.

Quoted 4 lines

Here are a few remarks:
- The NE2000 card doesn't work for the same reason as with the powerpc architecture. The kernel patch below fixes the problem. I will send it later along with the ppc patch.

There's something else strange with the PCI ethernet devices: they got no IRQ assigned (as if the BIOS does not configure them properly). And the RTL8139 never has a mac address, never detects the PHY link, then there may be endianness issues in the emulation (I did not check at all).

Quoted 3 lines

- The "floating point" problem I reported during the week-end does not exists, probably because of the switch from powerpc to ppc. I still don't know if it is a kernel problem or a QEMU problem (or both).

There may be issues with the floating point emulation, especially if some kernel or programs relies on the FPSCR (floating-point status) register which is never updated in Qemu.

Quoted 3 lines

- PCI is broken. PCI IDs are reported in the wrong endianness:
00:00.0 Non-VGA unclassified device: Unknown device 0148:5710 (rev 06) 00:01.0 Non-VGA unclassified device: Santa Cruz Operation Unknown device 3412 (rev 03)

This does not happen with 2.4 kernels. Using the 2.4.35 image, all PCI descriptors are OK and the drivers properly recognize the devices. What I suspect is that 2.6 kernels tweak the chipset to make it handle the endian-reverse accesses.

[...]

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#5 lore raw
Quoted 61 lines · J. Mayer
Quoted 49 lines · Aurelien Jarno
Quoted 43 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.
The issues I found in the kernel are:
- the OpenFirmware video console driver is broken in recent 2.4 kernels and have been removed from recent 2.6 kernel
- I then decided to use the vga16fb console driver but needed to do some patches in order to make it compile properly
- the CMOS RTC driver is not available for PPC architecture in 2.6 kernels and need some patches in order to be usable
- I discovered that the mkprep utility is bugged in 2.4.35 and 2.6.12 kernels. The bugs are visible only when cross-compiling from a little-endian and/or 64 bits host.
- I got issues (ie process freezing) when using the 2.6.22 kernel with HZ > 100. It seems to run properly when the system timer is set to 100 Hz but this needs more tests for confirmation.
- I got the 2.6.22 kernel crashing (ie kernel Oops in workqueue code) when it has no RTC available. There is no problem when the RTC is present. This is likely to be a kernel bug: when no RTC is available, it cannot calibrate its timers properly and the kernel timer seems to run very fast. Forcing (with hacks...) the timer to run at nearly real-time seems to prevent the bug to happen.

I then generated some kernels that allow me to boot and use those 3 kernels.
Here are 3 tarballs with:
- a patch to be applied to the vanilla kernel sources to fix the mentionned bugs
- the .config file I used to build the kernel
- the zImage.prep image
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.4.35-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.12-prep.tar.bz2>
<http://perso.magic.fr/l_indien/qemu-ppc/linux-tests/linux-2.6.22-prep.tar.bz2>

I then run Qemu with the following command line template:
./ppc-softmmu/qemu-system-ppc -serial stdio -net nic,model=ne2k_isa -net tap -net nic,model=ne2k_pci -net tap -net nic,model=rtl8139 -net tap

(quoted diff) +0 -2
-cpu 604 -M prep -L pc-bios/ -hda <my_first_disk> -cdrom <my_cdrom>
-kernel

<src_base>/linux-<kversion>.patched/arch/ppc/boot/images/zImage.prep

Quoted 2 lines

Hope this helps.

Yes, this help a lot, thanks! With your config file, I have been able to build and boot a 2.6.22 kernel. I have used a Debian sid chroot.

Quoted 4 lines

Here are a few remarks:
- The NE2000 card doesn't work for the same reason as with the powerpc architecture. The kernel patch below fixes the problem. I will send it later along with the ppc patch.

There's something else strange with the PCI ethernet devices: they got no IRQ assigned (as if the BIOS does not configure them properly). And the RTL8139 never has a mac address, never detects the PHY link, then there may be endianness issues in the emulation (I did not check at all).

Quoted 8 lines
Quoted 3 lines

- The "floating point" problem I reported during the week-end does not exists, probably because of the switch from powerpc to ppc. I still don't know if it is a kernel problem or a QEMU problem (or both).

There may be issues with the floating point emulation, especially if some kernel or programs relies on the FPSCR (floating-point status) register which is never updated in Qemu.

Is there any technical reason behind that, or is it just a lack of time?

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
author
#6 lore raw
Quoted 8 lines · Aurelien Jarno
Quoted 7 lines · J. Mayer
Quoted 6 lines · Aurelien Jarno
Quoted 5 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.

[...]

Quoted 6 lines
Quoted 1 line
Quoted 1 line

- The "floating point" problem I reported during the week-end does

not

Quoted 1 line
Quoted 1 line

exists, probably because of the switch from powerpc to ppc. I

still

Quoted 2 lines
Quoted 1 line

don't know if it is a kernel problem or a QEMU problem (or both).

Quoted 7 lines
Quoted 4 lines

There may be issues with the floating point emulation, especially if some kernel or programs relies on the FPSCR (floating-point status) register which is never updated in Qemu.

Is there any technical reason behind that, or is it just a lack of time?

I can say both:
for most program, using floating point arithmetic ala "fast-math", it's not necessary to maintain a precise FPU state, as those program will never raise any FPU exception, never generate NaNs, infinites, ... The other reason is that it would need to check every FPU insn arguments and results at run time and treat all special cases following the actual PowerPC implementations behavior if we want to get a precise emulation. This behavior could be for example selected at compile time: then one would have the choice to have a quick FPU emulation model or a precise one.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#7 lore raw
Quoted 25 lines · J. Mayer
Quoted 8 lines · Aurelien Jarno
Quoted 7 lines · J. Mayer
Quoted 6 lines · Aurelien Jarno
Quoted 5 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.

[...]

Quoted 6 lines
Quoted 1 line
Quoted 1 line

- The "floating point" problem I reported during the week-end does

not

Quoted 1 line
Quoted 1 line

exists, probably because of the switch from powerpc to ppc. I

still

Quoted 2 lines
Quoted 1 line

don't know if it is a kernel problem or a QEMU problem (or both).

Quoted 7 lines
Quoted 4 lines

There may be issues with the floating point emulation, especially if some kernel or programs relies on the FPSCR (floating-point status) register which is never updated in Qemu.

Is there any technical reason behind that, or is it just a lack of time?

Quoted 10 lines

I can say both:
for most program, using floating point arithmetic ala "fast-math", it's not necessary to maintain a precise FPU state, as those program will never raise any FPU exception, never generate NaNs, infinites, ... The other reason is that it would need to check every FPU insn arguments and results at run time and treat all special cases following the actual PowerPC implementations behavior if we want to get a precise emulation. This behavior could be for example selected at compile time: then one would have the choice to have a quick FPU emulation model or a precise one.

For mips I chose the middle ground: The emulation is architecturally correct but may not reflect FPU behaviour of the specific silicon. E.g. one effect is that in certain cases the emulation computes values close to underflow, while real hardware would throw the (mips FPU specific) unimplemented exception.

For most cases this should be good enough, since only specialized software will rely on a specific implementation's oddities.

Thiemo

author
#8 lore raw
Quoted 37 lines · Thiemo Seufer
Quoted 25 lines · J. Mayer
Quoted 8 lines · Aurelien Jarno
Quoted 7 lines · J. Mayer
Quoted 6 lines · Aurelien Jarno
Quoted 5 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.

[...]

Quoted 6 lines
Quoted 1 line
Quoted 1 line

- The "floating point" problem I reported during the week-end does

not

Quoted 1 line
Quoted 1 line

exists, probably because of the switch from powerpc to ppc. I

still

Quoted 2 lines
Quoted 1 line

don't know if it is a kernel problem or a QEMU problem (or both).

Quoted 7 lines
Quoted 4 lines

There may be issues with the floating point emulation, especially if some kernel or programs relies on the FPSCR (floating-point status) register which is never updated in Qemu.

Is there any technical reason behind that, or is it just a lack of time?

Quoted 10 lines

I can say both:
for most program, using floating point arithmetic ala "fast-math", it's not necessary to maintain a precise FPU state, as those program will never raise any FPU exception, never generate NaNs, infinites, ... The other reason is that it would need to check every FPU insn arguments and results at run time and treat all special cases following the actual PowerPC implementations behavior if we want to get a precise emulation. This behavior could be for example selected at compile time: then one would have the choice to have a quick FPU emulation model or a precise one.

Quoted 8 lines

For mips I chose the middle ground: The emulation is architecturally correct but may not reflect FPU behaviour of the specific silicon. E.g. one effect is that in certain cases the emulation computes values close to underflow, while real hardware would throw the (mips FPU specific) unimplemented exception.

For most cases this should be good enough, since only specialized software will rely on a specific implementation's oddities.

Well, what you've done for Mips is exactly what I called the "precise emulation" and is far slower than the "fast math" emulation I got for PowerPC. I was wrong talking about "PowerPC implementations" when I should have said "PowerPC specification"; but there should be no difference between the two (or it's not a PowerPC CPU...) because the POWER/PowerPC specification describes very precisely the behavior of the FPU.
The "fast math" model relies on the native-softmmu code and is suficient for most applications. But there are a few instructions that should always take care (or maybe at least reset) the FPSCR register, which is not done in the current code.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#9 lore raw
Quoted 42 lines · J. Mayer
Quoted 32 lines · Thiemo Seufer
Quoted 21 lines · J. Mayer
Quoted 8 lines · Aurelien Jarno
Quoted 7 lines · J. Mayer
Quoted 6 lines · Aurelien Jarno
Quoted 5 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.

[...]

Quoted 11 lines
Quoted 1 line
Quoted 1 line

- The "floating point" problem I reported during the week-end does

not

Quoted 1 line
Quoted 1 line

exists, probably because of the switch from powerpc to ppc. I

still

Quoted 5 lines
Quoted 1 line

don't know if it is a kernel problem or a QEMU problem (or both).

There may be issues with the floating point emulation, especially if some kernel or programs relies on the FPSCR (floating-point status) register which is never updated in Qemu.

Is there any technical reason behind that, or is it just a lack of time?

Quoted 10 lines

I can say both:
for most program, using floating point arithmetic ala "fast-math", it's not necessary to maintain a precise FPU state, as those program will never raise any FPU exception, never generate NaNs, infinites, ... The other reason is that it would need to check every FPU insn arguments and results at run time and treat all special cases following the actual PowerPC implementations behavior if we want to get a precise emulation. This behavior could be for example selected at compile time: then one would have the choice to have a quick FPU emulation model or a precise one.

Quoted 8 lines

For mips I chose the middle ground: The emulation is architecturally correct but may not reflect FPU behaviour of the specific silicon. E.g. one effect is that in certain cases the emulation computes values close to underflow, while real hardware would throw the (mips FPU specific) unimplemented exception.

For most cases this should be good enough, since only specialized software will rely on a specific implementation's oddities.

Quoted 12 lines

Well, what you've done for Mips is exactly what I called the "precise emulation" and is far slower than the "fast math" emulation I got for PowerPC. I was wrong talking about "PowerPC implementations" when I should have said "PowerPC specification"; but there should be no difference between the two (or it's not a PowerPC CPU...) because the POWER/PowerPC specification describes very precisely the behavior of the FPU.
The "fast math" model relies on the native-softmmu code and is suficient for most applications. But there are a few instructions that should always take care (or maybe at least reset) the FPSCR register, which is not done in the current code.

Then I guess it is what has been done on the SPARC target: after each FP instruction, check_ieee_exceptions() is called to accumulate the IEEE exceptions and generate real exceptions if they are enabled.

That doesn't look really complex, but I agree that could slow down a bit the emulation. I will get a closer look in two or three weeks.

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
author
#10 lore raw
Quoted 56 lines · Aurelien Jarno
Quoted 42 lines · J. Mayer
Quoted 32 lines · Thiemo Seufer
Quoted 21 lines · J. Mayer
Quoted 8 lines · Aurelien Jarno
Quoted 7 lines · J. Mayer
Quoted 6 lines · Aurelien Jarno
Quoted 5 lines · J. Mayer

Hi all,

I've been investigating more about PreP kernel boot using Qemu and I achieved to boot 2.4.35, 2.6.12 and 2.6.22 kernels using Qemu CVS and unmodified OHW.

[...]

Quoted 11 lines
Quoted 1 line
Quoted 1 line

- The "floating point" problem I reported during the week-end does

not

Quoted 1 line
Quoted 1 line

exists, probably because of the switch from powerpc to ppc. I

still

Quoted 5 lines
Quoted 1 line

don't know if it is a kernel problem or a QEMU problem (or both).

There may be issues with the floating point emulation, especially if some kernel or programs relies on the FPSCR (floating-point status) register which is never updated in Qemu.

Is there any technical reason behind that, or is it just a lack of time?

Quoted 10 lines

I can say both:
for most program, using floating point arithmetic ala "fast-math", it's not necessary to maintain a precise FPU state, as those program will never raise any FPU exception, never generate NaNs, infinites, ... The other reason is that it would need to check every FPU insn arguments and results at run time and treat all special cases following the actual PowerPC implementations behavior if we want to get a precise emulation. This behavior could be for example selected at compile time: then one would have the choice to have a quick FPU emulation model or a precise one.

Quoted 8 lines

For mips I chose the middle ground: The emulation is architecturally correct but may not reflect FPU behaviour of the specific silicon. E.g. one effect is that in certain cases the emulation computes values close to underflow, while real hardware would throw the (mips FPU specific) unimplemented exception.

For most cases this should be good enough, since only specialized software will rely on a specific implementation's oddities.

Quoted 12 lines

Well, what you've done for Mips is exactly what I called the "precise emulation" and is far slower than the "fast math" emulation I got for PowerPC. I was wrong talking about "PowerPC implementations" when I should have said "PowerPC specification"; but there should be no difference between the two (or it's not a PowerPC CPU...) because the POWER/PowerPC specification describes very precisely the behavior of the FPU.
The "fast math" model relies on the native-softmmu code and is suficient for most applications. But there are a few instructions that should always take care (or maybe at least reset) the FPSCR register, which is not done in the current code.

Quoted 6 lines

Then I guess it is what has been done on the SPARC target: after each FP instruction, check_ieee_exceptions() is called to accumulate the IEEE exceptions and generate real exceptions if they are enabled.

That doesn't look really complex, but I agree that could slow down a bit the emulation. I will get a closer look in two or three weeks.

It's not so complex. What would greatly slow down the emulation is that you need to use the softfloat model instead of the softfloat-native one for this to produce the expected result.
The PowerPC "fadd" instruction just compiles with 3 insns on amd64, using the "fast math" model:
movlpd 0x1b8(%r14),%xmm0 ; /* Load env->ft0 into a MMX register */ addsd 0x1b0(%r14),%xmm0 ; /* Add env->ft1 */
movsd %xmm0,0x1b0(%r14) ; /* Store the result into env->ft0 */ With the "precise" model, you need to:
1/ Clear the floating point flags
2/ Load operands from env->ft0 & env->ft1 into host registers 3/ Call the float64_add function
4/ Store the result into env->ft0
5/ Compute the architecture specific FPU flags
which will lead to execute much more code for each FPU operation and will consume much more space in the TB buffer.

It's a good idea to allow the use of such a precise model, when you want to use specific applications that rely on the FPU to properly handle NaNs, infinities and properly generate exceptions. But, as it's not needed by most applications, having a "fast math" model is also great to have a quicker emulation. I said it would be great to allow the choice of the model at compile time but it could in fact be choosen at run-time, just tweaking the code translator (which should not lead to any performance penalty for the "fast" model case) and compiling twice the FPU micro-operations, once with the CONFIG_SOFTFLOAT defined, once without. This way, the Qemu user could easily choose between "fast" or "precise" models, just changing a switch on the command line.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#11 lore raw
In reply to J. Mayer

J. Mayer wrote:
[snip]

Quoted 28 lines
Quoted 11 lines
Quoted 10 lines

I can say both:
for most program, using floating point arithmetic ala "fast-math", it's not necessary to maintain a precise FPU state, as those program will never raise any FPU exception, never generate NaNs, infinites, ... The other reason is that it would need to check every FPU insn arguments and results at run time and treat all special cases following the actual PowerPC implementations behavior if we want to get a precise emulation. This behavior could be for example selected at compile time: then one would have the choice to have a quick FPU emulation model or a precise one.

Quoted 8 lines

For mips I chose the middle ground: The emulation is architecturally correct but may not reflect FPU behaviour of the specific silicon. E.g. one effect is that in certain cases the emulation computes values close to underflow, while real hardware would throw the (mips FPU specific) unimplemented exception.

For most cases this should be good enough, since only specialized software will rely on a specific implementation's oddities.

Well, what you've done for Mips is exactly what I called the "precise emulation" and is far slower than the "fast math" emulation I got for PowerPC. I was wrong talking about "PowerPC implementations" when I should have said "PowerPC specification"; but there should be no difference between the two (or it's not a PowerPC CPU...) because the POWER/PowerPC specification describes very precisely the behavior of the FPU.

Quoted 4 lines

The "fast math" model relies on the native-softmmu code and is suficient for most applications. But there are a few instructions that should always take care (or maybe at least reset) the FPSCR register, which is not done in the current code.

My theory is that occasional FP users won't suffer from the performance impact, and heavy FP users are likely to expect IEEE conformance. Thus I gave priority to correctness.

Implementing a R8000-style fast FP mode sounds like fun, but for the moment I have already enough unfinished bits and pieces in Qemu. :-)

Thiemo

#12 lore raw
In reply to Aurelien Jarno
Quoted 7 lines · Aurelien Jarno
arch/ppc/syslib/i8259.c +0 -0
index 1e5a00a..559f27c 100644

arch/ppc/syslib/i8259.c static void i8259_unmask_irq(unsigned int irq_nr) · line 133

Quoted 7 lines
arch/ppc/syslib/i8259.c +1 -0
@@ -127,6 +127,7 @@ static void i8259_unmask_irq(unsigned int irq_nr)
 static struct irq_chip i8259_pic = {
 	.typename	= " i8259    ",
 	.mask		= i8259_mask_irq,
+	.disable	= i8259_mask_irq,
 	.unmask		= i8259_unmask_irq,
 	.mask_ack	= i8259_mask_and_ack_irq,
 };

Using mdm's qemu target platform and the 4k bios that supplies a device tree, I applied this but it didn't make any difference in the ne2k-pci adapter (not that I noticed). It still doesn't bind to anything during bootup. (There's no eth0.)

I also tried enabling the 8139too driver and telling qemu "-net nic,model=rtl8139 -net user" (which made arm work), and it goes:

Quoted 6 lines

PCI: Probing PCI hardware
Memory resource not set for host bridge 0
PCI: Cannot allocate resource region 2 of PCI bridge 0
PCI: can't move host bridge resource
PCI: Cannot allocate resource region 0 of device 0000:00:0d.0
PCI: Cannot allocate resource region 1 of device 0000:00:0d.0

...

Quoted 4 lines

8139too Fast Ethernet driver 0.9.28
8139too 0000:00:0d.0: This (id 10ec:8139 rev 20) is an enhanced 8139C+ chip 8139too 0000:00:0d.0: Use the "8139cp" driver for improved performance and stability.

And then there's an eth0, but it doesn't work. I can assign an address to it but no matter what I try, no packets are sent and received (the packet transmit/receive/error counts never even go up, they stay at zero).

Am I doing something wrong?

Rob

Signature · 2 lines
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.
#13 lore raw
Quoted 12 lines · Rob Landley
Quoted 11 lines · Aurelien Jarno
arch/ppc/syslib/i8259.c +1 -0
index 1e5a00a..559f27c 100644
@@ -127,6 +127,7 @@ static void i8259_unmask_irq(unsigned int irq_nr)
 static struct irq_chip i8259_pic = {
 	.typename	= " i8259    ",
 	.mask		= i8259_mask_irq,
+	.disable	= i8259_mask_irq,
Quoted 8 lines

arch/ppc/syslib/i8259.c static void i8259_unmask_irq(unsigned int irq_nr) · line 133

Quoted 3 lines
arch/ppc/syslib/i8259.c +0 -0
 	.unmask		= i8259_unmask_irq,
 	.mask_ack	= i8259_mask_and_ack_irq,
 };

Using mdm's qemu target platform and the 4k bios that supplies a device tree, I applied this but it didn't make any difference in the ne2k-pci adapter (not that I noticed). It still doesn't bind to anything during bootup. (There's no eth0.)

You need this patch to get the *ISA* NE2000 card working, the PCI one still doesn't work.

Quoted 10 lines

I also tried enabling the 8139too driver and telling qemu "-net nic,model=rtl8139 -net user" (which made arm work), and it goes:

Quoted 6 lines

PCI: Probing PCI hardware
Memory resource not set for host bridge 0
PCI: Cannot allocate resource region 2 of PCI bridge 0
PCI: can't move host bridge resource
PCI: Cannot allocate resource region 0 of device 0000:00:0d.0
PCI: Cannot allocate resource region 1 of device 0000:00:0d.0

...

Quoted 9 lines
Quoted 4 lines

8139too Fast Ethernet driver 0.9.28
8139too 0000:00:0d.0: This (id 10ec:8139 rev 20) is an enhanced 8139C+ chip 8139too 0000:00:0d.0: Use the "8139cp" driver for improved performance and stability.

And then there's an eth0, but it doesn't work. I can assign an address to it but no matter what I try, no packets are sent and received (the packet transmit/receive/error counts never even go up, they stay at zero).

The PCI emulation is broken for this target, it has to be fixed first.

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
#14 lore raw
Quoted 22 lines · Aurelien Jarno
Quoted 12 lines · Rob Landley
Quoted 11 lines · Aurelien Jarno
arch/ppc/syslib/i8259.c +1 -0
index 1e5a00a..559f27c 100644
@@ -127,6 +127,7 @@ static void i8259_unmask_irq(unsigned int irq_nr)
 static struct irq_chip i8259_pic = {
 	.typename	= " i8259    ",
 	.mask		= i8259_mask_irq,
+	.disable	= i8259_mask_irq,
Quoted 8 lines

arch/ppc/syslib/i8259.c static void i8259_unmask_irq(unsigned int irq_nr) · line 133

Quoted 3 lines
arch/ppc/syslib/i8259.c +0 -0
 	.unmask		= i8259_unmask_irq,
 	.mask_ack	= i8259_mask_and_ack_irq,
 };

Using mdm's qemu target platform and the 4k bios that supplies a device tree, I applied this but it didn't make any difference in the ne2k-pci adapter (not that I noticed). It still doesn't bind to anything during bootup. (There's no eth0.)

Quoted 2 lines

You need this patch to get the *ISA* NE2000 card working, the PCI one still doesn't work.

Hmmm, Milton's ppc_qemu patch forgot to add PPC_QEMU to the ISA dependency list along with PREP and CHRP. Let's see, patch that, switch on the config symbol, build in that driver and... Nope:

Quoted 3 lines

ne.c:v1.10 9/23/94 Donald Becker ([email protected]) Last modified Nov 1, 2000 by Paul Gortmaker
NE*000 ethercard probe at 0x300: failed to detect IRQ line.

I still have no eth0.

I just confirmed that arch/powerpc/sysdev/i8259.c has:

static struct irq_chip i8259_pic = {
        .typename       = " i8259    ",
        .mask           = i8259_mask_irq,
        .disable        = i8259_mask_irq,
        .unmask         = i8259_unmask_irq,
        .mask_ack       = i8259_mask_and_ack_irq,
};

Since your patch was to /arch/ppc instead...

Any ideas?

Rob

Signature · 2 lines
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.
#15 lore raw
Quoted 28 lines · Rob Landley
Quoted 20 lines · Aurelien Jarno
Quoted 19 lines · Rob Landley
Quoted 7 lines · Aurelien Jarno
arch/ppc/syslib/i8259.c +0 -0
index 1e5a00a..559f27c 100644

arch/ppc/syslib/i8259.c static void i8259_unmask_irq(unsigned int irq_nr) · line 133

Quoted 7 lines
arch/ppc/syslib/i8259.c +1 -0
@@ -127,6 +127,7 @@ static void i8259_unmask_irq(unsigned int irq_nr)
 static struct irq_chip i8259_pic = {
 	.typename	= " i8259    ",
 	.mask		= i8259_mask_irq,
+	.disable	= i8259_mask_irq,
 	.unmask		= i8259_unmask_irq,
 	.mask_ack	= i8259_mask_and_ack_irq,
 };

Using mdm's qemu target platform and the 4k bios that supplies a device tree, I applied this but it didn't make any difference in the ne2k-pci adapter (not that I noticed). It still doesn't bind to anything during bootup. (There's no eth0.)

Quoted 2 lines

You need this patch to get the *ISA* NE2000 card working, the PCI one still doesn't work.

Hmmm, Milton's ppc_qemu patch forgot to add PPC_QEMU to the ISA dependency list along with PREP and CHRP. Let's see, patch that, switch on the config symbol, build in that driver and... Nope:

Quoted 5 lines
Quoted 3 lines

ne.c:v1.10 9/23/94 Donald Becker ([email protected]) Last modified Nov 1, 2000 by Paul Gortmaker
NE*000 ethercard probe at 0x300: failed to detect IRQ line.

I still have no eth0.

You have to build the NE2000 driver as a module, and pass irq=9 io=0x300 when loading it.

Quoted 11 lines

I just confirmed that arch/powerpc/sysdev/i8259.c has:

static struct irq_chip i8259_pic = {
        .typename       = " i8259    ",
        .mask           = i8259_mask_irq,
        .disable        = i8259_mask_irq,
        .unmask         = i8259_unmask_irq,
        .mask_ack       = i8259_mask_and_ack_irq,
};

Since your patch was to /arch/ppc instead...

I have posted two patches, one for ppc and one for powerpc. I have send both of them upstream

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
#16 lore raw
Quoted 32 lines · Aurelien Jarno
Quoted 31 lines · Rob Landley
Quoted 22 lines · Aurelien Jarno
Quoted 12 lines · Rob Landley
Quoted 11 lines · Aurelien Jarno
arch/ppc/syslib/i8259.c +1 -0
index 1e5a00a..559f27c 100644
@@ -127,6 +127,7 @@ static void i8259_unmask_irq(unsigned int irq_nr)
 static struct irq_chip i8259_pic = {
 	.typename	= " i8259    ",
 	.mask		= i8259_mask_irq,
+	.disable	= i8259_mask_irq,
Quoted 8 lines

arch/ppc/syslib/i8259.c static void i8259_unmask_irq(unsigned int irq_nr) · line 133

Quoted 3 lines
arch/ppc/syslib/i8259.c +0 -0
 	.unmask		= i8259_unmask_irq,
 	.mask_ack	= i8259_mask_and_ack_irq,
 };

Using mdm's qemu target platform and the 4k bios that supplies a device tree, I applied this but it didn't make any difference in the ne2k-pci adapter (not that I noticed). It still doesn't bind to anything during bootup. (There's no eth0.)

Quoted 2 lines

You need this patch to get the *ISA* NE2000 card working, the PCI one still doesn't work.

Hmmm, Milton's ppc_qemu patch forgot to add PPC_QEMU to the ISA dependency list along with PREP and CHRP. Let's see, patch that, switch on the config

symbol, build in that driver and... Nope:

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

ne.c:v1.10 9/23/94 Donald Becker ([email protected]) Last modified Nov 1, 2000 by Paul Gortmaker
NE*000 ethercard probe at 0x300: failed to detect IRQ line.

I still have no eth0.

You have to build the NE2000 driver as a module, and pass irq=9 io=0x300 when loading it.

Hmmm... All the kernels I've built for this project are static. In theory I can add "ne.irq=9" to the kernel command line, but in practice it doesn't seem to work. Nor does ne.0.irq=9 or irq=9

However, when I hardwire "dev->irq=9;" into the source code, it does seem to work. (Or at least I can ping qemu's virtual gateway.)

Off to read the kernel command line parsing logic...

Thanks,

Rob

Signature · 2 lines
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.
#17 lore raw
Quoted 8 lines · Rob Landley

Hmmm... All the kernels I've built for this project are static. In theory I can add "ne.irq=9" to the kernel command line, but in practice it doesn't seem to work. Nor does ne.0.irq=9 or irq=9

However, when I hardwire "dev->irq=9;" into the source code, it does seem to work. (Or at least I can ping qemu's virtual gateway.)

Off to read the kernel command line parsing logic...

It seems that the driver.parameter syntax works only for parameters that the driver exports in /sys/module/driver/parameters. The ne driver doesn't define parameters at all when not compiled as a module, let alone export them via sysfs.

The attached patch is my feeble attempt to remedy the situation. With the patch, adding "ne.irq=9,10" to the kernel command line sets the correct irqs for eth0 and eth1.

--Ed

drivers/net/Space.c +0 -4
Index: linux-2.6.23.1/drivers/net/Space.c
===================================================================
@@ -181,10 +181,6 @@ static struct devprobe2 isa_probes[] __i
 #ifdef CONFIG_E2100		/* Cabletron E21xx series. */
 	{e2100_probe, 0},
 #endif
-#if defined(CONFIG_NE2000) || \
-    defined(CONFIG_NE_H8300)  /* ISA (use ne2k-pci for PCI cards) */
-	{ne_probe, 0},
-#endif
 #ifdef CONFIG_LANCE		/* ISA/VLB (use pcnet32 for PCI cards) */
 	{lance_probe, 0},
 #endif
drivers/net/ne.c +6 -8
Index: linux-2.6.23.1/drivers/net/ne.c
===================================================================
@@ -888,16 +888,15 @@ static void __exit ne_exit(void)
 	platform_driver_unregister(&ne_driver);
 }
 
-#ifdef MODULE
 #define MAX_NE_CARDS	4	/* Max number of NE cards per module */
 static struct net_device *dev_ne[MAX_NE_CARDS];
 static int io[MAX_NE_CARDS];
 static int irq[MAX_NE_CARDS];
 static int bad[MAX_NE_CARDS];	/* 0xbad = bad sig or no reset ack */
 
-module_param_array(io, int, NULL, 0);
-module_param_array(irq, int, NULL, 0);
-module_param_array(bad, int, NULL, 0);
+module_param_array(io, int, NULL, 0644);
+module_param_array(irq, int, NULL, 0644);
+module_param_array(bad, int, NULL, 0644);
 MODULE_PARM_DESC(io, "I/O base address(es),required");
 MODULE_PARM_DESC(irq, "IRQ number(s)");
 MODULE_PARM_DESC(bad, "Accept card(s) with bad signatures");
@@ -962,7 +961,6 @@ void __exit cleanup_module(void)
 		}
 	}
 }
-#else /* MODULE */
-module_init(ne_init);
-module_exit(ne_exit);
-#endif /* MODULE */
+
+module_init(init_module);
+module_exit(cleanup_module);