/*-------------------------------------------------------------------------- * page$GetProtectionFlags - Prompt for address and access flags, then change * the protection on the page containing the specified address to * the specified access(es), creating the page if necessary. *--------------------------------------------------------------------------*/ BOOL pagGProt(unsigned argc, char *argv[]) { ADDR adr; REG accr = ~0, accid = ~0; BOOL ok; if (Proclvl == level0) { cmdErr("No page protection in Level 0 systems\n"); return; } if (getVA(&sid, &adr) > 0) { getNumToken("Access rights: ", &accr, 16); getNumToken("Access ID: ", &accid, 16); if ((ok = pdeCreate(sid, adr, accr, accid)) == -1) cmdErr("Can't create page -- out of memory\n"); else if (!ok) cmdwPrint("Page created with specified protection\n"); else { dtlbPurge(sid, adr); itlbPurge(sid, adr); cmdwPrint("Access protection changed\n"); } } }
void build_process_address_space(struct PCB* process) { uint64_t entry = 0; uint64_t e_rsp = UXSTACKTOP; struct page* page_temp; //struct vma* vma_temp; //int ab=0; //Allocate for user pml4 table and initialize it //Since its in user space, will already be mapped. if(!process->pml4) { page_temp = page_alloc(); if(page_temp->ref_count==1) printf("PANIC\n"); memset((void *)getVA(page_temp),0,PAGE_SIZE); process->cr3 = (uint64_t *)getPA(page_temp); process->pml4 = (uint64_t *)getVA(page_temp); //Copy 1 entry from kernel_pml4 to this pml4 *(process->pml4 + PML4OFF(KERNBASE)) = *(kernel_pml4 + PML4OFF(KERNBASE)); } //printf("K: %x , U: %x\n", *(kernel_pml4 + PML4OFF(KERNBASE)), *(process->pml4 + PML4OFF(KERNBASE))); //New cr3 //loadcr3((void *)process->cr3); //ELF entry = getELF(process -> fileName, process); //printf("entry = %x\n", entry); (process -> reg).rip = entry; add_heap_vma(process); add_stack_vma(process); //AADY: 30 Apr if(process->processID < 0) { process -> processID = generate_pid(); e_rsp = UXSTACKTOP - (process->processID * PAGE_SIZE); (process -> ersp) = e_rsp; process -> hasRan = 0; //Already done in pcb_alloc, a safety check here. } /* //TEMP: 26th APR //ASM to set up tss __asm__ __volatile__("movq %%rsp, %0; \ movq $0x28,%%rax; \ ltr %%ax;" : "=r" (tss.rsp0) : : "rax"); //tss.rsp0 = process->ersp; //ASM to set up tss __asm__ __volatile__("movq $0x28,%%rax; \ ltr %%ax;" : : : "rax"); //printf("tss setting: %x\n",tss.rsp0); */ //switch_to_user_space(entry); }