# HG changeset patch # User tobaru # Date 1579855295 -32400 # Node ID c1d1721fd90745e5f03cd9c44580ca0c83952900 # Parent b8597756f7019851f35b30b969fd43d3db36ef40 uva2ka_check_pe_types diff -r b8597756f701 -r c1d1721fd907 src/impl/vm_impl.cbc --- a/src/impl/vm_impl.cbc Fri Jan 24 17:22:51 2020 +0900 +++ b/src/impl/vm_impl.cbc Fri Jan 24 17:41:35 2020 +0900 @@ -30,6 +30,7 @@ vm_impl->allocuvm_loop = C_allocuvm_loopvm_impl; vm_impl->copyuvm_check_null = C_copyuvm_check_nullvm_impl; vm_impl->copyuvm_loop = C_copyuvm_loopvm_impl; + vm_impl->uva2ka_check_pe_types = C_uva2ka_check_pe_types; vm->init_vmm = C_init_vmmvm_impl; vm->kpt_freerange = C_kpt_freerangevm_impl; vm->kpt_alloc = C_kpt_allocvm_impl; @@ -125,7 +126,7 @@ __code uva2kavm_impl(struct vm_impl* vm, pde_t* pgdir, char* uva, __code next(...)) { - goto next(...); + goto uva2ka_check_pe_types(vm, pgdir, uva, next(...)); } __code copyoutvm_impl(struct vm_impl* vm, pde_t* pgdir, uint va, void* pp, uint len, __code next(...)) { diff -r b8597756f701 -r c1d1721fd907 src/impl/vm_impl.h --- a/src/impl/vm_impl.h Fri Jan 24 17:22:51 2020 +0900 +++ b/src/impl/vm_impl.h Fri Jan 24 17:41:35 2020 +0900 @@ -26,6 +26,7 @@ __code copyuvm_check_null(Type* vm_impl, pde_t* pgdir, uint sz, __code next(...)); __code copyuvm_loop(Type* vm_impl,pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)); __code clearpteu_check_ptevm_impl(Type* vm_impl, pde_t* pgdir, char* uva, __code next(...)); + __code uva2ka_check_pe_types(Type* vm_impl, pde_t* pgdir, char* uva, __code next(...)); __code next(...); } vm_impl; diff -r b8597756f701 -r c1d1721fd907 src/impl/vm_impl_private.cbc --- a/src/impl/vm_impl_private.cbc Fri Jan 24 17:22:51 2020 +0900 +++ b/src/impl/vm_impl_private.cbc Fri Jan 24 17:41:35 2020 +0900 @@ -286,3 +286,22 @@ ret = 0; goto next(ret, ...); } + + +__code uva2ka_check_pe_types(struct vm_impl* vm, pde_t* pgdir, char* uva, __code next(int ret, ...)) { + pte_t* pte; + + pte = walkpgdir(pgdir, uva, 0); + + // make sure it exists + if ((*pte & PE_TYPES) == 0) { + ret = 0; + goto next(ret, ...); + } + goto uva2ka_check_pte_ap(vm, pgdir, uva, pte, next(...)); +} + +__code uva2ka_check_pte_ap(struct vm_impl* vm, pde_t* pgdir, char* uva, pte_t* pte, __code next(int ret, ...)) { + goto next(ret, ...); +} +