News for hackers. Stuff that matters.
Re:Intel x86 documentation has more pages than the 6502 has ... by mwcampbell on Wednesday December 07, 2016 @04:26PM (#13126360)
Is the situation appreciably better with ARMv8? How about ARMv7?
Re:Intel x86 documentation has more pages than the 6502 has ... by pcwalton on Wednesday December 07, 2016 @04:41PM (#13126503)
Most ARMv8 CPUs in the wild are backwards compatible with 32-bit ARM and Thumb (able to switch modes on CPU exceptions), but AArch64 is a near-complete redesign of the ISA to eliminate cruft. It's very nice that ARM removed things like the conditional execution, weird behavior of the "pc" register, and most of the barrel shifter complexity. It is not an architectural requirement for ARMv8 processors to implement the 32-bit ARM ISA (though of course for practical reasons they do today). So, eventually, if we start seeing ARMv8 processors that eliminate the 32-bit compatibility, we may see a nice architectural simplification (though I wouldn't be surprised if the transistor count doesn't decrease that much).
Re:Intel x86 documentation has more pages than the 6502 has ... by mwcampbell on Wednesday December 07, 2016 @04:53PM (#13126604)
I think Apple will be the first to drop 32-bit compatibility, since they've been requiring 64-bit support in all iOS App Store submissions for a while now.
Re:Intel x86 documentation has more pages than the 6502 has ... by dpc_pw on Wednesday December 07, 2016 @05:21PM (#13126804)
Definitely. As a dominant platform owner they can push everyone to bend over backwards all the time. And they will since any fab and power savings will be totally worth it for the user, even if they marginal.
Re:Intel x86 documentation has more pages than the 6502 has ... by flukus on Wednesday December 07, 2016 @06:45PM (#13127271)
So AArch64 is simpler? Could we expect a simpler architecture to take a performance lead in future?
Re:Intel x86 documentation has more pages than the 6502 has ... by userbinator on Wednesday December 07, 2016 @10:44PM (#13128263)
Could we expect a simpler architecture to take a performance lead in future?

That didn't happen in the past and I doubt it will be true in the future; in fact I'd say one of the reasons ARM remained competitive is because of conditional execution, the "free" barrel shifter, and Thumb mode, which really help with code density (directly related to cache usage) and avoiding branches.

AArch64 looks very much like MIPS, an ISA that hasn't really been known for anything other than being cheap and a good simple pedagogical aid (despite plenty of people being convinced it would easily outperform x86 at a fraction of the cost.) I'd guess any perceived performance increases over AArch32 are primarily due to the widening to 64 bits, and in any case much of the benchmark performance rests on the special functional units (SIMD, crypto, etc.)

Re:Intel x86 documentation has more pages than the 6502 has ... by pcwalton on Thursday December 08, 2016 @12:04AM (#13128515)
> in fact I'd say one of the reasons ARM remained competitive is because of conditional execution, the "free" barrel shifter

No compiler developer would agree with you. The conditional execution wreaks havoc with dependencies, and branches are very cheap if correctly predicted. The barrel shifter is not as useful as you would think (what fraction of instructions are shl or shr?)

Thumb mode does help code density, but not as much as you might think due to Thumb-1 not being practical and Thumb-2 being fairly large. AArch64 is quite a bit denser than x86-64 already.

It is true that the ISA doesn't matter too much from a performance point of view. But why not take advantage of the necessary compatibility break to clean things up? There's a lot of needless complexity in our ISAs from the programmer's point of view, and cleaning it up is just good engineering practice. Let's not saddle future generations with the mistakes of the 1980s.

Re:Intel x86 documentation has more pages than the 6502 has ... by userbinator on Thursday December 08, 2016 @07:30AM (#13129891)
The barrel shifter is not as useful as you would think (what fraction of instructions are shl or shr?)

https://news.ycombinator.com/item?id=7045759

Re:Intel x86 documentation has more pages than the 6502 has ... by pcwalton on Thursday December 08, 2016 @01:00PM (#13132442)
The immediate value encoding is still there. What's gone is the barrel shifter on arithmetic instructions, other than those that explicitly mention that they perform a shift.
Re:Intel x86 documentation has more pages than the 6502 has ... by nn3 on Wednesday December 07, 2016 @08:52PM (#13127822)
If you go by pages in the specification https://people-mozilla.org/~sstangl/arm/AArch64-Reference-Ma... is 5183 pages, which is about 10% longer than the Intel manual, which currently has 4670 pages.
Re:Intel x86 documentation has more pages than the 6502 has ... by pcwalton on Wednesday December 07, 2016 @10:41PM (#13128251)
2,036 of those pages are for AArch32, though. In contrast to ARM, AMD didn't introduce a new instruction set for 32-bit x86.

Personally, I prefer ARM's move, because while it's a complexity increase now, it paves the way to someday drop support for 32-bit ARM, which would be a major architectural simplification. It also means that, as a programmer, when you're in 64-bit mode you aren't burdened by all of that weird backwards compatibility stuff going back decades—you get a relatively clean ISA.

(I do have some gripes with AArch64, to be fair: there are too many addressing modes and the condition codes are unnecessary. But I'll take anything that moves us in a more RISC-y direction.)

Re:Intel x86 documentation has more pages than the 6502 has ... by pcwalton on Wednesday December 07, 2016 @06:59PM (#13127355)
Yes, it's significantly simpler. I would be very glad to see that yield a performance increase, though I suspect the difference would be small.
Re:Intel x86 documentation has more pages than the 6502 has ... by static_noise on Wednesday December 07, 2016 @04:32PM (#13126416)
Is the situation with x86 bad to begin with?

Granted, I didn't read the full documentation provided online for my hardware before I powered it on. Honestly, I didn't read any documentation and it just works, kind of.

Re:Intel x86 documentation has more pages than the 6502 has ... by pcwalton on Wednesday December 07, 2016 @04:37PM (#13126470)
x86-64 has tons of cruft: complex instruction encoding (mod R/M and SIB bytes), bloated instruction encoding thanks to REX prefixes, real mode, virtual 8086 mode, odd SIMD limitations, pointless instructions like XLAT, binary coded decimal, a non-orthogonal instruction set with some 3-register instructions (LEA, IMUL, AVX2) mixed with a bunch of other 2-register instructions, individually addressable low and high bytes of certain registers but not others…
Re:Intel x86 documentation has more pages than the 6502 has ... by h4nkoslo on Wednesday December 07, 2016 @06:04PM (#13127053)
Most of that cruft consumes minimal die area and results in absolutely minimal slowdown compared to an "optimized" minimal architecture. Fun exercise: do a histogram of instructions in some large program's binary. Not a ton of weirdness in practice.
Re:Intel x86 documentation has more pages than the 6502 has ... by pcwalton on Wednesday December 07, 2016 @06:58PM (#13127345)
I'm not disputing that. I'm talking about complexity of the programming model (number of pages in the manual), not performance.
Re:Intel x86 documentation has more pages than the 6502 has ... by flamedoge on Wednesday December 07, 2016 @11:38PM (#13128435)
What was the main reason to add REX prefix for 64bit? Why not create longer register bits to hold 16 registers? Was it for easier binary to binary transformation?
Re:Intel x86 documentation has more pages than the 6502 has ... by pcwalton on Thursday December 08, 2016 @12:33AM (#13128622)
Because AMD was deathly afraid of AMD64 going the way of Itanium. So they went out of their way to make their architecture as similar to 32-bit x86 as possible, right down to reusing the encoding.

They also probably figured that they could reuse decoding logic.

Re:Intel x86 documentation has more pages than the 6502 has ... by Redoubts on Wednesday December 07, 2016 @05:08PM (#13126716)
The paper on the Design of RISC-V has a really good survey of existing ISA like x86:

https://people.eecs.berkeley.edu/~krste/papers/EECS-2016-1.p...

Re:Intel x86 documentation has more pages than the 6502 has ... by Kubuxu on Wednesday December 07, 2016 @05:20PM (#13126799)
To show complexity of x86-64 it is best to look at boot process. You processor starts in 16bit mode, then is upgraded to 32bit and then to 64bit mode. You want to do some call to BIOS now? You have to downgrade through 32bit mode to 16 bit mode to do that and then back up to handle the response.

And it is just very small component of cruft that x86-64 has.

Re:Intel x86 documentation has more pages than the 6502 has ... by hlandau on Wednesday December 07, 2016 @06:56PM (#13127330)
The rate at which the complexity of the amd64 boot process is increasing is quite alarming.

UEFI is an overcomplicated, buggy monstrosity, but that's just the tail end of the "boot process". Nowadays, to get an x86 CPU to execute a single opcode, you need to have a Management Engine (or Platform Security Processor, in AMD-speak) firmware blob resident in the firmware flash chip. More modern CPUs, for Intel, say, oblige you to use Intel-provided "memory reference code" and other "firmware support package" blobs just to initialize the CPU in the early stage. AFAIK, Intel isn't even bothering to document the details of its CPU and chipset initialization sequences anymore, in favour of just making people use unexplained blobs. These are just some of the issues the coreboot project is having to deal with. It really feels like at least in the world of x86, the window is rapidly closing on projects like coreboot being able to accomplish anything useful, although there are at least some major users like Chromebooks.

And then of course we have things like SMM, and the way in which secure firmware updates are facilitated (which relies on things like flash write protect functionality)...

Re:Intel x86 documentation has more pages than the 6502 has ... by djsumdog on Wednesday December 07, 2016 @07:01PM (#13127373)
Those blobs are run by the BIOS/UEFI correct? Like Grub/the Linux kernel don't need those Intel blobs just to get booting do they?
Re:Intel x86 documentation has more pages than the 6502 has ... by hlandau on Wednesday December 07, 2016 @08:03PM (#13127629)
It's correct that these blobs are loaded way before GRUB or a Linux kernel gets booted. To be precise they are part of the firmware image; UEFI refers to a boot protocol specification. So for example with coreboot, you can select one of many "payloads". Payloads include UEFI boot, MBR boot, etc. So it's probably best to distinguish between the boot protocol and the firmware package as a whole.

The ME firmware is loaded by the CPU itself before anything begins executing; there's a header in the firmware image stored on the CPU to let the CPU find it. These are cryptographically signed, so all projects like Coreboot can do is incorporate the binaries provided by Intel.

The MRC/FSP blobs are executed by the x86 firmware, they're x86 code which runs very early. Theoretically projects like Coreboot could replace these blobs with their own code, but it would require reverse engineering these blobs to figure out what they're doing. The fact that this would be a major effort is a testiment to the complexity of the initialization routines implemented in these blobs.

The order is basically something along the lines of:

1. CPU loads ME firmware, verifies signature, starts it running on the ME coprocessor.

2. First x86 opcode is executed; this is part of the 3rd party firmware (Coreboot, AMI, etc.)

3. The 3rd party firmware will probably start by executing the Intel MRC/FSP blob. (Possibly this blob even expects to be the reset vector now, wouldn't surprise me; I'm not an expert on this.)

4. The memory controllers/chipset/etc. are now setup. The 3rd party firmware can do what it likes at this point.

5. Typically, firmware will implement a standard boot protocol like MBR boot or UEFI boot. Coreboot executes a payload at this stage.

I should add that microcode is another (signed, encrypted) blob. Modern x86 CPUs are so buggy out of the factory that they're often unable to even boot an OS unless a microcode upgrade is applied, so 3rd party firmware often performs a microcode upgrade before booting. Historically I don't believe it was uncommon for the OS kernel to perform a microcode upgrade, if configured to do so because a newer microcode was available than was incorporated in the firmware; Linux has functionality to do this. However I seem to recall that late (kernel boot or later) microcode application is being phased out; recent x86 CPUs want microcode updates to be completed very early, before kernel boot.

Re:Intel x86 documentation has more pages than the 6502 has ... by amluto on Wednesday December 07, 2016 @06:01PM (#13127039)
This particular issue is overhyped IMO. 64-bit UEFI mostly bypasses it. Sure, the firmware entry point has some bootstrapping to to, but this isn't a big deal.

The really weird initial state of SMM is a bigger deal since it happens at runtime.

Re:Intel x86 documentation has more pages than the 6502 has ... by mwcampbell on Wednesday December 07, 2016 @04:35PM (#13126452)
Depends on how much of the complexity described in those thousands of pages of documentation is actually necessary, and how much could be eliminated with a better design.
Re:Intel x86 documentation has more pages than the 6502 has ... by Someone on Wednesday December 07, 2016 @06:18PM (#13127121)
Lots of it isn't so much bad design as not willing to give up backwards compatibility. Some examples:

- the old floating point register stack and its 80-bit registers

- I don't know how many iterations on SIMD instructions (MMX, a few iterations of SSE, a few iterations of AVX, various prefixes to make older instructions use newer registers)

If you got rid of those, you also could get rid of quite a few prefix instructions, maybe a configuration bit here and there, etc.

It also doesn't help that, at times, Intel and AMD independently added stuff to the x86.

Re:Intel x86 documentation has more pages than the 6502 has ... by monocasa on Wednesday December 07, 2016 @04:35PM (#13126445)
ARMv7 was already approaching x86 levels of complexity. Something like 1200 instructions and 30 years of cruft.