Very interesting article at the IEEE ACM by David Chisnall.
In the wake of the recent Meltdown and Spectre vulnerabilities, it's worth spending some time looking at root causes. Both of these vulnerabilities involved processors speculatively executing instructions past some kind of access check and allowing the attacker to observe the results via a side channel. The features that led to these vulnerabilities, along with several others, were added to let C programmers continue to believe they were programming in a low-level language, when this hasn't been the case for decades.
(Score: 2) by Wootery on Saturday May 26 2018, @02:40PM (3 children)
Well, I'm stating that C has variables, and I'm assuming the target machine doesn't. If those assumptions hold, that's a big divide to cross, even sub-optimally. Without a seriously powerful macro system -- way beyond a typical assembly language -- I don't see how you'd do it.
Sure. When a compiler is said to generate poor code, poor register-allocation is probably a big part of it.
Well, some 'high-level assembler' languages, perhaps, but at that point it's a stretch to call it an assembly language. Show me a hardware infinite register machine, and sure, its assembly language could be said to have variables. (I'm a little disappointed that a quick Google turned up nothing on that front. Figured someone would have tried it.)
What would it mean to 'protect against external modification'?
Aside: here [cornell.edu] is a (freely available) paper exploring the idea of a register-allocation assembly macro, which would presumably exist as a special macro-language facility, not as a macro defined in the ordinary way. Rather thin on what an example usage might look like, though.
(Score: 2) by HiThere on Saturday May 26 2018, @05:26PM
You are assuming that register allocation is a part of being a low level language. This is only true on certain CPUs. Many I've programmed on only HAD two registers, and their use was essentially fixed. The i6502 could treat the entire lower page of memory as a set of registers.
I'm sorry I can't be more specific, but it's been multiple decades since I did any assembly language programming, but low level languages don't necessarily allocate registers in ways that aren't necessary. That depends on the architecture of the CPU. It also depends on various other features of the op code set. If registers aren't a highly constrained resource, and can also be addressed in other ways, it can make sense not to specify.
Now if you wanted to claim that assembler is lower level than C, I'd agree without question. And microcode is lower yet...if it's present. The IBM 7094 didn't have microcode, and I'm not sure anything much before 1980 did, but with chips you can't be sure without grinding them apart under a microscope. Still, I never even heard of microcode until after 1970. (I'm not sure how long.)
C allows you to suggest that variables be allocated to registers. It's free to ignore your suggestion, but that you can suggest that kind of hardware assignment is a low level feature. If it had to pay attention, that would limit the number of CPU types it could run on. If you happen to know the address of a hardware port, it lets you write to that port. I once wrote a printer driver in C. It wasn't a complete one, but it was needed for a special case (driving a dot matrix printer off a remote terminals secondary port) that the standard drivers wouldn't handle. That's a pretty low level activity.
Javascript is what you use to allow unknown third parties to run software you have no idea about on your computer.
(Score: 2) by HiThere on Saturday May 26 2018, @05:28PM (1 child)
What would it mean to 'protect against external modification'?
It would mean something like a C++ private variable.
Javascript is what you use to allow unknown third parties to run software you have no idea about on your computer.
(Score: 2) by Wootery on Saturday May 26 2018, @07:14PM
Register-allocation isn't a language feature, it's what a compiler does to map the variables onto the target machine's registers, spilling to memory if necessary. Whether you're compiling C, or Java, or JavaScript, you have to solve the register-allocation problem. All serious modern compilers will make the effort to enregister variables where appropriate. Wikipedia page. [wikipedia.org]
With some non-portable extensions of C, you can request/insist that the compiler use a specific register for a variable. That is certainly a low-level feature, yes.
You've misunderstood the intent of C++ private variables. They're about helping the programmer write good object-oriented code. They don't protect you against hostile code with access to your process. [itcsolutions.eu]
In other languages/programming environments, things might be different, but C++ provides no such language features, and has no such security model.