Fix extlh instruction on Alpha
PATCH 1/1 Fix extlh instruction on Alpha
The extlh instruction on Alpha currently doesn't work properly. It's a combination of a cut/paste bug (16 where it should be 32) as well as a "shift by 64" bug.
This improves on an earlier patch that used labels, conditional jumps, and local variables. Thanks go especially to Aurelien Jarno and Andreas Schwab who have a much better eye for bit-wise TCG optimization than I do.
Vince
target-alpha/translate.c +6 -5
@@ -524,14 +524,15 @@ static inline void gen_ext_h(void(*tcg_gen_ext_i64)(TCGv t0, TCGv t1),else tcg_gen_mov_i64 (cpu_ir[rc], cpu_ir[ra]); }else { -TCGv tmp1, tmp2; +TCGv tmp1; tmp1 =tcg_temp_new (); +tcg_gen_andi_i64 (tmp1, cpu_ir[rb],7 );tcg_gen_shli_i64 (tmp1, tmp1,3 ); - tmp2 =tcg_const_i64 (64 ); -tcg_gen_sub_i64 (tmp1, tmp2, tmp1); -tcg_temp_free (tmp2); +tcg_gen_neg_i64 (tmp1, tmp1); +tcg_gen_andi_i64 (tmp1, tmp1,0x3f );tcg_gen_shl_i64 (cpu_ir[rc], cpu_ir[ra], tmp1); +tcg_temp_free (tmp1); }if (tcg_gen_ext_i64)
@@ -1316,7 +1317,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x6A :/* EXTLH */ -gen_ext_h (&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit); +gen_ext_h (&tcg_gen_ext32u_i64, ra, rb, rc, islit, lit);break ;case 0x72 :/* MSKQH */
Aurelien Jarno
AppliedQuoted 5 lines · Vince Weaver
The extlh instruction on Alpha currently doesn't work properly. It's a combination of a cut/paste bug (16 where it should be 32) as well as a "shift by 64" bug.
Quoted 7 lines
This improves on an earlier patch that used labels, conditional jumps, and local variables. Thanks go especially to Aurelien Jarno and Andreas Schwab who have a much better eye for bit-wise TCG optimization than I do.
Vince
Signed-off-by Vince Weaver <[email protected]>
Thanks, applied to both master and stable-0.11.
Quoted 36 lines
target-alpha/translate.c +6
-5@@ -524,14 +524,15 @@ static inline void gen_ext_h(void(*tcg_gen_ext_i64)(TCGv t0, TCGv t1),else tcg_gen_mov_i64 (cpu_ir[rc], cpu_ir[ra]); }else { -TCGv tmp1, tmp2; +TCGv tmp1; tmp1 =tcg_temp_new (); +tcg_gen_andi_i64 (tmp1, cpu_ir[rb],7 );tcg_gen_shli_i64 (tmp1, tmp1,3 ); - tmp2 =tcg_const_i64 (64 ); -tcg_gen_sub_i64 (tmp1, tmp2, tmp1); -tcg_temp_free (tmp2); +tcg_gen_neg_i64 (tmp1, tmp1); +tcg_gen_andi_i64 (tmp1, tmp1,0x3f );tcg_gen_shl_i64 (cpu_ir[rc], cpu_ir[ra], tmp1); +tcg_temp_free (tmp1); }if (tcg_gen_ext_i64)@@ -1316,7 +1317,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x6A :/* EXTLH */ -gen_ext_h (&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit); +gen_ext_h (&tcg_gen_ext32u_i64, ra, rb, rc, islit, lit);break ;case 0x72 :/* MSKQH */
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 9 lines · On Thursday 17 September 2009 14:28:52 Vince Weaver wrote:
The extlh instruction on Alpha currently doesn't work properly. It's a combination of a cut/paste bug (16 where it should be 32) as well as a "shift by 64" bug.
This improves on an earlier patch that used labels, conditional jumps, and local variables. Thanks go especially to Aurelien Jarno and Andreas Schwab who have a much better eye for bit-wise TCG optimization than I do.
Vince
Any idea how hard it would be to whip up a qemu-system-alpha emulation? I note that several real-world alpha boards were essentially just a PC with a different processor. (In fact the original Athlon used the Alpha EV6 bus and was pin-compatible, so you could drop-in replace the processor with an Alpha if you could somehow reflash the bios with alpha instructions instead of x86.)
I'd like to boot Alpha Linux on qemu, and it doesn't seem like there's _that_ much more to do. But last I asked (a couple years ago) I was told the Alpha protected mode stuff wasn't implemented yet...
Rob
Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds
Quoted 10 lines · Rob Landley
Any idea how hard it would be to whip up a qemu-system-alpha emulation? I note that several real-world alpha boards were essentially just a PC with a different processor. (In fact the original Athlon used the Alpha EV6 bus and was pin-compatible, so you could drop-in replace the processor with an Alpha if you could somehow reflash the bios with alpha instructions instead of x86.)
I'd like to boot Alpha Linux on qemu, and it doesn't seem like there's _that_ much more to do. But last I asked (a couple years ago) I was told the Alpha protected mode stuff wasn't implemented yet...
There's been a series of patch to add ES40 proposed by Tristan Gingold last March. Look here:
Laurent
Quoted 9 lines · Laurent Desnogues
Quoted 3 lines · Rob Landley
I'd like to boot Alpha Linux on qemu, and it doesn't seem like there's _that_ much more to do. But last I asked (a couple years ago) I was told the Alpha protected mode stuff wasn't implemented yet...
There's been a series of patch to add ES40 proposed by Tristan Gingold last March. Look here:
I haven't had time to continue to work on it. It was able to boot and run linux and partially boot tru64. Both AlphaBios and SRM were ok.
The main issue was speed and IO-TLB (necessary for Tru64 and VMS).
Tristan.
Quoted 11 lines · On Monday 21 September 2009 06:37:24 Tristan Gingold wrote:
Quoted 10 lines · Laurent Desnogues
Quoted 5 lines · Rob Landley
I'd like to boot Alpha Linux on qemu, and it doesn't seem like there's _that_
much more to do. But last I asked (a couple years ago) I was told the Alpha
protected mode stuff wasn't implemented yet...There's been a series of patch to add ES40 proposed by Tristan Gingold last March. Look here:
Quoted 8 lines
Quoted 2 lines
http://www.archivum.info/[email protected]/2009-03/00723/%5BQemu-deve
l%5D_%5BPATCH_0_24%5D:_add_alpha_es40_system_emulationI haven't had time to continue to work on it. It was able to boot and run linux and partially boot
tru64. Both AlphaBios and SRM were ok.The main issue was speed and IO-TLB (necessary for Tru64 and VMS).
I'm only worrying about Linux at the moment. If the patch series boots Linux, I'm happy to test it.
Did you boot Linux with -kernel? Do you have the Linux .config you used? And what gcc/binutils tuple were you using? (Just straight alpha-unknown-linux?)
Thanks,
Rob
Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds
Quoted 15 lines · Rob Landley
Quoted 14 lines · On Monday 21 September 2009 06:37:24 Tristan Gingold wrote:
Quoted 12 lines · Laurent Desnogues
Quoted 5 lines · Rob Landley
I'd like to boot Alpha Linux on qemu, and it doesn't seem like there's _that_
much more to do. But last I asked (a couple years ago) I was told the Alpha
protected mode stuff wasn't implemented yet...There's been a series of patch to add ES40 proposed by Tristan Gingold last March. Look here:
http://www.archivum.info/[email protected]/2009-03/00723/%5BQemu-deve
l%5D_%5BPATCH_0_24%5D:_add_alpha_es40_system_emulation
Quoted 8 lines
Quoted 5 lines
I haven't had time to continue to work on it. It was able to boot and run linux and partially boot
tru64. Both AlphaBios and SRM were ok.The main issue was speed and IO-TLB (necessary for Tru64 and VMS).
I'm only worrying about Linux at the moment. If the patch series boots Linux, I'm happy to test it.
Yes, I got a linux shell.
Quoted 1 line
Did you boot Linux with -kernel?
No.
Quoted 2 lines
Do you have the Linux .config you used? And
what gcc/binutils tuple were you using? (Just straight alpha-unknown-linux?)
Yes.
Tristan.
Quoted 8 lines · On Monday 21 September 2009 01:23:50 Laurent Desnogues wrote:
Quoted 7 lines · Rob Landley
Any idea how hard it would be to whip up a qemu-system-alpha emulation?
I note that several real-world alpha boards were essentially just a PC
with a different processor. (In fact the original Athlon used the Alpha EV6 bus and was pin-compatible, so you could drop-in replace the processor with an Alpha if you could somehow reflash the bios with alpha instructions instead of x86.)
Quoted 6 lines
Quoted 3 lines
I'd like to boot Alpha Linux on qemu, and it doesn't seem like there's _that_ much more to do. But last I asked (a couple years ago) I was told the Alpha protected mode stuff wasn't implemented yet...
There's been a series of patch to add ES40 proposed by Tristan Gingold last March.
Ooh, thanks.
Quoted 4 lines
Look here:
http://www.archivum.info/[email protected]/2009-03/00723/%5BQemu-devel%
5D_%5BPATCH_0_24%5D:_add_alpha_es40_system_emulation
That's the March 19th posting, he actually posted a newer series on March 30. Still just boots the Bios, not Linux, but it seems a good thing to poke at
Looks promising. Has there been any progress since then? (Did any of the series get merged? Is it worth trying to apply this series to current -git, feeding it a linux -kernel, and seeing what happens?)
Quoted 1 line
Laurent
Rob
Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds
qemu-system-alpha (was: Re: [Qemu-devel] [PATCH] Fix extlh instruction on Alpha)
In reply to Rob LandleyQuoted 9 lines · Rob Landley
Quoted 8 lines · On Thursday 17 September 2009 14:28:52 Vince Weaver wrote:
The extlh instruction on Alpha currently doesn't work properly. It's a combination of a cut/paste bug (16 where it should be 32) as well as a "shift by 64" bug.
This improves on an earlier patch that used labels, conditional jumps, and local variables. Thanks go especially to Aurelien Jarno and Andreas Schwab who have a much better eye for bit-wise TCG optimization than I do.
Quoted 5 lines
Quoted 1 line
Vince
Any idea how hard it would be to whip up a qemu-system-alpha emulation? I note that several real-world alpha boards were essentially just a PC with a different processor.
Yep. The ES40 used the ALI1543 chipset and was pretty pc-ish is most respects. There were a couple of DEC specific chips on board (such as an IOMMU).
But the hardware isn't the real problem, I don't think. I think the real problems (for QEMU, at least) are the PAL and SRM.
The PAL adds several os-specific pseudo-instructions to the instruction set. MILO has a linux palcode, but no other open source ones are available that I know of. Without VMS or Tru64 Palcode you're limited to linux. I think the BSDs use the Tru64 Palcode. I suppose its possible to have the palcode routines hard-coded into qemu, though you'd need several sets of them (one for each supported OS type)
There doesn't seem to be an open source SRM which can be used to boot the machine and provide the initial user interface. MILO also performs this function, but its hard to build and pretty old.
I believe that charon axp solves this problem by having their own mini-implementation of the srm (and presumably the PAL) which only supports setting/viewing the environment and booting. The real SRM has lots of features that aren't really needed on emulated hardware.
Quoted 3 lines
I'd like to boot Alpha Linux on qemu, and it doesn't seem like there's _that_ much more to do. But last I asked (a couple years ago) I was told the Alpha protected mode stuff wasn't implemented yet...
There were patches last year for an es40, but they never made it to the main tree...and weren't quite finished.
Re: qemu-system-alpha (was: Re: [Qemu-devel] [PATCH] Fix extlh instruction on Alpha)
Quoted 24 lines · On Monday 21 September 2009 08:31:49 Brian Wheeler wrote:
Quoted 10 lines · Rob Landley
Quoted 9 lines · On Thursday 17 September 2009 14:28:52 Vince Weaver wrote:
The extlh instruction on Alpha currently doesn't work properly. It's a combination of a cut/paste bug (16 where it should be 32) as well as a "shift by 64" bug.
This improves on an earlier patch that used labels, conditional jumps, and local variables. Thanks go especially to Aurelien Jarno and Andreas Schwab who have a much better eye for bit-wise TCG optimization than I do.
Quoted 5 lines
Quoted 1 line
Vince
Any idea how hard it would be to whip up a qemu-system-alpha emulation? I note that several real-world alpha boards were essentially just a PC with a different processor.
Yep. The ES40 used the ALI1543 chipset and was pretty pc-ish is most respects. There were a couple of DEC specific chips on board (such as an IOMMU).
But the hardware isn't the real problem, I don't think. I think the real problems (for QEMU, at least) are the PAL and SRM.
Quoted 6 lines
The PAL adds several os-specific pseudo-instructions to the instruction set. MILO has a linux palcode, but no other open source ones are available that I know of. Without VMS or Tru64 Palcode you're limited to linux. I think the BSDs use the Tru64 Palcode. I suppose its possible to have the palcode routines hard-coded into qemu, though you'd need several sets of them (one for each supported OS type)
What I'd really like to use is the -kernel option to boot Linux.
I have a project (http://impactlinux.com/fwl) that's trying to build a simple uclibc/busybox Linux system image for each qemu-system target, plus a native compiler (gcc,binutils,make,bash), and then using distcc to call out to the host's cross compiler through the virtual network to speed up native builds without all the other complexity of cross compiling (lying to ./configure in three dozen different ways while keeping two different toolchains with their own sets of headers and libraries from leaking into each other).
It's also a fun way to do nightly regression tests of busybox, uClibc, and the linux kernel on various different targets, so things like 2.6.30's mips bug or the current sh4 weirdness in 2.6.31 get caught early enough that the developers remember what changed.
It boots a kernel via -kernel and feeds in a root filesystem as /dev/hda or /dev/sda (or initramfs in a pinch, but that seldom gives you enough space 11 megabytes of compressed toolchain before the memory mappings go "boing" during initramfs extract). The way I'm booting uses a serial console, emulated hard drive (ide or scsi), emulated network card, 256 megs of ram, and optionally a battery-backed clock (I can fake it with rdate if the network card works, make gets really unhappy otherwise), the processor emulation in question, and a kernel configured to boot on that particular qemu setup.
So far I've got ppc, arm, mips, sh4, x86, x86-64, and a very buggy sparc booting to a shell prompt, and all of 'em except sparc can build and run "hello world" natively. (uClibc's sparc support is not happy, hopefully current -git sucks less.)
I whipped up an Alpha config back when I started the project, but there's never been a way to test it, so it got lost. Similar with m68k and cris. (Last I checked the emulated cris boards were toys with a fixed small amount of memory, no hard drive, no way to add a network card, and I don't remember if they even emulated a battery-backed clock.)
Quoted 8 lines
There doesn't seem to be an open source SRM which can be used to boot the machine and provide the initial user interface. MILO also performs this function, but its hard to build and pretty old.
I believe that charon axp solves this problem by having their own mini-implementation of the srm (and presumably the PAL) which only supports setting/viewing the environment and booting. The real SRM has lots of features that aren't really needed on emulated hardware.
Reminds me of the nightmare getting openbios/openhackware on ppc to feed in a coherent device tree. I just want enough setup to make -kernel work, but that's often nontrivial. :(
Quoted 6 lines
Quoted 3 lines
I'd like to boot Alpha Linux on qemu, and it doesn't seem like there's _that_ much more to do. But last I asked (a couple years ago) I was told the Alpha protected mode stuff wasn't implemented yet...
There were patches last year for an es40, but they never made it to the main tree...and weren't quite finished.
I'm happy to test (and document) something that almost works. But if it doesn't almost work, I'm unlikely to be much help. :(
Rob
Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds