Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread Ard Biesheuvel
On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote: > > From: David Woodhouse > > Both i386 and x86_64 now copy the relocate_kernel function into the control > page and execute it from there, using an open-coded function pointer. > > Use a typedef for it instead. > > Signed-off-by: David Woodhou

Re: [PATCH 8/9] x86/kexec: Cope with relocate_kernel() not being at the start of the page

2024-12-17 Thread Ard Biesheuvel
On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote: > > From: David Woodhouse > > A few places in the kexec control code page make the assumption that the > first instruction of relocate_kernel is at the very start of the page. > > To allow for Clang CFI information to be added to relocate_kerne

Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread Ard Biesheuvel
On Tue, 17 Dec 2024 at 11:07, David Woodhouse wrote: > > On 17 December 2024 10:54:19 CET, Ard Biesheuvel wrote: > >On Tue, 17 Dec 2024 at 10:42, David Woodhouse wrote: > >> Hm, I am perfectly happy to believe that my memory is failing me, > >> especially when it comes to specifics of i386 asse

Re: [PATCH 8/9] x86/kexec: Cope with relocate_kernel() not being at the start of the page

2024-12-17 Thread Ard Biesheuvel
On Tue, 17 Dec 2024 at 10:17, David Woodhouse wrote: > > On 17 December 2024 09:47:36 CET, Ard Biesheuvel wrote: > >On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote: > >> > >> From: David Woodhouse > >> > >> A few places in the kexec control code page make the assumption that the > >> first

Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread Ard Biesheuvel
On Tue, 17 Dec 2024 at 10:42, David Woodhouse wrote: > > On 17 December 2024 10:29:21 CET, Ard Biesheuvel wrote: > >On Tue, 17 Dec 2024 at 10:21, David Woodhouse wrote: > >> > >> On 17 December 2024 09:49:04 CET, Ard Biesheuvel wrote: > >> >On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote:

Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread Ard Biesheuvel
On Tue, 17 Dec 2024 at 10:21, David Woodhouse wrote: > > On 17 December 2024 09:49:04 CET, Ard Biesheuvel wrote: > >On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote: > >> > >> From: David Woodhouse > >> > >> Both i386 and x86_64 now copy the relocate_kernel function into the control > >> pag

Re: [PATCH 1/9] x86/kexec: Disable global pages before writing to control page

2024-12-17 Thread Dave Hansen
On 12/17/24 04:25, Kirill A. Shutemov wrote: >> Clear the PGE bit in %cr4 early, before storing data in the control page. > It worth noting that flipping CR4.PGE triggers TLB flush. I was not sure > if CR3 write is required to make it happen. I thought about removing the CR3 write. But I decided a

Re: [EXTERNAL] [PATCH 1/9] x86/kexec: Disable global pages before writing to control page

2024-12-17 Thread David Woodhouse
On Tue, 2024-12-17 at 06:51 -0800, Dave Hansen wrote: > On 12/17/24 04:25, Kirill A. Shutemov wrote: > > > Clear the PGE bit in %cr4 early, before storing data in the control page. > > It worth noting that flipping CR4.PGE triggers TLB flush. I was not sure > > if CR3 write is required to make it h

Re: [PATCH 8/9] x86/kexec: Cope with relocate_kernel() not being at the start of the page

2024-12-17 Thread David Woodhouse
On 17 December 2024 10:25:56 CET, Ard Biesheuvel wrote: >On Tue, 17 Dec 2024 at 10:17, David Woodhouse wrote: >> >> On 17 December 2024 09:47:36 CET, Ard Biesheuvel wrote: >> >On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote: >> >> >> >> From: David Woodhouse >> >> >> >> A few places in the

Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread David Woodhouse
On 17 December 2024 10:54:19 CET, Ard Biesheuvel wrote: >On Tue, 17 Dec 2024 at 10:42, David Woodhouse wrote: >> Hm, I am perfectly happy to believe that my memory is failing me, especially >> when it comes to specifics of i386 assembler code. But are you also telling >> me that >>

Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread David Woodhouse
On 17 December 2024 10:54:19 CET, Ard Biesheuvel wrote: >On Tue, 17 Dec 2024 at 10:42, David Woodhouse wrote: >> Hm, I am perfectly happy to believe that my memory is failing me, especially >> when it comes to specifics of i386 assembler code. But are you also telling >> me that >>

