/* * Find the absolute bottom of the stack and set stuff up. * Pretty stupid way, at least find a way to use the system call for this (later) * @returns 0 if everything went well 0 otherwise */ int GC_init(void) { static int initted; extern char __bss_start; // Provided by the linker. void *tmp; if (initted) return; initted = 1; stack_bottom = get_stack_bottom(); usedptr = NULL; freeptr = NULL; BBSstart = aling_pointer((void*)&__bss_start, sizeof(void)); tmp = sbrk(0); if(tmp == (void*)-1) { fprintf(stderr, "Unable to init BBSend\n"); return 1; } BBSend = aling_pointer(tmp, sizeof(void)); return 0; }
int main(int argc, char * argv[]) { fprintf( stderr, "Current stack bottom is %p\n", get_stack_bottom()); while (1) ; return ( EXIT_SUCCESS); } /* end of main */
static void vmx_set_host_env(struct vcpu *v) { unsigned int cpu = smp_processor_id(); __vmwrite(HOST_IDTR_BASE, (unsigned long)idt_tables[cpu]); __vmwrite(HOST_TR_SELECTOR, __TSS(cpu) << 3); __vmwrite(HOST_TR_BASE, (unsigned long)&init_tss[cpu]); __vmwrite(HOST_SYSENTER_ESP, get_stack_bottom()); /* * Skip end of cpu_user_regs when entering the hypervisor because the * CPU does not save context onto the stack. SS,RSP,CS,RIP,RFLAGS,etc * all get saved into the VMCS instead. */ __vmwrite(HOST_RSP, (unsigned long)&get_cpu_info()->guest_cpu_user_regs.error_code); }