Re: [RFC PATCH 5/7] x86/module: perpare module loading for ROX allocations of text

2024-04-15 Thread Mike Rapoport
On Mon, Apr 15, 2024 at 12:43:16PM +0200, Peter Zijlstra wrote: > On Thu, Apr 11, 2024 at 07:05:24PM +0300, Mike Rapoport wrote: > > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > > index 45a280f2161c..b4d6868df573 100644 > > --- a/arch/x86/kernel/alternative.c > >

Re: [RFC PATCH 5/7] x86/module: perpare module loading for ROX allocations of text

2024-04-15 Thread Peter Zijlstra
On Thu, Apr 11, 2024 at 07:05:24PM +0300, Mike Rapoport wrote: > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > index 45a280f2161c..b4d6868df573 100644 > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -504,17 +513,17 @@ void

Re: [RFC PATCH 5/7] x86/module: perpare module loading for ROX allocations of text

2024-04-14 Thread Mike Rapoport
On Fri, Apr 12, 2024 at 11:08:00AM +0200, Ingo Molnar wrote: > > * Mike Rapoport wrote: > > > for (s = start; s < end; s++) { > > void *addr = (void *)s + *s; > > + void *wr_addr = addr + module_writable_offset(mod, addr); > > So instead of repeating this pattern in a

Re: [RFC PATCH 5/7] x86/module: perpare module loading for ROX allocations of text

2024-04-12 Thread Ingo Molnar
* Mike Rapoport wrote: > for (s = start; s < end; s++) { > void *addr = (void *)s + *s; > + void *wr_addr = addr + module_writable_offset(mod, addr); So instead of repeating this pattern in a dozen of places, why not use a simpler method: void

[RFC PATCH 5/7] x86/module: perpare module loading for ROX allocations of text

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" When module text memory will be allocated with ROX permissions, the memory at the actual address where the module will live will contain invalid instructions and there will be a writable copy that contains the actual module code. Update relocations and alternatives