Changeset b4ad39f in mainline


Ignore:
Timestamp:
2010-04-26T22:23:16Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b8f7ea78
Parents:
aeb6f25
Message:

Do not hold the sysinfo spinlock either when doing copy_from_uspace().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/sysinfo/sysinfo.c

    raeb6f25 rb4ad39f  
    632632/** Return sysinfo item determined by name from user space
    633633 *
    634  * Should be called with interrupts disabled
    635  * and sysinfo_lock held. The path string passed from
    636  * the user space has to be properly null-terminated
     634 * The path string passed from the user space has to be properly null-terminated
    637635 * (the last passed character must be null).
    638636 *
     
    656654       
    657655        if ((copy_from_uspace(path, ptr, size + 1) == 0)
    658             && (path[size] == 0))
     656            && (path[size] == 0)) {
     657                /*
     658                 * Prevent other functions from messing with sysinfo while we
     659                 * are reading it.
     660                 */
     661                ipl_t ipl = interrupts_disable();
     662                spinlock_lock(&sysinfo_lock);
    659663                ret = sysinfo_get_item(path, NULL, dry_run);
    660        
     664                spinlock_unlock(&sysinfo_lock);
     665                interrupts_restore(ipl);
     666        }
    661667        free(path);
    662668        return ret;
     
    677683unative_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size)
    678684{
    679         /* Avoid other functions to mess with sysinfo
    680            while we are reading it */
    681         ipl_t ipl = interrupts_disable();
    682         spinlock_lock(&sysinfo_lock);
    683        
    684         /* Get the item.
    685        
    686            N.B.: There is no need to free any potential generated
    687            binary data since we request a dry run */
     685        /*
     686         * Get the item.
     687         *
     688         * N.B.: There is no need to free any potential generated
     689         * binary data since we request a dry run.
     690         */
    688691        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
    689692       
    690         /* Map generated value types to constant types
    691            (user space does not care whether the
    692            value is constant or generated) */
     693        /*
     694         * Map generated value types to constant types (user space does not care
     695         * whether the value is constant or generated).
     696         */
    693697        if (ret.tag == SYSINFO_VAL_FUNCTION_VAL)
    694698                ret.tag = SYSINFO_VAL_VAL;
     
    696700                ret.tag = SYSINFO_VAL_DATA;
    697701       
    698         spinlock_unlock(&sysinfo_lock);
    699         interrupts_restore(ipl);
    700        
    701702        return (unative_t) ret.tag;
    702703}
     
    719720    void *value_ptr)
    720721{
    721         /* Avoid other functions to mess with sysinfo
    722            while we are reading it */
    723         ipl_t ipl = interrupts_disable();
    724         spinlock_lock(&sysinfo_lock);
    725        
    726         /* Get the item.
    727        
    728            N.B.: There is no need to free any potential generated
    729            binary data since we request a dry run */
     722        int rc;
     723
     724        /*
     725         * Get the item.
     726         *
     727         * N.B.: There is no need to free any potential generated binary data
     728         * since we request a dry run.
     729         */
    730730        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
    731 
    732         spinlock_unlock(&sysinfo_lock);
    733         interrupts_restore(ipl);
    734        
    735         int rc;
    736731       
    737732        /* Only constant or generated numerical value is returned */
     
    761756    void *size_ptr)
    762757{
    763         /* Avoid other functions to mess with sysinfo
    764            while we are reading it */
    765         ipl_t ipl = interrupts_disable();
    766         spinlock_lock(&sysinfo_lock);
    767        
    768         /* Get the item.
    769        
    770            N.B.: There is no need to free any potential generated
    771            binary data since we request a dry run */
     758        int rc;
     759       
     760        /*
     761         * Get the item.
     762         *
     763         * N.B.: There is no need to free any potential generated binary data
     764         * since we request a dry run.
     765         */
    772766        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
    773 
    774         spinlock_unlock(&sysinfo_lock);
    775         interrupts_restore(ipl);
    776        
    777         int rc;
    778767       
    779768        /* Only the size of constant or generated binary data is considered */
     
    809798    void *buffer_ptr, size_t buffer_size)
    810799{
    811         /* Avoid other functions to mess with sysinfo
    812            while we are reading it */
    813         ipl_t ipl = interrupts_disable();
    814         spinlock_lock(&sysinfo_lock);
     800        int rc;
    815801       
    816802        /* Get the item */
    817803        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, false);
    818804
    819         spinlock_unlock(&sysinfo_lock);
    820         interrupts_restore(ipl);
    821 
    822         int rc;
    823        
    824805        /* Only constant or generated binary data is considered */
    825806        if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA)) {
Note: See TracChangeset for help on using the changeset viewer.