Page 1 of 1
Does kernel base address can't be changed
Posted: Mon Apr 03, 2017 11:06 am
by kyowill
I'm doing some work on JOS. The kernel base address is 0xF0000000 in JOS. when the value is changed, some problems will happen. I'm wondering what determine the KERNBASE value.
Re: Does kernel base address can't be changed
Posted: Mon Apr 03, 2017 11:13 am
by kyowill
kyowill wrote:I'm doing some work on JOS. The kernel base address is 0xF0000000 in JOS. when the value is changed, some problems will happen. I'm wondering what determine the KERNBASE value.
when translates a VA to a PA, you can get PA by using VA - KERNBASE
Re: Does kernel base address can't be changed
Posted: Mon Apr 03, 2017 1:10 pm
by Schol-R-LEA
kyowill wrote:I'm doing some work on JOS. The kernel base address is 0xF0000000 in JOS.
Which JOS? I recall at least three OSes by that name, and odds are the one you mean isn't any of those three. It even appears to be used as a generic name for the student OS projects in the
MIT Open Courseware Operating System Engineering course. You may need to post a link to the specific one you mean. Here are a few I found just on a quick DDG search:
Java Operating System
JamesxX's JOS
LeJOS LEGO Minstorms OS
Jeremy's OS for Arduino
Jose's Operating System
I am pretty sure that there was a mainframe OS called JOS back in the day, as well.
kyowill wrote: I'm wondering what determine the KERNBASE value.
The whim of the primary developers, really.
Now, there are often good reasons for choosing a specific kernel base - for example, for a
Higher Half Kernel on a 32-bit platform, it is sometimes useful to put it at 0x10000000 - giving the kernel literally half of the address space - for a number of reasons (e.g., it ensures that the OS has plenty of room; it makes the user and kernel space sizes equal; it makes it easy to find it without a separate constant; it is easy to tell if a given address is in the kernel space or user space by checking the high bit - not that it comes up a lot, but still; etc.). However, different OSes have different purposes, and OS devs will have different priorities. What might seem like a good reason in one design for one group of developers may not make sense for something and someone else.
Unless it is explained in the documentation and/or code comments somewhere, you'd need to consult with whoever designed the kernel's memory layout to get the answer for a specific OS.
As for why it is causing problems, first off, how, when (e.g., at compile time, at link time, at run time, etc), and why are you trying to change it, and what actually happens when you do? If you could post any error messages or (if necessary) screenshots of the results, it might help a great deal.
Re: Does kernel base address can't be changed
Posted: Mon Apr 03, 2017 6:30 pm
by LtG
Schol-R-LEA wrote:0x10000000 - giving the kernel literally half of the address space
Sorry, couldn't help myself =)
Re: Does kernel base address can't be changed
Posted: Mon Apr 03, 2017 8:01 pm
by Schol-R-LEA
OK, that was a dumbass attack on my part. That should have been 0x80000000.
Or am I still an idiot here? I mean binary 10000000000000000000000000000000 (2^31), which should indeed be 0x80000000. Dunno what made me think that would be 0x10000000, I just wasn't paying attention when I wrote it.
Re: Does kernel base address can't be changed
Posted: Tue Apr 04, 2017 7:37 am
by LtG
Schol-R-LEA wrote:Or am I still an idiot here?
No, I was referring to the 0x1 vs 0x8..
Re: Does kernel base address can't be changed
Posted: Tue Apr 04, 2017 8:10 am
by kyowill
Schol-R-LEA wrote:OK, that was a dumbass attack on my part. That should have been 0x80000000.
Or am I still an idiot here? I mean binary 10000000000000000000000000000000 (2^31), which should indeed be 0x80000000. Dunno what made me think that would be 0x10000000, I just wasn't paying attention when I wrote it.
I still don‘t get the point why PA(physcial address) equal to VA(virtual address) - KERNBASE(0x80000000 or 0x10000000)
Re: Does kernel base address can't be changed
Posted: Tue Apr 04, 2017 9:23 am
by dozniak
kyowill wrote:
I still don‘t get the point why PA(physcial address) equal to VA(virtual address) - KERNBASE(0x80000000 or 0x10000000)
It depends on how the kernel is loaded.
If it's loaded starting from 0x0 in physical RAM while having virtual start address at KERNBASE, then indeed, subtracting KERNBASE from any kernel address will yield it's physical address in memory.
Re: Does kernel base address can't be changed
Posted: Tue Apr 04, 2017 5:07 pm
by kyowill
dozniak wrote:kyowill wrote:
I still don‘t get the point why PA(physcial address) equal to VA(virtual address) - KERNBASE(0x80000000 or 0x10000000)
It depends on how the kernel is loaded.
If it's loaded starting from 0x0 in physical RAM while having virtual start address at KERNBASE, then indeed, subtracting KERNBASE from any kernel address will yield it's physical address in memory.
if 0x0(physical address)is mapped to KERNBASE, but how do you know the mapping detail.
Re: Does kernel base address can't be changed
Posted: Tue Apr 04, 2017 9:42 pm
by Schol-R-LEA
I know I asked this earlier, but can you please specify which OS named JOS you are referring to? A link to a repo and/or a site describing it, if possible, would also be appreciated.
Re: Does kernel base address can't be changed
Posted: Wed Apr 05, 2017 8:09 am
by kyowill
Schol-R-LEA wrote:I know I asked this earlier, but can you please specify which OS named JOS you are referring to? A link to a repo and/or a site describing it, if possible, would also be appreciated.
https://pdos.csail.mit.edu/6.828/2016/
Re: Does kernel base address can't be changed
Posted: Wed Apr 05, 2017 11:33 am
by dozniak
kyowill wrote:
if 0x0(physical address)is mapped to KERNBASE, but how do you know the mapping detail.
You (JOS) made it yourself, so by definition you know it.