Changeset 625 for trunk/hal/generic


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

Location:
trunk/hal/generic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/generic/hal_context.h

    r457 r625  
    22 * hal_context.h - Generic Thread Context Access API definition.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3131// and hal_fpu_context_t, defined in hal_context.c file, that are accessed with generic
    3232// void* pointers stored in the thread descriptor.
    33 // - the "hal_context_t" struct is used for the CPU registers values at context switch.
    34 // - the "hal_fpu_context_t" struct is used for the FPU registers when required.
     33// - the "hal_cpu_context_t" struct saves the CPU registers values at context switch.
     34// - the "hal_fpu_context_t" struct saves the FPU registers values at FPU switch.
    3535//////////////////////////////////////////////////////////////////////////////////////////
    3636
     
    5656
    5757/****************************************************************************************
    58  * This function is used to implement the fork() system call.
    59  * 1) It saves in a remote (child) thread CPU context the current CPU registers values.
    60  *    Three slots are not simple copies of the parent registers values :
    61  *    - the thread pointer is set to the child thread local pointer.
    62  *    - the stack pointer is set to parrent SP + (child_base - parent_base).
    63  *    - the status register is set to kernel mode with IRQ disabled.
    64  * 2) It copies the content of the calling (parent) thread kernel_stack,
    65  *    to the remote (child) thread kernel_stack.
     58 * This function is called the sys_fork() function to complete the fork mechanism.
     59 * It is called by th local parent thread to initialize the CPU context of the remote
     60 * child thread, identified by the <thread_xp> argument.
     61 * It makes three actions:
     62 * 1) It copies the current values of the CPU registers of the core running the parent
     63 *    thread to the remote child CPU context.
     64 * 2) It patches four slots of this remote child CPU context:
     65 *    - the c0_th   slot is set to the child thread descriptor pointer.
     66 *    - the sp_29   slot is set to the child kernel stack pointer.
     67 *    - the c0_sr   slot is set to kernel mode with IRQ disabled.
     68 *    - the c2_ptpr slot is set to the child process GPT value.
     69 * 3) It copies the content of the parent thread kernel_stack, to the child thread
     70 *    kernel_stack, because the COW mechanism is not available on architectures where
     71 *    the data MMU is de-activated in kernel mode.
    6672 ****************************************************************************************
    67  * @ thread_xp  : extended pointer on the remote thread descriptor.
     73 * @ thread_xp  : extended pointer on the child thread descriptor.
    6874 ***************************************************************************************/
    6975void hal_cpu_context_fork( xptr_t    thread_xp );
  • trunk/hal/generic/hal_gpt.h

    r624 r625  
    167167
    168168/****************************************************************************************
    169  * This function is used to implement the "fork" system call: It copies one GPT entry
    170  * identified by the <vpn> argument, from a remote <src_gpt_xp> to a local <dst_gpt>.
     169 * This function is used to implement the "fork" system call: It copies a remote
     170 * source PTE, identified by the <src_gpt_xp> and <src_vpn> arguments, to a local
     171 * destination PTE, identified by the <dst_gpt> and <dst_vpn> arguments.
    171172 * It does nothing if the source PTE is not MAPPED and SMALL.
    172173 * It optionnally activates the "Copy on Write" mechanism: when the <cow> argument is
    173174 * true: the GPT_WRITABLE flag is reset, and the GPT_COW flag is set.
    174  * A new second level PT2(s) is allocated for destination GPT if required.
     175 * A new second level PT2 is allocated for the destination GPT if required.
    175176 * It returns in the <ppn> and <mapped> arguments the PPN value for the copied PTE,
    176177 * and a boolean indicating if the PTE is mapped and small, and was actually copied.
    177178 ****************************************************************************************
    178  * @ dst_gpt      : [in]  local pointer on the local destination GPT.
    179  * @ src_gpt_xp   : [in]  extended pointer on the remote source GPT.
    180  * @ vpn_base     : [in]  vpn defining the PTE to be copied.
     179 * @ dst_gpt      : [in]  local pointer on local destination GPT.
     180 * @ dst_vpn      : [in]  vpn defining the PTE in the desination GPT.
     181 * @ src_gpt_xp   : [in]  extended pointer on remote source GPT.
     182 * @ src_vpn      : [in]  vpn defining the PTE in the source GPT.
    181183 * @ cow          : [in]  activate the COPY-On-Write mechanism if true.
    182184 * @ ppn          : [out] PPN value (only if mapped is true).
     
    185187 ***************************************************************************************/
    186188error_t hal_gpt_pte_copy( gpt_t    * dst_gpt,
     189                          vpn_t      dst_vpn,
    187190                          xptr_t     src_gpt_xp,
    188                           vpn_t      vpn,
     191                          vpn_t      src_vpn,
    189192                          bool_t     cow,
    190193                          ppn_t    * ppn,
  • trunk/hal/generic/hal_special.h

    r624 r625  
    101101 * This function returns the current value of stack pointer from core register.
    102102 ****************************************************************************************/
    103 uint32_t hal_get_sp( void );
    104 
    105 /*****************************************************************************************
    106  * This function returns the current value of the return adddress from core register.
    107  ****************************************************************************************/
    108 uint32_t hal_get_ra( void );
    109 
    110 /*****************************************************************************************
    111  * This function registers a new value in the core stack pointer and returns previous one.
    112  ****************************************************************************************/
    113 inline uint32_t hal_set_sp( void * new_val );
     103reg_t hal_get_sp( void );
    114104
    115105/*****************************************************************************************
    116106 * This function returns the faulty address in case of address exception.
    117107 ****************************************************************************************/
    118 uint32_t hal_get_bad_vaddr( void );
     108reg_t hal_get_bad_vaddr( void );
    119109
    120110/*****************************************************************************************
  • trunk/hal/generic/hal_vmm.h

    r623 r625  
    5959error_t hal_vmm_kernel_update( struct process_s * process );
    6060
     61/****************************************************************************************
     62 * Depending on the hardware architecture, this function displays the current state
     63 * of the VMM of the process identified by the <process> argument.
     64 * It displays all valit GPT entries when the <mapping> argument is true.
     65 ****************************************************************************************
     66 * @ process   : local pointer on user process descriptor.
     67 * @ return 0 if success / return ENOMEM if failure.
     68 ***************************************************************************************/
     69void hal_vmm_display( struct process_s * process,
     70                      bool_t             mapping );
     71
     72
     73
    6174#endif  /* HAL_VMM_H_ */
Note: See TracChangeset for help on using the changeset viewer.