diff --git a/src/arch/aarch64/consts.rs b/src/arch/aarch64/consts.rs
index 59c5f0cececacbb093a921ce86d549c984048106..a34871411079e066c348d30739b0a3cf762f5100 100644
--- a/src/arch/aarch64/consts.rs
+++ b/src/arch/aarch64/consts.rs
@@ -81,7 +81,8 @@
     /// Offset to user TLS
     pub const USER_TLS_OFFSET: usize = USER_SIGSTACK_OFFSET + PML4_SIZE;
     pub const USER_TLS_PML4: usize = (USER_TLS_OFFSET & PML4_MASK)/PML4_SIZE;
-    pub const USER_TLS_SIZE: usize = 64 * 1024;
+    // Maximum TLS allocated to each PID, should be approximately 8 MB
+    pub const USER_TLS_SIZE: usize = PML4_SIZE / 65536;
 
     /// Offset to user temporary image (used when cloning)
     pub const USER_TMP_OFFSET: usize = USER_TLS_OFFSET + PML4_SIZE;
diff --git a/src/arch/aarch64/paging/mod.rs b/src/arch/aarch64/paging/mod.rs
index 29bf820c46973857e6c9f0e92fcefea3256734f9..43c8d13815e48640cd52545f292ab1dafc693cf6 100644
--- a/src/arch/aarch64/paging/mod.rs
+++ b/src/arch/aarch64/paging/mod.rs
@@ -392,6 +392,7 @@ impl PhysicalAddress {
 #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
 pub struct VirtualAddress(usize);
 
+#[derive(Debug, PartialEq)]
 pub enum VirtualAddressType {
     User,
     Kernel
diff --git a/src/context/arch/aarch64.rs b/src/context/arch/aarch64.rs
index e759f0cef04f9c8bb07935c9099f53afae9d7331..863766506a6ec5f1fc9b2d565599e6b1c9b37e74 100644
--- a/src/context/arch/aarch64.rs
+++ b/src/context/arch/aarch64.rs
@@ -87,10 +87,14 @@ impl Context {
         }
     }
 
-    pub fn get_page_table(&self) -> usize {
+    pub fn get_page_utable(&self) -> usize {
         self.ttbr0_el1
     }
 
+    pub fn get_page_ktable(&self) -> usize {
+        self.ttbr1_el1
+    }
+
     pub fn set_fx(&mut self, _address: usize) {
     }
 
diff --git a/src/context/memory.rs b/src/context/memory.rs
index e050467d8021b86df212dff083b3d29d134e6d3e..f61c1e9d4be848aa2d256b6e4eb3d096d1389b31 100644
--- a/src/context/memory.rs
+++ b/src/context/memory.rs
@@ -371,7 +371,7 @@ impl Grant {
     }
 
     pub fn map_inactive(from: VirtualAddress, to: VirtualAddress, size: usize, flags: EntryFlags, desc_opt: Option<FileDescriptor>, new_table: &mut InactivePageTable, temporary_page: &mut TemporaryPage) -> Grant {
-        let mut active_table = match to.get_type() {
+        let mut active_table = match from.get_type() {
             VirtualAddressType::User => unsafe { ActivePageTable::new(PageTableType::User) },
             VirtualAddressType::Kernel => unsafe { ActivePageTable::new(PageTableType::Kernel) }
         };
@@ -386,6 +386,11 @@ impl Grant {
             frames.push_back(frame);
         }
 
+        let mut active_table = match to.get_type() {
+            VirtualAddressType::User => unsafe { ActivePageTable::new(PageTableType::User) },
+            VirtualAddressType::Kernel => unsafe { ActivePageTable::new(PageTableType::Kernel) }
+        };
+
         active_table.with(new_table, temporary_page, |mapper| {
             let start_page = Page::containing_address(to);
             let end_page = Page::containing_address(VirtualAddress::new(to.data() + size - 1));
diff --git a/src/ptrace.rs b/src/ptrace.rs
index 930b10e4ae12dbb40887789b0e436e386e92cafc..aeea28f2114abcb081101b40190673ce1bcef8ac 100644
--- a/src/ptrace.rs
+++ b/src/ptrace.rs
@@ -460,7 +460,7 @@ where F: FnOnce(*mut u8) -> Result<()>
 
     let mut active_page_table = unsafe { ActivePageTable::new(PageTableType::User) };
     let mut target_page_table = unsafe {
-        InactivePageTable::from_address(context.arch.get_page_table())
+        InactivePageTable::from_address(context.arch.get_page_utable())
     };
 
     // Find the physical frames for all pages
diff --git a/src/scheme/user.rs b/src/scheme/user.rs
index 18fdfc414171cae80ed457e9490cc6ef162d1343..8ba07864856b749c8a18ebf6b8d3040ddd96c3d3 100644
--- a/src/scheme/user.rs
+++ b/src/scheme/user.rs
@@ -123,7 +123,7 @@ impl UserInner {
         let context_lock = context_weak.upgrade().ok_or(Error::new(ESRCH))?;
         let mut context = context_lock.write();
 
-        let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_table()) };
+        let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_utable()) };
         let mut temporary_page = TemporaryPage::new(Page::containing_address(VirtualAddress::new(crate::USER_TMP_GRANT_OFFSET)));
 
         let mut grants = context.grants.lock();
@@ -154,7 +154,7 @@ impl UserInner {
             let context_lock = self.context.upgrade().ok_or(Error::new(ESRCH))?;
             let mut context = context_lock.write();
 
-            let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_table()) };
+            let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_utable()) };
             let mut temporary_page = TemporaryPage::new(Page::containing_address(VirtualAddress::new(crate::USER_TMP_GRANT_OFFSET)));
 
             let mut grants = context.grants.lock();
diff --git a/src/syscall/process.rs b/src/syscall/process.rs
index 8518f99b90cc106e4750e84f0eccf914b0cb90dc..05b66e266757429f01cca2c7e01e7bef5c258216 100644
--- a/src/syscall/process.rs
+++ b/src/syscall/process.rs
@@ -599,7 +599,7 @@ fn empty(context: &mut context::Context, reaping: bool) {
             if reaping {
                 println!("{}: {}: Grant should not exist: {:?}", context.id.into(), unsafe { ::core::str::from_utf8_unchecked(&context.name.lock()) }, grant);
 
-                let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_table()) };
+                let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_utable()) };
                 let mut temporary_page = TemporaryPage::new(Page::containing_address(VirtualAddress::new(crate::USER_TMP_GRANT_OFFSET)));
 
                 grant.unmap_inactive(&mut new_table, &mut temporary_page);