Download presentation
Presentation is loading. Please wait.
Published byUmberto Montanari Modified over 5 years ago
1
Win64 Design Jeff Havens Architect NT Base Systems Microsoft Corporation
2
Areas Of Focus Image format Firmware Memory management Problem areas
General code
3
Image Format PE 32+ Image size limited to two gigabytes
Base of image is 64 bits All DLL code is position independent on IA-64 Stack and Heap have 64 bit sizes Import Address table entries are 64 bits Images cannot cross two gigabytes boundary
4
Memory Management Major redesign Three level page tables Self mapping
Virtual page numbers are 64 bits - log2(PAGE_SIZE) Page table entries are 64 bits
5
Memory Management IA-64 Currently 16 kilobyte page size
Two sets of page tables, system/user One system root page table One user root page table per process 248 = 2 * 211 * 211 * 211 * 214 User page tables stored in user address space LOWEST_SYSTEM_ADDRESS > 0
6
Memory Management System Areas
Four terabyte kernel One terabyte system cache Eight gigabyte HyperSpace 128 gigabyte paged pool 128 gigabyte System PTE space for kernel threads, etc. 128 gigabyte non-paged pool
7
IA-64 HAL Issues One HAL ACPI only One TLB domain No bus lock support
PNP drivers only
8
Driver Issues Physical addresses > four gigabytes
Use Mm64BitPhysicalAddresses to determine if 64 bit addressing is needed Use Dma64BitAddresses in DEVICE_DESCRIPTION to indicate that 64 bit addressing is supported The information field in the IoStatus block is a ULONG_PTR The parameters in the IRP stack locations are ULONG_PTR No sandbox addressing
9
Win32/Win64 RPC Common MIDL compiler for all platforms
RPC handles pointer size issues For porting the XXX_PTR types are supported RPC handles Context and Binding handles are not a problem Remoted handles such as HGLOBAL, HBITMAP, HPALETTE, HMETAFILE, HENHMETAFILE, and HMETAFILEPICT are also OK
10
XXX_PTR MIDL supports the XXX_PTR types such as ULONG_PTR and INT_PTR
Import “basetsd.h” Values are truncated when sent to a 32-bit client or server Values are extended appropriately when received from a 32-bit client Should only be used for legacy or in-proc applications
11
Cookie Pointers Cookie pointers are pointers which are passed as a DWORD over RPC DWORD_PTR cannot be used to solve this problem context_handle solves this problem but that changes the wire format Use [call_as]attribute to insert a 64-bit to 32-bit mapper
12
IA32 Internals Thunking is done at the “int 2e” system call interface
Thunks for ~800 interfaces will be developed Syscall interfaces are well defined, stable, and types are easily marshaled IA32 binaries are run all the way up to the int 2e instruction in ntdll.dll, user32.dll, and gdi32.dll
13
IA32 Internals IA32 process has stock IA32 versions of most DLLs kernel32.dll, mfc… DLLs like user32, gdi32, ntdll that include system call int 2e instructions will be slightly altered At the syscall thunk, we marshal IA32 arguments into Win64 arguments Structures that contain pointers, or “OUT” pointers are the only difficult part of this process (32-bit versus 64-bit) Instance data in the IA32 dlls requires no special attention
14
General Code Changes Cast pointers to PCHAR for +/-
ptr = ((PVOID) (PCHAR) ptr + pageSize); Cast pointer to LONG_PTR for masking ptr = (PVOID) ((LONG_PTR) ptr & -8); ~((UINT64) (PAGE_SIZE - 1)) != (UINT64) ~(PAGE_SIZE - 1) Replace region sizes with SIZE_T sizeof( P1 - P2 ) == sizeof(ptrdiff_t) == 8 Use %i to print xxx_PTR
15
Porting Functions Defined in <basetsd.h> HandleToLong()
LongToHandle() PonterToUlong()
16
Danger Areas All assembly code
Explicit and implicit unions with pointers Data structures stored on disk Security descriptors Code which uses the high address bit Functions with pointers as out parameters BOOL GetBuf( int fd, PCHAR *buf); Code which deals with region sizes
17
Danger Areas Piecemeal size allocations: struct foo {
DWORD NumberOfPointers; PVOID Pointers[1]; } xx; Wrong: malloc(sizeof(DWORD)+100*sizeof(PVOID)); Correct: malloc(offsetof(struct foo, Pointers) +100*sizeof(PVOID));
18
Call To Action Find problem areas Clean up code as part of development
Start to design them out of system Clean up code as part of development Use preliminary Win64 SDK Use types defined in <basetsd.h> Ensure plug-in interfaces are RPCable Make COM objects runnable out of process Consider ways to use the larger address space and higher performance
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.