VirtualBox

Ticket #20914: vbox-linux-5.19.patch

File vbox-linux-5.19.patch, 14.3 KB (added by galitsyn, 2 years ago)

VirtualBox-6.1.34 patch for Linux kernels 5.18.x and 5.19-rc2 support (should be applied on top of https://download.virtualbox.org/virtualbox/6.1.34/VirtualBox-6.1.34.tar.bz2)

  • include/VBox/sup.h

     
    21422142 */
    21432143SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void);
    21442144
     2145/**
     2146 * Notification from R0 VMM prior to loading the guest-FPU register state.
     2147 *
     2148 * @returns Whether the host-FPU register state has been saved by the host kernel.
     2149 * @param   fCtxHook    Whether thread-context hooks are enabled.
     2150 *
     2151 * @remarks Called with preemption disabled.
     2152 */
     2153SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook);
     2154
     2155/**
     2156 * Notification from R0 VMM after saving the guest-FPU register state (and
     2157 * potentially restoring the host-FPU register state) in ring-0.
     2158 *
     2159 * @param   fCtxHook    Whether thread-context hooks are enabled.
     2160 *
     2161 * @remarks Called with preemption disabled.
     2162 */
     2163SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook);
     2164
    21452165/** @copydoc RTLogGetDefaultInstanceEx
    21462166 * @remarks To allow overriding RTLogGetDefaultInstanceEx locally. */
    21472167SUPR0DECL(struct RTLOGGER *) SUPR0GetDefaultLogInstanceEx(uint32_t fFlagsAndGroup);
  • src/VBox/Additions/linux/drm/vbox_fb.c

     
    362362        info->screen_size = size;
    363363
    364364#ifdef CONFIG_FB_DEFERRED_IO
     365# if RTLNX_VER_MIN(5,19,0)
     366        info->fix.smem_len = info->screen_size;
     367# endif
    365368        info->fbdefio = &vbox_defio;
    366369        fb_deferred_io_init(info);
    367370#endif
  • src/VBox/Additions/linux/drm/vbox_ttm.c

     
    320320        if (ttm_tt_init(tt, bdev, size, page_flags, dummy_read_page)) {
    321321#elif RTLNX_VER_MAX(5,11,0) && !RTLNX_RHEL_RANGE(8,5, 8,99)
    322322        if (ttm_tt_init(tt, bo, page_flags)) {
     323#elif RTLNX_VER_MAX(5,19,0)
     324        if (ttm_tt_init(tt, bo, page_flags, ttm_write_combined)) {
    323325#else
    324         if (ttm_tt_init(tt, bo, page_flags, ttm_write_combined)) {
     326        if (ttm_tt_init(tt, bo, page_flags, ttm_write_combined, 0)) {
    325327#endif
    326328                kfree(tt);
    327329                return NULL;
  • src/VBox/Additions/linux/sharedfolders/regops.c

     
    35813581 * Needed for mmap and reads+writes when the file is mmapped in a
    35823582 * shared+writeable fashion.
    35833583 */
     3584#if RTLNX_VER_MIN(5,19,0)
     3585static int vbsf_read_folio(struct file *file, struct folio *folio)
     3586{
     3587    struct page *page = &folio->page;
     3588#else
    35843589static int vbsf_readpage(struct file *file, struct page *page)
    35853590{
     3591#endif
    35863592    struct inode *inode = VBSF_GET_F_DENTRY(file)->d_inode;
    35873593    int           err;
    35883594
     
    37283734/**
    37293735 * Called when writing thru the page cache (which we shouldn't be doing).
    37303736 */
    3731 int vbsf_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
    3732                      unsigned len, unsigned flags, struct page **pagep, void **fsdata)
     3737static inline void vbsf_write_begin_warn(loff_t pos, unsigned len, unsigned flags)
    37333738{
    37343739    /** @todo r=bird: We shouldn't ever get here, should we?  Because we don't use
    37353740     *        the page cache for any writes AFAIK.  We could just as well use
     
    37453750        WARN_ON(1);
    37463751# endif
    37473752    }
     3753}
     3754
     3755# if RTLNX_VER_MIN(5,19,0)
     3756int vbsf_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
     3757                     unsigned len, struct page **pagep, void **fsdata)
     3758{
     3759    vbsf_write_begin_warn(pos, len, 0);
     3760    return simple_write_begin(file, mapping, pos, len, pagep, fsdata);
     3761}
     3762# else
     3763int vbsf_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
     3764                     unsigned len, unsigned flags, struct page **pagep, void **fsdata)
     3765{
     3766    vbsf_write_begin_warn(pos, len, flags);
    37483767    return simple_write_begin(file, mapping, pos, len, flags, pagep, fsdata);
    37493768}
     3769# endif
     3770
    37503771#endif /* KERNEL_VERSION >= 2.6.24 */
    37513772
    37523773#if RTLNX_VER_MIN(5,14,0)
     
    38203841 * @todo the FsPerf touch/flush (mmap) test fails on 4.4.0 (ubuntu 16.04 lts).
    38213842 */
    38223843struct address_space_operations vbsf_reg_aops = {
     3844#if RTLNX_VER_MIN(5,19,0)
     3845    .read_folio     = vbsf_read_folio,
     3846#else
    38233847    .readpage       = vbsf_readpage,
     3848#endif
    38243849    .writepage      = vbsf_writepage,
    38253850    /** @todo Need .writepages if we want msync performance...  */
    3826 #if RTLNX_VER_MIN(2,5,12)
     3851#if RTLNX_VER_MIN(5,18,0)
     3852    .dirty_folio = filemap_dirty_folio,
     3853#elif RTLNX_VER_MIN(2,5,12)
    38273854    .set_page_dirty = __set_page_dirty_buffers,
    38283855#endif
    38293856#if RTLNX_VER_MIN(5,14,0)
     
    38403867    .direct_IO      = vbsf_direct_IO,
    38413868#endif
    38423869};
    3843 
  • src/VBox/Additions

  • src/VBox/HostDrivers/Support/SUPDrv.cpp

    Property changes on: src/VBox/Additions
    ___________________________________________________________________
    Modified: svn:mergeinfo
    ## -0,0 +0,2 ##
       Merged /trunk/src/VBox/Additions:r150844,151718-151720
       Merged /branches/VBox-6.1/src/VBox/Additions:r151572,151833-151835
     
    9898# endif
    9999#endif
    100100
     101#if defined(RT_OS_LINUX) && !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
     102/* In Linux 5.18-rc1, memcpy became a wrapper which does fortify checks
     103 * before triggering __underlying_memcpy() call. We do not pass these checks here,
     104 * so bypass them for now.  */
     105# if RTLNX_VER_MIN(5,18,0)
     106#  define SUPDRV_MEMCPY __underlying_memcpy
     107# else
     108# define SUPDRV_MEMCPY  memcpy
     109# endif
     110#else
     111# define SUPDRV_MEMCPY  memcpy
     112#endif
    101113
    102114/*
    103115 * Logging assignments:
     
    266278    SUPEXP_STK_BACK(    2,  SUPR0ContFree),
    267279    SUPEXP_STK_BACK(    2,  SUPR0ChangeCR4),
    268280    SUPEXP_STK_BACK(    1,  SUPR0EnableVTx),
     281    SUPEXP_STK_OKAY(    1,  SUPR0FpuBegin),
     282    SUPEXP_STK_OKAY(    1,  SUPR0FpuEnd),
    269283    SUPEXP_STK_BACK(    0,  SUPR0SuspendVTxOnCpu),
    270284    SUPEXP_STK_BACK(    1,  SUPR0ResumeVTxOnCpu),
    271285    SUPEXP_STK_OKAY(    1,  SUPR0GetCurrentGdtRw),
     
    17421756
    17431757            /* execute */
    17441758            pReq->u.Out.cFunctions = RT_ELEMENTS(g_aFunctions);
    1745             memcpy(&pReq->u.Out.aFunctions[0], g_aFunctions, sizeof(g_aFunctions));
     1759            SUPDRV_MEMCPY(&pReq->u.Out.aFunctions[0], g_aFunctions, sizeof(g_aFunctions));
    17461760            pReq->Hdr.rc = VINF_SUCCESS;
    17471761            return 0;
    17481762        }
  • src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

     
    20022002}
    20032003
    20042004
     2005SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
     2006{
     2007    RT_NOREF(fCtxHook);
     2008    return false;
     2009}
     2010
     2011
     2012SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
     2013{
     2014    RT_NOREF(fCtxHook);
     2015}
     2016
    20052017/*
    20062018 *
    20072019 * org_virtualbox_SupDrv
  • src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c

     
    640640    return 0;
    641641}
    642642
     643
     644SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
     645{
     646    RT_NOREF(fCtxHook);
     647    return false;
     648}
     649
     650
     651SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
     652{
     653    RT_NOREF(fCtxHook);
     654}
     655
  • src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

     
    4040#include <iprt/semaphore.h>
    4141#include <iprt/initterm.h>
    4242#include <iprt/process.h>
     43#include <iprt/thread.h>
    4344#include <VBox/err.h>
    4445#include <iprt/mem.h>
    4546#include <VBox/log.h>
     
    14541455}
    14551456
    14561457
     1458SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
     1459{
     1460    RT_NOREF(fCtxHook);
     1461#if RTLNX_VER_MIN(4,19,0) /* Going back to 4.19.0 for better coverage, we
     1462                             probably only need 5.17.7+ in the end. */
     1463    /*
     1464     * HACK ALERT!
     1465     *
     1466     * We'd like to use the old __kernel_fpu_begin() API which was removed in
     1467     * early 2019, because we typically run with preemption enabled and have an
     1468     * preemption hook installed which will call kernel_fpu_end() in case we're
     1469     * scheduled out after getting in here.  The preemption hook is almost
     1470     * useless if we run with preemption disabled.
     1471     *
     1472     * For the case where the kernel does not have preemption hooks, we get here
     1473     * with preemption already disabled and one more count doesn't make any
     1474     * difference.
     1475     *
     1476     * So, after the kernel_fpu_begin() call we undo the implicit preempt_disable()
     1477     * call it does, so the preemption hook can do its work and the VBox user has
     1478     * a more responsive system.
     1479     *
     1480     * See @bugref{10209#c12} and onwards for more details.
     1481     */
     1482    Assert(fCtxHook || !RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     1483    kernel_fpu_begin();
     1484# if 0 /* Always do it for now for better test coverage. */
     1485    if (fCtxHook)
     1486# endif
     1487        preempt_enable();
     1488    return false; /** @todo Not sure if we have license to use any extended state, or
     1489                   *        if we're limited to the SSE & x87 FPU. If it's the former,
     1490                   *        we should return @a true and the caller can skip
     1491                   *        saving+restoring the host state and save some time. */
     1492#else
     1493    return false;
     1494#endif
     1495}
     1496
     1497
     1498SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
     1499{
     1500    RT_NOREF(fCtxHook);
     1501#if RTLNX_VER_MIN(4,19,0)
     1502    /* HACK ALERT! See SUPR0FpuBegin for an explanation of this. */
     1503    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     1504# if 0 /* Always do it for now for better test coverage. */
     1505    if (fCtxHook)
     1506# endif
     1507        preempt_disable();
     1508    kernel_fpu_end();
     1509#endif
     1510}
     1511
     1512
    14571513int VBOXCALL    supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw)
    14581514{
    14591515#if RTLNX_VER_MIN(4,12,0)
  • src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp

     
    541541    return 0;
    542542}
    543543
     544
     545SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
     546{
     547    RT_NOREF(fCtxHook);
     548    return false;
     549}
     550
     551
     552SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
     553{
     554    RT_NOREF(fCtxHook);
     555}
     556
  • src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c

     
    13091309    return 0;
    13101310}
    13111311
     1312
     1313SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
     1314{
     1315    RT_NOREF(fCtxHook);
     1316    return false;
     1317}
     1318
     1319
     1320SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
     1321{
     1322    RT_NOREF(fCtxHook);
     1323}
     1324
  • src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

     
    27042704}
    27052705
    27062706
     2707SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
     2708{
     2709    RT_NOREF(fCtxHook);
     2710    return false;
     2711}
     2712
     2713
     2714SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
     2715{
     2716    RT_NOREF(fCtxHook);
     2717}
     2718
     2719
    27072720SUPR0DECL(int) SUPR0IoCtlSetupForHandle(PSUPDRVSESSION pSession, intptr_t hHandle, uint32_t fFlags, PSUPR0IOCTLCTX *ppCtx)
    27082721{
    27092722    /*
  • src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

     
    23112311                vboxNetFltDumpPacket(pSG, true, "host", (fDst & INTNETTRUNKDIR_WIRE) ? 0 : 1);
    23122312                Log6(("vboxNetFltPortOsXmit: pBuf->cb dump:\n%.*Rhxd\n", sizeof(pBuf->cb), pBuf->cb));
    23132313                Log6(("vboxNetFltPortOsXmit: netif_rx_ni(%p)\n", pBuf));
     2314#if RTLNX_VER_MIN(5,18,0)
     2315                local_bh_disable();
     2316                err = netif_rx(pBuf);
     2317                local_bh_enable();
     2318#else
    23142319                err = netif_rx_ni(pBuf);
     2320#endif
    23152321                if (err)
    23162322                    rc = RTErrConvertFromErrno(err);
    23172323            }
  • src/VBox/Runtime/r0drv/linux/the-linux-kernel.h

     
    184184# include <asm/tlbflush.h>
    185185#endif
    186186
     187/* for kernel_fpu_begin / kernel_fpu_end() */
     188#if RTLNX_VER_MIN(4,2,0)
     189# include <asm/fpu/api.h>
     190#endif
     191
    187192#if RTLNX_VER_MIN(3,7,0)
    188193# include <asm/smap.h>
    189194#else
  • src/VBox/VMM/VMMR0/CPUMR0.cpp

     
    440440    Assert(!(pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU_GUEST));
    441441    Assert(!(pVCpu->cpum.s.fUseFlags & CPUM_SYNC_FPU_STATE));
    442442
     443    /* Notify the support driver prior to loading the guest-FPU register state. */
     444    SUPR0FpuBegin(VMMR0ThreadCtxHookIsEnabled(pVCpu));
     445    /** @todo use return value? Currently skipping that to be on the safe side
     446     *        wrt. extended state (linux). */
     447
    443448    if (!pVM->cpum.s.HostFeatures.fLeakyFxSR)
    444449    {
    445450        Assert(!(pVCpu->cpum.s.fUseFlags & CPUM_USED_MANUAL_XMM_RESTORE));
     
    504509                cpumR0SaveGuestRestoreHostFPUState(&pVCpu->cpum.s);
    505510            pVCpu->cpum.s.fUseFlags &= ~CPUM_USED_MANUAL_XMM_RESTORE;
    506511        }
     512
     513        /* Notify the support driver after loading the host-FPU register state. */
     514        SUPR0FpuEnd(VMMR0ThreadCtxHookIsEnabled(pVCpu));
    507515    }
    508516    else
    509517        fSavedGuest = false;

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