-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird kernel panic #15
Comments
oh and a suggestion for the fix, you have this cpu struct, why dont you put the tss things here:
new:
and later init it per cpu like this:
for this to work, you need to allocate of course more GDTP space to hold all CPU TSS .. |
Thank you for reporting this. However, I think there maybe some confusion that comes from the statement, "But you GDT only holds one TSS." The GDT is a very weird structure in many ways, so the confusion is understandable. Let me explain. The GDT does not actually hold the TSS instead it holds a descriptor of the TSS bassicly just a little bit of info saying where the TSS is and some other stuff about it, it does not actually hold the TSS itself (I might rename the GDT member in order to highlight this). So when you load a TSS for a certain CPU you first make sure that CPU has loaded the GDT then you fill in the TSS descriptor in the GDT with information about that CPU's TSS you then call tss_load, the CPU at that point reads the data in the TSS descriptor located in the GDT and loads its TSS, after this the information stored in the GDT is useless and can be overwritten by the next CPU. So you don't need a unique TSS entry for each CPU, instead each CPU can use the same one as it's only needed when loading the actual TSS and not after. Now it wouldent be the first time I'm wrong, however you are correct in saying that if all the CPUs actually were using the same TSS then that could cause a panic. Most likely it would cause a panic pretty much immediately and unavoidably, so the fact that the operating system (mostly) works should mean that the CPUs are using different TSSs. I hope that helps. I'd gladly answer more questions if you have them. |
ah thanks ok.. i thought since all cpus share the GDT, i implemented it like this in my 2nd comment and added for each cpu a tss entry in the gdt. Thought maybe this could be of the stack being corrupt. |
Hmm well that is a rather weird kernel panic, it seems to be a page fault happening in process 0, on thread 16, but process 0 should never create 16 threads it should have a total of 2 threads at most. It's definitely something that needs to get looked into. The mouse behavior is also very weird, might have something to do with qemu, as while it's possible I find it unlikely that a code error could cause that. The only way I could see it is if some part of the PS2 standard is incorrectly implemented. However I am not able to replicate either issue, most likely these issues only happen with a specific combination of hardware, virtual machine and compiler, which makes it very difficult to diagnose from my side. |
i know this feeling ;-) and you dont want to see my combination where i test it ;-) shouldnt the panic stop btw? |
Haha its a very familiar feeling. Oh boy yeah sounds like that might introduce alot of additional points of failure. Tho of course, a proper OS should run no matter how you run it. What do you mean by stop? The panic will halt the entire OS and make the computer wait to be restarted as it can no longer safely continue. |
nope your panic runs and runs and runs.. this is why i pressed CTRL-C to stop qemu.. debug was in screen and on console.. |
Oh boy more weird issues. Anyway, that sounds like a good plan. I will keep this issue open, but rename it to something more representing these newly found issues. |
The panic running on and on should now be fixed. Haven't taken a look at the other issues yet. |
couldnt reproduce it.. trying it 2-3 times a day :) but what i noticed: you should ignore this file in .git otherwise it wants to checkin everytime ;-) |
That's one issue down. As it's bassicly impossible for me to diagnose and fix the other issues, as they are probably caused by a specific combination of hardware and software and there are almost certainly many more similar issues; I am making the decision to start accepting contributions. I will shortly edit the readme to reflect this. That means that (only if you want to of course :) ) you can try to fix the issues on your side and il try to help out if I can. I don't really have the time for it right now, unfortunately, but I might eventually write some proper documentation, to make contributions easier. I have also appended the gitignore. |
Have to see if i have time. Im also on my own OS im coding since the last 20 Years and trying to get it to 64bit + 3 Kids & 3 Jobs, time is precious :-) But i will check, when i get my scheduler running, and dig into your code. |
Yeah, of course, I don't quite have that much, mostly just my studies. But I totally understand the feeling, don't feel any pressure if you don't want to, either way good luck! |
i cant say no. i promise i will look into it.. maybe in 2-3 weeks. |
Gotcha, well in that case there is no hurry. |
of course there is no hurry.. os development is for ages ... i use it to relax and relieve stress :-) Noone is interessted in OSs anymore..you have out there perfected android, macos, linux,... so noone cares about us ^^ |
First of all thanks for your code. Its really nice and i hope you finde time to dig more into it :-)
What i noticed while studying your code + initialisation of GDT/IDT/TSS is, correct me if wrong, but GDT is shared over all CPUs. But you GDT only holds one TSS. So when you call:
cpu_init() in your SMP code you just fill out the struct for the cpu, but the original tss_load() in the gdt_load_tss() only initalised one on the BSP.
Maybe this could come to an Panic later since all cpu share the same tss = same IRQ Stack, same Kernel Stack, same io permission.
Since im new, i could be wrong, just using your code (and others) to understand x86-64 kernel coding.
The text was updated successfully, but these errors were encountered: