Ignore:
Timestamp:
Apr 10, 2019, 10:09:39 AM (2 years ago)
Author:
alain
Message:

Fix a bug in the vmm_remove_vseg() function: the physical pages
associated to an user DATA vseg were released to the kernel when
the target process descriptor was in the reference cluster.
This physical pages release should be done only when the page
forks counter value is zero.
All other modifications are cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/core/hal_gpt.c

    r624 r625  
    823823///////////////////////////////////////////
    824824error_t hal_gpt_pte_copy( gpt_t  * dst_gpt,
     825                          vpn_t    dst_vpn,
    825826                          xptr_t   src_gpt_xp,
    826                           vpn_t    vpn,
     827                          vpn_t    src_vpn,
    827828                          bool_t   cow,
    828829                          ppn_t  * ppn,
    829830                          bool_t * mapped )
    830831{
    831     uint32_t     ix1;       // index in PT1
    832     uint32_t     ix2;       // index in PT2
     832    uint32_t     src_ix1;   // index in SRC PT1
     833    uint32_t     src_ix2;   // index in SRC PT2
     834
     835    uint32_t     dst_ix1;   // index in DST PT1
     836    uint32_t     dst_ix2;   // index in DST PT2
    833837
    834838    cxy_t        src_cxy;   // SRC GPT cluster
     
    862866thread_t * this  = CURRENT_THREAD;
    863867if( DEBUG_HAL_GPT_COPY < cycle )
    864 printk("\n[%s] : thread[%x,%x] enter / vpn %x / src_cxy %x / dst_cxy %x / cycle %d\n",
    865 __FUNCTION__, this->process->pid, this->trdid, vpn, src_cxy, local_cxy, cycle );
     868printk("\n[%s] : thread[%x,%x] enter / src_cxy %x / dst_cxy %x / cycle %d\n",
     869__FUNCTION__, this->process->pid, this->trdid, src_cxy, local_cxy, cycle );
    866870#endif
    867871
     
    878882    assert( (dst_pt1 != NULL) , "dst_pt1 does not exist\n");
    879883
    880     ix1 = TSAR_MMU_IX1_FROM_VPN( vpn );
    881     ix2 = TSAR_MMU_IX2_FROM_VPN( vpn );
     884    // compute SRC indexes
     885    src_ix1 = TSAR_MMU_IX1_FROM_VPN( src_vpn );
     886    src_ix2 = TSAR_MMU_IX2_FROM_VPN( src_vpn );
     887
     888    // compute DST indexes
     889    dst_ix1 = TSAR_MMU_IX1_FROM_VPN( dst_vpn );
     890    dst_ix2 = TSAR_MMU_IX2_FROM_VPN( dst_vpn );
    882891
    883892    // get src_pte1
    884     src_pte1 = hal_remote_l32( XPTR( src_cxy , &src_pt1[ix1] ) );
     893    src_pte1 = hal_remote_l32( XPTR( src_cxy , &src_pt1[src_ix1] ) );
    885894
    886895    // do nothing if src_pte1 not MAPPED or not SMALL
     
    888897    {
    889898        // get dst_pt1 entry
    890         dst_pte1 = dst_pt1[ix1];
     899        dst_pte1 = dst_pt1[dst_ix1];
    891900
    892901        // map dst_pte1 if required
     
    915924
    916925            // register it in DST_GPT
    917             dst_pt1[ix1] = dst_pte1;
     926            dst_pt1[dst_ix1] = dst_pte1;
    918927        }
    919928
     
    927936
    928937        // get attr and ppn from SRC_PT2
    929         src_pte2_attr = hal_remote_l32( XPTR( src_cxy , &src_pt2[2 * ix2]     ) );
    930         src_pte2_ppn  = hal_remote_l32( XPTR( src_cxy , &src_pt2[2 * ix2 + 1] ) );
     938        src_pte2_attr = hal_remote_l32( XPTR( src_cxy , &src_pt2[2 * src_ix2]     ) );
     939        src_pte2_ppn  = hal_remote_l32( XPTR( src_cxy , &src_pt2[2 * src_ix2 + 1] ) );
    931940
    932941        // do nothing if src_pte2 not MAPPED
     
    934943        {
    935944            // set PPN in DST PTE2
    936             dst_pt2[2*ix2+1] = src_pte2_ppn;
     945            dst_pt2[2 * dst_ix2 + 1] = src_pte2_ppn;
    937946                       
    938947            // set attributes in DST PTE2         
    939948            if( cow && (src_pte2_attr & TSAR_MMU_WRITABLE) )
    940949            {
    941                 dst_pt2[2*ix2] = (src_pte2_attr | TSAR_MMU_COW) & (~TSAR_MMU_WRITABLE);
     950                dst_pt2[2 * dst_ix2] = (src_pte2_attr | TSAR_MMU_COW) & (~TSAR_MMU_WRITABLE);
    942951            }
    943952            else
    944953            {
    945                 dst_pt2[2*ix2] = src_pte2_attr;
     954                dst_pt2[2 * dst_ix2] = src_pte2_attr;
    946955            }
    947956
     
    953962cycle = (uint32_t)hal_get_cycles;
    954963if( DEBUG_HAL_GPT_COPY < cycle )
    955 printk("\n[%s] : thread[%x,%x] exit / copy done for vpn %x / cycle %d\n",
    956 __FUNCTION__, this->process->pid, this->trdid, vpn, cycle );
     964printk("\n[%s] : thread[%x,%x] exit / copy done for src_vpn %x / dst_vpn %x / cycle %d\n",
     965__FUNCTION__, this->process->pid, this->trdid, src_vpn, dst_vpn, cycle );
    957966#endif
    958967
     
    970979cycle = (uint32_t)hal_get_cycles;
    971980if( DEBUG_HAL_GPT_COPY < cycle )
    972 printk("\n[%s] : thread[%x,%x] exit / nothing done for vpn %x / cycle %d\n",
    973 __FUNCTION__, this->process->pid, this->trdid, vpn, cycle );
     981printk("\n[%s] : thread[%x,%x] exit / nothing done / cycle %d\n",
     982__FUNCTION__, this->process->pid, this->trdid, cycle );
    974983#endif
    975984
Note: See TracChangeset for help on using the changeset viewer.