From d90aeef62e41e534bc700daf20b7d351d12e0231 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 14 Sep 2023 14:34:04 +0200 Subject: [PATCH] Fix nop-filling code. --- src/arch/x86_64/alternative.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arch/x86_64/alternative.rs b/src/arch/x86_64/alternative.rs index 6b9274d91e..9fe2cbdc43 100644 --- a/src/arch/x86_64/alternative.rs +++ b/src/arch/x86_64/alternative.rs @@ -121,7 +121,7 @@ pub unsafe fn early_init(bsp: bool) { continue; } - let (dst, dst_nops) = code.split_at_mut(reloc.altcode_len); + let (dst, dst_nops) = code.split_at_mut(altcode.len()); dst.copy_from_slice(altcode); // XXX: The `.nops` directive only works for constant lengths, and the variable `.skip -X` @@ -144,7 +144,7 @@ pub unsafe fn early_init(bsp: bool) { ]; for chunk in dst_nops.chunks_mut(NOPS_TABLE.len()) { - chunk.copy_from_slice(NOPS_TABLE[chunk.len()]); + chunk.copy_from_slice(NOPS_TABLE[chunk.len() - 1]); } log::info!("feature {} new {:x?} altcode {:x?}", name, code, altcode);