VirtualBox

Changeset 87403 in vbox


Ignore:
Timestamp:
Jan 23, 2021 4:11:18 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142391
Message:

iprt/asm-amd64-x86.h: Added ASMGetFSBase, ASMSetFSBase, ASMGetGSBase and ASMSetGSBase.

Location:
trunk
Files:
2 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm-amd64-x86.h

    r87402 r87403  
    8484#  pragma intrinsic(__rdtscp)
    8585# endif
     86# if defined(RT_ARCH_AMD64) && RT_INLINE_ASM_USES_INTRIN >= RT_MSC_VER_VS2015 /*?*/
     87#  pragma intrinsic(_readfsbase_u64)
     88#  pragma intrinsic(_readgsbase_u64)
     89#  pragma intrinsic(_writefsbase_u64)
     90#  pragma intrinsic(_writegsbase_u64)
     91# endif
    8692#endif
    8793
     
    409415# endif
    410416
     417#ifdef RT_ARCH_AMD64
     418
     419/**
     420 * Get the FS base register.
     421 * @returns FS base address.
     422 */
     423#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < RT_MSC_VER_VS2015 /*?*/
     424DECLASM(uint64_t) ASMGetFSBase(void);
     425#else
     426DECLINLINE(uint64_t) ASMGetFSBase(void)
     427{
     428# if RT_INLINE_ASM_USES_INTRIN >= RT_MSC_VER_VS2015
     429    return (uint64_t)_readfsbase_u64();
     430# elif RT_INLINE_ASM_GNU_STYLE
     431    uint64_t uFSBase;
     432    __asm__ __volatile__("rdfsbase %0\n\t" : "=r" (uFSBase));
     433    return uFSBase;
     434# endif
     435}
     436# endif
     437
     438
     439/**
     440 * Set the FS base register.
     441 * @param   uNewBase    The new base value.
     442 */
     443#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < RT_MSC_VER_VS2015 /*?*/
     444DECLASM(void) ASMSetFSBase(uint64_t uNewBase);
     445#else
     446DECLINLINE(void) ASMSetFSBase(uint64_t uNewBase)
     447{
     448# if RT_INLINE_ASM_USES_INTRIN >= RT_MSC_VER_VS2015
     449    _writefsbase_u64(uNewBase);
     450# elif RT_INLINE_ASM_GNU_STYLE
     451    __asm__ __volatile__("wrfsbase %0\n\t" : : "r" (uNewBase));
     452# endif
     453}
     454# endif
     455
     456#endif /* RT_ARCH_AMD64 */
    411457
    412458/**
     
    432478}
    433479#endif
     480
     481#ifdef RT_ARCH_AMD64
     482
     483/**
     484 * Get the GS base register.
     485 * @returns GS base address.
     486 */
     487#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < RT_MSC_VER_VS2015 /*?*/
     488DECLASM(uint64_t) ASMGetGSBase(void);
     489#else
     490DECLINLINE(uint64_t) ASMGetGSBase(void)
     491{
     492# if RT_INLINE_ASM_USES_INTRIN >= RT_MSC_VER_VS2015
     493    return (uint64_t)_readgsbase_u64();
     494# elif RT_INLINE_ASM_GNU_STYLE
     495    uint64_t uGSBase;
     496    __asm__ __volatile__("rdgsbase %0\n\t" : "=r" (uGSBase));
     497    return uGSBase;
     498# endif
     499}
     500# endif
     501
     502
     503/**
     504 * Set the GS base register.
     505 * @param   uNewBase    The new base value.
     506 */
     507#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < RT_MSC_VER_VS2015 /*?*/
     508DECLASM(void) ASMSetGSBase(uint64_t uNewBase);
     509#else
     510DECLINLINE(void) ASMSetGSBase(uint64_t uNewBase)
     511{
     512# if RT_INLINE_ASM_USES_INTRIN >= RT_MSC_VER_VS2015
     513    _writegsbase_u64(uNewBase);
     514# elif RT_INLINE_ASM_GNU_STYLE
     515    __asm__ __volatile__("wrgsbase %0\n\t" : : "r" (uNewBase));
     516# endif
     517}
     518# endif
     519
     520#endif /* RT_ARCH_AMD64 */
    434521
    435522
  • trunk/src/VBox/Runtime/Makefile.kmk

    r87235 r87403  
    239239        common/asm/ASMGetLDTR.asm \
    240240        common/asm/ASMGetSegAttr.asm \
    241         common/asm/ASMGetTR.asm
     241        common/asm/ASMGetFSBase.asm \
     242        common/asm/ASMSetFSBase.asm \
     243        common/asm/ASMGetGSBase.asm \
     244        common/asm/ASMSetGSBase.asm \
     245        common/asm/ASMGetTR.asm \
    242246
    243247#
  • trunk/src/VBox/Runtime/common/asm/ASMGetFSBase.asm

    r87387 r87403  
    11; $Id$
    22;; @file
    3 ; IPRT - ASMGetTR().
     3; IPRT - ASMGetFSBase().
    44;
    55
    66;
    7 ; Copyright (C) 2006-2020 Oracle Corporation
     7; Copyright (C) 2006-2021 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828;* Header Files                                                                *
    2929;*******************************************************************************
     30%define RT_ASM_WITH_SEH64
    3031%include "iprt/asmdefs.mac"
    3132
     
    3334
    3435;;
    35 ; Get the TR register.
    36 ; @returns TR.
     36; Get the FS base register.
     37; @returns FS base
    3738;
    38 BEGINPROC_EXPORTED ASMGetTR
    39         str     ax
    40         movzx   eax, ax
     39BEGINPROC_EXPORTED ASMGetFSBase
     40        SEH64_END_PROLOGUE
     41        rdfsbase rax
    4142        ret
    42 ENDPROC ASMGetTR
     43ENDPROC ASMGetFSBase
    4344
  • trunk/src/VBox/Runtime/common/asm/ASMGetGSBase.asm

    r87387 r87403  
    11; $Id$
    22;; @file
    3 ; IPRT - ASMGetTR().
     3; IPRT - ASMGetGSBase().
    44;
    55
    66;
    7 ; Copyright (C) 2006-2020 Oracle Corporation
     7; Copyright (C) 2006-2021 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828;* Header Files                                                                *
    2929;*******************************************************************************
     30%define RT_ASM_WITH_SEH64
    3031%include "iprt/asmdefs.mac"
    3132
     
    3334
    3435;;
    35 ; Get the TR register.
    36 ; @returns TR.
     36; Get the GS base register.
     37; @returns GS base
    3738;
    38 BEGINPROC_EXPORTED ASMGetTR
    39         str     ax
    40         movzx   eax, ax
     39BEGINPROC_EXPORTED ASMGetGSBase
     40        SEH64_END_PROLOGUE
     41        rdgsbase rax
    4142        ret
    42 ENDPROC ASMGetTR
     43ENDPROC ASMGetGSBase
    4344
  • trunk/src/VBox/Runtime/common/asm/ASMSetFSBase.asm

    r87387 r87403  
    11; $Id$
    22;; @file
    3 ; IPRT - ASMGetTR().
     3; IPRT - ASMSetFSBase().
    44;
    55
    66;
    7 ; Copyright (C) 2006-2020 Oracle Corporation
     7; Copyright (C) 2006-2021 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828;* Header Files                                                                *
    2929;*******************************************************************************
     30%define RT_ASM_WITH_SEH64
    3031%include "iprt/asmdefs.mac"
    3132
     
    3334
    3435;;
    35 ; Get the TR register.
    36 ; @returns TR.
     36; Set the FS base register.
     37; @param    uNewBase    msc:rcx gcc:rdi     New FS base value.
    3738;
    38 BEGINPROC_EXPORTED ASMGetTR
    39         str     ax
    40         movzx   eax, ax
     39BEGINPROC_EXPORTED ASMSetFSBase
     40        SEH64_END_PROLOGUE
     41%ifdef ASM_CALL64_MSC
     42        wrfsbase rcx
     43%else
     44        wrfsbase rdi
     45%endif
    4146        ret
    42 ENDPROC ASMGetTR
     47ENDPROC ASMSetFSBase
    4348
  • trunk/src/VBox/Runtime/common/asm/ASMSetGSBase.asm

    r87387 r87403  
    11; $Id$
    22;; @file
    3 ; IPRT - ASMGetTR().
     3; IPRT - ASMSetGSBase().
    44;
    55
    66;
    7 ; Copyright (C) 2006-2020 Oracle Corporation
     7; Copyright (C) 2006-2021 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828;* Header Files                                                                *
    2929;*******************************************************************************
     30%define RT_ASM_WITH_SEH64
    3031%include "iprt/asmdefs.mac"
    3132
     
    3334
    3435;;
    35 ; Get the TR register.
    36 ; @returns TR.
     36; Set the GS base register.
     37; @param    uNewBase    msc:rcx gcc:rdi     New GS base value.
    3738;
    38 BEGINPROC_EXPORTED ASMGetTR
    39         str     ax
    40         movzx   eax, ax
     39BEGINPROC_EXPORTED ASMSetGSBase
     40        SEH64_END_PROLOGUE
     41%ifdef ASM_CALL64_MSC
     42        wrgsbase rcx
     43%else
     44        wrgsbase rdi
     45%endif
    4146        ret
    42 ENDPROC ASMGetTR
     47ENDPROC ASMSetGSBase
    4348
Note: See TracChangeset for help on using the changeset viewer.

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