Ignore:
Timestamp:
Apr 10, 2019, 10:09:39 AM (5 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_kentry.S

    r438 r625  
    44 * AUthors   Ghassan Almaless (2007,2008,2009,2010,2011,2012)
    55 *           Mohamed Lamine Karaoui (2015)
    6  *           Alain Greiner (2017)
     6 *           Alain Greiner (2016,2017,2018,2019)
    77 *
    88 * Copyright (c) UPMC Sorbonne Universites
     
    8787#------------------------------------------------------------------------------------
    8888# Kernel Entry point for Interrupt / Exception / Syscall
    89 # The c2_dext and c2_iext CP2 registers must have been previously set
    90 # to "local_cxy", because the kernel run with MMU desactivated.
     89# The c2_dext CP2 register must have been previously set
     90# to "local_cxy", because the kernel run with data MMU desactivated.
    9191#------------------------------------------------------------------------------------
    9292
     
    9696        andi    $26,    $26,  0x10          # test User Mode bit
    9797        beq     $26,    $0,       kernel_mode   # jump if core already in kernel
    98         ori     $27,    $0,       0x3           # $27 <= code for MMU OFF
     98        ori     $27,    $0,       0xB           # $27 <= code data MMU OFF
    9999       
    100100#------------------------------------------------------------------------------------
     
    102102# to handle a syscall, an interrupt, or an user exception.
    103103# - save current c2_mode in $26.
    104 # - set MMU OFF.
     104# - set data MMU OFF.
    105105# - copy user stack pointer in $27 to be saved in uzone.
    106 # - set kernel stack pointer in $29 == top_kernel_stack(this).
     106# - set kernel stack pointer in $29 (kernel stack empty at firts entry).
    107107
    108108user_mode:
    109109
    110110    mfc2    $26,    $1                  # $26 <= c2_mode
    111         mtc2    $27,    $1                              # set MMU OFF
     111        mtc2    $27,    $1                              # set data MMU OFF
    112112    move    $27,    $29                 # $27 <= user stack pointer
    113113        mfc0    $29,    $4,   2             # get pointer on thread descriptor from c0_th
     
    121121# after a syscall, to handle an interrupt, or to handle a non-fatal exception.
    122122# - save current c2_mode in $26.
    123 # - set MMU OFF.
     123# - set data MMU OFF.
    124124# - copy current kernel stack pointer in $27.
    125125
     
    127127
    128128    mfc2    $26,    $1                  # $26 <= c2_mode
    129         mtc2    $27,    $1                              # set MMU OFF
     129        mtc2    $27,    $1                              # set data MMU OFF
    130130    move    $27,    $29                 # $27 <= current kernel stack pointer
    131131
     
    133133# This code is executed in both modes (user or kernel):
    134134# The assumptions are:
    135 # - c2_mode contains the MMU OFF value.
     135# - c2_mode contains the data MMU OFF value.
    136136# - $26 contains the previous c2_mode value.
    137137# - $27 contains the previous sp value (can be usp or ksp).
     
    139139# We execute the following actions:
    140140# - decrement $29 to allocate an uzone in kernel stack
    141 # - save relevant GPR, CP0 and CP2 registers to uzone.
    142 # - set the SR in kernel mode: IRQ disabled, clear exl.
     141# - save GPR, CP0 and CP2 registers to uzone.
     142# - set the SR in kernel mode: IRQ disabled, clear EXL.
    143143
    144144unified_mode:
     
    195195    sw      $26,    (UZ_MODE*4)($29)    # save previous c2_mode (can be user or kernel)
    196196
    197     mfc0    $3,     $12
     197    mfc0    $3,     $12                 # $3 <= c0_sr
    198198        srl         $3,     $3,   5
    199199        sll     $3,         $3,   5                 # reset 5 LSB bits
     
    216216    nop
    217217    move    $4,     $2
     218    jal     putd
     219    nop
     220    la      $4,     msg_crlf
     221    jal     puts
     222    nop   
     223    # display saved CR value
     224    la      $4,     msg_cr
     225    jal     puts
     226    nop
     227    lw      $4,         (UZ_CR*4)($29)
    218228    jal     putx
    219229    nop
     
    286296   
    287297#------------------------------------------------------------------------------------
    288 # This code handle the uzone pointers stack, and calls the relevant
     298# This code handle the two-slots uzone pointers stack, and calls the relevant
    289299# Interrupt / Exception / Syscall handler, depending on XCODE in CP0_CR.
    290300# Both the hal_do_syscall() and the hal_do_exception() functions use
     
    338348# - All registers saved in the uzone are restored, using the pointer on uzone,
    339349#   that is contained in $29.
    340 # - The "uzone" field in thread descriptor, that has beeen modified at kernel entry
    341 #   is restored from value contained in the uzone[UZ_SP] slot.
     350# - The "current_uzone" pointer in thread descriptor, that has beeen modified at
     351#   kernel entry is restored from value contained in the uzone[UZ_SP] slot.
    342352# -----------------------------------------------------------------------------------
    343353
     
    365375    nop
    366376    move    $4,     $2
     377    jal     putd
     378    nop
     379    la      $4,     msg_crlf
     380    jal     puts
     381    nop   
     382    # display saved CR value
     383    la      $4,     msg_cr
     384    jal     puts
     385    nop
     386    lw      $4,         (UZ_CR*4)($29)
    367387    jal     putx
    368388    nop
     
    479499
    480500        lw          $26,    (UZ_MODE*4)($27)   
    481     mtc2    $26,    $1                  # restore CP2_MODE from uzone
     501    mtc2    $26,    $1                  # restore c2_mode from uzone
    482502
    483503# -----------------------------------------------------------------------------------
     
    494514    .section .kdata
    495515
     516msg_cr:
     517    .align 2
     518    .asciiz "- UZ_CR   = "
    496519msg_sp:
    497520    .align 2
Note: See TracChangeset for help on using the changeset viewer.