VirtualBox

Changeset 21452 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jul 9, 2009 5:43:31 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49866
Message:

Solaris/vbi: Fixed preemption issue for Solaris 10 by hardcoded offsets.

Location:
trunk/src/VBox/Runtime/r0drv/solaris/vbi
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c

    r20471 r21452  
    5656#include <sys/modctl.h>
    5757#include <sys/machparam.h>
     58#include <sys/utsname.h>
    5859
    5960#include "vbi.h"
     
    111112 */
    112113static struct modlmisc vbi_modlmisc = {
    113         &mod_miscops, "VirtualBox Interfaces V5"
     114        &mod_miscops, "VirtualBox Interfaces V6"
    114115};
    115116
     
    124125
    125126#define VBI_VERBOSE(msg) {if (vbi_verbose) cmn_err(CE_WARN, msg);}
     127
     128/* Introduced in v6 */
     129static int vbi_is_nevada = 0;
     130
     131#ifdef _LP64
     132/* 64-bit Solaris 10 offsets */
     133/* CPU */
     134static int off_s10_cpu_runrun   = 232;
     135static int off_s10_cpu_kprunrun = 233;
     136/* kthread_t */
     137static int off_s10_t_preempt    = 42;
     138
     139/* 64-bit Solaris 11 (Nevada/OpenSolaris) offsets */
     140/* CPU */
     141static int off_s11_cpu_runrun   = 216;
     142static int off_s11_cpu_kprunrun = 217;
     143/* kthread_t */
     144static int off_s11_t_preempt    = 42;
     145#else
     146/* 32-bit Solaris 10 offsets */
     147/* CPU */
     148static int off_s10_cpu_runrun   = 124;
     149static int off_s10_cpu_kprunrun = 125;
     150/* kthread_t */
     151static int off_s10_t_preempt    = 26;
     152
     153/* 32-bit Solaris 11 (Nevada/OpenSolaris) offsets */
     154/* CPU */
     155static int off_s11_cpu_runrun   = 112;
     156static int off_s11_cpu_kprunrun = 113;
     157/* kthread_t */
     158static int off_s11_t_preempt    = 26;
     159#endif
     160
     161
     162/* Which offsets will be used */
     163static int off_cpu_runrun       = -1;
     164static int off_cpu_kprunrun     = -1;
     165static int off_t_preempt        = -1;
     166
     167#define VBI_T_PREEMPT            (*((char *)curthread + off_t_preempt))
     168#define VBI_CPU_KPRUNRUN         (*((char *)CPU + off_cpu_kprunrun))
     169#define VBI_CPU_RUNRUN           (*((char *)CPU + off_cpu_runrun))
     170
     171#undef kpreempt_disable
     172#undef kpreempt_enable
     173
     174#define VBI_PREEMPT_DISABLE()                   \
     175        {                                                                       \
     176                VBI_T_PREEMPT++;                                \
     177                ASSERT(VBI_T_PREEMPT >= 1);             \
     178        }
     179#define VBI_PREEMPT_ENABLE()                    \
     180        {                                                                       \
     181                ASSERT(VBI_T_PREEMPT >= 1);             \
     182                if (--VBI_T_PREEMPT == 0 &&     \
     183                    VBI_CPU_RUNRUN)                             \
     184                        kpreempt(KPREEMPT_SYNC);        \
     185        }
     186
     187/* End of v6 intro */
     188
    126189
    127190int
     
    161224        }
    162225
     226        /*
     227         * Check if this is S10 or Nevada
     228         */
     229        if (!strncmp(utsname.release, "5.11", sizeof("5.11") - 1))
     230        {
     231                /* Nevada detected... */
     232                vbi_is_nevada = 1;
     233
     234                off_cpu_runrun = off_s11_cpu_runrun;
     235                off_cpu_kprunrun = off_s11_cpu_kprunrun;
     236                off_t_preempt = off_s11_t_preempt;
     237        }
     238        else
     239        {
     240                /* Solaris 10 detected... */
     241                vbi_is_nevada = 0;
     242
     243                off_cpu_runrun = off_s10_cpu_runrun;
     244                off_cpu_kprunrun = off_s10_cpu_kprunrun;
     245                off_t_preempt = off_s10_t_preempt;
     246        }
     247
     248        /*
     249         * Sanity checking...
     250         */
     251        /* CPU */
     252        char crr = VBI_CPU_RUNRUN;
     253        char krr = VBI_CPU_KPRUNRUN;
     254        if (   (crr < 0 || crr > 1)
     255                || (krr < 0 || krr > 1))
     256        {
     257                cmn_err(CE_NOTE, ":CPU structure sanity check failed! OS version mismatch.\n");
     258                return EINVAL;
     259        }
     260
     261        /* Thread */
     262        char t_preempt = VBI_T_PREEMPT;
     263        if (t_preempt < 0 || t_preempt > 32)
     264        {
     265                cmn_err(CE_NOTE, ":Thread structure sanity check failed! OS version mismatch.\n");
     266                return EINVAL;
     267        }
     268
    163269        err = mod_install(&vbi_modlinkage);
    164270        if (err != 0)
     
    287393        int rv = 0;
    288394
    289         kpreempt_disable();
    290         if (curthread->t_preempt == 1 && CPU->cpu_kprunrun)
     395        vbi_preempt_disable();
     396
     397        char tpr = VBI_T_PREEMPT;
     398        char kpr = VBI_CPU_KPRUNRUN;
     399        if (tpr == 1 && kpr)
    291400                rv = 1;
    292         kpreempt_enable();
     401
     402        vbi_preempt_enable();
    293403        return (rv);
    294404}
     
    474584vbi_preempt_disable(void)
    475585{
    476         kpreempt_disable();
     586        VBI_PREEMPT_DISABLE();
    477587}
    478588
     
    480590vbi_preempt_enable(void)
    481591{
    482         kpreempt_enable();
     592        VBI_PREEMPT_ENABLE();
    483593}
    484594
     
    10691179vbi_is_preempt_enabled(void)
    10701180{
    1071         return (curthread->t_preempt == 0);
     1181        char tpr = VBI_T_PREEMPT;
     1182        return (tpr == 0);
    10721183}
    10731184
     
    10841195 * increased. Also change vbi_modlmisc at the top of the file.
    10851196 */
    1086 uint_t vbi_revision_level = 5;
     1197uint_t vbi_revision_level = 6;
    10871198
    10881199void *
     
    10971208        p_contig_free(va, size);
    10981209}
     1210
     1211/*
     1212 * This is revision 6 of the interface.
     1213 */
     1214
     1215int
     1216vbi_is_preempt_pending(void)
     1217{
     1218        char crr = VBI_CPU_RUNRUN;
     1219        char krr = VBI_CPU_KPRUNRUN;
     1220        return crr != 0 || krr != 0;
     1221}
     1222
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/sys/vbi.h

    r20480 r21452  
    331331/* end of interfaces defined for version 5 */
    332332
     333/* begin interfaces defined for version 6 */
     334extern int vbi_is_preempt_pending(void);
     335
     336/* end of interfaces defined for version 6 */
     337
    333338#ifdef  __cplusplus
    334339}
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread-r0drv-solaris.c

    r20124 r21452  
    108108    Assert(hThread == NIL_RTTHREAD);
    109109    /** @todo Review this! */
    110     return CPU->cpu_runrun   != 0
    111         || CPU->cpu_kprunrun != 0;
     110    return !!vbi_is_preempt_pending();
    112111}
    113112
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