Skip to contentSkip to conversation

Memory management while loading program in Linux

DISCUSSION Sreeni 5 participants 8 messages Jun 28, 2005 – Jun 29, 2005

lore
Share & tools
lore

Sreeni

author
#0 lore raw

Hello,

I have a query regarding memory management using Linux kernel.

In our system we have a secure physical memory starting and ending at predefined addresses. We want to execute certain programs, which have to be running secure in those address spaces only.

Is it possible to force the loader to load the "particular" program (both the code and data segment) at that pre-defined secure physical memory, without any major kernel changes?

Thanks,

Sreeni

([email protected])

#1 lore raw
Quoted 11 lines · Sreeni

Hello,

I have a query regarding memory management using Linux kernel.

In our system we have a secure physical memory starting and ending at predefined addresses. We want to execute certain programs, which have to be running secure in those address spaces only.

Is it possible to force the loader to load the "particular" program (both the code and data segment) at that pre-defined secure physical memory, without any major kernel changes?

Sounds a little silly but in essence the loader is implemented in user space so it shouldn't require any kernel changes.

Eric

author
#2 lore raw

**** How to lock memory pages?

Hi,

Is there a way to lock a particular portion of the memory pages during kernel bootup? I want to re-use these pages when I load my application. I *don't* wanna use the idea of reserving some physical memory and using ioremap. I want something that kernel should be able to manage this memory but I don't want any other application to use this memory.

Thanks in advance
Sreeni

#3 lore raw

Re: **** How to lock memory pages?

Quoted 9 lines · Sreeni

Hi,

Is there a way to lock a particular portion of the memory pages during kernel bootup? I want to re-use these pages when I load my application. I *don't* wanna use the idea of reserving some physical memory and using ioremap. I want something that kernel should be able to manage this memory but I don't want any other application to use this memory.

Quoted 3 lines

Thanks in advance
Sreeni
-

Wrong kind of kernel for this kind of use. The kernel dynamically allocates/deallocates/pages of memory that it knows about. The only way to do what you want, with a kernel designed for multi-tasking multi-user applications use, is to reserve memory during boot.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.

#4 lore raw

Re: **** How to lock memory pages?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Richard" == Richard B Johnson <[email protected]> writes:

Quoted 6 lines · Sreeni
Quoted 6 lines

Is there a way to lock a particular portion of the memory pages during kernel bootup? I want to re-use these pages when I load my application. I *don't* wanna use the idea of reserving some physical memory and using ioremap. I want something that kernel should be able to manage this memory but I don't want any other application to use this memory.

Richard> Wrong kind of kernel for this kind of use. The kernel Richard> dynamically allocates/deallocates/pages of memory that it Richard> knows about. The only way to do what you want, with a kernel Richard> designed for multi-tasking multi-user applications use, is to Richard> reserve memory during boot.

Sreeni, you might want to look at the mlockall() interface, but it's also hard to know what's right to do here if you don't explain what you are trying to do. For example, why do you *care* which memory address(es) your application gets?

John

author
#5 lore raw

Forcing loader to load a prog at a fixed memory location

Hello,

May I know the possible ways of instrcuting the compiler/loader to place a process's 'data segments (data, stack, heap bss etc)' at a *fixed* physical/virtual addresses?

Thanks
Sreeni

#6 lore raw

Re: Forcing loader to load a prog at a fixed memory location

Quoted 9 lines · Sreeni

Hello,

May I know the possible ways of instrcuting the compiler/loader to place a process's 'data segments (data, stack, heap bss etc)' at a *fixed* physical/virtual addresses?

Thanks
Sreeni

.org ADDRESS

Starts code or data at the OFFSET specified. However, you would need to know where ld put the beginning of that segment to know what the offset referred to.

If the code is in the kernel, You can tell the linker set fixups
for some load address as the kernel does. Look at linux-uname -r/arch/i386/boot/compressed/Makefile to see a possible syntax.

In user-space, you can check where the loader put label '_start' and '_end' using. You can make code that is supposed to execute at an offset from there. However, it will never be a physical location that you can count on.

The way a user-mode program accesses physical memory is by using mmap() MAP_FIXED.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.

#7 lore raw

Re: **** How to lock memory pages?

In reply to Sreeni

Le 29/06/05 11:37 -0400, Sreeni écrivit:

Quoted 8 lines

Hi,

Is there a way to lock a particular portion of the memory pages during kernel bootup? I want to re-use these pages when I load my application. I *don't* wanna use the idea of reserving some physical memory and using ioremap. I want something that kernel should be able to manage this memory but I don't want any other application to use this memory.

Please note that this is a newbie advice:
I'd have a look at how the kernel reserves pages DMA usage (below 1M)

Regards,
Frederik Deweerdt

Signature · 4 lines
o---------------------------------------------o
| http://open-news.net : l'info alternative   |
| Tech - Sciences - Politique - International |
o---------------------------------------------o