kernel/x86: Use multibyte NOP constants in altcodepatch.

Follows up on a suggestion from the commits mailing list.
This commit is contained in:
Augustin Cavalier
2026-05-04 15:27:11 -04:00
parent b6878c0f30
commit e7cc89a038
2 changed files with 29 additions and 15 deletions
@@ -9,15 +9,15 @@
#include <arch/x86/arch_kernel.h>
#define ASM_NOP1 .byte 0x90
#define ASM_NOP2 .byte 0x66, 0x90
#define ASM_NOP3 .byte 0x0f, 0x1f, 0x00
#define ASM_NOP4 .byte 0x0f, 0x1f, 0x40, 0x00
#define ASM_NOP5 .byte 0x0f, 0x1f, 0x44, 0x00, 0x00
#define ASM_NOP6 .byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00
#define ASM_NOP7 .byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
#define ASM_NOP8 .byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
#define ASM_NOP9 .byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
#define X86_NOP1 0x90
#define X86_NOP2 0x66, 0x90
#define X86_NOP3 0x0f, 0x1f, 0x00
#define X86_NOP4 0x0f, 0x1f, 0x40, 0x00
#define X86_NOP5 0x0f, 0x1f, 0x44, 0x00, 0x00
#define X86_NOP6 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00
#define X86_NOP7 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
#define X86_NOP8 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
#define X86_NOP9 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
#define ALTCODEPATCH_TAG_STAC 1
@@ -38,11 +38,11 @@
.popsection
#define ASM_STAC CODEPATCH_START \
ASM_NOP3 ; \
.byte X86_NOP3 ; \
CODEPATCH_END(ALTCODEPATCH_TAG_STAC)
#define ASM_CLAC CODEPATCH_START \
ASM_NOP3 ; \
.byte X86_NOP3 ; \
CODEPATCH_END(ALTCODEPATCH_TAG_CLAC)
#else
@@ -59,11 +59,11 @@
".popsection"
#define ASM_STAC CODEPATCH_START \
STRINGIFY(ASM_NOP3) "\n" \
STRINGIFY(.byte X86_NOP3) "\n" \
CODEPATCH_END(ALTCODEPATCH_TAG_STAC)
#define ASM_CLAC CODEPATCH_START \
STRINGIFY(ASM_NOP3) "\n"\
STRINGIFY(.byte X86_NOP3) "\n"\
CODEPATCH_END(ALTCODEPATCH_TAG_CLAC)