bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] Handle proxy memory objects with len


From: olafBuddenhagen
Subject: [PATCH 2/2] Handle proxy memory objects with len
Date: Mon, 18 May 2009 07:49:03 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

diff --git a/vm/memory_object_proxy.c b/vm/memory_object_proxy.c
index 3474cd1..8676951 100644
--- a/vm/memory_object_proxy.c
+++ b/vm/memory_object_proxy.c
@@ -55,6 +55,7 @@ struct memory_object_proxy
   ipc_port_t object;
   vm_prot_t max_protection;
   vm_offset_t offset;
+  vm_offset_t len;
 };
 typedef struct memory_object_proxy *memory_object_proxy_t;
 
@@ -144,8 +145,8 @@ memory_object_create_proxy (ipc_space_t space, vm_prot_t 
max_protection,
   if (!IP_VALID(object[0]))
     return KERN_INVALID_NAME;
 
-  /* FIXME: Support a different range from total.  */
-  if (start[0] != 0 || len[0] != (vm_offset_t) ~0)
+  /* FIXME: Support a different start.  */
+  if (start[0] != 0)
     return KERN_INVALID_ARGUMENT;
 
   proxy = (memory_object_proxy_t) zalloc (memory_object_proxy_zone);
@@ -169,13 +170,14 @@ memory_object_create_proxy (ipc_space_t space, vm_prot_t 
max_protection,
   proxy->object = ipc_port_copy_send (object[0]);
   proxy->max_protection = max_protection;
   proxy->offset = offset[0];
+  proxy->len = len[0];
 
   *port = ipc_port_make_send (proxy->port);
   return KERN_SUCCESS;
 }
 
 
-/* Lookup the real memory object, maximum protection, and offset for the proxy
+/* Lookup the real memory object, maximum protection, offset, and length for 
the proxy
    memory object port PORT, for which the caller holds a reference.
    *OBJECT is only guaranteed to be valid as long as the caller holds
    the reference to PORT (unless the caller acquires its own reference
@@ -183,7 +185,8 @@ memory_object_create_proxy (ipc_space_t space, vm_prot_t 
max_protection,
    KERN_INVALID_ARGUMENT.  */
 kern_return_t
 memory_object_proxy_lookup (ipc_port_t port, ipc_port_t *object,
-                           vm_prot_t *max_protection, vm_offset_t *offset)
+                           vm_prot_t *max_protection, vm_offset_t *offset,
+                           vm_offset_t *len)
 {
   memory_object_proxy_t proxy;
 
@@ -194,6 +197,7 @@ memory_object_proxy_lookup (ipc_port_t port, ipc_port_t 
*object,
    *object = proxy->object;
    *max_protection = proxy->max_protection;
    *offset = proxy->offset;
+   *len = proxy->len;
 
   return KERN_SUCCESS;
 }
diff --git a/vm/vm_user.c b/vm/vm_user.c
index 522e1ed..40c13da 100644
--- a/vm/vm_user.c
+++ b/vm/vm_user.c
@@ -280,7 +280,8 @@ kern_return_t vm_copy(map, source_address, size, 
dest_address)
 /* XXX From memory_object_proxy.c  */
 kern_return_t
 memory_object_proxy_lookup (ipc_port_t proxy_object, ipc_port_t *object,
-                            vm_prot_t *max_protection, vm_offset_t *offset);
+                            vm_prot_t *max_protection, vm_offset_t *offset,
+                           vm_offset_t *len);
 
 /*
  *     Routine:        vm_map
@@ -334,9 +335,9 @@ kern_return_t vm_map(
          {
            ipc_port_t real_memobj;
            vm_prot_t prot;
-           vm_offset_t offs;
+           vm_offset_t offs, len;
            result = memory_object_proxy_lookup (memory_object, &real_memobj,
-                                                &prot, &offs);
+                                                &prot, &offs, &len);
            if (result != KERN_SUCCESS)
              return result;
 
@@ -344,6 +345,11 @@ kern_return_t vm_map(
            max_protection &= prot;
            cur_protection &= prot;
 
+           if (offset > len)
+             size = 0;
+           else if (size > len - offset)
+             size = trunc_page(len - offset);
+
            offset += offs;
 
            if ((object = vm_object_enter(real_memobj, size, FALSE))
-- 
1.5.6.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]