4 ms·
x86 code is never actually marked as executable from the CPU's point of view, since that CPU does not know how to execute x86 code. The pages which contain the
by anyfoo 5y ago
x86 code is never actually marked as executable from the CPU's point of view, since that CPU does not know how to execute x86 code. The pages which contain the translated code are, but those are not something the x86 code knows about.
- chrisseaton 5y ago> x86 code is never actually marked as executable from the CPU's point of view, since that CPU does not know how to execute x86 code. The pages which contain the translated code are, but those are not something the x86 code knows about. No, pages and the executable bit are something that the processor knows about.
- a-dub 5y agoyou think that x86 pages are marked executable by the arm processor? probably not. maybe arm pages with an arm wrapper that calls the jit for big literals filled with x86 code are, or arm pages loaded with stubs that jump into the jit to compile x86 code sitting in data pages are... but if the arm processor cannot execute x86 pages directly, then it wouldn't make a lot of sense for them to be marked executable, would it?
- chrisseaton 5y agoNo the AMD64 page executable bit system is implemented in software by Rosetta.
- saagarjha 5y agoNo, it doesn't need to. Rosetta only emulates userspace, so it just needs to give the illusion of protections to the program.
- anyfoo 5y agoAh, in this case I took "x86 execution semantics" just as how it behaves from user space, i.e. what permissions you can set and that they behave the same from an x86 observer (no matter what shenanigans is actually going behind the scenes).
- deleted 5y ago[deleted]
- anyfoo 5y agoSorry, I don't understand what you are trying to say. Of course the CPU knows about pages and the executable bit? But there is no executable bit on a page filled with x86 code running on an ARM CPU, because the ARM CPU cannot execute that. It can only execute the translated ARM code that sits somewhere else, essentially out of sight for the x86 program.
- chrisseaton 5y ago> Sorry, I don't understand what you are trying to say. Rosetta implements x86 execution bit semantics. It does this by invalidating translated pages when the system call to set the execution bit is set. Which bit do you not understand? How do you think for example the JVM works today on Rosetta?
- anyfoo 5y ago> Which bit do you not understand? How you are disagreeing with me, then? The actual page table entries that the ARM CPU looks at will never mark a page containing x86 code as executable. x86 execution bit semantics are implemented, but on a different layer. From the ARM CPU's POV, the x86 code is always just data.
- chrisseaton 5y ago> those are not something the x86 code knows about The implementation of AMD64 is in software. It knows about page executable bits. The 'x86' code knows about them. Again, how do you think things like V8 and the JVM work on Rosetta otherwise?
- anyfoo 5y ago> The implementation of AMD64 is in software. It knows about page executable bits. The 'x86' code knows about them. Where did I claim anything else? The thing I claimed the x86 code does not know about is the pages that contain the translated ARM code, which are distinct from the pages that contain the x86 code. The former pages are marked executable in the actual page tables, the latter pages have a software executable bit in the kernel, but are not marked as such in the actual page tables. > Again, how do you think things like V8 and the JVM work on Rosetta otherwise? Did I write something confusing that gave the wrong impression? My last answer says: "x86 execution bit semantics are implemented, but on a different layer".