From ae3f8612ebf28eff624d7db955abcc91c0c6df37 Mon Sep 17 00:00:00 2001 From: tkchia Date: Mon, 12 Sep 2022 05:25:10 +0000 Subject: [PATCH] Bare metal: simplify logic for creating page table entries (partly reverts 577c0f6226fde54a0018a8ebe7ff0ddbd0e16207) It turns out that I can address the physical addresses [0, 0x200000 - 1] via the virtual addresses [BANE, BANE + 0x200000 - 1], even within __get_virtual( ), rather than having to go through VAs [0, 0x200000 - 1]. This is because the [BANE, ...] mapping had already been created earlier by the pinit routine in ape.S. --- libc/intrin/mman.greg.c | 7 +------ libc/runtime/mman.internal.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/libc/intrin/mman.greg.c b/libc/intrin/mman.greg.c index cf872aa22..6e0cc8c47 100644 --- a/libc/intrin/mman.greg.c +++ b/libc/intrin/mman.greg.c @@ -74,10 +74,7 @@ noasan textreal uint64_t *__get_virtual(struct mman *mm, uint64_t *t, if (!(*e & PAGE_V)) { if (!maketables) return NULL; if (!(p = __new_page(mm))) return NULL; - if (mm->use_bane) - __clear_page(BANE + p); - else - __clear_page(p); + __clear_page(BANE + p); *e = p | PAGE_V | PAGE_RW; } t = (uint64_t *)(BANE + (*e & PAGE_TA)); @@ -127,12 +124,10 @@ static noasan textreal void __invert_memory(struct mman *mm, uint64_t *pml4t) { *m = p | PAGE_V | PAGE_RW; } } - mm->use_bane = 1; } } noasan textreal void __setup_mman(struct mman *mm, uint64_t *pml4t) { - mm->use_bane = 0; __normalize_e820(mm); __invert_memory(mm, pml4t); } diff --git a/libc/runtime/mman.internal.h b/libc/runtime/mman.internal.h index 3b3a54777..8c582a52d 100644 --- a/libc/runtime/mman.internal.h +++ b/libc/runtime/mman.internal.h @@ -17,7 +17,6 @@ struct mman { unsigned char pc_drive_last_head; /* 0x1d20 */ unsigned char pc_drive; /* 0x1d21 */ char bad_idt[6]; /* 0x1d22 */ - unsigned use_bane : 1, : 31; /* 0x1d28 */ }; COSMOPOLITAN_C_END_