104 points · by tosh · 8y ago · 72 comments
Cache updates will need to be staged and not “retired” (aka committed and made visible to other cores) until the speculated instructions are retired. That will have some perf impact and cost some die space, but it is hardly fatal.
Whether AVX survives in its current form is an open question. Those 512-bit vector units cost a lot of power. Intel gets away with powering them down when unused, leading to a large delay when the first vector instruction is encountered after an idle period. Powering them up continuously blows their TurboBoost strategy. If they can eliminate the penalty or make the units more power efficient it might not require many changes, otherwise AVX may need to shrink back down to narrower units, or maybe force them through a shutdown cycle on every context switch? Not sure what the solution is here.
In general, I think the problem is that we probably don't know about all possible side channels, and might not for many years. So the approach you suggest - eliminating side channels one by one so that you can't extract information from speculative execution that way - is inherently risky.
See this suggestion a lot. At any given time, a CPU is trying to execute 5-8 u-ops in different execution units every cycle. These 5-8 u-ops must come from instructions somewhere. To have something to do, CPUs need to load dozens, even hundreds of instructions from "the future" using branch prediction. As such, there literally could be hundreds of instructions in its reorder buffer at once. Of these, 5-10 of them might represent branches which cannot been executed due to dependencies but instead have been simply guessed at using branch prediction.
TLDR; that pretty much means that the CPU is always speculating--perhaps 95% of all cycles.
Typical CPU designs do not explicitly track branch dependencies in the reorder buffer. Instead, they either rely on anulling at commit time or clearing the reorder buffer when a mispredicted branch commits. That means the CPU literally has no way of knowing whether it is currently "speculating". To fix this, one would have to add control dependencies to AVX instructions so that they could never execute with branch instructions on which they depend (i.e. earlier on their proper architected path) in-flight. That would almost certainly annihilate performance, which, after all, is the point of AVX instructions.
One you have a CPU of that design, you can eliminate that AVX-512 sidechannel by not sending the signal to power up the full AVX-512 ALUs until a AVX-512 instruction is fully executed.
https://www.intel.com/content/dam/www/public/us/en/documents...
They also claimed the Itanium-based solutions were immune to Spectre and Meltdown. I'm not a CPU expert. I'll let others review that. A lot of attacks are showing up.
https://secure64.com/not-vulnerable-intel-itanium-secure64-s...
So, the processor that was about stronger reliability and security that the market and mainstream security ignored seems to mitigate some of the risks both are now griping about. Maybe folks who don't depend specifically on x86 might buy some Itaniums to signal they'll pay for security-enhanced processors. Be sure to tell the sales rep why so they can pass it up the chain. :)
For embedded stuff, there's also Microsemi's CodeSEAL and Dover's CoreGuard which have advanced protections. The first has encrypted/authenticated RAM plus control-flow integrity at CPU level. The second has a flexible, metadata unit that enforces many types of security policies at CPU level on per-instruction basis.
There's simply no "killer feature" for Itanium. It's not coming back.
So, Intel should continue to make deliberately insecure processors and patch them since that's what people pay for. It's the market's fault for rarely buying anything better. Plus, voters not doing something about patent reform which would've led to more x86 competitors. The Chinese supplier is an interesting development where we might get a secure-ish x86 that way.
"There's simply no "killer feature" for Itanium. It's not coming back."
I just named its killer feature: security enhancements that make it hard to inject code into it. Most security audits of OS's find problems. The one of SourceT on Itanium didn't find a way to inject code into it since it used hardware to mitigate and contain most of that. Whereas, the protections on x86 are a source of vulnerabilities at the moment.
Unfortunately, that was the only company that I'm aware of which saw that potential. The market's direction means they're porting the product to insecure hardware right now. Who knows what they'll come up with since it's impossible to secure software on insecure hardware. I'm so grateful to the markets for buying such things so little that they basically don't exist in the mainstream space.
Note: Another example was Cell processor. Green Hills, who make INTEGRITY-178B OS for high security, did an assessment of the Cell processor for baking security into systems. It had some nice capabilities for that. Market wasn't going to buy it even to protect their systems, though. So, they're not pushing that.
However, VLIW-like architectures could give us back the performance of out-of-order execution without the drawbacks since the compiler has much more direct control over the caches and registers used in the CPU as well as branch prediction and lots of other internals.
Of course, you also need much smarter compilers, since the Itanium failure, we've come a long way and I'm convinced that Rust and friends would be able to get the maximum out of a VLIW-like with some additional work.
> Of course, you also need much smarter compilers, since the Itanium failure, we've come a long way and I'm convinced that Rust and friends would be able to get the maximum out of a VLIW-like with some additional work.
- What kind of compiler magic do you have upon your sleeves that will enable that kind of magic, but circumvents the problem of non-existence of a "sufficiently smart compiler" that plagued Itanium? In particular: What kind of magic does Rust offer for this?
- How do you intend to solve the problem (that also plagued Itanium) that mostly scientific code has the kind of parallelity that is very suitable to VLIW which lead to the problem that "lots of ordinary, existing code" did not benefit so much from the potential speed that Itanium offered?
- How do you intend to solve the problem that putting deep microarchitecture details into the instruction set is usually a bad idea, because it "cements" these details (I just say: MIPS' delay slots), while having a good instruction set makes deep changes in the underlying microarchitecture easy.
Lots of code runs fairly well in CPU pipelines with multiple work units, if the work pipeline is too wide that sucks of course and is a bit of a waste but, say, having a Intel-sized pipeline would run most of the current code with the same efficiency.
This isn't purely about parallelizing threads, this is about microcode instructions which can be parallelized very easily; pull a instruction from the list of the program and put it in the first free execution unit on no conflict, if a conflict occurs resolve it (WaW; drop it or assign new register, RaR; free reordering, WaR; assign new register, RaW, strictly no ordering before), repeat. A compiler should be easily able to do that.
Of course having the microarchitecture and instruction set tightly married is a problem but considering we have a fairly alive ARM marketplace of varying instruction sets from ARM, I think it's not unsolvable from the compilation direction and you can abstract out some details so porting is easier or you can atleast emulate the other CPU with high efficiency.
Not much, comparing to C, they both are too low-level for that. Just like almost all the programming languages widely in use. Except maybe Haskell.
That's just impossible to optimize C code beyond some (not very impressive) level. And every CPU hoping for wide adoption is pretty much "CPU for C compiler" - and that's a problem.
Even if this were financially suitable for Intel (it is not), a necessity for this is that Intel has a microarchitecture available that "really fixes these problems" - but there is none. I consider it as plausible that the old in-order Atoms are less prone to these problems - but do you really want such a much slower CPU?
So... why not do exactly that? Let compilers access cache and stop this nonsense where we pretend computer memory is flat in order to let C developers believe they're "close to the metal [sic]"
[0] https://queue.acm.org/detail.cfm?id=3212479
Old discussion (skip the first reply for meat!)
Is there a reason speculative execution had to be added to the processor and not compilers? Would we have been better off if the true memory model was exposed to compilers?
The CPU knows what the software is actually doing and has done in the past. The compiler does not.
The CPU can change implementations; the compiler must bake any assumptions in at build time.
Speculative execution is required so long as memory latencies are so large. That trend isn’t reversing itself anytime soon.
profile guided optimizations?
Wasn't this supposed to be the lesson of Itanium and VLIW?
I have read (without understanding for myself) that VLIW it had two problems: (a) no one can actually write an appropriate compiler, and (b) that's not surprising because the non-literalness of assembly is a useful hinge point allowing CPU designers to evolve their implementations while retaining a stable interface.
But this thread is talking about going even further and exposing new CPU features to programmers, and not just compilers. Does anyone have thoughts about what abstractions they would like to see?
You could argue they already do, __builtin_prefetch and it's associated assembly instructions offer a way to manipulate the cache, but at the same time they seem to hedge their bets and pretend the cache isn't there. On the other end we've got programmers that know it's there and jump through hoops to try and keep things in contiguous memory, tricking the CPU into doing the correct thing.
That is truly an elephant in the room situation, everyone knows there is a magic black box there but do their best to ignore it because there is no other option.
> Wasn't this supposed to be the lesson of Itanium and VLIW?
It was the lesson, but that doesn't mean it was the correct one. In an alternate universe where there was no x86_64 we might have learned the opposite lesson.
Case in point, we have already seen a few times how unanticipated NUMA or thread scheduling weirdness can totally tank performance- and these are finer details!
Binary compatibility is the reason. You can't break the memory model or the instruction set unless you actually have the ability to re-compile everything that your users want to run. This almost never happens in the personal computing world, and emulation is only a partial solution. Intel managed to transition from the 8080 to the 8086 without backwards compatibility by preserving assembly language compatibility, but every architecture shift since then has required either emulation or a backwards-compatible processor mode.
I fail to see how having shared speculation is incompatible with existing binaries. AMD processors for example check security before speculating, instead of just running things in parallel and hoping they don't need to reset registers later.
Can you explain how speculative execution is systemic to x86? I can't see it to be honest.
Considering that radio stocks were the “hot item” in the 20’s, to a point where it became something of a bubble, it doesn’t look like businesses made out too bad.
I think this can entirely be hidden below the ISA abstraction, but it will be a lot of development work to do this and unfortunately getting new hardware into the field is a slow process. One part of this is buffering and killing speculative updates (or flushing on "time domain" switches). The other, and harder part, is to manage/avoid bandwidth contentions caused by speculation.
I think the better, long-term solutions will involve address IDs/capabilities to better denote security boundaries to the hardware. But that requires a lot of buy-in across many layers of the compute stack(OS/platform change for starters).
[1] https://content.riscv.org/wp-content/uploads/2018/05/13.00-1...
Mill may be cool and all but x86 isn't going anywhere.
Although I think it'd be hilarious if Intel decided to bring back Itanium with explicit per task cache indexing and no speculative execution. They already have the technology while Mill has never had a silicon implementation.
(I kid)
Although seriously with the "invisible hand" pushing platform lockdowns across the industry, it's time to stockpile some G34's next to the canned goods.
That's one design cycle == 10x improvement.
So not unreasonable within the context of the history of the industry.
The proof will be in the product when it ships.
Glad we cleared that up.
Here's the last two companies to spout this line of garbage: Transmeta and SiByte. Remember them?
Your statement implies that the Intel engineers have left a lot of design on the table. I assure you, this hasn't been true for quite a long time (circa 1996, arguably, but certainly not since 2000--that's why both Transmeta and SiByte failed).
The simple answer to this is: graph the active area vs power consumed for all the chips of a particular technology node. Unless Intel is significantly below that line, you're not going to beat them by much.
The Mill folks would rather argue that Intel's problem is they aren't leaving things on the table—instead, they're shoving tons of extra machinery into their core designs while the Mill tries to avoid extremely power-hungry performance enhancing techniques like speculative out of order execution.
> graph the active area vs power consumed for all the chips of a particular technology node
Setting aside the difficulties of accounting for differences between different manufacturer's processes at the same node, this still isn't a very informative measure. Active areas of the chip don't all make the same contribution to performance. Speculative execution can light up a lot of silicon executing instructions that don't actually need to be executed.
I'm quite skeptical that the Mill guys will ever produce a core that beats Intel on raw performance, but they have plenty of convincing arguments for why their power consumption will be much lower, and I think it's plausible that they will be able to beat Intel on performance per watt for some workloads.
Go look at Alpha 21164 vs x86 in the timeframe. You don't save as much as you think (and Intel's designs were much shoddier back then).
> Setting aside the difficulties of accounting for differences between different manufacturer's processes at the same node, this still isn't a very informative measure.
You would think so, but the graph is remarkably consistent. Just because a measure has noise does not make it a useless measure.
Intel could be significantly below the curve. But beating the curve is ferociously difficult.
When you say the CPU do you mean a working ASIC? Some simulation? Or a plan to make one?
And how do you compare them if they have completely different instructions set?