switching to new pagemap causes 0xe and more exceptions
-
- Member
- Posts: 43
- Joined: Tue Jul 05, 2022 12:37 pm
Re: switching to new pagemap causes 0xe and more exceptions
theres a lot of vmm region corruption going on here
i might just give up at this point idfk
i might just give up at this point idfk
-
- Member
- Posts: 790
- 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: 43
- 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: 43
- 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: 43
- 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: 790
- 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: 790
- 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;
}
-
- Member
- Posts: 43
- Joined: Tue Jul 05, 2022 12:37 pm
-
- Member
- Posts: 43
- Joined: Tue Jul 05, 2022 12:37 pm
Re: switching to new pagemap causes 0xe and more exceptions
thank you so much!!!! actually. everything is solved (except for ksan) do u have any idea why ksan isnt working?
-
- Member
- Posts: 790
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: switching to new pagemap causes 0xe and more exceptions
When I get a chance this weekend I will look at your kasan implementation. What I know is that the kasan issue is not related to any bugs you were currently hunting down and was a unique problem specific to that code.
I also have another pull request coming that cleans up your IDT stubs and handler, and also sets a default handler for idt entries that you aren't handling. I noticed in your code if you didn't set up a handler your unhandled interrupts would cause yet another exception leading to possible double and triple faults.
Edit: New pull request is here: https://github.com/rayanmargham/NyauxKC/pull/2
I also have another pull request coming that cleans up your IDT stubs and handler, and also sets a default handler for idt entries that you aren't handling. I noticed in your code if you didn't set up a handler your unhandled interrupts would cause yet another exception leading to possible double and triple faults.
Edit: New pull request is here: https://github.com/rayanmargham/NyauxKC/pull/2
-
- Member
- Posts: 43
- Joined: Tue Jul 05, 2022 12:37 pm
Re: switching to new pagemap causes 0xe and more exceptions
Thank you! merged
-
- Member
- Posts: 43
- Joined: Tue Jul 05, 2022 12:37 pm
Re: switching to new pagemap causes 0xe and more exceptions
Let me know when u get a chance to look at ksan, Thanks!
-
- Member
- Posts: 43
- Joined: Tue Jul 05, 2022 12:37 pm
-
- Member
- Posts: 790
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: switching to new pagemap causes 0xe and more exceptions
Didn't have time. You'll have to investigate.
-
- Member
- Posts: 43
- Joined: Tue Jul 05, 2022 12:37 pm
Re: switching to new pagemap causes 0xe and more exceptions
also ive found a bug
the handler for page fault says its a unhandled exception... what???? even tho its changed????
the handler for page fault says its a unhandled exception... what???? even tho its changed????