When relocate_kernel() gets called, %rdi holds 'indirection_page' and
%rsi holds 'page_list'. And %rdi always holds 'indirection_page' when
swap_pages() is called.
Therefore the comment of the first line code of swap_pages()
movq %rdi, %rcx /* Put the page_list in %rcx */
.. isn't correct because it actually moves the 'indirection_page' to
the %rcx. Fix it.
Signed-off-by: Kai Huang <kai.huang@intel.com>
---
arch/x86/kernel/relocate_kernel_64.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
index 042c9a0334e9..f7a3ca3dee53 100644
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -258,7 +258,7 @@ SYM_CODE_END(virtual_mapped)
/* Do the copies */
SYM_CODE_START_LOCAL_NOALIGN(swap_pages)
UNWIND_HINT_END_OF_STACK
- movq %rdi, %rcx /* Put the page_list in %rcx */
+ movq %rdi, %rcx /* Put the indirection_page in %rcx */
xorl %edi, %edi
xorl %esi, %esi
jmp 1f
--
2.45.2
On Tue, Aug 20, 2024 at 12:21:11AM +1200, Kai Huang wrote:
> When relocate_kernel() gets called, %rdi holds 'indirection_page' and
> %rsi holds 'page_list'. And %rdi always holds 'indirection_page' when
> swap_pages() is called.
>
> Therefore the comment of the first line code of swap_pages()
>
> movq %rdi, %rcx /* Put the page_list in %rcx */
>
> .. isn't correct because it actually moves the 'indirection_page' to
> the %rcx. Fix it.
>
> Signed-off-by: Kai Huang <kai.huang@intel.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Looks like it got broken by 4bfaaef01a1b ("[PATCH] Avoid overwriting the
current pgd (V4, x86_64)")
--
Kiryl Shutsemau / Kirill A. Shutemov
On Tue, 2024-08-20 at 11:40 +0300, Kirill A. Shutemov wrote:
> On Tue, Aug 20, 2024 at 12:21:11AM +1200, Kai Huang wrote:
> > When relocate_kernel() gets called, %rdi holds 'indirection_page' and
> > %rsi holds 'page_list'. And %rdi always holds 'indirection_page' when
> > swap_pages() is called.
> >
> > Therefore the comment of the first line code of swap_pages()
> >
> > movq %rdi, %rcx /* Put the page_list in %rcx */
> >
> > .. isn't correct because it actually moves the 'indirection_page' to
> > the %rcx. Fix it.
> >
> > Signed-off-by: Kai Huang <kai.huang@intel.com>
>
> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>
> Looks like it got broken by 4bfaaef01a1b ("[PATCH] Avoid overwriting the
> current pgd (V4, x86_64)")
>
Thanks for finding this. I spent some time yesterday trying to do so but it
wasn't obvious to me. :-)
Yes that line was firstly introduced by commit 5234f5eb04abb ("[PATCH] kexec:
x86_64 kexec implementation") but by that time it was correct: %rdi indeed
holds 'page_list'. The commit you mentioned above adds a new (first) argument
to relocate_kernel() and %rdi was changed to hold 'indirection_page', but the
comment was leftover.
But the two commits were introduced at 2004 and 2006, so I don't think it
worth any Fixes tag?
On Tue, Aug 20, 2024 at 10:32:39AM +0000, Huang, Kai wrote: > But the two commits were introduced at 2004 and 2006, so I don't think it > worth any Fixes tag? Nah. It is a comment after all. -- Kiryl Shutsemau / Kirill A. Shutemov
© 2016 - 2026 Red Hat, Inc.