2016년 10월 18일 화요일

x86 Address Translation Basics

x86 Address Translation Basics

AMD-V의 Nested Paging을 이해하기 위해서 먼저 x86 Address translation에 대해 알아보자.

Virtual address는 프로그램에서 instruction과 data에 접근하기 위해 사용하는 주소이다. 이 주소로 실제 메모리 주소인 physical address에 접근하려면 먼저 address translation 과정을 거쳐야 한다. Page table walker라는 것이 page table을 이용해서 virtual address를 physical address로 바꿔준다. Page table walker는 processor hardware에 (CPU에) 구현되어 있다.

Figure 1은 long mode에서의 page table walk를 보여주고 있다. 먼저 CR3 레지스터를 보고 Page-map level-4 base address를 확인한다. 47-39 bit, 38 - 30 bit, 29 - 21 bit을 타고 타고 20 - 12 bit의 Page-table offset으로 4KB 페이지를 특정 짓고 11-0 bit 의 physical-page offset으로 정확한 physical address를 가리키고 있다.
OS는 context switch를 할때 page table's base pointer (CR3)를 업데이트 한다.

AMD-V Nested Page Tables (NPT)

 gPT는 guest virtual address를 guest physical address로 맵핑하고 nPT는 guest physical address를 system physical address(machine address)로 맵핑한다.

댓글 없음:

댓글 쓰기