1.. SPDX-License-Identifier: GPL-2.0 2.. include:: ../disclaimer-zh_CN.rst 3 4:Original: Documentation/mm/vmalloced-kernel-stacks.rst 5 6:������: 7 8 ��������� Yanteng Si <siyanteng@loongson.cn> 9 10:������: 11 12==================== 13������������������������������ 14==================== 15 16:������: Shuah Khan <skhan@linuxfoundation.org> 17 18.. contents:: :local: 19 20������ 21---- 22 23������������ `��������������������������� <https://lwn.net/Articles/694348/>` ��������� 24��������������������������������������� 25 26������ 27---- 28 29������������������������������������������������������������������������������������������������������������������������������������ 30������������������������������ 31 32������������������������������������������������������������������������������������������������������������������������ 33������ 34 35HAVE_ARCH_VMAP_STACK���VMAP_STACK��������������������������������������������������������������� 36��������������������������������������������������������������������������������������������������������������������� 37������������������������ 38 39.. note:: 40 ������������������������ arm64, powerpc, riscv, s390, um, ��� x86 ������VMAP_STACK��� 41 42HAVE_ARCH_VMAP_STACK 43-------------------- 44 45������������������������������������������������������������bool������������������������: 46 47- vmalloc���������������������������������������������������������������������������32������������ 48- vmalloc������������������������������������������������������vmap������������������������������������������ 49 ������������������������������������������������������������������������������������������switch_to()��� 50 switch_mm()������������������������������������������������������������������������������������������������ 51 ������ 52- ��������������������������������������������������������������������������������������������������������������������� 53 ��������������������������������������������������������������������� 54 55VMAP_STACK 56---------- 57 58VMAP_STACK bool������������������������������������������������������������������������������ 59HAVE_ARCH_VMAP_STACK��� 60 61- ������������������������������������������������������������������������������������������������������������������ 62 ��������������������������������������������������� 63 64.. note:: 65 66 ������KASAN��������������������������������������������������������������������������������������� 67 ������������KASAN_VMALLOC��� 68 69.. note:: 70 71 ������VMAP_STACK���������������������������������������������DMA��� 72 73������������������������������������������������������������������������: 74 75`Kconfig <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/Kconfig>` 76 77������������ 78-------- 79 80������������������������������������������������������������������������������������������������������������������������ 81������������������������PAGE_KERNEL��������������������������������������� 82 83alloc_thread_stack_node()������__vmalloc_node_range()���������������PAGE_KERNEL 84��������������� 85 86- ���������������������������������������������������������������������������������/������������������������������������ 87 ������memcg������������������__vmalloc_node_range������������������__GFP_ACCOUNT��� 88- vm_struct��������������������������������������������������������������������������������� free_thread_stack() 89 ������������������������������������ 90- ���arm64������������VMAP������������������������������������������������������VMAP��������������������������� 91 ������������������������vmap������������������������������������������ 92- ���������������������������--������������������ 93 94���������������������clone()���fork()���vfork()���kernel_thread()������kernel_clone() 95��������������������������������������������������������������������������������������������������� 96 97���������������������: 98`kernel/fork.c <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/fork.c>`. 99 100task_struct������stack_vm_area���������������������������������������������������������stack_vm_area 101������������������������������������������������������������ 102 103:: 104 105 struct vm_struct *stack_vm_area; 106 107������������������ 108------------ 109 110��������������������������������������������������������������������������������������������������������������������������� 111������������������������������������������������������������������������������������������ 112 113���x86������������������������������������������������������������������������������������������������ 114 115������������������VMAP������ 116-------------------- 117 118������������������VMAP_STACK��������������������������������������������������������������������� lkdtm ������ 119��������������������������������� 120 121:: 122 123 void lkdtm_STACK_GUARD_PAGE_LEADING() 124 void lkdtm_STACK_GUARD_PAGE_TRAILING() 125 126������ 127---- 128 129- vmalloced���������percpu������������������������������������������������������������������������������������ 130- THREAD_INFO_IN_TASK���������������arch-specific thread_info������������������ 131 thread_info������������������������'int cpu'������task_struct������ 132- ���������������������������������������������������������������RCU���������������������������vmapped��������� 133 ������������������������������������������������cpu������������������ 134