Changeset 629 for trunk/kernel/libk


Ignore:
Timestamp:
May 17, 2019, 9:27:04 AM (5 years ago)
Author:
alain
Message:

Remove the "giant" rwlock protecting the GPT, and
use the GPT_LOCKED attribute in each PTE to prevent
concurrent modifications of one GPT entry.
The version number has been incremented to 2.1.

Location:
trunk/kernel/libk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/queuelock.c

    r623 r629  
    22 * queuelock.c - local kernel lock with waiting queue implementation.
    33 *
    4  * Authors   Alain Greiner     (2016,2017,2018)
     4 * Authors   Alain Greiner     (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    4747#if DEBUG_QUEUELOCK_TYPE
    4848thread_t * this = CURRENT_THREAD;
    49 if( DEBUG_QUEUELOCK_TYPE == type )
     49if( (type      == DEBUG_QUEUELOCK_TYPE) &&
     50    (lock      == DEBUG_QUEUELOCK_PTR ) &&
     51    (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    5052printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
    5153__FUNCTION__, this->process->pid, this->trdid,
     
    7577
    7678#if DEBUG_QUEUELOCK_TYPE
    77 if( (DEBUG_QUEUELOCK_TYPE == lock_type) || (DEBUG_QUEUELOCK_TYPE == 1000) )
     79if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     80    (lock      == DEBUG_QUEUELOCK_PTR ) &&
     81    (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    7882printk("\n[%s ] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n",
    7983__FUNCTION__, this->process->pid, this->trdid,
     
    100104
    101105#if DEBUG_QUEUELOCK_TYPE
    102 if( (DEBUG_QUEUELOCK_TYPE == lock_type) || (DEBUG_QUEUELOCK_TYPE == 1000) )
     106if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     107    (lock      == DEBUG_QUEUELOCK_PTR ) &&
     108    (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    103109printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n",
    104110__FUNCTION__, this->process->pid, this->trdid,
     
    126132uint32_t   lock_type = lock->lock.type;
    127133thread_t * this      = CURRENT_THREAD;
    128 if( (DEBUG_QUEUELOCK_TYPE == lock_type) || (DEBUG_QUEUELOCK_TYPE == 1000) )
     134if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     135    (lock      == DEBUG_QUEUELOCK_PTR ) &&
     136    (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    129137printk("\n[%s] thread[%x,%x] RELEASE q_lock %s [%x,%x]\n",
    130138__FUNCTION__, this->process->pid, this->trdid,
     
    142150
    143151#if DEBUG_QUEUELOCK_TYPE
    144 if( (DEBUG_QUEUELOCK_TYPE == lock_type) || (DEBUG_QUEUELOCK_TYPE == 1000) )
     152if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     153    (lock      == DEBUG_QUEUELOCK_PTR ) &&
     154    (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    145155printk("\n[%s] thread[%x,%x] UNBLOCK thread [%x,%x] / q_lock %s [%x,%x]\n",
    146156__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
  • trunk/kernel/libk/remote_barrier.c

    r623 r629  
    467467if( cycle > DEBUG_BARRIER_WAIT )
    468468printk("\n[%s] thread[%x,%x] exit / barrier (%x,%x) / cycle %d\n",
    469 __FUNCTION__, this->trdid, this->process->pid, barrier_cxy, barrier_ptr, cycle );
     469__FUNCTION__, this->process->pid, this->trdid, barrier_cxy, barrier_ptr, cycle );
    470470#endif
    471471
  • trunk/kernel/libk/remote_queuelock.c

    r623 r629  
    22 * remote_queuelock.c - remote kernel lock with waiting queue implementation.
    33 *
    4  * Authors   Alain Greiner     (2016,2017,2018)
     4 * Authors   Alain Greiner     (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    5656#if DEBUG_QUEUELOCK_TYPE
    5757thread_t * this = CURRENT_THREAD;
    58 if( DEBUG_QUEUELOCK_TYPE == type )
     58if( (type     == DEBUG_QUEUELOCK_TYPE) &&
     59    (lock_ptr == DEBUG_QUEUELOCK_PTR ) &&
     60    (lock_cxy == DEBUG_QUEUELOCK_CXY ) )
    5961printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
    6062__FUNCTION__, this->process->pid, this->trdid,
     
    9193
    9294#if DEBUG_QUEUELOCK_TYPE
    93 if( (DEBUG_QUEUELOCK_TYPE == lock_type) || (DEBUG_QUEUELOCK_TYPE == 1000) )
     95if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     96    (lock_ptr  == DEBUG_QUEUELOCK_PTR ) &&
     97    (lock_cxy  == DEBUG_QUEUELOCK_CXY ) )
    9498printk("\n[%s] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n",
    9599__FUNCTION__, this->process->pid, this->trdid,
     
    117121
    118122#if DEBUG_QUEUELOCK_TYPE
    119 if( (DEBUG_QUEUELOCK_TYPE == lock_type) || (DEBUG_QUEUELOCK_TYPE == 1000) )
     123if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     124    (lock_ptr  == DEBUG_QUEUELOCK_PTR ) &&
     125    (lock_cxy  == DEBUG_QUEUELOCK_CXY ) )
    120126printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n",
    121127__FUNCTION__, this->process->pid, this->trdid,
     
    152158thread_t * this      = CURRENT_THREAD;
    153159uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
    154 if( (DEBUG_QUEUELOCK_TYPE == lock_type) || (DEBUG_QUEUELOCK_TYPE == 1000) )
     160if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     161    (lock_ptr  == DEBUG_QUEUELOCK_PTR ) &&
     162    (lock_cxy  == DEBUG_QUEUELOCK_CXY ) )
    155163printk("\n[%s] thread[%x,%x] RELEASE q_lock %s (%x,%x)\n",
    156164__FUNCTION__, this->process->pid, this->trdid,
     
    171179
    172180#if DEBUG_QUEUELOCK_TYPE
    173 if( (DEBUG_QUEUELOCK_TYPE == lock_type) || (DEBUG_QUEUELOCK_TYPE == 1000) )
     181if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     182    (lock_ptr  == DEBUG_QUEUELOCK_PTR ) &&
     183    (lock_cxy  == DEBUG_QUEUELOCK_CXY ) )
    174184{
    175185    trdid_t     trdid   = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
  • trunk/kernel/libk/remote_rwlock.c

    r627 r629  
    5555#if DEBUG_RWLOCK_TYPE
    5656thread_t * this = CURRENT_THREAD;
    57 if( DEBUG_RWLOCK_TYPE == type )
     57if( (type               == DEBUG_RWLOCK_TYPE) &&
     58    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     59    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    5860printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
    5961__FUNCTION__, this->process->pid, this->trdid,
     
    9395
    9496#if DEBUG_RWLOCK_TYPE
    95 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     97if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     98    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     99    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    96100printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
    97101__FUNCTION__, this->process->pid, this->trdid,
     
    124128
    125129#if DEBUG_RWLOCK_TYPE
    126 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
    127 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken = %d / count = %d\n",
     130if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     131    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     132    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
     133printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
    128134__FUNCTION__, this->process->pid, this->trdid,
    129135lock_type_str[lock_type], lock_cxy, lock_ptr,
     
    166172
    167173#if DEBUG_RWLOCK_TYPE
    168 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     174if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     175    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     176    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    169177printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
    170178__FUNCTION__, this->process->pid, this->trdid,
     
    196204
    197205#if DEBUG_RWLOCK_TYPE
    198 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     206if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     207    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     208    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    199209printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
    200210__FUNCTION__, this->process->pid, this->trdid,
     
    235245uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
    236246xptr_t     taken_xp  = XPTR( lock_cxy , &lock_ptr->taken );
    237 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     247if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     248    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     249    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    238250printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
    239251__FUNCTION__, this->process->pid, this->trdid,
     
    258270
    259271#if DEBUG_RWLOCK_TYPE
    260 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     272if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     273    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     274    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    261275{
    262276    trdid_t     trdid     = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
     
    289303
    290304#if DEBUG_RWLOCK_TYPE
    291 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     305if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     306    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     307    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    292308{
    293309    trdid_t     trdid     = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
     
    334350uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
    335351xptr_t     count_xp  = XPTR( lock_cxy , &lock_ptr->count );
    336 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     352if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     353    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     354    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    337355printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
    338356__FUNCTION__, this->process->pid, this->trdid,
     
    356374
    357375#if DEBUG_RWLOCK_TYPE
    358 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     376if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     377    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     378    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    359379{
    360380    trdid_t     trdid     = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
     
    386406
    387407#if DEBUG_RWLOCK_TYPE
    388 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     408if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
     409    ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
     410    (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    389411{
    390412    trdid_t     trdid     = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
  • trunk/kernel/libk/remote_rwlock.h

    r627 r629  
    4242 *   taken, or if the number of readers is non zero, it registers in the "wr_root" waiting
    4343 *   queue, blocks, and deschedules. It set "taken" otherwise.
    44  * - when a reader completes its access, it decrement the readers "count", unblock the
     44 * - when a reader completes its access, it decrement the readers "count", unblock
    4545 *   the first waiting writer if there is no other readers, and unblock all waiting
    4646 *   readers if there no write request.
  • trunk/kernel/libk/rwlock.c

    r623 r629  
    22 * rwlock.c - kernel local read/write lock implementation.
    33 *
    4  * Author  Alain Greiner     (2016,2017,2018)
     4 * Author  Alain Greiner     (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    5252#if DEBUG_RWLOCK_TYPE
    5353thread_t * this = CURRENT_THREAD;
    54 if( DEBUG_RWLOCK_TYPE == type )
     54if( (type           == DEBUG_RWLOCK_TYPE) &&
     55    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     56    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    5557printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
    5658__FUNCTION__, this->process->pid, this->trdid,
     
    8082
    8183#if DEBUG_RWLOCK_TYPE
    82 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     84if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     85    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     86    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    8387printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
    8488__FUNCTION__, this->process->pid, this->trdid,
     
    105109
    106110#if DEBUG_RWLOCK_TYPE
    107 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     111if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     112    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     113    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    108114printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
    109115__FUNCTION__, this->process->pid, this->trdid,
     
    136142
    137143#if DEBUG_RWLOCK_TYPE
    138 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     144if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     145    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     146    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    139147printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
    140148__FUNCTION__, this->process->pid, this->trdid,
     
    161169
    162170#if DEBUG_RWLOCK_TYPE
    163 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     171if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     172    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     173    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    164174printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
    165175__FUNCTION__, this->process->pid, this->trdid,
     
    187197thread_t * this = CURRENT_THREAD;
    188198uint32_t lock_type = lock->lock.type;
    189 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     199if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     200    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     201    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    190202printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
    191203__FUNCTION__, this->process->pid, this->trdid,
     
    201213
    202214#if DEBUG_RWLOCK_TYPE
    203 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     215if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     216    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     217    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    204218printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n",
    205219__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
     
    223237
    224238#if DEBUG_RWLOCK_TYPE
    225 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     239if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     240    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     241    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    226242printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n",
    227243__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
     
    257273thread_t * this = CURRENT_THREAD;
    258274uint32_t lock_type = lock->lock.type;
    259 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     275if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     276    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     277    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    260278printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
    261279__FUNCTION__, this->process->pid, this->trdid,
     
    270288
    271289#if DEBUG_RWLOCK_TYPE
    272 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     290if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     291    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     292    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    273293printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n",
    274294__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
     
    291311
    292312#if DEBUG_RWLOCK_TYPE
    293 if( (DEBUG_RWLOCK_TYPE == lock_type) || (DEBUG_RWLOCK_TYPE == 1000) )
     313if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
     314    ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
     315    (local_cxy      == DEBUG_RWLOCK_CXY ) )
    294316printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n",
    295317__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
  • trunk/kernel/libk/user_dir.c

    r619 r629  
    22 * user_dir.c - kernel DIR related operations implementation.
    33 *
    4  * Authors   Alain   Greiner (2016,2017,2018)
     4 * Authors   Alain   Greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    9191    pid_t           ref_pid;           // reference process PID
    9292    xptr_t          gpt_xp;            // extended pointer on reference process GPT
    93     uint32_t        gpt_attributes;    // attributes for all mapped gpt entries
     93    uint32_t        attr;              // attributes for all GPT entries
    9494    uint32_t        dirents_per_page;  // number of dirent descriptors per page
    9595    xptr_t          page_xp;           // extended pointer on page descriptor 
     
    9999    uint32_t        total_dirents;     // total number of dirents in dirent array
    100100    uint32_t        total_pages;       // total number of pages for dirent array
    101     vpn_t           vpn;               // first page in dirent array vseg
     101    vpn_t           vpn_base;          // first page in dirent array vseg
     102    vpn_t           vpn;               // current page in dirent array vseg
    102103    ppn_t           ppn;               // ppn of currently allocated physical page
    103104    uint32_t        entries;           // number of dirent actually comied in one page
     
    107108    uint32_t        page_id;           // page index in list of physical pages
    108109    kmem_req_t      req;               // kmem request descriptor
     110    ppn_t           fake_ppn;          // unused, but required by hal_gptlock_pte()
     111    uint32_t        fake_attr;         // unused, but required by hal_gptlock_pte()
    109112    error_t         error;
    110113
    111     // get cluster, local pointer, and pid of reference user process
     114    // get cluster, local pointer, and pid of reference process
    112115    ref_cxy = GET_CXY( ref_xp );
    113116    ref_ptr = GET_PTR( ref_xp );
     
    256259"unconsistent vseg size for dirent array" );
    257260
    258     // build extended pointer on reference process GPT, PTE attributes and ppn
     261    // build extended pointer on reference process GPT
    259262    gpt_xp         = XPTR( ref_cxy , &ref_ptr->vmm.gpt );
    260     gpt_attributes = GPT_MAPPED   |
    261                      GPT_SMALL    |
    262                      GPT_READABLE |
    263                      GPT_CACHABLE |
    264                      GPT_USER     ;
     263
     264    // build PTE attributes
     265    attr = GPT_MAPPED   |
     266           GPT_SMALL    |
     267           GPT_READABLE |
     268           GPT_CACHABLE |
     269           GPT_USER     ;
    265270
    266271    // get first vpn from vseg descriptor
    267     vpn = hal_remote_l32( XPTR( ref_cxy , &vseg->vpn_base ) );
     272    vpn_base = hal_remote_l32( XPTR( ref_cxy , &vseg->vpn_base ) );
    268273
    269274    // scan the list of allocated physical pages to map
    270     // all physical pages in the in the reference process GPT
     275    // all physical pages in the reference process GPT
    271276    page_id = 0;
    272277    while( list_is_empty( &root ) == false )
     
    277282        // compute ppn
    278283        ppn = ppm_page2ppn( XPTR( local_cxy , page ) );
     284
     285        // compute vpn
     286        vpn = vpn_base + page_id;
    279287       
    280         error = hal_gpt_set_pte( gpt_xp,
    281                                  vpn + page_id,
    282                                  gpt_attributes,
    283                                  ppn );
     288        // lock the PTE (and create PT2 if required)
     289        error = hal_gpt_lock_pte( gpt_xp,
     290                                  vpn,
     291                                  &fake_attr,
     292                                  &fake_ppn );
    284293        if( error )
    285294        {
    286295            printk("\n[ERROR] in %s : cannot map vpn %x in GPT\n",
    287             __FUNCTION__, (vpn + page_id) );
     296            __FUNCTION__, vpn );
    288297
    289298            // delete the vseg
    290             if( ref_cxy == local_cxy) vmm_delete_vseg( ref_pid, vpn<<CONFIG_PPM_PAGE_SHIFT );
    291             else rpc_vmm_delete_vseg_client( ref_cxy, ref_pid, vpn<<CONFIG_PPM_PAGE_SHIFT );
     299            if( ref_cxy == local_cxy)
     300                vmm_delete_vseg( ref_pid, vpn_base << CONFIG_PPM_PAGE_SHIFT );
     301            else
     302                rpc_vmm_delete_vseg_client( ref_cxy, ref_pid, vpn_base << CONFIG_PPM_PAGE_SHIFT );
    292303
    293304            // release the user_dir descriptor
     
    298309        }
    299310
     311        // set PTE in GPT                         
     312        hal_gpt_set_pte( gpt_xp,
     313                         vpn,
     314                         attr,
     315                         ppn );
     316
    300317#if DEBUG_USER_DIR
    301318if( cycle > DEBUG_USER_DIR )
     
    317334    dir->current = 0;
    318335    dir->entries = total_dirents;
    319     dir->ident   = (intptr_t)(vpn << CONFIG_PPM_PAGE_SHIFT);
     336    dir->ident   = (intptr_t)(vpn_base << CONFIG_PPM_PAGE_SHIFT);
    320337
    321338    // build extended pointers on root and lock of user_dir xlist in ref process
  • trunk/kernel/libk/user_dir.h

    r623 r629  
    22 * user_dir.h -  DIR related operations definition.
    33 *
    4  * Authors   Alain Greiner   (2016,2017,2018)
     4 * Authors   Alain Greiner   (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
Note: See TracChangeset for help on using the changeset viewer.