VirtualBox

Changeset 95134 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
May 27, 2022 2:50:17 PM (3 years ago)
Author:
vboxsync
Message:

VMM,SUPDrv: Pass proper fCtxHook value to SUPR0FpuBegin/End so it can be used for assertions on linux. Wrote a more detailed explanation for the preemption hack in the linux SUPR0FpuBegin code and propped it up with an Assert(). bugref:10209

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r95125 r95134  
    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>
     
    17331734{
    17341735    RT_NOREF(fCtxHook);
    1735 #if RTLNX_VER_MIN(4,19,0)
     1736#if RTLNX_VER_MIN(4,19,0) /* Going back to 4.19.0 for better coverage, we
     1737                             probably only need 5.17.7+ in the end. */
     1738    /*
     1739     * HACK ALERT!
     1740     *
     1741     * We'd like to use the old __kernel_fpu_begin() API which was removed in
     1742     * early 2019, because we typically run with preemption enabled and have an
     1743     * preemption hook installed which will call kernel_fpu_end() in case we're
     1744     * scheduled out after getting in here.  The preemption hook is almost
     1745     * useless if we run with preemption disabled.
     1746     *
     1747     * For the case where the kernel does not have preemption hooks, we get here
     1748     * with preemption already disabled and one more count doesn't make any
     1749     * difference.
     1750     *
     1751     * So, after the kernel_fpu_begin() call we undo the implicit preempt_disable()
     1752     * call it does, so the preemption hook can do its work and the VBox user has
     1753     * a more responsive system.
     1754     *
     1755     * See @bugref{10209#c12} and onwards for more details.
     1756     */
     1757    Assert(fCtxHook || !RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    17361758    kernel_fpu_begin();
    1737     /* if (fCtxHook) */
    1738         preempt_enable();  /* HACK ALERT! undo the implicit preempt_disable() in kernel_fpu_begin(). */
    1739     return true;
     1759# if 0 /* Always do it for now for better test coverage. */
     1760    if (fCtxHook)
     1761# endif
     1762        preempt_enable();
     1763    return false; /** @todo Not sure if we have license to use any extended state, or
     1764                   *        if we're limited to the SSE & x87 FPU. If it's the former,
     1765                   *        we should return @a true and the caller can skip
     1766                   *        saving+restoring the host state and save some time. */
    17401767#else
    17411768    return false;
     
    17491776    RT_NOREF(fCtxHook);
    17501777#if RTLNX_VER_MIN(4,19,0)
    1751     /* if (fCtxHook) */
    1752         preempt_disable();  /* HACK ALERT! undo the implicit preempt_enable() in SUPR0FpuBegin(). */
     1778    /* HACK ALERT! See SUPR0FpuBegin for an explanation of this. */
     1779    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     1780# if 0 /* Always do it for now for better test coverage. */
     1781    if (fCtxHook)
     1782# endif
     1783        preempt_disable();
    17531784    kernel_fpu_end();
    17541785#endif
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