On Thu, Apr 21, 2022 at 11:01 PM Nicholas Piggin <npiggin@xxxxxxxxx> wrote: > > This reverts commit 559089e0a93d44280ec3ab478830af319c56dbe3 > > The previous commit fixes huge vmalloc for drivers that use the > vmalloc_to_page() struct pages. Yeah, no. The very revert shows the problem: > --- a/arch/powerpc/kernel/module.c > +++ b/arch/powerpc/kernel/module.c > @@ -101,7 +101,7 @@ __module_alloc(unsigned long size, unsigned long start, unsigned long end, bool > * too. > */ > return __vmalloc_node_range(size, 1, start, end, gfp, prot, > - VM_FLUSH_RESET_PERMS, > + VM_FLUSH_RESET_PERMS | VM_NO_HUGE_VMAP, > NUMA_NO_NODE, __builtin_return_address(0)); This VM_NO_HUGE_VMAP is a sign of the fact that using hugepages for mapping still isn't a transparent operation. Now, in some cases that would be perfectly fine, ie the s390 case has a nice clear comment about how it's a very special case: > + /* > + * The Create Secure Configuration Ultravisor Call does not support > + * using large pages for the virtual memory area. > + * This is a hardware limitation. > + */ > + kvm->arch.pv.stor_var = vmalloc_no_huge(vlen); but as long as it is "anything that plays permission games with the mapping is broken" we are not reverting that opt-in thing. And no, it's not just that powerpc module code that is somehow magical. This is the exact same issue that the bpf people hit. It's also elsewhere, although it might well be hidden by "small allocations will never trigger this" (eg the arm64 kprobes case only does a single page). I also wonder how this affects any use of 'set_memory_xyz()' with partial mappings (I can point to "frob_text()" and friends for modules, but I can easily imagine drivers doing odd things). In particular, x86 does support pmd splitting for pmd's in set_memory_xyz(), but I *really* couldn't tell you that it's ok with a largepage that has already had its page counts split. It only used to hit the big IO mappings traditionally. Now I *think* it JustWorks(tm) - I don't actually see any obvious problems there - and I also really hope that nobody actually even does that "partial set_memory" on some vmalloc allocation in the first place, but no, that kind of "let's hope" is not ok. And we already know it happens at least for modules. And no, don't even start about that "it's x86". It *still* isn't about x86 as shown by this very patch. The issue is generic, and x86 just tends to hit more odd cases and drivers. In fact, I think x86 probably does *better* than powerpc. Because it looks like 'set_memory_xyz()' just returns an error for vmalloc addresses on powerpc. Sounds strange. Doesn't powerpc do STRICT_MODULE_RWX? Does it work only because 'frob_text()' doesn't actually check the return value? Or maybe set_memory_xyz() is ok and it is *only* VM_FLUSH_RESET_PERMS that doesn't work? I don't know. But I do know bpf was affected, and I'm looking at that module thing, and so I suspect it's elsewhere too. Just opt-in with the mappings that matter. Linus