theres a lot of vmm region corruption going on here
i might just give up at this point idfk
switching to new pagemap causes 0xe and more exceptions
-
- Member
- Posts: 29
- Joined: Tue Jul 05, 2022 12:37 pm
-
- Member
- Posts: 770
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: switching to new pagemap causes 0xe and more exceptions
I am still baffled by your find_pte even after your changes which really didn't do anything. You have
For instance: Why do you use `i == 2` and stop at the Page Directory? What happens when you have a 4KiB page? wouldn't you have to descend one level further to the Page Table??
Code: Select all
uint64_t *find_pte(uint64_t *pt, uint64_t virt) {
uint64_t shift = 48;
for (int i = 0; i < 4; i++) {
shift -= 9;
uint64_t idx = (virt >> shift) & 0x1ff;
uint64_t *page_table =
(uint64_t *)((uint64_t)pt + hhdm_request.response->offset);
if (i == 2) {
return page_table + idx;
}
if (!(page_table[idx] & PRESENT)) {
if (page_table[idx] & PAGE2MB) {
panic("This shall not happen.");
}
return page_table + idx;
} else {
pt = (uint64_t *)(page_table[idx] & 0x000ffffffffff000);
}
}
return 0;
}
Code: Select all
if (i == 2) {
return page_table + idx;
}
-
- Member
- Posts: 29
- Joined: Tue Jul 05, 2022 12:37 pm
Re: switching to new pagemap causes 0xe and more exceptions
ill remove that right now
-
- Member
- Posts: 29
- Joined: Tue Jul 05, 2022 12:37 pm
Re: switching to new pagemap causes 0xe and more exceptions
its changed look at git
-
- Member
- Posts: 29
- Joined: Tue Jul 05, 2022 12:37 pm
Re: switching to new pagemap causes 0xe and more exceptions
so now im trying to implment ksan and theres a bunch of faults going on
read my code its in src/mem/ksan.c
read my code its in src/mem/ksan.c
-
- Member
- Posts: 770
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: switching to new pagemap causes 0xe and more exceptions
I have made a pull request with a fix for `find_pte` here: https://github.com/rayanmargham/NyauxKC/pull/1 . The pull request disables your ksan. I didn't have time to investigate the reason but with your ksan implementation the stack overflows and the result is the pml4_table is corrupted and a page fault occurs.
-
- Member
- Posts: 770
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: switching to new pagemap causes 0xe and more exceptions
I discovered another bug in `vmm_init` . I had noticed page faults when building with `-O0` and discovered a bug in a switch statement:
The bug is specifically `hhdm_pages += page_amount;`. This should be `hhdm_pages += page_amountz;`. It is possible to use an uninitialized variable defined in another case statement (at the same scope). This is allowed in older versions of C. I have updated my pull request with a bug fix that fixes this issue in a cleaner way by putting the case statements in a new scope using {}. My pull request is here: https://github.com/rayanmargham/NyauxKC/pull/1
Code: Select all
default:
uint64_t disalignz = entry->base % 2097152;
entry->base = align_down(entry->base, 2097152);
uint64_t page_amountz =
align_up(entry->length - disalignz, 2097152) / 2097152;
for (uint64_t j = 0; j != page_amountz; j++) {
map2mb(ker_map.pml4, entry->base + (j * 2097152),
hhdm_request.response->offset + entry->base + (j * 2097152),
PRESENT | RWALLOWED);
}
hhdm_pages += page_amount;
break;
}