Does kernel base address can't be changed

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kyowill
Posts: 5
Joined: Mon Apr 03, 2017 10:59 am
Libera.chat IRC: 587

Does kernel base address can't be changed

Post 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.
kyowill
Posts: 5
Joined: Mon Apr 03, 2017 10:59 am
Libera.chat IRC: 587

Re: Does kernel base address can't be changed

Post 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
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Does kernel base address can't be changed

Post 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.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
LtG
Member
Member
Posts: 384
Joined: Thu Aug 13, 2015 4:57 pm

Re: Does kernel base address can't be changed

Post by LtG »

Schol-R-LEA wrote:0x10000000 - giving the kernel literally half of the address space
Sorry, couldn't help myself =)
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Does kernel base address can't be changed

Post 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.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
LtG
Member
Member
Posts: 384
Joined: Thu Aug 13, 2015 4:57 pm

Re: Does kernel base address can't be changed

Post by LtG »

Schol-R-LEA wrote:Or am I still an idiot here?
No, I was referring to the 0x1 vs 0x8..
kyowill
Posts: 5
Joined: Mon Apr 03, 2017 10:59 am
Libera.chat IRC: 587

Re: Does kernel base address can't be changed

Post 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)
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Does kernel base address can't be changed

Post 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.
Learn to read.
kyowill
Posts: 5
Joined: Mon Apr 03, 2017 10:59 am
Libera.chat IRC: 587

Re: Does kernel base address can't be changed

Post 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.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Does kernel base address can't be changed

Post 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.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
kyowill
Posts: 5
Joined: Mon Apr 03, 2017 10:59 am
Libera.chat IRC: 587

Re: Does kernel base address can't be changed

Post 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/
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Does kernel base address can't be changed

Post 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.
Learn to read.
Post Reply