Index: trunk/kernel/kern/rpc.c
===================================================================
--- trunk/kernel/kern/rpc.c	(revision 640)
+++ trunk/kernel/kern/rpc.c	(revision 641)
@@ -349,13 +349,14 @@
                 rpc_server[index]( desc_xp );
 
+                // update responses counter
+                responses = hal_remote_atomic_add( rsp_xp , -1 );
+
 #if DEBUG_RPC_SERVER_GENERIC
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
-printk("\n[%s] RPC thread[%x,%x] completes rpc %s / client_cxy %x / cycle %d\n",
-__FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], desc_cxy, cycle );
+printk("\n[%s] RPC thread[%x,%x] completes rpc %s / responses %d / cycle %d\n",
+__FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], responses, cycle );
 #endif
                 // decrement expected responses counter 
-                responses = hal_remote_atomic_add( rsp_xp , -1 );
-
                 // unblock client thread if last response
                 if( responses == 1 ) 
@@ -2388,9 +2389,9 @@
 
 //////////////////////////////////////////////////////////
-void rpc_vmm_resize_vseg_client( cxy_t             cxy,
-                                 struct process_s * process,
-                                 struct vseg_s    * vseg,
-                                 intptr_t           new_base,
-                                 intptr_t           new_size )
+void rpc_vmm_resize_vseg_client( cxy_t          cxy,
+                                 pid_t          pid,
+                                 intptr_t       base,
+                                 intptr_t       new_base,
+                                 intptr_t       new_size )
 {
 #if DEBUG_RPC_VMM_RESIZE_VSEG
@@ -2411,6 +2412,6 @@
 
     // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)(intptr_t)process;
-    rpc.args[1] = (uint64_t)(intptr_t)vseg;
+    rpc.args[0] = (uint64_t)pid;
+    rpc.args[1] = (uint64_t)base;
     rpc.args[2] = (uint64_t)new_base;
     rpc.args[3] = (uint64_t)new_size;
@@ -2438,5 +2439,7 @@
 #endif
 
+    pid_t       pid;
     process_t * process;
+    intptr_t    base;
     vseg_t    * vseg;
     intptr_t    new_base;
@@ -2448,8 +2451,14 @@
 
     // get arguments from client RPC descriptor
-    process  = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
-    vseg     = (vseg_t    *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
-    new_base =              (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
-    new_size =              (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
+    pid      = (pid_t)   hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
+    base     = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
+    new_base = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
+    new_size = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
+
+    // get local pointer on target process
+    process = cluster_get_local_process_from_pid( pid );
+
+    // get target vseg from vaddr
+    vmm_get_vseg( process , base , &vseg );
 
     // call relevant kernel function
@@ -2474,6 +2483,6 @@
 /////////////////////////////////////////////////
 void rpc_vmm_remove_vseg_client( cxy_t       cxy,
-                                 process_t * process,
-                                 vseg_t    * vseg )
+                                 pid_t       pid,
+                                 intptr_t    base )
 {
 #if DEBUG_RPC_VMM_REMOVE_VSEG
@@ -2494,6 +2503,6 @@
 
     // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)(intptr_t)process;
-    rpc.args[1] = (uint64_t)(intptr_t)vseg;
+    rpc.args[0] = (uint64_t)pid;
+    rpc.args[1] = (uint64_t)base;
 
     // register RPC request in remote RPC fifo
@@ -2519,4 +2528,6 @@
 #endif
 
+    pid_t       pid;
+    intptr_t    vaddr;
     process_t * process;
     vseg_t    * vseg;
@@ -2527,6 +2538,12 @@
 
     // get arguments from RPC descriptor
-    process  = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
-    vseg     = (vseg_t    *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
+    pid   = (pid_t)   hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
+    vaddr = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
+
+    // get local pointer on target process
+    process = cluster_get_local_process_from_pid( pid );
+
+    // get target vseg from vaddr
+    vmm_get_vseg( process , vaddr , &vseg );
 
     // call relevant kernel function
