VirtualBox

Ignore:
Timestamp:
Aug 11, 2020 5:05:29 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139838
Message:

IPRT,lnx-kmods: Use new linux kernel version checking macros. Moved them to separate wrapper header.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r85552 r85698  
    5555
    5656#elif defined(RT_OS_LINUX)
    57 #   include <linux/version.h>
    58 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
     57#   include <iprt/linux/version.h>
     58#   if RTLNX_VER_MIN(2,6,33)
    5959#    include <generated/autoconf.h>
    6060#   else
     
    6565#   if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
    6666#       define MODVERSIONS
    67 #       if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
     67#       if RTLNX_VER_MAX(2,5,71)
    6868#           include <linux/modversions.h>
    6969#       endif
    7070#   endif
    7171#   ifndef KBUILD_STR
    72 #       if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
     72#       if RTLNX_VER_MAX(2,6,16)
    7373#            define KBUILD_STR(s) s
    7474#       else
     
    7979#   include <linux/spinlock.h>
    8080#   include <linux/slab.h>
    81 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     81#   if RTLNX_VER_MIN(2,6,27)
    8282#       include <linux/semaphore.h>
    8383#   else /* older kernels */
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r85505 r85698  
    4747
    4848/** @todo figure out the exact version number */
    49 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
     49#if RTLNX_VER_MIN(2,6,16)
    5050# include <iprt/power.h>
    5151# define VBOX_WITH_SUSPEND_NOTIFICATION
     
    5757# include <linux/platform_device.h>
    5858#endif
    59 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) && defined(SUPDRV_WITH_MSR_PROBER)
     59#if (RTLNX_VER_MIN(2,6,28)) && defined(SUPDRV_WITH_MSR_PROBER)
    6060# define SUPDRV_LINUX_HAS_SAFE_MSR_API
    6161# include <asm/msr.h>
     
    7272/* check kernel version */
    7373# ifndef SUPDRV_AGNOSTIC
    74 #  if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     74#  if RTLNX_VER_MAX(2,6,0)
    7575#   error Unsupported kernel version!
    7676#  endif
     
    112112#ifdef VBOX_WITH_SUSPEND_NOTIFICATION
    113113static int  VBoxDrvProbe(struct platform_device *pDev);
    114 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     114# if RTLNX_VER_MIN(2,6,30)
    115115static int  VBoxDrvSuspend(struct device *pDev);
    116116static int  VBoxDrvResume(struct device *pDev);
     
    140140#define DEVICE_NAME_USR     "vboxdrvu"
    141141
    142 #if (defined(RT_ARCH_AMD64) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
     142#if (defined(RT_ARCH_AMD64) && RTLNX_VER_MAX(2,6,23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
    143143/**
    144144 * Memory for the executable memory heap (in IPRT).
     
    203203    name:       DEVICE_NAME_SYS,
    204204    fops:       &gFileOpsVBoxDrvSys,
    205 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
     205# if RTLNX_VER_MAX(2,6,18)
    206206    devfs_name: DEVICE_NAME_SYS,
    207207# endif
     
    213213    name:       DEVICE_NAME_USR,
    214214    fops:       &gFileOpsVBoxDrvUsr,
    215 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
     215# if RTLNX_VER_MAX(2,6,18)
    216216    devfs_name: DEVICE_NAME_USR,
    217217# endif
     
    220220
    221221#ifdef VBOX_WITH_SUSPEND_NOTIFICATION
    222 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     222# if RTLNX_VER_MIN(2,6,30)
    223223static struct dev_pm_ops gPlatformPMOps =
    224224{
     
    233233{
    234234    .probe = VBoxDrvProbe,
    235 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
     235# if RTLNX_VER_MAX(2,6,30)
    236236    .suspend = VBoxDrvSuspend,
    237237    .resume  = VBoxDrvResume,
     
    241241    {
    242242        .name = "vboxdrv",
    243 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     243# if RTLNX_VER_MIN(2,6,30)
    244244        .pm = &gPlatformPMOps,
    245245# endif
     
    260260DECLINLINE(RTUID) vboxdrvLinuxUid(void)
    261261{
    262 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    263 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     262#if RTLNX_VER_MIN(2,6,29)
     263# if RTLNX_VER_MIN(3,5,0)
    264264    return from_kuid(current_user_ns(), current->cred->uid);
    265265# else
     
    273273DECLINLINE(RTGID) vboxdrvLinuxGid(void)
    274274{
    275 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    276 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     275#if RTLNX_VER_MIN(2,6,29)
     276# if RTLNX_VER_MIN(3,5,0)
    277277    return from_kgid(current_user_ns(), current->cred->gid);
    278278# else
     
    286286DECLINLINE(RTUID) vboxdrvLinuxEuid(void)
    287287{
    288 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    289 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     288#if RTLNX_VER_MIN(2,6,29)
     289# if RTLNX_VER_MIN(3,5,0)
    290290    return from_kuid(current_user_ns(), current->cred->euid);
    291291# else
     
    332332        if (RT_SUCCESS(rc))
    333333        {
    334 #if (defined(RT_ARCH_AMD64) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
     334#if (defined(RT_ARCH_AMD64) && RTLNX_VER_MAX(2,6,23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
    335335# ifdef VBOX_WITH_TEXT_MODMEM_HACK
    336336            set_memory_x(&g_abExecMemory[0], sizeof(g_abExecMemory) / PAGE_SIZE);
     
    516516 *                      Ignored.
    517517 */
    518 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) && !defined(DOXYGEN_RUNNING)
     518# if RTLNX_VER_MIN(2,6,30) && !defined(DOXYGEN_RUNNING)
    519519static int VBoxDrvSuspend(struct device *pDev)
    520520# else
     
    531531 * @param   pDev        Pointer to the platform device.
    532532 */
    533 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     533# if RTLNX_VER_MIN(2,6,30)
    534534static int VBoxDrvResume(struct device *pDev)
    535535# else
     
    757757RTCCUINTREG VBOXCALL supdrvOSChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask)
    758758{
    759 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
     759#if RTLNX_VER_MIN(5,8,0)
    760760    RTCCUINTREG const uOld = __read_cr4();
    761 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     761#elif RTLNX_VER_MIN(3,20,0)
    762762    RTCCUINTREG const uOld = this_cpu_read(cpu_tlbstate.cr4);
    763763#else
     
    767767    if (uNew != uOld)
    768768    {
    769 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
     769#if RTLNX_VER_MIN(5,8,0)
    770770        ASMSetCR4(uNew);
    771 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     771#elif RTLNX_VER_MIN(3,20,0)
    772772        this_cpu_write(cpu_tlbstate.cr4, uNew);
    773773        __write_cr4(uNew);
     
    11211121
    11221122        /* Nobody waiting and no exit function. */
    1123 #  if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
     1123#  if RTLNX_VER_MAX(3,13,0)
    11241124        pMyMod->waiter              = NULL;
    11251125#  endif
     
    11281128        /* References, very important as we must not allow the module
    11291129           to be unloaded using rmmod. */
    1130 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
     1130#  if RTLNX_VER_MIN(3,19,0)
    11311131        atomic_set(&pMyMod->refcnt, 42);
    11321132#  else
     
    12131213        mutex_unlock(&module_mutex);
    12141214
    1215 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
     1215# if RTLNX_VER_MAX(3,19,0)
    12161216        free_percpu(pMyMod->refptr);
    12171217# endif
     
    14321432    fFlags |= SUPKERNELFEATURES_GDT_READ_ONLY;
    14331433#endif
    1434 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     1434#if RTLNX_VER_MIN(4,12,0)
    14351435    fFlags |= SUPKERNELFEATURES_GDT_NEED_WRITABLE;
    14361436#endif
     
    14471447int VBOXCALL    supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw)
    14481448{
    1449 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     1449#if RTLNX_VER_MIN(4,12,0)
    14501450    *pGdtRw = (RTHCUINTPTR)get_current_gdt_rw();
    14511451    return VINF_SUCCESS;
  • trunk/src/VBox/HostDrivers/Support/linux/files_vboxdrv

    r85523 r85698  
    7373    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
    7474    ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
     75    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    7576    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    7677    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
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