VirtualBox

Changeset 82590 in vbox


Ignore:
Timestamp:
Dec 16, 2019 5:48:40 PM (5 years ago)
Author:
vboxsync
Message:

SUPDrv,IPRT: Adding SUPR0HCPhysToVirt to linux & solaris; introducing IPRT_WITHOUT_EFLAGS_AC_PRESERVING and VBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV config macros for disabling EFLAGS.AC hacks (not active). bugref:9627

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/sup.h

    r81304 r82590  
    20192019SUPR0DECL(void) SUPR0BadContext(PSUPDRVSESSION pSession, const char *pszFile, uint32_t uLine, const char *pszExpr);
    20202020
     2021#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
     2022/**
     2023 * Translates a physical address to a virtual mapping (valid up to end of page).
     2024 * @returns VBox status code.
     2025 * @param   HCPhys      The physical address, must be page aligned.
     2026 * @param   ppv         Where to store the mapping address on success.
     2027 */
     2028SUPR0DECL(int) SUPR0HCPhysToVirt(RTHCPHYS HCPhys, void **ppv);
     2029#endif
     2030
    20212031/** Context structure returned by SUPR0IoCtlSetup for use with
    20222032 * SUPR0IoCtlPerform and cleaned up by SUPR0IoCtlCleanup. */
  • trunk/src/VBox/HostDrivers/Support/Makefile.kmk

    r81158 r82590  
    762762                $(PATH_SUB_CURRENT)/$(KBUILD_TARGET)/Makefile \
    763763                $$(if $$(eq $$(Support/$(KBUILD_TARGET)/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
     764                $$(if $$(eq $$(Support/$(KBUILD_TARGET)/Makefile_VBOX_RAM_IN_KERNEL),$$(VBOX_WITH_RAM_IN_KERNEL)),,FORCE) \
    764765                | $$(dir $$@)
    765766        $(call MSG_TOOL,Creating,,$@)
    766767        $(QUIET)$(SED) -e "" \
    767768                $(if-expr !defined(VBOX_WITH_HARDENING)   ,-e "s;VBOX_WITH_HARDENING;;g",) \
    768                 $(if-expr ($(VBOX_VERSION_BUILD) % 2) == 0 \
     769                $(if-expr ($(VBOX_VERSION_BUILD) % 2) == 0 || defined(VBOX_WITH_RAM_IN_KERNEL) \
    769770                 , -e "s;VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV;;g" -e "s;IPRT_WITH_EFLAGS_AC_PRESERVING;;g",) \
     771                $(if-expr !defined(VBOX_WITH_RAM_IN_KERNEL) \
     772                 , -e 's;VBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV;;g' -e 's;IPRT_WITHOUT_EFLAGS_AC_PRESERVING;;g',) \
    770773                --output $@ $<
    771774        %$(QUIET2)$(APPEND) -t '$(PATH_TARGET)/vboxdrv-src-1.dep' \
    772                 'Support/$(KBUILD_TARGET)/Makefile_VBOX_HARDENED=$(VBOX_WITH_HARDENING)'
     775                'Support/$(KBUILD_TARGET)/Makefile_VBOX_HARDENED=$(VBOX_WITH_HARDENING)' \
     776                'Support/$(KBUILD_TARGET)/Makefile_VBOX_RAM_IN_KERNEL=$(VBOX_WITH_RAM_IN_KERNEL)'
    773777
    774778 #
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp

    r81623 r82590  
    105105 * Checks that the AC flag is set if SMAP is enabled.  If AC is not set, it
    106106 * will be logged and @a a_BadExpr is executed. */
    107 #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
     107#if (defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)) && !defined(VBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV)
    108108# define SUPDRV_CHECK_SMAP_SETUP() uint32_t const fKernelFeatures = SUPR0GetKernelFeatures()
    109109# define SUPDRV_CHECK_SMAP_CHECK(a_pDevExt, a_BadExpr) \
     
    227227    { "SUPR0PageMapKernel",                     (void *)(uintptr_t)SUPR0PageMapKernel },
    228228    { "SUPR0PageProtect",                       (void *)(uintptr_t)SUPR0PageProtect },
     229#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
     230    { "SUPR0HCPhysToVirt",                      (void *)(uintptr_t)SUPR0HCPhysToVirt },         /* only-linux, only solaris */
     231#endif
    229232    { "SUPR0Printf",                            (void *)(uintptr_t)SUPR0Printf },
    230233    { "SUPR0GetSessionGVM",                     (void *)(uintptr_t)SUPR0GetSessionGVM },
  • trunk/src/VBox/HostDrivers/Support/linux/Makefile

    r77403 r82590  
    154154        VBOX_WITH_HARDENING \
    155155        SUPDRV_WITH_RELEASE_LOGGER \
     156        VBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV \
    156157        VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV \
     158        IPRT_WITHOUT_EFLAGS_AC_PRESERVING \
    157159        IPRT_WITH_EFLAGS_AC_PRESERVING \
    158160        VBOX_WITH_64_BITS_GUESTS # <-- must be consistent with Config.kmk!
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r79444 r82590  
    558558    PSUPDRVSESSION pSession = (PSUPDRVSESSION)pFilp->private_data;
    559559    int rc;
    560 #if defined(VBOX_STRICT) || defined(VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV)
     560#ifndef VBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV
     561# if defined(VBOX_STRICT) || defined(VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV)
    561562    RTCCUINTREG fSavedEfl;
    562563
     
    577578    stac();
    578579# endif
     580#endif
    579581
    580582    /*
     
    599601#endif  /* !HAVE_UNLOCKED_IOCTL */
    600602
    601 #if defined(VBOX_STRICT) || defined(VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV)
     603#ifndef VBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV
     604# if defined(VBOX_STRICT) || defined(VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV)
    602605    /*
    603606     * Before we restore AC and the rest of EFLAGS, check if the IOCtl handler code
     
    612615    }
    613616    ASMSetFlags(fSavedEfl);
    614 #else
     617# else
    615618    clac();
     619# endif
    616620#endif
    617621    return rc;
     
    13881392
    13891393
     1394SUPR0DECL(int) SUPR0HCPhysToVirt(RTHCPHYS HCPhys, void **ppv)
     1395{
     1396    AssertReturn(!(HCPhys & PAGE_OFFSET_MASK), VERR_INVALID_POINTER);
     1397    AssertReturn(HCPhys != NIL_RTHCPHYS, VERR_INVALID_POINTER);
     1398    /* Would've like to use valid_phys_addr_range for this test, but it isn't exported. */
     1399    AssertReturn((HCPhys | PAGE_OFFSET_MASK) < __pa(high_memory), VERR_INVALID_POINTER);
     1400    *ppv = phys_to_virt(HCPhys);
     1401    return VINF_SUCCESS;
     1402}
     1403
     1404
    13901405RTDECL(int) SUPR0Printf(const char *pszFormat, ...)
    13911406{
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c

    r76553 r82590  
    4646#include <sys/file.h>
    4747#include <sys/priv_names.h>
     48#include <vm/hat.h>
    4849#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
    4950
     
    6465
    6566#include "dtrace/SUPDrv.h"
     67
     68extern "C" caddr_t hat_kpm_pfn2va(pfn_t); /* Found in vm/hat.h on solaris 11.3, but not on older like 10u7. */
    6669
    6770
     
    12771280
    12781281
     1282SUPR0DECL(int) SUPR0HCPhysToVirt(RTHCPHYS HCPhys, void **ppv)
     1283{
     1284    AssertReturn(!(HCPhys & PAGE_OFFSET_MASK), VERR_INVALID_POINTER);
     1285    AssertReturn(HCPhys != NIL_RTHCPHYS, VERR_INVALID_POINTER);
     1286    HCPhys >>= PAGE_SHIFT;
     1287    AssertReturn(HCPhys <= physmax, VERR_INVALID_POINTER);
     1288    *ppv = hat_kpm_pfn2va(HCPhys);
     1289    return VINF_SUCCESS;
     1290}
     1291
     1292
    12791293RTDECL(int) SUPR0Printf(const char *pszFormat, ...)
    12801294{
  • trunk/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h

    r81587 r82590  
    420420 * restoring flags.
    421421 * @{ */
    422 #if defined(CONFIG_X86_SMAP) || defined(RT_STRICT) || defined(IPRT_WITH_EFLAGS_AC_PRESERVING)
     422#if (defined(CONFIG_X86_SMAP) || defined(RT_STRICT) || defined(IPRT_WITH_EFLAGS_AC_PRESERVING)) \
     423  && !defined(IPRT_WITHOUT_EFLAGS_AC_PRESERVING)
    423424# include <iprt/asm-amd64-x86.h>
    424425# define IPRT_X86_EFL_AC                    RT_BIT(18)
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