diff options
Diffstat (limited to 'debian/patches')
-rw-r--r-- | debian/patches/libpager-fix-receiver-lookups.patch | 487 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 488 insertions, 0 deletions
diff --git a/debian/patches/libpager-fix-receiver-lookups.patch b/debian/patches/libpager-fix-receiver-lookups.patch new file mode 100644 index 00000000..fc8f78ff --- /dev/null +++ b/debian/patches/libpager-fix-receiver-lookups.patch @@ -0,0 +1,487 @@ +commit b7cbdde8854ee4c51ec9cd49ce639bd02d646355 +Author: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Mon Mar 3 20:48:20 2014 +0100 + + libpager: fix receiver lookups + + Previously, the receiver lookup was done manually in all the server + functions. Use mig translator functions instead. + + * libpager/mig-decls.h: New file. + * libpager/mig-mutate.h: Likewise. + * libpager/Makefile (MIGSFLAGS): Include mig-mutate.h. + * libpager/chg-compl.c: Fix receiver lookups. + * libpager/data-request.c: Likewise. + * libpager/data-return.c: Likewise. + * libpager/data-unlock.c: Likewise. + * libpager/lock-completed.c: Likewise. + * libpager/object-init.c: Likewise. + * libpager/object-terminate.c: Likewise. + * libpager/stubs.c: Likewise. + * libpager/seqnos.c (_pager_update_seqno): Move the actual + functionality... + (_pager_update_seqno_p): ... into a new function that can be called + with a pointer to struct pager. + * libpager/priv.h (_pager_update_seqno_p): New declaration. + +diff --git a/libpager/Makefile b/libpager/Makefile +index 7c4da38..b622295 100644 +--- a/libpager/Makefile ++++ b/libpager/Makefile +@@ -31,7 +31,7 @@ HURDLIBS= ports + LDLIBS += -lpthread + OBJS = $(SRCS:.c=.o) memory_objectServer.o notifyServer.o + +-MIGSFLAGS = -DSEQNOS ++MIGSFLAGS = -DSEQNOS -imacros $(srcdir)/mig-mutate.h + MIGCOMSFLAGS = -prefix _pager_ + + include ../Makeconf +diff --git a/libpager/chg-compl.c b/libpager/chg-compl.c +index 0b0c99c..d77c46c 100644 +--- a/libpager/chg-compl.c ++++ b/libpager/chg-compl.c +@@ -22,16 +22,15 @@ + when a memory_object_change_attributes call has completed. Read this + in combination with pager-attr.c. */ + kern_return_t +-_pager_seqnos_memory_object_change_completed (mach_port_t obj, ++_pager_seqnos_memory_object_change_completed (struct pager *p, + mach_port_seqno_t seq, + boolean_t maycache, + memory_object_copy_strategy_t strat) + { +- struct pager *p; + struct attribute_request *ar; +- +- p = ports_lookup_port (0, obj, _pager_class); +- if (!p) ++ ++ if (!p ++ || p->port.class != _pager_class) + { + printf ("Bad change completed\n"); + return EOPNOTSUPP; +@@ -50,6 +49,5 @@ _pager_seqnos_memory_object_change_completed (mach_port_t obj, + + _pager_release_seqno (p, seq); + pthread_mutex_unlock (&p->interlock); +- ports_port_deref (p); + return 0; + } +diff --git a/libpager/data-request.c b/libpager/data-request.c +index 34b8b43..82ce904 100644 +--- a/libpager/data-request.c ++++ b/libpager/data-request.c +@@ -22,22 +22,21 @@ + + /* Implement pagein callback as described in <mach/memory_object.defs>. */ + kern_return_t +-_pager_seqnos_memory_object_data_request (mach_port_t object, ++_pager_seqnos_memory_object_data_request (struct pager *p, + mach_port_seqno_t seqno, + mach_port_t control, + vm_offset_t offset, + vm_size_t length, + vm_prot_t access) + { +- struct pager *p; + short *pm_entry; + int doread, doerror; + error_t err; + vm_address_t page; + int write_lock; + +- p = ports_lookup_port (0, object, _pager_class); +- if (!p) ++ if (!p ++ || p->port.class != _pager_class) + return EOPNOTSUPP; + + /* Acquire the right to meddle with the pagemap */ +@@ -126,7 +125,6 @@ _pager_seqnos_memory_object_data_request (mach_port_t object, + _pager_mark_object_error (p, offset, length, 0); + _pager_allow_termination (p); + pthread_mutex_unlock (&p->interlock); +- ports_port_deref (p); + return 0; + + error_read: +@@ -136,7 +134,6 @@ _pager_seqnos_memory_object_data_request (mach_port_t object, + pthread_mutex_lock (&p->interlock); + _pager_allow_termination (p); + pthread_mutex_unlock (&p->interlock); +- ports_port_deref (p); + return 0; + + allow_release_out: +@@ -144,6 +141,5 @@ _pager_seqnos_memory_object_data_request (mach_port_t object, + release_out: + _pager_release_seqno (p, seqno); + pthread_mutex_unlock (&p->interlock); +- ports_port_deref (p); + return 0; + } +diff --git a/libpager/data-return.c b/libpager/data-return.c +index 6a3b903..ee6c6e8 100644 +--- a/libpager/data-return.c ++++ b/libpager/data-return.c +@@ -26,7 +26,7 @@ + as for _pager_seqnos_memory_object_data_return; the additional + INITIALIZING arg identifies which function is calling us. */ + kern_return_t +-_pager_do_write_request (mach_port_t object, ++_pager_do_write_request (struct pager *p, + mach_port_seqno_t seqno, + mach_port_t control, + vm_offset_t offset, +@@ -36,7 +36,6 @@ _pager_do_write_request (mach_port_t object, + int kcopy, + int initializing) + { +- struct pager *p; + short *pm_entries; + int npages, i; + char *notified; +@@ -47,8 +46,8 @@ _pager_do_write_request (mach_port_t object, + int wakeup; + int omitdata = 0; + +- p = ports_lookup_port (0, object, _pager_class); +- if (!p) ++ if (!p ++ || p->port.class != _pager_class) + return EOPNOTSUPP; + + /* Acquire the right to meddle with the pagemap */ +@@ -249,19 +248,17 @@ _pager_do_write_request (mach_port_t object, + } + } + +- ports_port_deref (p); + return 0; + + release_out: + _pager_release_seqno (p, seqno); + pthread_mutex_unlock (&p->interlock); +- ports_port_deref (p); + return 0; + } + + /* Implement pageout call back as described by <mach/memory_object.defs>. */ + kern_return_t +-_pager_seqnos_memory_object_data_return (mach_port_t object, ++_pager_seqnos_memory_object_data_return (struct pager *p, + mach_port_seqno_t seqno, + mach_port_t control, + vm_offset_t offset, +@@ -270,6 +267,6 @@ _pager_seqnos_memory_object_data_return (mach_port_t object, + int dirty, + int kcopy) + { +- return _pager_do_write_request (object, seqno, control, offset, data, ++ return _pager_do_write_request (p, seqno, control, offset, data, + length, dirty, kcopy, 0); + } +diff --git a/libpager/data-unlock.c b/libpager/data-unlock.c +index 02339ab..599237c 100644 +--- a/libpager/data-unlock.c ++++ b/libpager/data-unlock.c +@@ -22,18 +22,17 @@ + /* Implement kernel requests for access as described in + <mach/memory_object.defs>. */ + kern_return_t +-_pager_seqnos_memory_object_data_unlock (mach_port_t object, ++_pager_seqnos_memory_object_data_unlock (struct pager *p, + mach_port_seqno_t seqno, + mach_port_t control, + vm_offset_t offset, + vm_size_t length, + vm_prot_t access) + { +- struct pager *p; + volatile int err; + +- p = ports_lookup_port (0, object, _pager_class); +- if (!p) ++ if (!p ++ || p->port.class != _pager_class) + return EOPNOTSUPP; + + pthread_mutex_lock (&p->interlock); +@@ -84,6 +83,5 @@ _pager_seqnos_memory_object_data_unlock (mach_port_t object, + _pager_mark_next_request_error (p, offset, length, err); + } + out: +- ports_port_deref (p); + return 0; + } +diff --git a/libpager/lock-completed.c b/libpager/lock-completed.c +index 9ab640f..a3f3f16 100644 +--- a/libpager/lock-completed.c ++++ b/libpager/lock-completed.c +@@ -23,18 +23,17 @@ + when a memory_object_lock_request call has completed. Read this + in combination with lock-object.c. */ + kern_return_t +-_pager_seqnos_memory_object_lock_completed (mach_port_t object, ++_pager_seqnos_memory_object_lock_completed (struct pager *p, + mach_port_seqno_t seqno, + mach_port_t control, + vm_offset_t offset, + vm_size_t length) + { + error_t err = 0; +- struct pager *p; + struct lock_request *lr; + +- p = ports_lookup_port (0, object, _pager_class); +- if (!p) ++ if (!p ++ || p->port.class != _pager_class) + return EOPNOTSUPP; + + pthread_mutex_lock (&p->interlock); +@@ -62,7 +61,6 @@ _pager_seqnos_memory_object_lock_completed (mach_port_t object, + out: + _pager_release_seqno (p, seqno); + pthread_mutex_unlock (&p->interlock); +- ports_port_deref (p); + + return err; + } +diff --git a/libpager/mig-decls.h b/libpager/mig-decls.h +new file mode 100644 +index 0000000..0c7b402 +--- /dev/null ++++ b/libpager/mig-decls.h +@@ -0,0 +1,42 @@ ++/* ++ Copyright (C) 2014 Free Software Foundation, Inc. ++ Written by Justus Winter. ++ ++ This file is part of the GNU Hurd. ++ ++ The GNU Hurd is free software; you can redistribute it and/or ++ modify it under the terms of the GNU General Public License as ++ published by the Free Software Foundation; either version 2, or (at ++ your option) any later version. ++ ++ The GNU Hurd is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifndef __LIBPAGER_MIG_DECLS_H__ ++#define __LIBPAGER_MIG_DECLS_H__ ++ ++#include "priv.h" ++ ++typedef struct pager *pager_t; ++ ++/* Called by server stub functions. */ ++ ++static inline struct pager * __attribute__ ((unused)) ++begin_using_pager (mach_port_t port) ++{ ++ return ports_lookup_port (0, port, _pager_class); ++} ++ ++static inline void __attribute__ ((unused)) ++end_using_pager (struct pager *p) ++{ ++ if (p) ++ ports_port_deref (p); ++} ++ ++#endif /* __LIBPAGER_MIG_DECLS_H__ */ +diff --git a/libpager/mig-mutate.h b/libpager/mig-mutate.h +new file mode 100644 +index 0000000..54f7de8 +--- /dev/null ++++ b/libpager/mig-mutate.h +@@ -0,0 +1,22 @@ ++/* ++ Copyright (C) 2014 Free Software Foundation, Inc. ++ Written by Justus Winter. ++ ++ This file is part of the GNU Hurd. ++ ++ The GNU Hurd is free software; you can redistribute it and/or ++ modify it under the terms of the GNU General Public License as ++ published by the Free Software Foundation; either version 2, or (at ++ your option) any later version. ++ ++ The GNU Hurd is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */ ++ ++#define MEMORY_OBJECT_INTRAN pager_t begin_using_pager (memory_object_t) ++#define MEMORY_OBJECT_DESTRUCTOR end_using_pager (pager_t) ++#define MEMORY_OBJECT_IMPORTS import "mig-decls.h"; +diff --git a/libpager/object-init.c b/libpager/object-init.c +index 90ffc01..6683e24 100644 +--- a/libpager/object-init.c ++++ b/libpager/object-init.c +@@ -22,16 +22,14 @@ + /* Implement the object initialiation call as described in + <mach/memory_object.defs>. */ + kern_return_t +-_pager_seqnos_memory_object_init (mach_port_t object, ++_pager_seqnos_memory_object_init (struct pager *p, + mach_port_seqno_t seqno, + mach_port_t control, + mach_port_t name, + vm_size_t pagesize) + { +- struct pager *p; +- +- p = ports_lookup_port (0, object, _pager_class); +- if (!p) ++ if (!p ++ || p->port.class != _pager_class) + return EOPNOTSUPP; + + pthread_mutex_lock (&p->interlock); +@@ -73,7 +71,6 @@ _pager_seqnos_memory_object_init (mach_port_t object, + out: + _pager_release_seqno (p, seqno); + pthread_mutex_unlock (&p->interlock); +- ports_port_deref (p); + + return 0; + } +diff --git a/libpager/object-terminate.c b/libpager/object-terminate.c +index 896e2c2..365ba27 100644 +--- a/libpager/object-terminate.c ++++ b/libpager/object-terminate.c +@@ -22,15 +22,13 @@ + /* Implement the object termination call from the kernel as described + in <mach/memory_object.defs>. */ + kern_return_t +-_pager_seqnos_memory_object_terminate (mach_port_t object, ++_pager_seqnos_memory_object_terminate (struct pager *p, + mach_port_seqno_t seqno, + mach_port_t control, + mach_port_t name) + { +- struct pager *p; +- +- p = ports_lookup_port (0, object, _pager_class); +- if (!p) ++ if (!p ++ || p->port.class != _pager_class) + return EOPNOTSUPP; + + pthread_mutex_lock (&p->interlock); +@@ -79,7 +77,6 @@ _pager_seqnos_memory_object_terminate (mach_port_t object, + out: + _pager_release_seqno (p, seqno); + pthread_mutex_unlock (&p->interlock); +- ports_port_deref (p); + + return 0; + } +diff --git a/libpager/priv.h b/libpager/priv.h +index 7aa0fb4..d49cbb9 100644 +--- a/libpager/priv.h ++++ b/libpager/priv.h +@@ -139,6 +139,7 @@ struct port_class *_pager_class; + void _pager_wait_for_seqno (struct pager *, mach_port_seqno_t); + void _pager_release_seqno (struct pager *, mach_port_seqno_t); + void _pager_update_seqno (mach_port_t, mach_port_seqno_t); ++void _pager_update_seqno_p (struct pager *, mach_port_seqno_t); + void _pager_block_termination (struct pager *); + void _pager_allow_termination (struct pager *); + error_t _pager_pagemap_resize (struct pager *, vm_address_t); +diff --git a/libpager/seqnos.c b/libpager/seqnos.c +index 77bfbf2..cab2f33 100644 +--- a/libpager/seqnos.c ++++ b/libpager/seqnos.c +@@ -57,13 +57,23 @@ _pager_update_seqno (mach_port_t object, + struct pager *p; + + p = ports_lookup_port (0, object, _pager_class); ++ _pager_update_seqno_p (p, seqno); + if (p) ++ ports_port_deref (p); ++} ++ ++ ++/* Just update the seqno, pointer version. */ ++void ++_pager_update_seqno_p (struct pager *p, ++ mach_port_seqno_t seqno) ++{ ++ if (p ++ && p->port.class == _pager_class) + { + pthread_mutex_lock (&p->interlock); + _pager_wait_for_seqno (p, seqno); + _pager_release_seqno (p, seqno); + pthread_mutex_unlock (&p->interlock); +- +- ports_port_deref (p); + } + } +diff --git a/libpager/stubs.c b/libpager/stubs.c +index 8478212..411f483 100644 +--- a/libpager/stubs.c ++++ b/libpager/stubs.c +@@ -21,7 +21,7 @@ + #include <stdio.h> + + kern_return_t +-_pager_seqnos_memory_object_copy (mach_port_t obj, ++_pager_seqnos_memory_object_copy (struct pager *p, + mach_port_seqno_t seq, + memory_object_control_t obj_ctl, + vm_offset_t off, +@@ -30,13 +30,13 @@ _pager_seqnos_memory_object_copy (mach_port_t obj, + { + printf ("m_o_copy called\n"); + +- _pager_update_seqno (obj, seq); ++ _pager_update_seqno_p (p, seq); + + return EOPNOTSUPP; + } + + kern_return_t +-_pager_seqnos_memory_object_data_write (mach_port_t obj, ++_pager_seqnos_memory_object_data_write (struct pager *p, + mach_port_seqno_t seq, + mach_port_t ctl, + vm_offset_t off, +@@ -45,13 +45,13 @@ _pager_seqnos_memory_object_data_write (mach_port_t obj, + { + printf ("m_o_data_write called\n"); + +- _pager_update_seqno (obj, seq); ++ _pager_update_seqno_p (p, seq); + + return EOPNOTSUPP; + } + + kern_return_t +-_pager_seqnos_memory_object_supply_completed (mach_port_t obj, ++_pager_seqnos_memory_object_supply_completed (struct pager *p, + mach_port_seqno_t seq, + mach_port_t ctl, + vm_offset_t off, +@@ -61,7 +61,7 @@ _pager_seqnos_memory_object_supply_completed (mach_port_t obj, + { + printf ("m_o_supply_completed called\n"); + +- _pager_update_seqno (obj, seq); ++ _pager_update_seqno_p (p, seq); + + return EOPNOTSUPP; + } diff --git a/debian/patches/series b/debian/patches/series index db39cde1..9a0a9635 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -46,3 +46,4 @@ xkb-compat.patch xxx-fix-build.patch mach-defpager-protected-payload.patch #ext2fs-skip-unallocated-blocks.patch +libpager-fix-receiver-lookups.patch |