Skip to content

Commit ea49cdb

Browse files
kaihuangKAGA-KOKO
authored andcommitted
x86/kexec: Add comments around swap_pages() assembly to improve readability
The current assembly around swap_pages() in the relocate_kernel() takes some time to follow because the use of registers can be easily lost when the line of assembly goes long. Add a couple of comments to clarify the code around swap_pages() to improve readability. Signed-off-by: Kai Huang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Link: https://lore.kernel.org/all/8b52b0b8513a34b2a02fb4abb05c6700c2821475.1724573384.git.kai.huang@intel.com
1 parent 3c41ad3 commit ea49cdb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/kernel/relocate_kernel_64.S

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
170170
wbinvd
171171
.Lsme_off:
172172

173+
/* Save the preserve_context to %r11 as swap_pages clobbers %rcx. */
173174
movq %rcx, %r11
174175
call swap_pages
175176

@@ -289,18 +290,21 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages)
289290
movq %rcx, %rsi /* For ever source page do a copy */
290291
andq $0xfffffffffffff000, %rsi
291292

292-
movq %rdi, %rdx
293-
movq %rsi, %rax
293+
movq %rdi, %rdx /* Save destination page to %rdx */
294+
movq %rsi, %rax /* Save source page to %rax */
294295

296+
/* copy source page to swap page */
295297
movq %r10, %rdi
296298
movl $512, %ecx
297299
rep ; movsq
298300

301+
/* copy destination page to source page */
299302
movq %rax, %rdi
300303
movq %rdx, %rsi
301304
movl $512, %ecx
302305
rep ; movsq
303306

307+
/* copy swap page to destination page */
304308
movq %rdx, %rdi
305309
movq %r10, %rsi
306310
movl $512, %ecx

0 commit comments

Comments
 (0)