On 64-bit ‘code-relocation’ How we can launch a procedure in 64-bit mode that resides in a page-frame at a high address.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: Memory Management
Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
Crafting a ‘boot time’ program How we can utilize some standard ‘real-mode’ routines that reside in the PC’s ROM-BIOS firmware.
ITEC 352 Lecture 27 Memory(4). Review Questions? Cache control –L1/L2  Main memory example –Formulas for hits.
Paging Hardware With TLB
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
CS2422 Assembly Language & System Programming January 2, 2007.
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
Memory Management (II)
Linux Vs. Windows NT Memory Management Hitesh Kumar
File System Implementation: beyond the user’s view A possible file system layout on a disk.
What is ‘bootstrapping’? The process of loading larger programs for execution than can fit within a single disk-sector.
An introduction to systems programming
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Introduction to the Intel x86’s support for “virtual” memory
A ‘protected-mode’ exploration A look at the steps needed to build segment-descriptors for displaying a message while in protected-mode.
CS 140 Lecture Notes: Virtual MemorySlide 1 Load-Time Relocation Process 1 0 ∞ Process 3 Operating System Process 6.
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
Silberschatz, Galvin and Gagne  Operating System Concepts Segmentation Memory-management scheme that supports user view of memory. A program.
Protected Mode. Protected Mode (1 of 2) 4 GB addressable RAM –( to FFFFFFFFh) Each program assigned a memory partition which is protected from.
VIRTUAL MEMORY. Virtual memory technique is used to extents the size of physical memory When a program does not completely fit into the main memory, it.
Enabling the ARM Learning in INDIA ARM DEVELOPMENT TOOL SETUP.
Paging Examples Assume a page size of 1K and a 15-bit logical address space. How many pages are in the system?
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Operating Systems Chapter 8
MIPS coding. SPIM Some links can be found such as:
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Topic 2d High-Level languages and Systems Software
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Implementation of Page Table Page table is kept in main memory Page-table base.
CE Operating Systems Lecture 14 Memory management.
1 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
9.1 Operating System Concepts Paging Example. 9.2 Operating System Concepts.
Memory Management CS Spring Overview Partitioning, Segmentation, and Paging External versus Internal Fragmentation Logical to Physical Address.
Paging Paging is a memory-management scheme that permits the physical-address space of a process to be noncontiguous. Paging avoids the considerable problem.
Memory management Ref: Stallings G.Anuradha. What is memory management? The task of subdivision of user portion of memory to accommodate multiple processes.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
Silberschatz, Galvin and Gagne  Operating System Concepts Paging Logical address space of a process can be noncontiguous; process is allocated.
Memory Management & Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
Basic Paging (1) logical address space of a process can be made noncontiguous; process is allocated physical memory whenever the latter is available. Divide.
Chapter 9: Memory Management
SLC/VER1.0/OS CONCEPTS/OCT'99
CS 140 Lecture Notes: Virtual Memory
Paging COMP 755.
Chapter 9: Virtual Memory
System Programming and administration
Background Information Text Chapter 8
143A: Principles of Operating Systems Lecture 5: Address translation
Paging Examples Assume a page size of 1K and a 15-bit logical address space. How many pages are in the system?
Paging and Segmentation
CSE 153 Design of Operating Systems Winter 2018
Virtual Memory: Concepts /18-213/14-513/15-513: Introduction to Computer Systems 17th Lecture, October 23, 2018.
CS 140 Lecture Notes: Virtual Memory
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
CS 140 Lecture Notes: Virtual Memory
Introduction to the Intel x86’s support for “virtual” memory
Lecture 3: Main Memory.
CSE 153 Design of Operating Systems Winter 2019
An introduction to systems programming
CS 140 Lecture Notes: Virtual Memory
CSE 542: Operating Systems
Instructor: Phil Gibbons
Presentation transcript:

On 64-bit ‘code-relocation’ How we can launch a procedure in 64-bit mode that resides in a page-frame at a high address

64-bit virtual address-space Invalid address range valid addresses valid addresses 0x x00007FFFFFFFFFFF 0xFFFFFFFFFFFFFFFF 0xFFFF ‘non-canonical’ 64-bit addresses positive canonical addresses negative canonical addresses (128 TeraBytes) Total number of locations having ‘canonical’ 64-bit addresses is 2 48 Bytes (= 256 TeraBytes)

The ‘canonical’ addresses In a 64-bit ‘canonical’ virtual address, the uppermost 16-bits are identical to bit 47 The number of distinct virtual addresses actually implemented is 2 48 (= 256 TB) sign-extension 64-bits 48-bits

Our ‘highcode.s’ demo We have created a demo-program which loads and executes a procedure that will reside at a very high location within the processor’s 64-bit virtual address space Some aspects of our design were shaped by limitations of our GNU software tools, and by our desire to keep the addressing ‘page-map’ tables as simple as possible

Two components Non- canonical addresses highdraw.b highcode.b 0x xFFFFFFFFC virtual address space

Subfields of 64-bit address sign-extension (16-bits) index into the page-map level4 table (9-bits) index into page-directory pointer table (9-bits) index into page-directory (9-bits) index into page-table (9-bits) offset into page frame (12-bits)

4-level page-mapping tables CR3 page-map level4 table page directory pointer tables page directories page tables page frames

Disk-partition’s layout /dev/sda … Our ‘cs686ipl.b’ boot-loader goes here (in ‘boot-sector’ of this disk-partition) The ‘highcode.b’ program-component goes here The ‘highdraw.b’ program-component goes here unused

‘ld’ handles 32-bit relocations We use a special linker-script to ‘relocate’ symbolic addresses used in ‘highdraw.s’ OUTPUT_FORMAT(binary); SECTIONS {. = 0xFFFFFFFFC ;.text : { *(.text) } =0x data : { *(.data) } = 0x bss : { *(.bss) } = 0x }

assembly commands Assemble the ‘highcode.s’ component: $ as highcode.s –o highcode.o Assemble the ‘highdraw.s’ component: $ as highdraw.s -o highdraw.o

Linker commands Link the ‘highcode.o’ component: $ ld highcode.o -T ldscript -o highcode.b Assemble the ‘highdraw.s’ component: $ ld highdraw.o -T hiscript -o highdraw.b

Installation commands Install the ‘highcode.b’ component: $ dd if=highcode.b of=/dev/sda4 seek=1 Assemble the ‘highdraw.s’ component: $ dd if=highdraw.b of=/dev/sda4 seek=128

Addition to ‘cs686ipl.s’ We made a small but useful enhancement to our ‘cs686ipl.s’ boot-loader program, so subsequent program components will not need to repeat the search for the starting Logical Block Address of the disk-partition That block-number is left in register EBX, where the next component can find it It’s also written to the ROM-BIOS ‘mailbox’

In-class exercise After you have successfully downloaded, assembled, linked, installed, and executed the ‘highcode.s’ demo-program, see if you can modify it so that its ‘highdraw’ code- component will reside at an even higher virtual address, namely: 0xFFFFFFFFFFE00000 instead of: 0xFFFFFFFFC