]> git.buserror.net Git - polintos/scott/priv.git/commitdiff
Remove Mem.AddrSpace.alloc_and_map(); a Mappable that allocates
authorScott Wood <scott@odin.buserror.net>
Sun, 3 Dec 2006 21:52:06 +0000 (15:52 -0600)
committerScott Wood <scott@odin.buserror.net>
Sun, 3 Dec 2006 21:52:32 +0000 (15:52 -0600)
anonymous memory should be used instead.  Later, add a way to
instantiate anonmem mappables with a given set of AllocFlags.

idl/addrspace.idl
kernel/include/kern/mem.h
kernel/mem/addrspace.cc

index 14f4ae28f48e77a7a84f43192eeeb7445bfe8eb5..d26a681d4c39b5af70a5666f92ffddd926f4bd6b 100644 (file)
@@ -177,7 +177,7 @@ bitfield MapFlags {
        CopyOnWrite,   // Share the mapped object only until it is written to;
                       // then, before the write takes place, copy the object. 
                       // It is undefined whether this mapping will receive
-                      // the copy or the original.  Ignored for alloc_and_map.
+                      // the copy or the original.
        
        AccessFlags access:3,
                       // These are the requested read/write/execute
@@ -228,11 +228,6 @@ interface AddrSpace {
 
        clone(AddrSpace addrspace out, bool clone_is_real);
        
-       // Create an anonymous RAM mapping.     
-
-       alloc_and_map(ulong len, ulong vstart inout, 
-                     AllocFlags aflags, MapFlags mflags);
-       
        // Mappable must be implemented by the local kernel, and must hold
        // read/write/exec permissions appropriate for the MapFlags given.
        
index ac60e84ba663644e8e3ab3a970baf267b442927d..be628b4ccbb204adca4b0c63e1c764e44205b353 100644 (file)
@@ -400,9 +400,6 @@ namespace Mem {
                void get_mappable(IMappable *ma);
                void clone(IAddrSpace *addrspace, u8 clone_is_real);
 
-               void alloc_and_map(u64 len, u64 *vstart,
-                                  AllocFlags aflags, MapFlags mflags);
-
                enum {
                        map_user,
                        map_protected,
@@ -410,7 +407,7 @@ namespace Mem {
                };
 
                void map(IMappable ma, Region region, u64 *vstart, MapFlags mflags,
-                        bool from_kernel = false, int map_type = map_user);
+                        int map_type = map_user);
                void unmap(Region region, bool from_kernel = false);
                
                void set_mapflags(Region region, MapFlags mflags);
index b9bd07af82f54c2c92e483fbda899aa7eb58d83f..f014c5458c621d97b08a5efe3787d342852dd533 100644 (file)
@@ -46,7 +46,7 @@ extern int roshared_start, roshared_page_end;
 extern int rwshared_start, rwshared_page_end;
 
 namespace Mem {
-       extern IMappable physmem;
+       extern IMappable physmem, anonmem;
 
        class AddrSpaceFactory {
        public:
@@ -86,8 +86,7 @@ namespace Mem {
                        mf.access_IDLNS_Read = 1;
                        mf.access_IDLNS_Exec = 1;
                        
-                       as->map(physmem, region, &vstart, mf,
-                               true, AddrSpace::map_protected);
+                       as->map(physmem, region, &vstart, mf, AddrSpace::map_protected);
                        
                        region.start = kvirt_to_phys(&rwshared_start);
                        region.end = kvirt_to_phys(&rwshared_page_end);
@@ -96,12 +95,14 @@ namespace Mem {
                        mf.access_IDLNS_Write = 1;
                        mf.CopyOnWrite = 1;
                        
-                       as->map(physmem, region, &vstart, mf,
-                               true, AddrSpace::map_protected);
+                       as->map(physmem, region, &vstart, mf, AddrSpace::map_protected);
                        
-                       AllocFlags af = 0;
-                       vstart = Arch::stack_bottom;
-                       as->alloc_and_map(Arch::stack_top - vstart + 1, &vstart, af, mf);
+                       // Leave the stack no-exec by default.
+                       region.start = vstart = Arch::stack_bottom;
+                       region.end = Arch::stack_top;
+                       mf.CopyOnWrite = 0;
+                       printf("vstart %llx\n", vstart);
+                       as->map(anonmem, region, &vstart, mf);
                        
                        *obj = static_cast<IAddrSpace>(*(as));
                }
@@ -154,12 +155,6 @@ namespace Mem {
                *addrspace = NULL;
        }
        
-       void AddrSpace::alloc_and_map(u64 len, u64 *vstart,
-                                     AllocFlags aflags, MapFlags mflags)
-       {
-               // FIXME: implement
-       }
-       
        bool AddrSpace::handle_fault(ulong vaddr, bool write, bool exec, bool user)
        {
                if (lock.held_by_curthread())
@@ -542,6 +537,7 @@ namespace Mem {
                        // gets its copy-on-write broken.
 
                        assert((oldflags & reqflags) == reqflags);
+                       assert(!va->flags.FaultOnWrite || oldphys == phys);
                        return true;
                }
 
@@ -580,7 +576,7 @@ namespace Mem {
        }
        
        void AddrSpace::map(IMappable ma, Region region, u64 *vstart,
-                           MapFlags mflags, bool from_kernel, int map_type)
+                           MapFlags mflags, int map_type)
        {
                // FIXME: check alignment for VIPT caches
                // FIXME: Implement the "Replace" map flag
@@ -614,7 +610,7 @@ namespace Mem {
                
                if (*vstart != System::Mem::AddrSpace_ns::unspecified_start) {
                        vregion.start = *vstart;
-                       vregion.end = vregion.start + region.end - region.start + 1;
+                       vregion.end = vregion.start + region.end - region.start;
                
                        if (is_process) {
                                if (!valid_addr(vregion.start))
@@ -631,7 +627,7 @@ namespace Mem {
                }
                
                if (*vstart == System::Mem::AddrSpace_ns::unspecified_start) {
-                       if (fixed) 
+                       if (fixed)
                                throw_idl(ResourceBusy, 2, countarray("varea overlap"));
                        
                        if (!get_free_region(region.end - region.start + 1, vregion, prev))