Can I lock out physical memory blocks from linux?

Can I lock out physical memory blocks from linux?

Post by David Ho » Wed, 22 May 1996 04:00:00



Hi folks,

I've got a question that I need help with:

I have Linux 1.2.13 running on a 486 which is actually a vme card. This
486 "slaves" (exports) some of it's memory to other devices that are on
the same vme bus. It's got 16 MB of ram and I'm trying to slave phys
addr E00000-EFFFFF. I need to be able to read and write to these
memory locations from both the 486 and other devices on the vme
bus, (and I am able to right now).  The problem is that the OS seems
to use the same memory space (EXXXXX) as well and I'm not
sure how to tell the OS that this memory is not for general purpose
use.

My current implementation requires iopl() and writing to some ioports
that setup the board for vme slaving.  I then open /dev/mem as root
and do an mmap(). the 486 performs IO on the desired addresses thru
the returned address from mmap(). I've tried the
MAP_SHARED/MAP_PRIVATE/MAP_FIXED and the PROT_READ/PROT_WRITE flags
 and permissions and that doesn't seem to be the answer. I end up
happily running my process for the vme until other processes start
up and stomp on the EXXXXX area which eventually propogates to system
meltdown. (i can practically install linux with my eyes closed now)

How can I deny the OS general purpose use of EXXXXX while still being
able to mmap() it, or is this not possible?  I am able to  
move this address space, and actually we are only using two 64kb
segments.  The vme setup does not have very good granularity on
specifying starting and ending memory locations. Moving this adress
to somewhere else may be possible but will be painful due to the other
devices on the vme bus and the development tools available. I therefore
would like to keep it in the same location

This 486 can be dedicated to this effort -- I do not need to use it
for other things if that is necessary, memory is not an issue either,
if it needs to be that linux runs in the first 8MB, thats fine.

I guess my current thought is to try and tell linux that the 486 only
has 14MB instead of the actual 16MB. not sure how to do this but I've
started to wade thru the code.  I'd rather not get into this level of
coding if theres a better choice.

Anyway,  your help and comments are appreciated.
--

David
--

David

 
 
 

Can I lock out physical memory blocks from linux?

Post by Paul Gortmak » Thu, 23 May 1996 04:00:00



>I have Linux 1.2.13 running on a 486 which is actually a vme card. This
>486 "slaves" (exports) some of it's memory to other devices that are on
>the same vme bus. It's got 16 MB of ram and I'm trying to slave phys
>addr E00000-EFFFFF. I need to be able to read and write to these
>memory locations from both the 486 and other devices on the vme
>bus, (and I am able to right now).  The problem is that the OS seems
>to use the same memory space (EXXXXX) as well and I'm not
>sure how to tell the OS that this memory is not for general purpose
>use.

[...]

Quote:>How can I deny the OS general purpose use of EXXXXX while still being
>able to mmap() it, or is this not possible?  I am able to  
>move this address space, and actually we are only using two 64kb

During memory init, you can just mark the pages reserved, just like
the kernel treats the 640k -> 1MB region. The kernel will then leave
it alone, but you will still be able to read and write to the area.
(If you are only using two 64kB regions, you can just mark the two
sets of 16 pages that fully contain those regions as reserved) To
mark 14 --> 15MB as reserved is easy: Go to ./arch/i386/mm/init.c
and look for mem_init() and apply the following pseudo-patch:

        while (start_mem < high_memory) {
-               mem_map[MAP_NR(start_mem)] = 0;
+               if ((start_mem >= 0xE00000) && (start_mem < 0xF00000))
+                       mem_map[MAP_NR(start_mem)] = MAP_PAGE_RESERVED;
+               else
+                       mem_map[MAP_NR(start_mem)] = 0;
                start_mem += PAGE_SIZE;
        }

The memory size message at boot will still only report 384k reserved,
but it will show your 1MB as being kernel "data". This is just an
artefact of how it reports things. If you hit <Shift>-<Scroll-Lck> you
should see the proper number of reserved pages.

Quote:>This 486 can be dedicated to this effort -- I do not need to use it
>for other things if that is necessary, memory is not an issue either,
>if it needs to be that linux runs in the first 8MB, thats fine.
>I guess my current thought is to try and tell linux that the 486 only
>has 14MB instead of the actual 16MB. not sure how to do this but I've
>started to wade thru the code.  I'd rather not get into this level of
>coding if theres a better choice.

To do it this way is soooo easy it will make you cry. At the boot
prompt, which is usually handled by LILO, you just enter:

LILO: linux mem=14m

If you need finer granularity, you can use mem=14336k or mem=14680064
and linux will not touch anything above that.

Paul.

 
 
 

1. How can I allocate a continous block of physical memory?

Hello,
    I am writing a program where I need to allocate  2Mb of continous
memory (array).  The OS will let me do this ensuring that it is
continous in virtual memory but I need to ensure that it is continous in
physical memory as well.  The reason for this is that I am trying to
write a benchmark to measure cache performance.  Since most caches use
tags based on physical memory addresses I have no way of finding out
properties of the cache  without knowing where the data is stored in
memory.

    So, my question is this.  Is there a system call I could make to
request continous block of physical memory ?

Thanks in Advance.

Anthony Di Paola

2. Hangs - Netscape Enterprise Server 3.51 / Sybase web.sql 1.2 / Solaris 2.6

3. physical blocks and logical blocks

4. about remove 'LF' but keep 'CR/LF'

5. Physical memory versus detected memory 2.4.7-10

6. aliasing arrow keys to command history in ksh

7. mmap, virtual memory, physical memory

8. www: nodevice.com

9. Real Memmory /Virtual Memory /Physical Memory Accountancy.

10. Is "shared memory" a way to reduce physical memory usage?

11. Modem lock outs

12. physical memory in linux

13. size(/proc/kcore) != size (physical memory) in linux 2.4.20