Re: [PATCH 8/9] x86/kexec: Cope with relocate_kernel() not being at the start of the page

2024-12-17 Thread David Woodhouse
On 17 December 2024 09:47:36 CET, Ard Biesheuvel wrote: >On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote: >> >> From: David Woodhouse >> >> A few places in the kexec control code page make the assumption that the >> first instruction of relocate_kernel is at the very start of the page. >> >>

Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread David Woodhouse
On 17 December 2024 09:49:04 CET, Ard Biesheuvel wrote: >On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote: >> >> From: David Woodhouse >> >> Both i386 and x86_64 now copy the relocate_kernel function into the control >> page and execute it from there, using an open-coded function pointer. >>

Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread David Woodhouse
On 17 December 2024 11:14:29 CET, Ard Biesheuvel wrote: >On Tue, 17 Dec 2024 at 11:07, David Woodhouse wrote: >> >> On 17 December 2024 10:54:19 CET, Ard Biesheuvel wrote: >> >On Tue, 17 Dec 2024 at 10:42, David Woodhouse wrote: >> >> Hm, I am perfectly happy to believe that my memory is failin

Re: [EXTERNAL] [PATCH 1/9] x86/kexec: Disable global pages before writing to control page

2024-12-17 Thread Dave Hansen
On 12/17/24 06:56, David Woodhouse wrote: >> Anyway, I think we can leave the belt-and-suspenders programming in this >> case. A comment wouldn't hurt I guess. > I'm a little lost. In this case I don't see belt-and-suspenders > programming. We're not loading CR3 after clearing CR4.PGE just to be >

Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype

2024-12-17 Thread David Woodhouse
On 17 December 2024 10:29:21 CET, Ard Biesheuvel wrote: >On Tue, 17 Dec 2024 at 10:21, David Woodhouse wrote: >> >> On 17 December 2024 09:49:04 CET, Ard Biesheuvel wrote: >> >On Tue, 17 Dec 2024 at 00:37, David Woodhouse wrote: >> >> >> >> From: David Woodhouse >> >> >> >> Both i386 and x86_6

Re: [PATCH v5 07/20] x86/kexec: Invoke copy of relocate_kernel() instead of the original

2024-12-17 Thread David Woodhouse
On Mon, 2024-12-16 at 12:09 +, David Woodhouse wrote: > On Sun, 2024-12-15 at 22:49 -0700, Nathan Chancellor wrote: > > On Sun, Dec 15, 2024 at 10:09:57AM +, David Woodhouse wrote: > > > On Sat, 2024-12-14 at 16:08 -0700, Nathan Chancellor wrote: > > > > > > > > I guess this seems somewhat

Re: [PATCH 1/9] x86/kexec: Disable global pages before writing to control page

2024-12-17 Thread Kirill A. Shutemov
On Mon, Dec 16, 2024 at 11:24:08PM +, David Woodhouse wrote: > From: David Woodhouse > > The kernel switches to a new set of page tables during kexec. The global > mappings (_PAGE_GLOBAL==1) can remain in the TLB after this switch. This > is generally not a problem because the new page tables

Re: [PATCH 1/9] x86/kexec: Disable global pages before writing to control page

2024-12-17 Thread David Woodhouse
On 17 December 2024 13:25:48 CET, "Kirill A. Shutemov" wrote: >On Mon, Dec 16, 2024 at 11:24:08PM +, David Woodhouse wrote: >> From: David Woodhouse >> >> The kernel switches to a new set of page tables during kexec. The global >> mappings (_PAGE_GLOBAL==1) can remain in the TLB after this

Re: [PATCH 2/9] x86/kexec: Ensure preserve_context flag is set on return to kernel

2024-12-17 Thread Uros Bizjak
On 17. 12. 24 00:24, David Woodhouse wrote: From: David Woodhouse The swap_pages function will only actually *swap*, as its name implies, if the preserve_context flag in the %r11 register is non-zero. On the way back from a ::preserve_context kexec, ensure that the %r11 register is non-zero