diff --git a/usr/src/sp1/amd64/cpu/cpu_mmu.c b/usr/src/sp1/amd64/cpu/cpu_mmu.c new file mode 100644 index 0000000..4cab90c --- /dev/null +++ b/usr/src/sp1/amd64/cpu/cpu_mmu.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * All rights reserved. + * + * The following sources are CONFIDENTIAL and PROPRIETARY + * property of Mirocom Laboratories. Unauthorized copying, + * use, distribution or modification of this file, in whole + * and in part, is strictly prohibited without the prior written + * consent from Mirocom Laboratories. + */ + +#include +#include + +void +mu_mmu_readvfr(struct mmu_vfr *res) +{ + if (res == NULL) { + return; + } + + __asmv( + "mov %%cr3, %0" + : "=r" (res->cr3) + : + : "memory" + ); +} + +void +mu_mmu_writevfr(struct mmu_vfr *vfr) +{ + if (vfr == NULL) { + return; + } + + __asmv( + "mov %0, %%cr3" + : + : "r" (vfr->cr3) + : "memory" + ); +} diff --git a/usr/src/sp1/head/amd64/vfr.h b/usr/src/sp1/head/amd64/vfr.h new file mode 100644 index 0000000..f65f4e8 --- /dev/null +++ b/usr/src/sp1/head/amd64/vfr.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * All rights reserved. + * + * The following sources are CONFIDENTIAL and PROPRIETARY + * property of Mirocom Laboratories. Unauthorized copying, + * use, distribution or modification of this file, in whole + * and in part, is strictly prohibited without the prior written + * consent from Mirocom Laboratories. + */ + +#ifndef _MACHINE_VFR_H_ +#define _MACHINE_VFR_H_ 1 + +#include + +/* + * Virtual fuck region for AMD64 + */ +struct mmu_vfr { + uint64_t cr3; +}; + +#endif /* !_MACHINE_VFR_H_ */ diff --git a/usr/src/sp1/head/mu/mmu.h b/usr/src/sp1/head/mu/mmu.h new file mode 100644 index 0000000..3443e23 --- /dev/null +++ b/usr/src/sp1/head/mu/mmu.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * All rights reserved. + * + * The following sources are CONFIDENTIAL and PROPRIETARY + * property of Mirocom Laboratories. Unauthorized copying, + * use, distribution or modification of this file, in whole + * and in part, is strictly prohibited without the prior written + * consent from Mirocom Laboratories. + */ + +#ifndef _MU_MMU_H_ +#define _MU_MMU_H_ 1 + +/* + * Each running SP1 process is to have a virtual fuck region + * which logically isolates their address space with the help + * of the platform memory management unit. + */ +#include /* shared; virtual fuck region~ */ + +/* + * Obtain the current VFR in-use + * + * @res: Result is written here + */ +void mu_mmu_readvfr(struct mmu_vfr *res); + +/* + * Write a new VFR to the processor + * + * @vfr: Virtual fuck region to set + */ +void mu_mmu_writevfr(struct mmu_vfr *vfr); + +#endif /* !_MU_MMU_H_ */