From a3eb63c58543ca9a651692502805bf8272ed6d79 Mon Sep 17 00:00:00 2001 From: Brian Brooks Date: Tue, 7 Nov 2017 21:28:42 -0600 Subject: [PATCH] Map SVM regions at a sane offset on arm64 Mapping shared virtual memory at 0x30000000, which appears to be derived from x86-32, turns out to be too close to the heap on arm64 systems. The symptoms of memory corruption were random and included crashes in the Python runtime and what appeared to be corruption of malloc's internal mutex. Thanks to Gabriel Ganne for pointing out that disabling ASLR seemed to mitigate the situation. This patch maps SVM regions at an offset from the arm64 kernel constant TASK_UNMAPPED_BASE and also assumes a 48-bit VA (for Ubuntu). Change-Id: I642e5fe83344ab9b5c66c93e0cf1575c17251f3b Signed-off-by: Brian Brooks --- src/svm/svm_common.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/svm/svm_common.h b/src/svm/svm_common.h index a7160286a44..58cd0e94f5c 100644 --- a/src/svm/svm_common.h +++ b/src/svm/svm_common.h @@ -83,9 +83,15 @@ typedef struct svm_map_region_args_ * Base should be "out of the way," and size should be big enough to * cover everything we plan to put here. */ -#define SVM_GLOBAL_REGION_BASEVA 0x30000000 #define SVM_GLOBAL_REGION_SIZE (64<<20) #define SVM_GLOBAL_REGION_NAME "/global_vm" +#if defined (__aarch64__) +#define VA_BITS 48 +#define BASEVA ((1ul << VA_BITS) / 4) +#define SVM_GLOBAL_REGION_BASEVA (BASEVA - (2 * SVM_GLOBAL_REGION_SIZE)) +#else +#define SVM_GLOBAL_REGION_BASEVA 0x30000000 +#endif /* * Memory shared across individual router instances. -- 2.16.6