Baremetal and 16Gb system

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.
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Baremetal and 16Gb system

Post by JulienDarc »

Hello,

I have a baremetal project on a machine with 16Gb of RAM on x86_64 with a intel i5.
Why the hell x86? Because the processing power available on this arch is needed.

I don't want any mmu, or paging or anything really. Minimal overhead. There will be only one program running bare metal.

BUT, I will need to address 16 Gb of memory.

How will I deal with this constraint? I can only address 1Mb of memory in real mode.

How-will-I-do-that...

Thanks
Octocontrabass
Member
Member
Posts: 5588
Joined: Mon Mar 25, 2013 7:01 pm

Re: Baremetal and 16Gb system

Post by Octocontrabass »

You can't access more than 4GB without paging. On a PC, this will be less than 4GB of RAM due to MMIO.

Use long mode. You'll be able to access all of your RAM, and you'll have extra registers to work with.
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Re: Baremetal and 16Gb system

Post by JulienDarc »

I cannot deal with physical memory that large directly in long mode?
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: Baremetal and 16Gb system

Post by Techel »

JulienDarc wrote:I cannot deal with physical memory that large directly in long mode?
Octocontrabass wrote:Use long mode. You'll be able to access all of your RAM, and you'll have extra registers to work with.
:? I dont't understand.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Baremetal and 16Gb system

Post by onlyonemac »

JulienDarc wrote:I cannot deal with physical memory that large directly in long mode?
Yes, actually you can.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Re: Baremetal and 16Gb system

Post by JulienDarc »

hoops, actually there is some typing gone.

My question was if it was possible to address that much ram without using mmu and paging, at all.
Octocontrabass answered it: no it isn't.

I ask because that would add a lot of code and create overhead (page walk, mmu, tlb) for a code that knows where to take its information (hardcoded).

I think that architecture is a mistake to start that project on.

Could you propose another arch that doesn't have this limitation (4Gb- ram)?
Maybe multiple arm64 processors could make it after all.. or not.

Edit:
multiple i5 in 32 bit mode is a waste of money..
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Baremetal and 16Gb system

Post by iansjack »

onlyonemac wrote:
JulienDarc wrote:I cannot deal with physical memory that large directly in long mode?
Yes, actually you can.
No you can't. Paging is a pre-requisite for long mode.
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Re: Baremetal and 16Gb system

Post by JulienDarc »

Forget that, that project, as-is, is wrong.

I will propose small 32bits embedded cpus (arm) and a new framework. The 16Gb will be dispatched among those "cheap" chips.

We even may see a thoughput increase all in all.

Thanks a lot
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Baremetal and 16Gb system

Post by Nable »

One can use large pages (several 2G mappings + a bunch of 4M + some 4k for I/O areas) + identity mapping. This leads you to zero (or very close to it) overhead of paging.
Ready4Dis
Member
Member
Posts: 571
Joined: Sat Nov 18, 2006 9:11 am

Re: Baremetal and 16Gb system

Post by Ready4Dis »

Yes, you will have almost no overhead if you do the paging properly and don't need to task switch and reload page tables... although it is extra code. I am not sure of something as powerful as an i5 that would meet your requirements. What exactly are your requirements?
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Re: Baremetal and 16Gb system

Post by JulienDarc »

@Ready4Dis:
I need a high processing power for lot of data analysis(medical, audio).

i5 (haswell) is a very powerful beast that can grok the amount of data we plan to throw at it.

Yet, the system has to be amazingly simple (no real OS) to limit a possible bug.
The same logic will be used for real time system if the first implementation is OK, because the code is made very deterministic.

@Nable:
2G page? Isn't the limit on i5 1G for huge page? Or is there a -pleasing- trick?
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Baremetal and 16Gb system

Post by Nable »

Oops, of course it's 1G, not 2. Sorry for this mistake. But it doesn't change the idea.
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Re: Baremetal and 16Gb system

Post by JulienDarc »

You are right, this would enable negligible overhead.

Thanks a lot
Ready4Dis
Member
Member
Posts: 571
Joined: Sat Nov 18, 2006 9:11 am

Re: Baremetal and 16Gb system

Post by Ready4Dis »

Not only is there very little overhead, but it can actually simplify things for you. You can take a non-contiguous memory map and make it appear flat, making things even simpler for the actual programming. Or move things like MMIO away from useable ram so there is less chance of accidentally overrunning into it, etc.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Baremetal and 16Gb system

Post by bluemoon »

JulienDarc wrote:Yet, the system has to be amazingly simple (no real OS) to limit a possible bug.
I don't know why people thinks bare metal (ie. rolling their own mini-OS in form of exo-kernel) reduce bugs compare to adopt a mature OS.
Bare metal does not mean no OS, you still need code to manage hardware and resources, and that is not amazingly simple.

BTW, to access 16GB of memory you need to use long mode or PAE, and both require paging.
Post Reply