Re: buildkernel is broken in if_ndis

From: Bill Paul (wpaul_at_FreeBSD.ORG)
Date: 10/12/05

  • Next message: Sam Leffler: "Re: panic: ifc_free_unit: bit is already cleared"
    To: maksim.yevmenkin@savvis.net (Maksim Yevmenkin)
    Date: Tue, 11 Oct 2005 22:10:45 +0000 (GMT)
    
    

    [Charset ISO-8859-1 unsupported, filtering to ASCII...]
    > dear hackers,
    >
    > make buildworld is broken for me. since NDIS_LOCK(sc) does not uses
    > sc->ndis_mtx anymore, shouldn't the following patch be put in place?
    >
    > max
    >
    > p.s. i could not find KeIsInitializedSpinLock function in subr_ndis.c.
    > quick look at msdn did not reveal it either
    >
    >
    > --- if_ndis.c.orig Tue Oct 11 11:11:52 2005
    > +++ if_ndis.c Tue Oct 11 11:11:31 2005
    > @@ -917,8 +917,6 @@
    > driver_object *drv;
    >
    > sc = device_get_softc(dev);
    > - KASSERT(mtx_initialized(&sc->ndis_mtx),
    > - ("ndis mutex not initialized"));
    > NDIS_LOCK(sc);
    > ifp = sc->ifp;
    > ifp->if_flags &= ~IFF_UP;
    >

    Fixed. The KASSERT just doesn't need to be there anymore. In Windows,
    a spinlock is just a 32-bit long, and the only thing
    KeInitializeSpinLock() does is set spinlock = 0. There is no
    KeDestroySpinLock(): when you're done with the spinlock, you just
    free the storage in which it resides (after unlocking it for the
    last time, of course).

    Now, the NDIS API has NdisAllocateSpinLock() and NdisFreeSpinLock(),
    however I think Microsoft put them there based on the assumption that
    someone might want to implement the NDIS API on another OS where
    you really do have to allocate and free resources for spinlocks.
    However, NdisAllocateSpinLock() doesn't really allocate anything:
    it just calls KeInitializeSpinLock(), and NdisFreeSpinLock() does
    nothing.

    (Note also there's at least one driver out there which calls
    NdisFreeSpinLock() _AFTER_ releasing the storage in which the spinlock
    resides. But since NdisFreeSpinLock() is a no-op in Windows, the
    Microsoft driver verified never flags the error.)

    -Bill

    --
    =============================================================================
    -Bill Paul            (510) 749-2329 | Senior Engineer, Master of Unix-Fu
                     wpaul@windriver.com | Wind River Systems
    =============================================================================
                  <adamw> you're just BEGGING to face the moose
    =============================================================================
    _______________________________________________
    freebsd-current@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-current
    To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
    

  • Next message: Sam Leffler: "Re: panic: ifc_free_unit: bit is already cleared"

    Relevant Pages

    • Re: How to check if a spin lock has been freed or released?
      ... > Since all the four functions NdisAcpuireSpinLock, NdisAllocateSpinLock, ... > spin lock has been freed or released in a NDIS protocol driver? ... > NdisFreeSpinLock in DriverUnload routine? ... here is how the NDIS spinlock functions map to Windows ...
      (microsoft.public.development.device.drivers)
    • Re: How to check if a spin lock has been freed or released?
      ... > Maybe MS should issue some analog of Driver Verifier for ACPI BIOSes ... > lessen the number of hardware able to run Windows). ... >> bugs like NdisFreeSpinLock() misuse would show up immediately during ...
      (microsoft.public.development.device.drivers)
    • Re: How to check if a spin lock has been freed or released?
      ... >> your unload routine you have a crash that is waiting to happen. ... I think there would be no problem to acquire and release spinlock ... >in unload routine as long as I call NdisFreeSpinLock at the end of unload ... observed harmful consequences in acquiring a previously freed spinlock ...
      (microsoft.public.development.device.drivers)
    • Re: How to check if a spin lock has been freed or released?
      ... lessen the number of hardware able to run Windows). ... For Linux and FreeBSD, this can be ... > bugs like NdisFreeSpinLock() misuse would show up immediately during ... KeRaise/LowerIrql, as it is done in uniprocessor NT kernels, but the spinlock ...
      (microsoft.public.development.device.drivers)
    • Re: [RFC, 2.6] a simple FIFO implementation
      ... > which let's you specify the buffer and the spinlock you want to use. ... I guess you need to pass down the size of the buffer too. ... you should force the caller to allocate it, and force it to pass it down ...
      (Linux-Kernel)

    Loading