changeset 221:098942ff5f44

uva2ka_check_pte_ap
author tobaru
date Fri, 24 Jan 2020 17:44:25 +0900
parents c1d1721fd907
children 7a4d299a35be
files src/impl/vm_impl_private.cbc
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/impl/vm_impl_private.cbc	Fri Jan 24 17:41:35 2020 +0900
+++ b/src/impl/vm_impl_private.cbc	Fri Jan 24 17:44:25 2020 +0900
@@ -302,6 +302,12 @@
 }
 
 __code uva2ka_check_pte_ap(struct vm_impl* vm, pde_t* pgdir, char* uva, pte_t* pte, __code next(int ret, ...)) {
+    // make sure it is a user page
+    if (PTE_AP(*pte) != AP_KU) {
+        ret = 0;
+        goto next(ret, ...);
+    }
+    ret = (char*) p2v(PTE_ADDR(*pte));
     goto next(ret, ...);
 }