1.1 --- a/libfsserver/lib/generic/pager.cc Thu May 19 14:08:28 2022 +0200
1.2 +++ b/libfsserver/lib/generic/pager.cc Fri May 20 00:40:27 2022 +0200
1.3 @@ -89,7 +89,7 @@
1.4
1.5 /* Prevent access beyond that defined by the pager. */
1.6
1.7 - if (flags & ~_flags)
1.8 + if (flags & (~(_flags | L4RE_DS_F_X)))
1.9 return -L4_EACCESS;
1.10
1.11 Flexpage *flexpage = _mapper->get(file_offset, flags);
2.1 --- a/libmem/Control Thu May 19 14:08:28 2022 +0200
2.2 +++ b/libmem/Control Fri May 20 00:40:27 2022 +0200
2.3 @@ -1,3 +1,3 @@
2.4 -requires: libstdc++ libc libsystypes
2.5 +requires: libstdc++ libc libsystypes libipc
2.6 provides: libmem
2.7 maintainer: paul@boddie.org.uk
3.1 --- a/libmem/include/mem/memory_incremental.h Thu May 19 14:08:28 2022 +0200
3.2 +++ b/libmem/include/mem/memory_incremental.h Fri May 20 00:40:27 2022 +0200
3.3 @@ -1,7 +1,7 @@
3.4 /*
3.5 * A memory pool allocating a region at a time from the system.
3.6 *
3.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
3.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
3.9 *
3.10 * This program is free software; you can redistribute it and/or
3.11 * modify it under the terms of the GNU General Public License as
3.12 @@ -43,6 +43,8 @@
3.13
3.14 Region *allocate(offset_t size);
3.15
3.16 + void deallocate(Region *region);
3.17 +
3.18 public:
3.19 explicit MemoryIncremental(unsigned int limit, offset_t region_size=PAGE_SIZE);
3.20
4.1 --- a/libmem/include/mem/region.h Thu May 19 14:08:28 2022 +0200
4.2 +++ b/libmem/include/mem/region.h Fri May 20 00:40:27 2022 +0200
4.3 @@ -1,7 +1,7 @@
4.4 /*
4.5 * Memory region abstractions.
4.6 *
4.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
4.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
4.9 *
4.10 * This program is free software; you can redistribute it and/or
4.11 * modify it under the terms of the GNU General Public License as
4.12 @@ -59,8 +59,6 @@
4.13
4.14 explicit Region(offset_t start, offset_t end);
4.15
4.16 - virtual ~Region();
4.17 -
4.18 offset_t size();
4.19
4.20 int compare(Region *other);
5.1 --- a/libmem/lib/src/Makefile Thu May 19 14:08:28 2022 +0200
5.2 +++ b/libmem/lib/src/Makefile Fri May 20 00:40:27 2022 +0200
5.3 @@ -8,7 +8,7 @@
5.4 flexpage.cc memory_incremental.cc memory_preallocated.cc \
5.5 memory_utils.cc region.cc
5.6
5.7 -REQUIRES_LIBS = l4re_c-util libstdc++ libsystypes
5.8 +REQUIRES_LIBS = l4re_c-util libstdc++ libsystypes libipc
5.9
5.10 PRIVATE_INCDIR = $(PKGDIR)/include $(PKGDIR)/include/mem
5.11 CONTRIB_INCDIR = libmem
6.1 --- a/libmem/lib/src/memory_incremental.cc Thu May 19 14:08:28 2022 +0200
6.2 +++ b/libmem/lib/src/memory_incremental.cc Fri May 20 00:40:27 2022 +0200
6.3 @@ -1,7 +1,7 @@
6.4 /*
6.5 * A memory pool allocating a region at a time from the system.
6.6 *
6.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
6.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
6.9 *
6.10 * This program is free software; you can redistribute it and/or
6.11 * modify it under the terms of the GNU General Public License as
6.12 @@ -21,6 +21,8 @@
6.13
6.14 #include "memory_incremental.h"
6.15
6.16 +#include <ipc/mem_ipc.h>
6.17 +
6.18 #include <stdlib.h>
6.19
6.20
6.21 @@ -45,18 +47,31 @@
6.22 {
6.23 /* Attempt to allocate aligned memory. */
6.24
6.25 - void *current;
6.26 + void *current = NULL;
6.27 + l4re_ds_t ds;
6.28
6.29 /* Make the size appropriate for the invocation. */
6.30
6.31 size = round_multiple(size, PAGE_SIZE);
6.32
6.33 - if (posix_memalign(¤t, size, size))
6.34 + /* Use allocation permitting executable mapping of the memory.
6.35 + NOTE: A collection of blocks needs to be allocated, and a collection of
6.36 + dataspaces might also be employed. */
6.37 +
6.38 + if (ipc_allocate_align(size, L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RWX, page_order(size), ¤t, &ds))
6.39 return NULL;
6.40
6.41 return new Region((offset_t) current, (offset_t) current + size);
6.42 }
6.43
6.44 +/* Deallocate the given region. */
6.45 +
6.46 +void MemoryIncremental::deallocate(Region *region)
6.47 +{
6.48 + ipc_detach_dataspace((void *) region->start);
6.49 + delete region;
6.50 +}
6.51 +
6.52 /* Allocate a new region of the given 'size' rounded to the nearest page. */
6.53
6.54 Region *MemoryIncremental::region(offset_t size)
6.55 @@ -109,7 +124,7 @@
6.56 if (_limited)
6.57 _limit += pages;
6.58
6.59 - delete region;
6.60 + deallocate(region);
6.61 }
6.62
6.63 // vim: tabstop=4 expandtab shiftwidth=4
7.1 --- a/libmem/lib/src/region.cc Thu May 19 14:08:28 2022 +0200
7.2 +++ b/libmem/lib/src/region.cc Fri May 20 00:40:27 2022 +0200
7.3 @@ -58,13 +58,6 @@
7.4 memset((void *) start, 0, end - start);
7.5 }
7.6
7.7 -/* Deallocate the region, freeing its memory. */
7.8 -
7.9 -Region::~Region()
7.10 -{
7.11 - free((void *) start);
7.12 -}
7.13 -
7.14 /* Return the size of the region. */
7.15
7.16 offset_t Region::size()