CS 686: Special Topic: Intel EM64T and VT Extensions (Spring 2007)
Tue-Thu 7:30pm-9:15pm (Room HRN-235)
Instructor:
Allan Cruse
cruse@usfca.edu
Phone: (415) 422-6562
Office: 212 Harney Science Center
Office Hours: (see my homepage)
Many companies do an excellent job of providing information
to help customers use their
products... but in the end there's
no substitute for real-life experiments: putting together the
hardware, writing the program code, and watching what happens
when the code executes.
Then when the result isn't as expected -- as
it often isn't -- it means trying something else
or searching
the documentation for clues.
-- Jan Axelson, author, Lakeview Research (1998)
Course Synopsis:
This course explores some recently implemented extensions
to the world's most popular microprocessor architecture,
dubbed EM64T ("Extended Memory 64-bit Technology", also
known as "Intel64") for Intel's enlarged (e.g., up to 1TB)
virtual memory address-space with 64-bit integer arithmetical
capabilities, eight extra 'general-purpose' registers, and
VT-x ("Virtualization Technology") for
the ubiquitous Intel x86 family of server, workstation, and
laptop CPUs.
Planned course-topics include:
- Programming the PC's serial UART (for remote-access to new machines)
- Review of IA-32 architectural features utilized in application programming
- Support for multitasking operating systems: privilege-levels and protection
- Constructing the processor's 2-level, 3-level, and 4-level page-map tables
- New concepts of "canonical" memory-addresses and "compatibility" mode
- Enabling and then activating Intel's Extended Memory 64-bit Technology
- Model-Specific Registers (MSRs) and the new fast system-call mechanism
- Responding to peripheral-device interrupts, and to processor exceptions
- Multiple processors and the Advanced Programmable Interrupt Controller
- Initializing and querying the CPU's Virtual Machine Control Structures
- Using Linux kernel modules to provide the interface to a "Virtual Machine"
Throughout the course small software-component prototypes will be
written using the GNU/Linux program development
tools (including
assemblers and C/C++ compilers). The course is open to graduate
students in computer science (and to
qualified undergraduates or
non-degree students in cases where the Instructor has granted permission).
Students are assumed to be familiar with Linux or UNIX, and with
programming in C/C++, and to be acquainted with the
Intel x86
processor family's registers, instruction-set, and assembly language.
The site for meetings of this class will be
the University's
Michael D. Kudlick interactive computer classroom
(Room 235, Harney Science Center) which affords
convenient opportunities
for combining formal instruction with "hands-on" programming exercises.
This endowed facility,
a gift of USF alumnus
Alfred S. Chuang ('82),
opened in Fall 2002 and regularly is upgraded: students who enroll in this
semester's class will have access to new Core-2 Duo platforms
that implement the Intel EM64T and VT technologies.
Learning Outcomes:
- You will deepen your knowledge of standard 32-bit Intel Architectures.
- You will become acquainted with Intel's Dual-Core 64-bit capabilities.
- You will understand how CPU hardware features support "virtual" memory.
- You will get some practice in implementing a Virtual Machine Manager.
- You will increase your proficiency with using C and assembler language.
- You will acquire a background for understanding newest-generation CPUs.
- You will lay a foundation for pursuing some additional career options.
Textbook and Reference:
Intel Architecture Software Developer's Manual (Intel Corporation):
Volume I: Basic Architecture
Volume II: Instruction-Set Reference
Volume III: System Programmer's Reference
Resources
Readings
- For Thu, Jan 25: Read three sections in
PC16550D Serial UART: "General Description", "Features", and "Registers"
and browse
The Serial UART online tutorial by Lammert Bies
- For Tue, Jan 30: Intel Manual (Volume I):
Chapter 1 "About This Manual" and
Chapter 2 "IA-32 Intel Architecture".
- For Thu, Feb 01: Intel Manual (Volume I):
Chapter 3 "Basic Execution Environment".
- For Tue, Feb 06: Intel Manual (Volume I):
Chapter 4 "Data Types" and
Chapter 5 "Instruction Set Summary".
- For Thu, Feb 08: Intel Manual (Volume I):
Chapter 6 "Procedure Calls, Interrupts, and Exceptions".
- For Tue, Feb 13: Intel Manual (Volume I):
Chapter 7 "Programming with General Purpose Instructions"
and Chapter 13 "Input/Output"
- For Thu, Feb 15: Intel Manual (Volume I):
Chapter 14 "Processor Identification and Feature Determination".
- For Tue, Feb 20: No new reading assignment -- University Holiday.
- For Tue, Feb 22: No new reading assignment -- Midterm Exam I.
- For Tue, Feb 27: Intel Manual (Volume III):
Chapter 1 "About this Manual" and
Chapter 2 "System Architecture Overview"
- For Thu, Mar 01: Intel Manual (Volume III):
Chapter 3 "Protected-Mode Memory Management"
- For Tue, Mar 06 Intel Manual (Volume III):
Chapter 4 "Protection"
- For Thu, Mar 08: Intel Manual (Volume III):
Chapter 5 "Interrupt and Exception Handling"
- For Tue-Thu, Mar 13-15: No new reading assignments -- Spring Recess
- For Tue, Mar 20 Intel Manual (Volume III):
Chapter 6 "Task Management" and
Chapter 7 "Multiple-Processor Management"
- For Thu, Mar 22 Intel Manual (Volume III):
Chapter 8 "Advanced Programmable Interrupt Controller (APIC)"
- For Tue, Mar 27 Intel Manual (Volume III):
Chapter 9 "Processor Management and Initialization"
- For Thu, Mar 29 Intel Manual (Volume III):
Chapter 15 "8086 Emulation"
- For Tue, Apr 03: No new reading assignment -- Midterm Exam II.
- For Thu, Apr 05: No new reading assignment -- University Closes at 4pm
for Good Friday.
- For Tue, Apr 10: Intel Manual (Volume III):
Chapter 16 "Mixing 16-bit and 32-bit Code"
- For Thu, Apr 12: Intel Manual (Volume III):
Chapter 19 "Introduction to Virtual-Machine Extensions"
- For Tue, Apr 17: Intel Manual (Volume III):
Chapter 20 "Virtual-Machine Control Structures"
- For Thu, Apr 19: Intel Manual (Volume III):
Chapter 21 "VMX Non-Root Operation"
- For Tue, Apr 24: Intel Manual (Volume III):
Chapter 22 "VM Entries"
- For Thu, Apr 26: Intel Manual (Volume III):
Chapter 23 "VM Exits"
- For Tue, May 01: Intel Manual (Volume III):
Chapter 25 "Virtual-Machine Monitor Programming Considerations"
- For Thu, May 03: Intel Manual (Volume III):
Chapter 26 "Virtualization of System Resources"
- For Tue, May 08: Intel Manual (Volume III):
Chapter 27 "Handling Boundary Conditions in a Virtual-Machine Monitor"
- For Thu, May 10: No new reading assignment -- review for Final Exam
Systems Software
- Utility program: iopl3.cpp
(a tool by Alex Fedosov that lets user-programs do direct I/O)
- Utility program: ljpages.cpp
(a tool that submits your program source to a laser printer)
- Linker script: ldscript
allows the GNU linker 'ld' to produce a 'binary-format' executable
- Utility program: fileview.cpp
(a navigation tool for viewing the contents of binary files)
- Utility program: dump.cpp
(a tool that displays the contents of any file in hex and ascii)
- Development tool: rxrender.cpp
it polls the UART and prints any characters it receives
<--- revised on 3/1/2007
- Development tool: newapp64.cpp
creates 'boilerplate' code for future boot-time demos
- Utility program: mmake.cpp
(a tool you can use for compiling Linux 2.6 kernel modules)
- Device-driver: dram.c
needed to allow reading from the workstation's physical memory
- Development tool: newproc.cpp
builds the skeleton for an LKM that creates a '/proc' file
- Kernel-module: vmxmsrs.c
lets users see virtualization capabilities on x86_64 platforms
Handouts
- 0203-686-01: Course syllabus (PDF)
- lesson01.ppt (Powerpoint Slides)
- Demo program: testuart.cpp
uses 'loopback' mode to illustrate programming of the serial UART
- Demo programs: uartecho.cpp
and trycable.cpp
for checking that your null-modem cable works
- lesson02.ppt (Powerpoint Slides)
- Demo program: feedback.s
shows how you can program the UART using Linux assembly language
- lesson03.ppt (Powerpoint Slides)
- Demo program: eflags.s
shows the initial contents of the EFLAGS register as a 32-bit binary integer
- Exercise solution: gdtr.s
shows one way to modify 'eflags.s' so it shows the 48-bit value from GDTR
- lesson04.ppt (Powerpoint Slides)
- Demo program: typesize.cpp
shows the widths (in bytes) of scalar data-types supported by C/C++
- lesson05.ppt (Powerpoint Slides)
- Demo program: trycpuid.s
shows how to use the CPUID instruction in an assembly language program
- Demo program: usecpuid.cpp
shows how you can use 'inline' assembly language in a C++ application
- Demo program: cpuid.cpp
displays the processor's vendor-identification and its 'features' information
- lesson06.ppt (Powerpoint Slides)
- Demo program: bootdemo.s
illustrates programming requirements for a real-mode 'boot-sector' program
- lesson07.ppt (Powerpoint Slides)
- Demo program: finalpte.s
reads the Master Boot Record and shows its final Partition-Table Entry
- Demo program: cs686ipl.s
a 'boot-loader' that launches binary-executables from our disk-partition
<--- revised on 03/22/2007
- Demo program: controls.s
this program displays the cpu's control registers in hexadecimal format
- lesson08.ppt (Powerpoint Slides)
- Demo program: pagedemo.s
shows assembly-time creation of page-mapping tables for protected-mode
- lesson09.ppt (Powerpoint Slides)
- Demo program: inandout.s
takes the processor from 'real-mode' to '64-bit mode' (and back again)
- Demo program: showregs.s
which runs under Linux x86_64 and shows general-purpose registers
- lesson10.ppt (Powerpoint Slides)
- Demo program: tryisr32.s
it illustrates the use of an Interrupt Service Routine in 'protected-mode'
<--- revised on 03/16/2007
- Exercise solution: tryisr64.s
modifies 'tryisr32.s' so that its interrupt-handler executes 64-bit code
- lesson11.ppt (Powerpoint Slides)
- Demo program: emitinfo.s
has a protected-mode interrupt-handler that uses the null-modem cable
- lesson12.ppt (Powerpoint Slides)
- Demo program: tryring3.s
shows how the CPU accomplishes privilege-level transitions in 64-bit mode
- lesson13.ppt (Powerpoint Slides)
- Demo program: activity.s
it produces a dynamic display of all interrupt-activity at boot-time
- Demo program: activity.cpp
shows a similar display of interrupt-activity under the Linux OS
- Kernel module: activity.c
this driver is needed for running the Linux 'activity.cpp' application
- Demo program: showgdt.cpp
it shows Global Descriptors used by Linux (if 'dram.ko' is installed)
- Demo program: showidt.cpp
it shows all Interrupt Descriptors used by 64-bit Linux (on 'anchor')
- lesson14.ppt (Powerpoint Slides)
- Demo program: hangdemo.s
to discover why some demos 'hang' during a return to real-mode
- lesson15.ppt (Powerpoint Slides)
- Demo program: highcode.s
loads and executes 64-bit code from a very high virtual memory address
- Demo program: highdraw.s
here is our example-code that gets executed by the 'highcode.s' demo
- Linker script: hiscript this linker-script
is used to 'relocate' all the virtual-addresses in 'highdraw.o'
- Programmer commentary: highcode.txt
explaining how the various pieces of this demo fit together
- lesson16.ppt (Powerpoint Slides)
- Demo program: fastcall.s
to demonstrate usage of the EM64T 'syscall' and 'sysret' instructions
- Exercise solution: highvram.s
shows one possible solution to the Question V on Midterm Exam II
- lesson17.ppt (Powerpoint Slides)
- Kernel-module: vmxmsrs.c
lets users see virtualization capabilities on x86_64 platforms
<--- revised on 7/21/2008
- lesson18.ppt (Powerpoint Slides)
- Demo program: vm86demo.s
it executes a 'real-mode' procedure in Virtual-8086 emulation mode
- Exercise solution: vm86uart.s
transmits a message-string via the serial-uart in Virtual-8086 mode
- lesson19.ppt (Powerpoint Slides)
- Demo program: vm86trap.s
illustrating the 'trap-and-emulate' concept (important for virtualization)
<--- modified on 1/22/2008
- lesson20.ppt (Powerpoint Slides)
- Demo program: vmxstep1.s
implements the 'Guest' component of our planned VMX demo-program
<-- modified on 7/13/2007
- Test program: trystep1.s
(this is 'throwaway' code -- just a 'testbed' for our 'vmxstep1.s' component)
- Demo program: queryA20.s
this will check to see if the A20 address-line is enabled at boot-time
- Demo program: vmxstep2.s
implements (partially) the 'Host' component of our planned VMX demo
<-- modified on 7/13/2007
- Exercise solution: tryvmxon.s
shows working code for our in-class exercise on executing 'vmxon'
- lesson21.ppt (Powerpoint Slides)
- Demo program: vmxstep3.s
implements data for the 'Control' component of our planned VMX demo
- Demo program: vmxdemo.s
this is the initialization launchpad for our promised VMX demo-program
- lesson22.ppt (Powerpoint Slides)
<-- slides added on 4/27/2007
- Exercise notes: excerpt.s
to implement "reflecting" of external interrupts back to Virtual-8086 mode
- Files for our in-class VMX-demo debugging exercise:
intstep1.s,
intstep2.s,
intstep3.s,
intdemo.s
- lesson23.ppt (Powerpoint Slides)
- Kernel module: fsandgs.c
lets users view the MSRs associated with FS and GS in 64-bit mode
<--- revised on 7/21/2008
- lesson24.ppt (Powerpoint Slides)
<-- slide added on 5/4/20007
- Demo program: int0x11.s
executes the BIOS 'Equipment-Check' interrupt-handler in real-mode
- Kernel module: linuxvmm.c
this is an initial device-driver prototype for our '/dev/vmm' device-file
<--- revised on 7/21/2008
- Demo program: tryoutpc.cpp
written for testing the functions in our 'linuxvmm.c' device-driver
<-- modified on 5/4/2007
- Header files: machine.h and
myvmx.h
needed to compile our 'linuxvmm.c' and 'tryoutpc.cpp' files
- lesson25.ppt (Powerpoint Slides)
- Kernel module: inject08.c
modifies our 'linuxvmm.c' driver so it 'injects' an event into its guest VM
<-- modified on 7/3/2008
- Demo program: seeevent.cpp
shows us the effect of the event-injection performed by 'inject08.c'
- lesson26.ppt (Powerpoint Slides)
- Kernel module: ioapic.c
lets users view current register-values in the memory-mapped I/O-APIC
<--- revised on 7/21/2008
- Exam question: finished.s
needs a few additions to its .data section for its .text section to work
- Kernel module: nmiexits.c
modifies our 'linuxvmm.c' driver so host handles all asychronous events
<--- revised on 7/21/2008
- Demo program: trydelay.cpp
for testing our 'nmiexits.ko' driver (and counting the interrupts handled)
- Demo program: tryvideo.cpp
proves graphics mode-setting can execute in a VM under Linux x86_64
- Kernel module: vram.c
driver for graphics-processor on our 'anchor' machines (needed by 'tryvideo')
- Demo program: tryEM64T.s
additional boot-time program showing use of '.data' and '.bss' sections
<-- posted on 7/14/2008
- Kernel module: newvmm64.c
reimplements our earlier Virtual Machine Manager device-driver module
<-- posted on 7/30/2008
- Demo program: e820info.cpp
executes 16-bit code within a Virtual Machine using our 'newvmm64.c'
<-- posted on 7/30/2008
- Header files: machine.h and
myvmx.h
needed to compile our 'newvmm64.c' and 'e820info.cpp' files
Announcements
- Enrolled students may join the class mailing-list
here
- Midterm Exam 1: Thursday, February 22, 7:30pm
- project1: Due 7:30pm Tuesday, 20 March 2007
- Midterm Exam 2: Tuesday, April 3, 7:30pm
- FINAL EXAMINATION: Tuesday, 15 May 2007, 7:30pm
Last updated on 07/30/2008