7 ms·
Why doesn’t Windows use 64-bit virtual address space below 0x00000000`7ffe0000?
- herpderperator 4y agoWhat does the ` mean?
- muststopmyths 4y agoThat’s the convention on windows for denoting 64-bit addresses, separating the two 32bit parts with the backtick. Don’t recall why now.
- avianlyric 4y agoI assume it just makes the address easier to read. I imagine most programs don’t deal with address spaces larger than 4GB, so being able to quickly identify the lower bytes of the address when physically looking at a memory address is probably quite handy.
- dtgriscom 4y agoC++14 allows you to add apostrophes (') to numeric literals anywhere you want (presumably you do so at regular and rational intervals, but you don't have to).
- darknavi 4y agoI enjoy the short and sweet blog posts from Raymond Chen on "Why does Windows X?".
- krylon 4y agoHe is great at summing up these things in a way I can understand (most of the time, not being very experienced with Windows internals) without having the feeling he is dumbing it down, just that he is explaining it very clearly.
- tyleo 4y agoWhile this article doesn’t have it, I especially like his subtitles which are essentially a 1-line TL;DR of the content. As a recent example: Title: Instead of a C++ template parlor trick, why not just add support based on whether the header file has already been included? Subtitle: Header file inclusion order dependencies
- deleted 4y ago[deleted]
- analog31 4y agoThey need to reserve the first 2147352576 bytes for the Color Graphics Adapter display buffer.
- tadfisher 4y agoHas anyone tried loading COMMAND.COM in there? Surely CGA isn't using all that space.
- TazeTSchnitzel 4y agoTangent: on 64-bit Apple platforms, nothing is mapped in the lowest 4GiB of address space. This ensures any pointer truncated to 32 bits and dereferenced will segfault.
- CalChris 4y agoThis was only 'enforced' by the linker on x86. You could handcraft a Mach-O executable to get around it. But it is now enforced enforced by OSX on ARM. I don't see any good reason for this. My own half assed explanation is they're enforcing 32b cleanliness. It's not a very good explanation. But it's my explanation for something I don't like.
- worewood 4y agoWhen migrating 32bit apps to 64bit platforms, it's common to follow the recipe: 1. Try to recompile on 64bit without any changes 2. Realize the program does not work because the types have different sizes now 3. Cast everything on sight to types that have same size as in 32bit. 4. Now the program "works" (as in, it compiled and maybe ran but you didn't test thoroughly) This address space restrictions ensures that if you happen to cast a pointer in this way it will not work, forcing the developer to review what he's doing.
- CalChris 4y agoThis argument is similar to my enforcing 32b cleanliness. Really, that was an issue back in the 90s. But this enforcement happened with the x86_64 to ARMv8 migration, 64b to 64b. So I would like an explanation from Apple for why this now. What is their rationale?
- DHowett 4y agoThe first iPhones were AArch32, and there was likely a sizable contingent of iOS software that was written to target the only existing bitness at the time :) The same reasons GP offered still apply there. The amount of software directly ported from x86_64 to AArch64 was probably minimal.
- bunabhucan 4y agoHas anyone here ever used Windows NT on a DEC Alpha? A company in Ireland I worked for gave a mobile phone GIS demo to the Irish national phone company and Digital lent us a beefy server with two AXP CPUs (it was gonna be the future!) running windows NT. We literally pulled it on cobbled dublin streets on a a handcart to bring it to their offices.
- avidphantasm 4y agoBack around 2001, I bought a secondhand Alpha ATX mobo and for a lark installed NT 4 on it. I didn’t do much with it though.
- jamesfinlayson 4y agoWhat was the overlap of both products being commercially available? I didn't think it was too long.
- peteri 4y agoWikipedia says it was only commercially available for NT4, I do somewhere have the Dec Alpha Windows 2000 beta discs (It got killed very late in the beta).
- toast0 4y agoA friend of mine had an Alpha, and I was getting the Windows betas (I got 98se, 2000, and XP, and then nothing else). My friend was really happy to 'borrow' the win2k for alpha discs. IIRC, release candidates 1 and 2 had alpha discs, and then 3 and beyond didn't; but I might be off by one. I assume it would have shipped as part of the release if only Alpha was cancelled a couple months later.
- p_l 4y agoIIRC every RC disk had alpha binaries, only the RTM and later doesn't - because Alpha getting canned was declared in the short window between last RC and RTM, in a rather abrupt manner to everyone involved on the project.
- titzer 4y ago> No. The virtual address space starts at the 64KB boundary. You can confirm this by calling GetSystemInfo and checking the lpMinimumApplicationAddress. It will be 0x00000000`00010000. Aw, man. I recently found out there is also a similar restriction on Linux. Bummer, because I have a good use for putting code into the lower 64KB of memory (not 4KB, still want to use that for catching NPEs). My use case is a fast interpreter for bytecode. Since every bytecode handler needs an entry in the dispatch table, and I have 7--yes 7!--dispatch tables, I'd like to make their entries 2 bytes. So instead of taking 1KB each, they would take only 512B each. But alas. Another great use case is Wasm. Since the memory is a sandboxed 4GB range and only indexed into by 32-bit offsets, placing it at virtual address 0 would save an add instruction (or use of segment register) on every access.
- p_l 4y agoOn linux it depends on a sysctl parameter, and on 4kB platforms some runtimes used the fact that it was set to "one page" as a method to have very short pointers starting at address 4097 for things very often references (and which might need guard page, like NULL value). Made for some borked code with Clozure Common Lisp when people started running 64kB pagesize on PPC64, and that meant that even with minimal zero page it still was too big to map the "low memory" where CCL stuck it's NULL definition.
- messe 4y ago> Since every bytecode handler needs an entry in the dispatch table, and I have 7--yes 7!--dispatch tables, I'd like to make their entries 2 bytes. So instead of taking 1KB each, they would take only 512B each. But alas. Hmm. If the upper half of the handler addresses are the same, then why not store just the lower 2-bytes of each handler address in the dispatch table. If you're on x86, there's no add needed if the upper bytes of the register you're loading into already contain the upper half of the address, for example: mov eax, HANDLER_BASE mov ax, [edi + ebx]
- titzer 4y agoInteresting idea. I think it means using another register to permanently hold the HANDLER_BASE though? The dispatch sequence is only 4 instructions. I tried it as a delta encoding, requiring another add instruction on every dispatch, but that is an approx. 5% penalty. So I was hoping that putting it at absolute address < 64KB I could do the sequence without another add.
- cihangir 4y ago> That is a special page of memory that is mapped read-only into user mode from kernel mode, and it contains things like the current time, so that applications can get this information quickly without having to take a kernel transition. This page is at a fixed location for performance reasons. I didn't know there was a vdso-like mechanism in Windows as in Linux.
- monocasa 4y agoYeah, it's called KUSER_SHARED_DATA, and contains a lot of interesting items. https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-kuser_shared_data https://learn.microsoft.com/en-us/windows-hardware/drivers/d...
- deleted 4y ago[deleted]
- aebtebeten 4y agotl;dr several reasons, the most specific of which is "to keep linker relocs simple"
- alexklarjr 4y ago…on a long dead architecture.
- jasoneckert 4y agoI still have Windows 2000 installed on a Digital Ultimate Workstation (2x Alpha 21164). I turn it on every few years when I need a nostalgia kick ;-)
- KMag 4y agoSo sad to see Alpha die off, especially since I haven't noticed any architectures with anything like PALCode spring up since. The Alpha's firmware was essentially a hypervisor that only supported a single guest, and the OS kernel had to upcall to the firmware for any privileged operations. In particular, it would be nice to have userspace programs be able to take advantage of new/larger registers without requiring the OS kernel to support the extra CPU state. If the firmware (which presumably is available as soon as the new CPU ships) handles the context switch, then the OS kernel doesn't need an update.
- cesarb 4y agoOn the other hand, Alpha had an infamously weak memory ordering, and it dying means that we don't have to deal with that when writing software. Check Documentation/memory-barriers.txt on the Linux kernel for the gory details (recent versions are after the kernel was changed to make Alpha work somewhat more similar to other architectures; check that documentation file on older kernel versions for the full horror).
- KMag 4y agoYes, I'm familiar with the woes of the particularly weak memory model. It's mostly a problem when writing lockfree data structures, as mutex acquisition and release executed the necessary fence instructions to maintain proper happens-before relations.