What is going on:
Code: Select all
command_t command_list[10];
Something ever more bizarre!
This:
Code: Select all
command_t* command_list[10];
What does the f̶o̶x̶ Bochs say? Nothing, 3rd exception with no resolution.
Code: Select all
command_t command_list[10];
Code: Select all
command_t* command_list[10];
Are you sure? Some kinds of bugs (like not invalidating the TLB correctly) can be elusive.Octacone wrote:This freaking thing triggers a page fault out of nowhere. It has nothing to do with paging.
Code: Select all
command_t* command_list[10];
Code: Select all
command_t(* command_list)[10];
Code: Select all
*command_list = (command_t*) Heap.Malloc(sizeof(command_t) * 10);
I actually completely forgot about that. Not sure when it is needed doe. Since I am only allocating memory addresses and mapping them, not freeing/modifying them. If I modify a page directory aka change something in it, it won't automatically update, right? So I need to wipe the TLB and "rebuild" it. How could I have forgotten this? Edit: What address do I need to pass to "invlpg", can't figure this one out.Brendan wrote:Hi,
I'd recommend forgetting about whatever causes the first page fault and focusing on whatever causes the second problem (finding out why the page fault handler crashes).
Are you sure? Some kinds of bugs (like not invalidating the TLB correctly) can be elusive.Octacone wrote:This freaking thing triggers a page fault out of nowhere. It has nothing to do with paging.
Cheers,
Brendan
Hmm. 32 KB is not enough? Could be, possibly.iansjack wrote:Sounds like a stack overrun. Debugging will confirm that.
Code: Select all
(gdb) break Basic_OS::Shell_Class::Initialize
Breakpoint 3 at 0x107160: file Sources/Kernel/Shell.cpp, line 136.
(gdb) c
Continuing.
/build/gdb-cXfXJ3/gdb-7.11.1/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
It is definitely confusing sometimes. I have actually already tried this. Something else is causing it for sure. In fact, I don't even need any of this. The problem lies somewhere else since command_t command_list[10] should be okay by itself, it does not need to by dynamically allocated since it is a fixed size array.simeonz wrote:This is array of pointers.This is pointer to an array.Code: Select all
command_t* command_list[10];
I'm mentioning this, because it is a point of confusion sometimes. The rule for declaration types is to read from right to left within a given precedence level, where a parenthesis increases the precedence as usual.Code: Select all
command_t(* command_list)[10];
That being said, fixing the declaration wont fix your problem.assigns to the first "pointer" in the array, which should be ok, but the location of the array is apparently faulty for some reason. So see the other suggestions for that.Code: Select all
*command_list = (command_t*) Heap.Malloc(sizeof(command_t) * 10);
You run the INVLPG instruction on each 4 KB-aligned address you modified the mapping for. For example, if you map/unmap or modify three pages starting at address 0x2000, you'd do something like:Octacone wrote:If I modify a page directory aka change something in it, it won't automatically update, right? So I need to wipe the TLB and "rebuild" it. How could I have forgotten this? Edit: What address do I need to pass to "invlpg", can't figure this one out.
Code: Select all
mov eax, 0x2000 ; first page
invlpg [eax]
add eax, 4096 ; second page
invlpg [eax]
add eax, 4096 ; third page
invlpg [eax]
That solves my dilemma, thanks! I can't quite do anything user space related yet. Still have to gather some knowledge before I can get into that. I can't function without a shell, definitely need one.omarrx024 wrote:You run the INVLPG instruction on each 4 KB-aligned address you modified the mapping for. For example, if you map/unmap or modify three pages starting at address 0x2000, you'd do something like:Octacone wrote:If I modify a page directory aka change something in it, it won't automatically update, right? So I need to wipe the TLB and "rebuild" it. How could I have forgotten this? Edit: What address do I need to pass to "invlpg", can't figure this one out.EDIT: Don't put a shell inside your kernel. Now that you have proper paged memory management, the next thing to work on is multitasking or userspace.Code: Select all
mov eax, 0x2000 ; first page invlpg [eax] add eax, 4096 ; second page invlpg [eax] add eax, 4096 ; third page invlpg [eax]
Code: Select all
typedef struct command_t
{
char name[32];
char description[128];
void (*function_pointer)();
}command_t;
Code: Select all
typedef struct command_t
{
char name;
char description;
void (*function_pointer)();
}command_t;
I enabled those two switches and everything seems reasonable:simeonz wrote:Probably won't help much, but you can try "-fstack-usage". You can also turn on the "-Wstack-usage=len" option in general. Having a working gdb is the best method as you can break on function entry, but you said there is an issue with that.
To be honest, I'm not sufficiently competent in these matters, but if your page fault handler does not use a separate exception stack, it seems logical that it should triple fault.
Code: Select all
xxx 32 dynamic,bounded
xxx 32 dynamic,bounded
xxx 4 static
xxx 32 dynamic,bounded
xxx 4 static
xxx 32 dynamic,bounded
xxx 32 dynamic,bounded
xxx 4 static
xxx 48 dynamic,bounded
xxx 32 dynamic,bounded
xxx = some function, removed for easier readability
GDB is now working properly, thanks to LtG.iansjack wrote:If you only have one stack then a corrupted stack, or a stack overrun, is always going to lead to a triple-fault, masking the original GPF or PF. Set a separate stack to be used exclusively by the page fault handler at least. Your current problem may not be a stack overrun but it certainly sounds like some form of stack corruption.
Actually, I think your first move should be to solve your problem with gdb. Without proper debugging facilities life is always going to be tough. Alternatively, you could use Bochs with its own debugger.