VirtualBox

Changeset 87411 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Jan 25, 2021 9:50:56 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142399
Message:

VMM/HMVMX: Straight path thru VMXRestoreHostState for windows hosts, moving the read-only gdt and wrmsr bits out of the way.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMR0A.asm

    r87409 r87411  
    402402;
    403403; @returns VBox status code
    404 ; @param   f32RestoreHost x86: [ebp + 08h]  msc: ecx  gcc: edi   RestoreHost flags.
    405 ; @param   pRestoreHost   x86: [ebp + 0ch]  msc: rdx  gcc: rsi   Pointer to the RestoreHost struct.
     404; @param   f32RestoreHost   msc: ecx  gcc: edi   RestoreHost flags.
     405; @param   pRestoreHost     msc: rdx  gcc: rsi   Pointer to the RestoreHost struct.
    406406;
    407407ALIGNCODE(64)
     
    448448    and         eax, X86_SEL_MASK_OFF_RPL                       ; mask away TI and RPL bits leaving only the descriptor offset
    449449    test        edi, VMX_RESTORE_HOST_GDT_READ_ONLY | VMX_RESTORE_HOST_GDT_NEED_WRITABLE
    450     jnz         .gdt_readonly
     450    jnz         .gdt_readonly_or_need_writable
    451451    add         rax, qword [rsi + VMXRESTOREHOST.HostGdtr + 2]  ; xAX <- descriptor offset + GDTR.pGdt.
    452452    and         dword [rax + 4], ~RT_BIT(9)                     ; clear the busy flag in TSS desc (bits 0-7=base, bit 9=busy bit)
    453453    ltr         dx
    454     jmp short   .restore_fs
    455 .gdt_readonly:
    456     test        edi, VMX_RESTORE_HOST_GDT_NEED_WRITABLE
    457     jnz         .gdt_readonly_need_writable
    458     mov         rcx, cr0
    459     mov         r9, rcx
    460     add         rax, qword [rsi + VMXRESTOREHOST.HostGdtr + 2]  ; xAX <- descriptor offset + GDTR.pGdt.
    461     and         rcx, ~X86_CR0_WP
    462     mov         cr0, rcx
    463     and         dword [rax + 4], ~RT_BIT(9)                     ; clear the busy flag in TSS desc (bits 0-7=base, bit 9=busy bit)
    464     ltr         dx
    465     mov         cr0, r9
    466     jmp short   .restore_fs
    467 .gdt_readonly_need_writable:
    468     add         rax, qword [rsi + VMXRESTOREHOST.HostGdtrRw + 2]  ; xAX <- descriptor offset + GDTR.pGdtRw
    469     and         dword [rax + 4], ~RT_BIT(9)                     ; clear the busy flag in TSS desc (bits 0-7=base, bit 9=busy bit)
    470     lgdt        [rsi + VMXRESTOREHOST.HostGdtrRw]
    471     ltr         dx
    472     lgdt        [rsi + VMXRESTOREHOST.HostGdtr]                 ; load the original GDT
    473454
    474455.restore_fs:
     
    505486    mov         gs, ecx
    506487    wrgsbase    rax
    507     jmp         .restore_flags
    508 
     488
     489.restore_flags:
     490    popfq
     491
     492.restore_success:
     493    mov         eax, VINF_SUCCESS
     494%ifndef ASM_CALL64_GCC
     495    ; Restore RDI and RSI on MSC.
     496    mov         rdi, r10
     497    mov         rsi, r11
     498%endif
     499    ret
     500
     501ALIGNCODE(8)
     502.gdt_readonly_or_need_writable:
     503    test        edi, VMX_RESTORE_HOST_GDT_NEED_WRITABLE
     504    jnz         .gdt_readonly_need_writable
     505.gdt_readonly:
     506    mov         rcx, cr0
     507    mov         r9, rcx
     508    add         rax, qword [rsi + VMXRESTOREHOST.HostGdtr + 2]  ; xAX <- descriptor offset + GDTR.pGdt.
     509    and         rcx, ~X86_CR0_WP
     510    mov         cr0, rcx
     511    and         dword [rax + 4], ~RT_BIT(9)                     ; clear the busy flag in TSS desc (bits 0-7=base, bit 9=busy bit)
     512    ltr         dx
     513    mov         cr0, r9
     514    jmp         .restore_fs
     515
     516ALIGNCODE(8)
     517.gdt_readonly_need_writable:
     518    add         rax, qword [rsi + VMXRESTOREHOST.HostGdtrRw + 2]  ; xAX <- descriptor offset + GDTR.pGdtRw
     519    and         dword [rax + 4], ~RT_BIT(9)                     ; clear the busy flag in TSS desc (bits 0-7=base, bit 9=busy bit)
     520    lgdt        [rsi + VMXRESTOREHOST.HostGdtrRw]
     521    ltr         dx
     522    lgdt        [rsi + VMXRESTOREHOST.HostGdtr]                 ; load the original GDT
     523    jmp         .restore_fs
     524
     525ALIGNCODE(8)
    509526.restore_fs_using_wrmsr:
    510527    test        edi, VMX_RESTORE_HOST_SEL_FS
     
    526543    mov         ecx, MSR_K8_GS_BASE
    527544    wrmsr
    528 
    529 .restore_flags:
    530     popfq
    531 
    532 .restore_success:
    533     mov         eax, VINF_SUCCESS
    534 %ifndef ASM_CALL64_GCC
    535     ; Restore RDI and RSI on MSC.
    536     mov         rdi, r10
    537     mov         rsi, r11
    538 %endif
    539     ret
     545    jmp         .restore_flags
    540546ENDPROC VMXRestoreHostState
    541547
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette