VirtualBox

Changeset 90408 in vbox for trunk/src


Ignore:
Timestamp:
Jul 29, 2021 1:21:10 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146000
Message:

Debugger/DBGPlugInLinux: Fix loaded kernel module processing for kernels starting with 4.5.0, the struct module layout has changed significantly.

Location:
trunk/src/VBox/Debugger
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGPlugInLinuxModuleCodeTmpl.cpp.h

    r82968 r90408  
    7171    LNX_PTR_T           uPtrDriverDir;  /**< Points to struct kobject. */
    7272#  endif
     73#  if LNX_VER >= LNX_MK_VER(4,5,0)
     74    LNX_PTR_T           uPtrMp;
     75    LNX_PTR_T           uPtrCompletion; /**< Points to struct completion. */
     76#  endif
    7377} RT_CONCAT(LNXMODKOBJECT,LNX_SUFFIX);
    7478#endif
     
    8084
    8185
     86#if LNX_VER >= LNX_MK_VER(4,5,0)
     87/**
     88 * Red black tree node.
     89 */
     90typedef struct RT_CONCAT(LNXRBNODE,LNX_SUFFIX)
     91{
     92    LNX_ULONG_T         uRbParentColor;
     93    LNX_PTR_T           uPtrRbRight;
     94    LNX_PTR_T           uPtrRbLeft;
     95} RT_CONCAT(LNXRBNODE,LNX_SUFFIX);
     96
     97
     98/**
     99 * Latch tree node.
     100 */
     101typedef struct RT_CONCAT(LNXLATCHTREENODE,LNX_SUFFIX)
     102{
     103    RT_CONCAT(LNXRBNODE,LNX_SUFFIX) aNode[2];
     104} RT_CONCAT(LNXLATCHTREENODE,LNX_SUFFIX);
     105
     106
     107/**
     108 * Module tree node.
     109 */
     110typedef struct RT_CONCAT(LNXMODTREENODE,LNX_SUFFIX)
     111{
     112    LNX_PTR_T                              uPtrKMod;
     113    RT_CONCAT(LNXLATCHTREENODE,LNX_SUFFIX) Node;
     114} RT_CONCAT(LNXMODTREENODE,LNX_SUFFIX);
     115
     116
     117/**
     118 * Module layout.
     119 */
     120typedef struct RT_CONCAT(LNXKMODLAYOUT,LNX_SUFFIX)
     121{
     122    LNX_PTR_T                               uPtrBase; /**< Base pointer to text and data. */
     123    uint32_t                                cb;       /**< Size of the module. */
     124    uint32_t                                cbText;   /**< Size of the text section. */
     125    uint32_t                                cbRo;     /**< Size of the readonly portion (text + ro data). */
     126    RT_CONCAT(LNXMODTREENODE,LNX_SUFFIX)    ModTreeNd; /**< Only available when CONFIG_MODULES_TREE_LOOKUP is set (default). */
     127} RT_CONCAT(LNXKMODLAYOUT,LNX_SUFFIX);
     128
     129
     130/**
     131 * Mutex.
     132 */
     133typedef struct RT_CONCAT(LNXMUTEX,LNX_SUFFIX)
     134{
     135    LNX_ULONG_T                             uOwner;
     136    uint32_t                                wait_lock; /**< Actually spinlock_t */
     137    PAD32ON64(0)
     138    LNX_PTR_T                               uWaitLstPtrNext;
     139    LNX_PTR_T                               uWaitLstPtrPrev;
     140} RT_CONCAT(LNXMUTEX,LNX_SUFFIX);
     141#endif
     142
    82143
    83144/**
     
    86147typedef struct RT_CONCAT(LNXKMODULE,LNX_SUFFIX)
    87148{
    88 #if LNX_VER >= LNX_MK_VER(2,5,48)
     149#if LNX_VER >= LNX_MK_VER(4,5,0)
     150    /* Completely new layout to not feed the spaghetti dragons further. */
     151    int32_t                             state;
     152    PAD32ON64(0)
     153    LNX_PTR_T                           uPtrNext;
     154    LNX_PTR_T                           uPtrPrev;
     155    char                                name[64 - sizeof(LNX_PTR_T)];
     156
     157    RT_CONCAT(LNXMODKOBJECT,LNX_SUFFIX) mkobj;
     158    LNX_PTR_T                           uPtrModInfoAttrs;   /**< Points to struct module_attribute. */
     159    LNX_PTR_T                           uPtrVersion;        /**< String pointers. */
     160    LNX_PTR_T                           uPtrSrcVersion;     /**< String pointers. */
     161    LNX_PTR_T                           uPtrHolderDir;      /**< Points to struct kobject. */
     162
     163    /** @name Exported Symbols
     164     * @{ */
     165    LNX_PTR_T                           uPtrSyms;           /**< Array of struct kernel_symbol. */
     166    LNX_PTR_T                           uPtrCrcs;           /**< unsigned long array */
     167    uint32_t                            num_syms;
     168    /** @} */
     169
     170    /** @name Kernel parameters
     171     * @{ */
     172    RT_CONCAT(LNXMUTEX,LNX_SUFFIX)      Mtx;                /**< Mutex. */
     173    LNX_PTR_T                           uPtrKp;             /**< Points to struct kernel_param */
     174    uint32_t                            num_kp;
     175    /** @} */
     176
     177    /** @name GPL Symbols
     178     * @{ */
     179    uint32_t                            num_gpl_syms;
     180    LNX_PTR_T                           uPtrGplSyms;        /**< Array of struct kernel_symbol. */
     181    LNX_PTR_T                           uPtrGplCrcs;        /**< unsigned long array */
     182    /** @} */
     183
     184    /** @name Unused symbols
     185     * @{ */
     186    LNX_PTR_T                           uPtrUnusedSyms;     /**< Array of struct kernel_symbol. */
     187    LNX_PTR_T                           uPtrUnusedCrcs;     /**< unsigned long array */
     188    uint32_t                            num_unused_syms;
     189    uint32_t                            num_unused_gpl_syms;
     190    LNX_PTR_T                           uPtrUnusedGplSyms;  /**< Array of struct kernel_symbol. */
     191    LNX_PTR_T                           uPtrUnusedGplCrcs;  /**< unsigned long array */
     192    /** @} */
     193
     194    uint8_t                             sig_ok;
     195    uint8_t                             async_probe_requested;
     196
     197    /** @name Future GPL Symbols
     198     * @{ */
     199    LNX_PTR_T                           uPtrGplFutureSyms;  /**< Array of struct kernel_symbol. */
     200    LNX_PTR_T                           uPtrGplFutureCrcs;  /**< unsigned long array */
     201    uint32_t                            num_gpl_future_syms;
     202    /** @} */
     203
     204    /** @name Exception table.
     205     * @{ */
     206    uint32_t                            num_exentries;
     207    LNX_PTR_T                           uPtrEntries;        /**< struct exception_table_entry array. */
     208    /** @} */
     209
     210    LNX_PTR_T                           pfnInit;
     211    RT_CONCAT(LNXKMODLAYOUT,LNX_SUFFIX) CoreLayout;         /**< Should be aligned on a cache line. */
     212    RT_CONCAT(LNXKMODLAYOUT,LNX_SUFFIX) InitLayout;
     213
     214#elif LNX_VER >= LNX_MK_VER(2,5,48)
    89215    /*
    90216     * This first part is mostly always the same.
     
    284410     * Create a simple module for it.
    285411     */
    286     LogRelFunc((" %#RX64: %#RX64 LB %#RX64 %s\n", pAddrModule->FlatPtr, Module.uPtrModuleCore, Module.cbCore, pszName));
     412#if LNX_VER >= LNX_MK_VER(4,5,0)
     413    LNX_PTR_T uPtrModuleCore = Module.CoreLayout.uPtrBase;
     414    uint32_t cbCore          = Module.CoreLayout.cb;
     415#else
     416    LNX_PTR_T uPtrModuleCore = Module.uPtrModuleCore;
     417    uint32_t cbCore          = (uint32_t)Module.cbCore;
     418#endif
     419    LogRelFunc((" %#RX64: %#RX64 LB %#RX32 %s\n", pAddrModule->FlatPtr, uPtrModuleCore, cbCore, pszName));
    287420
    288421    RTDBGMOD hDbgMod;
    289     rc = RTDbgModCreate(&hDbgMod, pszName, Module.cbCore, 0 /*fFlags*/);
     422    rc = RTDbgModCreate(&hDbgMod, pszName, cbCore, 0 /*fFlags*/);
    290423    if (RT_SUCCESS(rc))
    291424    {
     
    294427        {
    295428            RTDBGAS hAs = DBGFR3AsResolveAndRetain(pUVM, DBGF_AS_KERNEL);
    296             rc = RTDbgAsModuleLink(hAs, hDbgMod, Module.uPtrModuleCore, RTDBGASLINK_FLAGS_REPLACE /*fFlags*/);
     429            rc = RTDbgAsModuleLink(hAs, hDbgMod, uPtrModuleCore, RTDBGASLINK_FLAGS_REPLACE /*fFlags*/);
    297430            RTDbgAsRelease(hAs);
    298431        }
  • trunk/src/VBox/Debugger/DBGPlugInLinuxModuleVerTmpl.cpp.h

    r82968 r90408  
    1919 * Newest first so the list walker can select the right instance.
    2020 */
     21
     22#define LNX_VER     LNX_MK_VER(4,5,0)
     23#define LNX_SUFFIX  RT_CONCAT(_4_5_0,LNX_BIT_SUFFIX)
     24#include LNX_TEMPLATE_HEADER
    2125
    2226#define LNX_VER     LNX_MK_VER(2,6,27)
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