From f294ec608eaa3f8a5262b173234dffd9a5375519 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 5 Mar 2018 23:34:03 +0100 Subject: [PATCH] rump: tweak memory configuration Adjust managed dataspace (== max memory provided to rump kernel) based on 32/64 bit architecture. On 32bit is it 256M, on 64bit is 4G. Additionally limit the actual announced memory to rump by the available RAM and by the maximum size of the managed dataspace. Fixes #2709 --- repos/dde_rump/include/util/allocator_fap.h | 10 +++++----- repos/dde_rump/src/lib/rump/hypercall.cc | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/repos/dde_rump/include/util/allocator_fap.h b/repos/dde_rump/include/util/allocator_fap.h index ba559add5..3f75526a4 100644 --- a/repos/dde_rump/include/util/allocator_fap.h +++ b/repos/dde_rump/include/util/allocator_fap.h @@ -21,8 +21,8 @@ #include namespace Allocator { - template class Backend_alloc; - template class Fap; + template class Backend_alloc; + template class Fap; } @@ -48,7 +48,7 @@ namespace Allocator { /** * Back-end allocator for Genode's slab allocator */ - template + template class Backend_alloc : public Genode::Allocator, public Genode::Rm_connection, public Genode::Region_map_client @@ -56,7 +56,7 @@ namespace Allocator { private: enum { - BLOCK_SIZE = 1024 * 1024, /* 1 MB */ + BLOCK_SIZE = 2 * 1024 * 1024, /* 2 MB */ ELEMENTS = VM_SIZE / BLOCK_SIZE, /* MAX number of dataspaces in VM */ }; @@ -193,7 +193,7 @@ namespace Allocator { /** * Interface */ - template + template class Fap { private: diff --git a/repos/dde_rump/src/lib/rump/hypercall.cc b/repos/dde_rump/src/lib/rump/hypercall.cc index fef8a934c..b8e8e38c4 100644 --- a/repos/dde_rump/src/lib/rump/hypercall.cc +++ b/repos/dde_rump/src/lib/rump/hypercall.cc @@ -22,7 +22,10 @@ #include #include -enum { SUPPORTED_RUMP_VERSION = 17 }; +enum { + SUPPORTED_RUMP_VERSION = 17, + MAX_VIRTUAL_MEMORY = (sizeof(void *) == 4 ? 256UL : 4096UL) * 1024 * 1024 +}; static bool verbose = false; @@ -170,6 +173,7 @@ int rumpuser_getparam(const char *name, void *buf, size_t buflen) } rump_ram -= RESERVE_MEM; + rump_ram = Genode::min((unsigned long)MAX_VIRTUAL_MEMORY, rump_ram); /* convert to string */ Genode::snprintf((char *)buf, buflen, "%zu", rump_ram); @@ -233,7 +237,7 @@ struct Allocator_policy }; -typedef Allocator::Fap<128 * 1024 * 1024, Allocator_policy> Rump_alloc; +typedef Allocator::Fap Rump_alloc; static Genode::Lock & alloc_lock() {