Stories
Slash Boxes
Comments

SoylentNews is people

SoylentNews is powered by your submissions, so send in your scoop. Only 17 submissions in the queue.
posted by cmn32480 on Wednesday May 23 2018, @06:47PM   Printer-friendly
from the your-computer-is-not-a-fast-PDP-11 dept.

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.


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by HiThere on Wednesday May 23 2018, @08:43PM (9 children)

    by HiThere (866) Subscriber Badge on Wednesday May 23 2018, @08:43PM (#683270) Journal

    Sure it was, or pretty nearly. Byte once had an article about a bunch of M6800 assembler macros that implemented well over 90% of C.

    Now it's true you could do a lot with that assembler that was quite difficult to do with C, but that's a rather different argument.

    --
    Javascript is what you use to allow unknown third parties to run software you have no idea about on your computer.
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (Score: 2) by Wootery on Thursday May 24 2018, @01:11PM (8 children)

    by Wootery (2341) on Thursday May 24 2018, @01:11PM (#683529)

    Byte once had an article about a bunch of M6800 assembler macros that implemented well over 90% of C.

    Register allocation, static scoping, and static type-checking in a macro system? And C's precedence and type-promotion rules? And all the rest?

    Sounds like quite a macro system.

    • (Score: 2) by DannyB on Thursday May 24 2018, @03:57PM

      by DannyB (5839) Subscriber Badge on Thursday May 24 2018, @03:57PM (#683597) Journal

      I remember looking at some assembler language once. In the 1980's. I think it was 68000, but memory grows weaker. But I was astonished at how much you could do with the macro system. The macro system was a programming language.

      Interesting to study. But I didn't want to make a career of it. I just needed to accomplish a few specific things.

      --
      To transfer files: right-click on file, pick Copy. Unplug mouse, plug mouse into other computer. Right-click, paste.
    • (Score: 2) by HiThere on Thursday May 24 2018, @05:47PM (6 children)

      by HiThere (866) Subscriber Badge on Thursday May 24 2018, @05:47PM (#683644) Journal

      C doesn't handle specifying register allocation. That's something this is only optionally paid attention to (and usually ignored). Etc.

      Also, I didn't say it handled all of C (circa 1980's), just over 90% of it. I don't have a copy of the article, so I can't specify just what it handled, and what it didn't. I'm not sure it handled floating point.

      FWIW, I also never actually tested the provided code. I was coding in Fortran on a mainframe and didn't have access to an M6800 machine, so it was more a "that's really interesting".

      --
      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 Friday May 25 2018, @09:21AM (5 children)

        by Wootery (2341) on Friday May 25 2018, @09:21AM (#683939)

        C doesn't handle specifying register allocation.

        I don't follow. C has the concept of local variables. Assembly languages don't. The process of mapping variables onto the register file, and memory, of the target machine, is called register allocation. It's a considerable algorithmic challenge. Indeed, solving the problem optimally is an NP-complete problem.

        If you've somehow implemented a C compiler in an assembly macro system, that means you've implemented register-allocation, no?

        • (Score: 2) by HiThere on Friday May 25 2018, @05:27PM (4 children)

          by HiThere (866) Subscriber Badge on Friday May 25 2018, @05:27PM (#684088) Journal

          You are assuming features common to compilers creating efficient code, but not specified by the language. And I've used compilers in the past that didn't handle that at all well. (Actually, of course, I though you were referring to the register allocation declaration rather than local variables, but it's still true.)

          FWIW, I used a C compiler on a Apple ][ (i6502) and subset compiler on an i8088. These were "around" the same time as the Byte article.

          Also, to claim that assembler languages don't have local variables is also a mistake. Some of them do. Most (all?) of them don't protect local variables against external modification, but then neither did (do?) a lot of C compilers. I think that's usually an OS protection, and doesn't work within the program, though admittedly in C it's hard to find the address of a stack variable, and in some machines they actually don't usually *have* an address, being stored in registers. Again, this is implementation dependent, and not part of the C language. (At least not the older standard. I don't know the more recent ones. The last time I looked in detail was around 1990 or a possibly a bit earlier.)

          But it's also true that the M6800 had a powerful macro assembler, which was the actual point of the Byte article. (Well, that an how well the M6800 instruction set was adapted to programming.)

          --
          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, @02:40PM (3 children)

            by Wootery (2341) on Saturday May 26 2018, @02:40PM (#684528)

            You are assuming features common to compilers creating efficient code, but not specified by the language.

            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.

            I've used compilers in the past that didn't handle that at all well.

            Sure. When a compiler is said to generate poor code, poor register-allocation is probably a big part of it.

            to claim that assembler languages don't have local variables is also a mistake. Some of them do.

            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.)

            Most (all?) of them don't protect local variables against external modification, but then neither did (do?) a lot of C compilers.

            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

              by HiThere (866) Subscriber Badge on Saturday May 26 2018, @05:26PM (#684597) Journal

              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)

              by HiThere (866) Subscriber Badge on Saturday May 26 2018, @05:28PM (#684599) Journal

              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

                by Wootery (2341) on Saturday May 26 2018, @07:14PM (#684634)

                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.

                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]

                you can suggest that kind of hardware assignment is a low level feature

                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.

                something like a C++ private variable

                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.