Exemplo n.º 1
0
NORETURN void CreateSession(struct NaClApp *nap)
{
  uintptr_t stack_ptr;

  assert(nap != NULL);

  /* set up user stack */
  stack_ptr = nap->mem_start + ((uintptr_t)1U << nap->addr_bits);
  stack_ptr -= STACK_USER_DATA_SIZE;
  memset((void*)stack_ptr, 0, STACK_USER_DATA_SIZE);
  ((uint32_t*)stack_ptr)[4] = 1;
  ((uint32_t*)stack_ptr)[5] = 0xfffffff0;

  /* construct "nacl_user" global */
  ThreadContextCtor(nacl_user, nap, nap->initial_entry_pt, stack_ptr, 0);
  nacl_user->sysret = nap->break_addr;
  nacl_user->prog_ctr = NaClUserToSys(nap, nap->initial_entry_pt);
  nacl_user->new_prog_ctr = NaClUserToSys(nap, nap->initial_entry_pt);

  /* initialize "nacl_sys" global */
  nacl_sys->rbp = GetStackPtr();
  nacl_sys->rsp = GetStackPtr();

  /* pass control to the user side */
  ZLOGS(LOG_DEBUG, "SESSION %d STARTED", nap->manifest->node);
  SwitchToApp(nap, nacl_user->new_prog_ctr);
  ZLOGFAIL(1, EFAULT, "the unreachable has been reached");
}
Exemplo n.º 2
0
void AnalyzeMemory(uint8_t **largest_begin,uint16_t *largest_size)
{
   uint8_t *memptr, *endptr, *section_begin;
   uint16_t section_size;
   
   *largest_size=0;
   memptr = *largest_begin = EndOfUsedMem();
   endptr = GetStackPtr();

   while(memptr < endptr)
   {
     if (*memptr == ((uint16_t)memptr & 0xFF))
     {
       section_begin = memptr;
       while(1)
    {
           memptr++;
           //*largest_begin = (uint8_t *) 1;
       if ((*memptr != ((uint16_t)memptr & 0xFF)) || (memptr == endptr-1)) 
        {
            //*largest_begin = (uint8_t *) 2;
           if ((section_size =  (memptr - section_begin)) > *largest_size)
        {
           *largest_size = section_size;
           *largest_begin = section_begin;
        }
           break;
        }
    } /* while(1) */
      }
      memptr++;
    } /* while(memptr < endptr) */
}
Exemplo n.º 3
0
Arquivo: sel.c Projeto: Abioy/zerovm
NORETURN void CreateSession(struct NaClApp *nap)
{
  uintptr_t stack_ptr;

  assert(nap != NULL);

  /* set up user stack */
  stack_ptr = nap->mem_start + ((uintptr_t)1U << nap->addr_bits);
  stack_ptr -= STACK_USER_DATA_SIZE;
  memset((void*)stack_ptr, 0, STACK_USER_DATA_SIZE);
  ((uint32_t*)stack_ptr)[4] = 1;
  ((uint32_t*)stack_ptr)[5] = 0xfffffff0;

  /*
   * construct "nacl_user" and "nacl_sys" globals
   * note: nacl_sys->prog_ctr meaningless but should not be 0
   */
  ThreadContextCtor(nacl_user, nap, nap->initial_entry_pt, stack_ptr);
  ThreadContextCtor(nacl_sys, nap, 1, GetStackPtr());

  /* pass control to the user side */
  ZLOGS(LOG_DEBUG, "SESSION %d STARTED", nap->manifest->node);
  ContextSwitch(nacl_user);
  ZLOGFAIL(1, EFAULT, "the unreachable has been reached");
}
void InitializeMemory()
{
   uint8_t *memptr;
   
   for(memptr = EndOfUsedMem(); memptr < GetStackPtr(); memptr++)
      *memptr = (uint16_t)memptr & 0xFF;   
}
Exemplo n.º 5
0
void showRAMused() {
    int ramused = 0x881E0000 - (int)GetStackPtr();
    debugMessage((char*)"RAM", (char*)"B:", ramused);
    debugMessage((char*)"MB", (char*)"c:", getMsgBoxCount());
}