News for hackers. Stuff that matters.
Re:Modern CPUs have a backstage cast by kccqzy on Tuesday May 30, 2023 @02:43PM (#36128816)
> It's responsible for initialising the chip and getting it out of bed enough to the point where at least one of the main cores can run using cache-as-RAM mode

The somewhat surprising but true implication is that on boot, the CPU is initialized before the RAM is initialized. So there is a window of time during boot when the main core on the CPU is running instructions that cannot access the RAM. Even on register-starved x86 it is possible to write code without using RAM, but it certainly seems more convenient to me to treat the cache as RAM.

Documentation for a special compiler that compiles to code that doesn't use RAM: https://github.com/wt/coreboot/blob/master/util/romcc/romcc....

Re:Modern CPUs have a backstage cast by notacoward on Tuesday May 30, 2023 @03:21PM (#36129292)
I got some exposure to this at SiCortex, where we had our own MIPS-based processors and so had to do many of these things in software. There was one ColdFire (embedded 68K) processor running μClinux per board, plus 27 of our own. This "Module Service Processor" would boot first, fetch a boot image from the one-per-system "System Service Processor" (pretty generic PC), load that via JTAG into each node's cache, then finally set each one loose to do things like memory registration and interconnect setup. This all set the stage for the actual Linux boot, which itself involved two stages with a switch_root in between. My very first assignment was to work on some of that MSP-to-node stuff, then later I had to dive into memory registration at least twice, even though both were pretty far from my real specialty. Small company, y'know.

This kind of low-level work is significantly more complicated than even most kernel developers realize - hence the need for articles like OP. Ditto for anything on large (more than single-board) systems. The intersection of the two was, frankly, a bit exhausting. Just keeping track of all the moving parts and their respective states induced a cognitive load that made debugging other already-hard problems that much more difficult. My hat's off for anyone who has kept on doing that stuff longer than I did, or who has to do it in an environment where vendors are keeping so many secrets.

Re:Modern CPUs have a backstage cast by lgg on Tuesday May 30, 2023 @05:28PM (#36131122)
This stuff is certainly pretty rarified these days. I remember when the PPC970 came out people were shocked how difficult it was to bootstrap. IBM didn't really care as POWER4 (from which it was derived) was not a merchant chip and they had management processors (and very high margins) in all their machines to handle it. Apple was the launch partner and even back then had a lot of in house expertise doing this sort of work. Everyone else who tried to use it was in for some real pain and most of them gave up. The guys doing the eval boards with support from IBM literally posted this: https://web.archive.org/web/20060715134515/http://www.970eva...

TL;DR, the last line is "Once all of the above is completed, the processor will be able to successfully fetch instructions from a boot source. You are now effectively at the same point you would have been 5 months ago, had this been a standard 750 bringup... Board bringup from this point should be very straightforward and follow established methods."

Re:Modern CPUs have a backstage cast by notacoward on Tuesday May 30, 2023 @06:25PM (#36131849)
That's an amazing document. Practically every sentence, though tersely stated, hints at hours (or worse) of experimentation and head-scratching. The "would have been 5 months ago" bit at the end is remarkably restrained. I'm certain I would have quit (or worse) by that point. Respect and condolences to whoever did this.
Re:Modern CPUs have a backstage cast by jacquesm on Tuesday May 30, 2023 @05:36PM (#36131225)
I had to do some of this while bringing up a 486 to run my own kernel. Very frustrating, to the point that I had the reset switch of the machine wired to a sustain pedal just so that I didn't have to dive under the desk all the time.
Re:Modern CPUs have a backstage cast by bsoft16385 on Wednesday May 31, 2023 @02:29AM (#36135166)
That reminds me of a story about SiCortex.

My university (University of Colorado Boulder) bought one of a very few SiCortex systems ever sold. As an undergraduate I competed at SC07 and SC08 in the Cluster Challenge competition.

Our coach was a CU facility member, Doug, who also was responsible for the SiCortex box we bought. At SC08 he told us that another one of the teams was competing with a SiCortex box. We knew that they would win the LINPACK part of the challenge, but we didn't know that LINPACK was basically the only thing they managed to get working.

We had also heard rumors that SiCortex was in trouble financially at that time. When we were walking the show floor at SC08, we came across the huge SiCortex booth, which had 10 or so machines of different sizes (I believe the smallest was a 64-core workstation and the largest was a ~5000 whole rack system).

I remarked to Doug that SiCortex didn't look to be in such bad shape.

Doug turned to me and said, "25% of the machines SiCortex has ever made are in that booth".

The SiCortex idea was like VLIW. On paper the numbers look great. On highly optimized synthetic benchmarks it looks good. On real world code you find out how hard it is to get good performance.

Re:Modern CPUs have a backstage cast by notacoward on Wednesday May 31, 2023 @07:37AM (#36137117)
Sounds about right. The processors were six-core 500MHz single issue, which was pretty damn slow even by the standards of the time (2006-2008), beefed up with some extra floating point and some relatively very fast interconnect stuff. The key is that there were a lot of processors - 972 in the big machine. So you really really had to rely on parallelism to get any kind of performance, and a lot of code doesn't parallelize well at all. Even in the HPC space, a surprising number of codes just aren't designed to work for more than about 64.

Also the machine positively sucked for linear integer code - like, say, compilers or OS kernels. One of the first things customers would do, naturally, was compile. Bad first impression. Also, it was nearly impossible to get a Lustre MDS for a thousand-node cluster (which is what the biggest machine was) to run for any length of time without falling over, because Lustre was designed around the assumption that the MDS would be bigger and beefier than anything else and have "poor man's flow control" in the form of a relatively slow network. In our case it was exactly the same and completely unprotected because the interconnect was the fastest part of the system by quite a margin. That was my nightmare for those two years. I've heard that Lustre has since added some flow control ("network request scheduler") but I was never able to benefit from that. PVFS2 worked better, and Gluster (which I worked on for nearly a decade afterward) would probably have been better still because it's more fully distributed and less CPU-hungry.

The reason I mention all this is that there's an important lesson: building a system with a very unusual set of performance characteristics is a terrible idea business-wise, because people won't be able to realize its potential. Not even in a fairly specialized market. They'll just think it's slow. Unless it's truly bespoke, literally a one-off or close to it, nobody will want it.

P.S. I actually had to visit CU-Boulder to debug something on that machine, with the aforementioned Doug. It became one of my favorite "war stories" from a 30-year career, but this has gone on long enough so I'll skip it.

Re:Modern CPUs have a backstage cast by lproven on Thursday June 01, 2023 @11:16AM (#36152307)
Hey, some of us are listening, and would love to hear that story!
Re:Modern CPUs have a backstage cast by intelVISA on Tuesday May 30, 2023 @02:47PM (#36128882)
CAR is a gem. It's great for lite OSes in hostile envs.
Re:Modern CPUs have a backstage cast by derefr on Tuesday May 30, 2023 @02:55PM (#36128997)
Funny enough, a modern CPU doing CAR still has more memory than a PC from the 1980s. Presuming you statically recompiled them, you could run entire SNES games from a modern CPU’s cache!

(And that being said, now I’m wondering whether you could force eviction and retainment into L3 cache on demand, to achieve something like memory bank switching…)

Re:Modern CPUs have a backstage cast by JonathonW on Tuesday May 30, 2023 @03:50PM (#36129713)
SNES games? You could comfortably run Windows 95 within the L3 cache on many recent Intel processors (the one in my 2019-era MBP has 16 MB of L3 onboard; current generation processors go even bigger and Windows 95 only needs 4 MB).

It's not really clear to me from the limited bits of info that I've read whether or not L3 is guaranteed to be accessible when doing CAR, but, if it is, you've got enough memory available to do a lot of stuff. (And even the L2 cache is starting to get pretty big on the higher-end current-gen chips.)

Re:Modern CPUs have a backstage cast by Arrath on Tuesday May 30, 2023 @04:41PM (#36130456)
Man now I want to see this.
Re:Modern CPUs have a backstage cast by derefr on Tuesday May 30, 2023 @04:13PM (#36130061)
Well, keep in mind that in the sort of state the computer is in when doing CAR, you don't get to talk to storage devices; nor do you get the benefit of having some kind of ROM on the bus. I know Windows 95 is happy to run from 4MB RAM with access to a hard drive; but how much memory would W95 need for a "bootable live-CD environment" where the disk image must be resident (if compressed) in memory along with all work RAM?

(This is why I compared to the SNES: if you have to map the SNES's RAM and [every bank of] the game's ROM, then you're looking at 4–16MB depending on the game. The SNES is pretty much the newest console whose games would entirely fit, I think.)

Re:Modern CPUs have a backstage cast by dfox on Tuesday May 30, 2023 @05:37PM (#36131232)
I think that the only thing that prevents you from ignoring the memory controller and initializing the rest of x86 board while still remaining in the CAR mode is the sheer ridiculousness of doing that. As for whether you have an memory-mapped ROM available I'm not exactly sure, but the high-level model of what x86 firmware does seems to imply, that the hardware maps an part of SPI Flash at the address range where there was an ROM chip on the 8086/286/386 PCs (the actual address ranges are different).
Re:Modern CPUs have a backstage cast by justsomehnguy on Tuesday May 30, 2023 @06:03PM (#36131575)
About 35Mb IMSMR. Win98 could be stripped to around 50Mb without a loss of functionality.

NB L3 is unified most of the time, but but with L2 you still need to distinguish between data/code.

Re:Modern CPUs have a backstage cast by atq2119 on Wednesday May 31, 2023 @12:32AM (#36134493)
L2 is unified on all CPUs I'm aware of. Only L1 is split between instructions and data.
Re:Modern CPUs have a backstage cast by justsomehnguy on Wednesday May 31, 2023 @01:17PM (#36140886)
Guess I got L1/L2 messed up with L3 (don't drink and comment, kids).

But I found out what Itanium 2 did had a split L2 cache.

Re:Modern CPUs have a backstage cast by pezezin on Wednesday May 31, 2023 @05:58PM (#36144933)
The Ryzen 5800X3D has 96 MB of L3 cache, enough to fit the biggest NeoGeo or N64 games.

The Zen 4-based Genoa-X will have up to 1 GB of L3 cache! You could comfortably fit Windows 95 there...

Re:Modern CPUs have a backstage cast by lproven on Thursday June 01, 2023 @11:14AM (#36152272)
For a benchmark test for a British computer magazine in about 1996, I hand stripped down an installation of Windows 95 so that it could fit on a mid-1990s SSD: which is to say, a PCI slot device with 16 MB of DRAM which appeared to the computer as a disk drive. So, effectively, a 16 MB SSD. Not gigabytes, megabytes.

So I can say with some authority that it is possible to have a complete running installation of Windows 95 in 16 megs of disk space; however I had to trim it pretty brutally to fit, so, for example, I think it had 2 fonts left, one of which was used for the widgets that display window-close boxes and so on.

The problem was that the object of the exercise was the benchmark how much quicker it was — but there wasn't enough space left to install any applications, and our benchmark tool used real applications. So, although I did several days work and I did get paid for it, the effort was at heart in vain. But in principle yes you could run Windows 95 entirely out of 16 MB of cache memory, and if you had say 32 MB of cache memory it would be no problem at all.

Re:Modern CPUs have a backstage cast by hlandau on Tuesday May 30, 2023 @03:54PM (#36129783)
In fact, the largest POWER9 CPUs have up to 110MB of L3... and Zen 4's L3 apparently maxes out at 384MB(!!).
Re:Modern CPUs have a backstage cast by Dylan16807 on Wednesday May 31, 2023 @12:35AM (#36134510)
> Zen 4's L3 apparently maxes out at 384MB(!!).

That's with them holding back and not adding any v-cache. If you stacked an extra 64MB on each of the 12 compute dies, you'd have 1152MB.

Re:Modern CPUs have a backstage cast by andai on Tuesday May 30, 2023 @07:25PM (#36132548)
What does hostile mean in this context?
Re:Modern CPUs have a backstage cast by sweetjuly on Tuesday May 30, 2023 @08:21PM (#36132993)
It might be desirable to not trust RAM as other agents who have access to physical memory could be tampering with it.
Re:Modern CPUs have a backstage cast by intelVISA on Wednesday May 31, 2023 @03:54AM (#36135672)
Any machine you may not have True Control over e.g. outside of JTAG range, in the cloud, runs proprietary software.