Rod Evans wrote:
> 
> I'm sponsoring the following case for Mike Corcoran.  Time out 04/07/08.
> 
> The case introduces a new system call, mmapfd(2).  This call is primarily
> targeted for use by ld.so.1(1), and provides for the efficient mapping of
> ELF files (and 4.x AOUT files).
> 
> Release Binding:                 Patch/Micro
> mmapfd(2):                       Consolidation Private
> 
> --------------------------------------------------------------------------
> 
> 1. Introduction
>     1.1. Project/Component Working Name:
>          mmapfd: mmap file descriptor
[snip]
> 4. Technical Description:
>      4.1. Details:
>          mmapfd is a new system call which can interpret and map ELF and AOUT
>          (4.x) objects.  This system call allows the interpretation and 
> mapping
>          of ELF and AOUT files to be carried out completely by the kernel 
> rather
>          than by ld.so.1.

Erm... the call seems to be ELF+AOUT-specifc - why does it have such a
generic name ? The call can't handle other types of executables (e.g.
"javaexec" or "shbinexec") nor does it seem to be usefull to map normal
files...
... what renaming the call to |mmapexecfd()| (= "memory map of
executable fd") ?

>          mmapfd also provides for mapping a whole file, without interpretation
>          in a read only mode.

What does that mean ? Can these data+MMU mappings be shared between
processes ?

[snip]
> System Calls                                                     mmapfd(2)
> 
>   NAME
> 
>    mmapfd - map a file descriptor in the appropriate manner.
> 
>   SYNOPSIS
> 
>   #include <sys/mman.h>
> 
>   int
>   mmapfd(int fd, uint_t flags, mmapfd_result_t *storage,
>         uint_t *elements, void *arg)

Uhm... how do I unmap the mapping done by |mmapfd()| ?

>   DESCRIPTION
> 
>    The mmapfd() function establishes a set of mappings between a process's
>    address space and a file.  By default, mmapfd maps the whole file as a 
> single,
>    private, read-only mapping.  The MMFD_INTERPRET flag instructs mmapfd to
>    attempt to interpret the file and map it according to the rules for that 
> file
>    format.  Currently only the following ELF and AOUT formats are supported.

What will happen if the file is executable but uses an unsupported
format (e.g. "javaexec", "shbinexec" etc.) ?

>    ET_EXEC and AOUT executables
>          Result in one or more mappings whose size, alignment and protections
>          are as described by the files program header information.  The 
> address
>          of each mapping is explicitly defined by the files program headers.
> 
>    ET_DYN and AOUT shared objects
>          Result in one or more mappings whose size, alignment and protections
>          are as described by the files program header information.  The base
>          address of the initial mapping is obtained by mapfd().  The address 
> of
>          adjacent mappings are based off of this base address as explicitly
>          defined by the files program headers.
> 
>    ET_REL and ET_CORE
>          Result in a single, read-only  mapping.  The base address of this
>          mapping is obtained by mmapfd().
> 
>    mmapfd will not map over any currently used mappings within the process
>    except for the case of an ELF file for which a previous reservation has 
> been
>    made via /dev/null.
> 
>   PARAMETERS
> 
>    fd    The open file descriptor for the file to be mapped.
> 
>    flags Indicates that the default behavior of mmapfd should be modified
>          accordingly.  Available flags are MMFD_INTERPRET and MMFD_PADDING.
> 
>    storage
>          A pointer to the mmapfd_result_t array where the mapping
>          data will be copied out after a successful mapping of fd.
> 
>    elements
>          A pointer to the number of mmapfd_result_t elements pointed to by
>          storage.  On return, elements contains the number of mappings 
> required
>          to fully map the requested object.  If the original value of
>          elements was too small, an error will be returned, and elements
>          will be modified to contain the number of mappings necessary.
> 
>    arg   A pointer to additional information that might be associated with the
>          specific request.  Presently, only the MMFD_PADDING request uses this
>          argument.  In this case, args should be a pointer to size_t that
>          indicates how much padding is requested.  This amount of padding is
>          added before the first mapping and immediately after the last 
> mapping.
> 
>   FLAGS
> 
>    MMFD_INTERPRET
>          Interpret the contents of the file descriptor instead of just 
> mapping a
>          single image.  Can only be used with ELF and AOUT files.
> 
>    MMFD_PADDING
>          When mapping in the file descriptor, padding of the amount pointed 
> to by
>          arg is requested before the lowest mapping and after the highest
>          mapping.
> 
>   TYPES USED
> 
>    typedef struct {
>          caddr_t         mr_addr;         /* mapping address */
>          size_t          mr_msize;        /* mapping size */
>          size_t          mr_fsize;        /* file size */
>          size_t          mr_offset;       /* offset into file */
>          int             mr_prot;         /* the protections provided */

Why is this |signed int| ?

>          uint_t          mr_flags;        /* info on the mapping */

Please change this to |uint64_t| (e.g. it may be nice to have more flags
available by default).

>    } mmapfd_result_t;
> 
>    Values for mr_flags include:
> 
>    MFD_ELF_HDR           0x1     /* the ELF header is mapped at mr_addr */
>    MFD_AOUT_HDR          0x2     /* the AOUT header is mapped at mr_addr */

What about reserving the first four bits for |MFD_*_HDR| flags
(|MFD_ELF_HDR|, |MFD_AOUT_HDR| and two bits reserved for future
|MFD_*_HDR| flags) ?

Finally... how can I _force_ the mapping to use something like 64k pages
by default ?

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)

Reply via email to