AMD SVM
syuu1228 from   @livedoor
SVM
AMD

Intel-VT

VMM




qemu
↑
SVM
Ring                  Host/Guest



Guest

DMA             Host/Guest


Guest
Guest


Tagged TLB


Nested Paging
Host


Guest

VMM

          ex:
Guest

VMCB       VMRUN           Guest
 VMCB   Guest


Host                            ex:
                       Host
  ...
Host             Guest


       Guest   VMRUN



λ...           #VMEXIT




Host                     #VMEXIT   VMRUN
VMCB
Virtual Machine Control Block


 VM            VMCB

4KB aligned    4KB         1



Control area

Guest   CPU       ...
Control Area             (1)
            on/off bit

               R/W




        ,




  I/O

  MSR
Control Area          (2)
 I/O Permissons Map
 IO



 MSR Permissons Map
 MSR



 Time stamp counter
 RDTSC, RDTSCP
Control Area                              (3)
 TLB       , Guest   ASID(TLB   tag   )




 #VMEXIT

 Nested Paging

 Event...
Save state area
                          RIP,RSP,RAX
ES,CS,SS,DS,FS,GS
                          STAR,LSTAR,CSTAR
GDTR,LD...
…

Save state area



  Guest
  (RBX,RCX,RDX,RSI,RDI,RBI)

  Host            (!!!!)
…
Guest
	   	   "mov   %c[rbx](%[svm]),   %%ebx   nt"           ※kvm-6
	   	   "mov   %c[rcx](%[svm]),   %%ecx   nt"
	   	...
Host



	   __asm __volatile (                                  ※kvm-6
	   	 "push %%ebx; push %%ecx; push %%edx;"
	   	 "...
Host




 MSR,FS,GS,LDT,CR2,DR0-3,DR6-7,TR
SVM
VM_HSAVE_PA on MSR
SVM             MSR

Host

VMRUN/#VMEXIT




  CS,SS,RIP,RSP,CR0,CR4,EFER,IDTR,GDTR
/* Enter guest mode */               ※kvm-6
	   	   "push %%eax nt"
	   	   "mov %c[vmcb](%[svm]), %%eax nt"
	   	   SVM_V...
VMLOAD/VMSAVE


                                       VMRUN/#VMEXIT


CS,RIP,RFLAGS,RAX,SS,RSP,CR0,CR2-4,EFER,IDTR,GDTR,E...
Host
Host
Guest
Guest                VMLOAD)
Host           (VMRUN)
Guest           (VMRUN)
 Guest   !!!
Guest           (...
AMD SVMってなあに
Upcoming SlideShare
Loading in …5
×

AMD SVMってなあに

2,412 views

Published on

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,412
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
22
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • AMD SVMってなあに

    1. 1. AMD SVM syuu1228 from @livedoor
    2. 2. SVM AMD Intel-VT VMM qemu ↑
    3. 3. SVM Ring Host/Guest Guest DMA Host/Guest Guest Guest Tagged TLB Nested Paging
    4. 4. Host Guest VMM ex:
    5. 5. Guest VMCB VMRUN Guest VMCB Guest Host ex: Host AMD #VMEXIT Host #VMEXIT VMRUN
    6. 6. Host Guest Guest VMRUN λ... #VMEXIT Host #VMEXIT VMRUN
    7. 7. VMCB Virtual Machine Control Block VM VMCB 4KB aligned 4KB 1 Control area Guest CPU Save state area
    8. 8. Control Area (1) on/off bit R/W , I/O MSR
    9. 9. Control Area (2) I/O Permissons Map IO MSR Permissons Map MSR Time stamp counter RDTSC, RDTSCP
    10. 10. Control Area (3) TLB , Guest ASID(TLB tag ) #VMEXIT Nested Paging Event Injection Guest LBR LBR Last Branch Record)AMD64
    11. 11. Save state area RIP,RSP,RAX ES,CS,SS,DS,FS,GS STAR,LSTAR,CSTAR GDTR,LDTR,IDTR SFMASK TR KernelGsBase CPL SYSENTER_CS,SYSENTER CR0,CR2,CR3,CR4 _ESP,SYSENTER_EIP DR6,DR7 PAT RFLAGS LBR registers RBX
    12. 12. … Save state area Guest (RBX,RCX,RDX,RSI,RDI,RBI) Host (!!!!)
    13. 13. … Guest "mov %c[rbx](%[svm]), %%ebx nt" ※kvm-6 "mov %c[rcx](%[svm]), %%ecx nt" "mov %c[rdx](%[svm]), %%edx nt" "mov %c[rsi](%[svm]), %%esi nt" "mov %c[rdi](%[svm]), %%edi nt" "mov %c[rbp](%[svm]), %%ebp nt" /* Enter guest mode */ "push %%eax nt" "mov %c[vmcb](%[svm]), %%eax nt" SVM_VMLOAD "nt" SVM_VMRUN "nt" SVM_VMSAVE "nt" "pop %%eax nt" /* Save guest registers, load host registers */ "mov %%ebx, %c[rbx](%[svm]) nt" "mov %%ecx, %c[rcx](%[svm]) nt" "mov %%edx, %c[rdx](%[svm]) nt" "mov %%esi, %c[rsi](%[svm]) nt" "mov %%edi, %c[rdi](%[svm]) nt" "mov %%ebp, %c[rbp](%[svm]) nt" mov ;)
    14. 14. Host __asm __volatile ( ※kvm-6 "push %%ebx; push %%ecx; push %%edx;" "push %%esi; push %%edi; push %%ebp;" "pop %%ebp; pop %%edi; pop %%esi;" "pop %%edx; pop %%ecx; pop %%ebx; nt" push/pop
    15. 15. Host MSR,FS,GS,LDT,CR2,DR0-3,DR6-7,TR
    16. 16. SVM VM_HSAVE_PA on MSR SVM MSR Host VMRUN/#VMEXIT CS,SS,RIP,RSP,CR0,CR4,EFER,IDTR,GDTR
    17. 17. /* Enter guest mode */ ※kvm-6 "push %%eax nt" "mov %c[vmcb](%[svm]), %%eax nt" SVM_VMLOAD "nt" SVM_VMRUN "nt" SVM_VMSAVE "nt" "pop %%eax nt" VMRUN
    18. 18. VMLOAD/VMSAVE VMRUN/#VMEXIT CS,RIP,RFLAGS,RAX,SS,RSP,CR0,CR2-4,EFER,IDTR,GDTR,ES,DS,DR6-7,CPL →VMLOAD/VMSAVE FS,GS,TR,LDTR,KernelGsBase,STAR,LSTAR,CSTAR,SFMASK,SYSENTER_CS,SY SENTER_ESP,SYSENTER_EIP KVM VMLOAD→VMRUN→VMSAVE
    19. 19. Host Host Guest Guest VMLOAD) Host (VMRUN) Guest (VMRUN) Guest !!! Guest (#VMEXIT) Host (#VMEXIT) Guest (VMSAVE) Guest Host Host

    ×