Skip mapping the shadow stack as a writable page and the redundant memory zeroing. Currently, the shadow stack is allocated using alloc_page(), then mapped as a writable page, zeroed, and finally mapped as a shadow stack page. The memory zeroing is redundant as alloc_page() already does that. Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx> --- x86/cet.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/x86/cet.c b/x86/cet.c index 51a54a50..214976f9 100644 --- a/x86/cet.c +++ b/x86/cet.c @@ -67,7 +67,6 @@ int main(int ac, char **av) { char *shstk_virt; unsigned long shstk_phys; - unsigned long *ptep; pteval_t pte = 0; bool rvc; @@ -90,14 +89,8 @@ int main(int ac, char **av) shstk_phys = (unsigned long)virt_to_phys(alloc_page()); /* Install the new page. */ - pte = shstk_phys | PT_PRESENT_MASK | PT_WRITABLE_MASK | PT_USER_MASK; + pte = shstk_phys | PT_PRESENT_MASK | PT_USER_MASK | PT_DIRTY_MASK; install_pte(current_page_table(), 1, shstk_virt, pte, 0); - memset(shstk_virt, 0x0, PAGE_SIZE); - - /* Mark it as shadow-stack page. */ - ptep = get_pte_level(current_page_table(), shstk_virt, 1); - *ptep &= ~PT_WRITABLE_MASK; - *ptep |= PT_DIRTY_MASK; /* Flush the paging cache. */ invlpg((void *)shstk_virt); -- 2.47.1