Compensate missing return address, which is a 4-byte on i686 and an 8-byte on amd64

This commit is contained in:
Rafal Kupiec 2023-11-05 20:07:13 +01:00
parent ba833422b0
commit 91ce0f9947
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 8 additions and 2 deletions

View File

@ -133,6 +133,9 @@
#define KTRAP_FRAME_ALIGN 0x10 #define KTRAP_FRAME_ALIGN 0x10
#define KTRAP_FRAME_SIZE sizeof(KTRAP_FRAME) #define KTRAP_FRAME_SIZE sizeof(KTRAP_FRAME)
/* Return address size pushed by 'call' instruction */
#define KRETURN_ADDRESS_SIZE 0x8
/* Size of legacy 387 registers */ /* Size of legacy 387 registers */
#define SIZE_OF_80387_REGISTERS 80 #define SIZE_OF_80387_REGISTERS 80

View File

@ -162,6 +162,9 @@
/* Number of supported extensions */ /* Number of supported extensions */
#define MAXIMUM_SUPPORTED_EXTENSION 512 #define MAXIMUM_SUPPORTED_EXTENSION 512
/* Return address size pushed by 'call' instruction */
#define KRETURN_ADDRESS_SIZE 0x4
/* Size of 387 registers */ /* Size of 387 registers */
#define SIZE_OF_80387_REGISTERS 80 #define SIZE_OF_80387_REGISTERS 80
#define SIZE_OF_FX_REGISTERS 128 #define SIZE_OF_FX_REGISTERS 128

View File

@ -105,6 +105,6 @@ KepSwitchBootStack(IN ULONG_PTR Stack)
"jmp KepStartKernel\n" "jmp KepStartKernel\n"
: :
: "m" (Stack), : "m" (Stack),
"i" (FLOATING_SAVE_AREA_SIZE | KEXCEPTION_FRAME_SIZE | KSWITCH_FRAME_SIZE), "i" (FLOATING_SAVE_AREA_SIZE | KEXCEPTION_FRAME_SIZE | KSWITCH_FRAME_SIZE | KRETURN_ADDRESS_SIZE),
"p" (KepStartKernel)); "p" (KepStartKernel));
} }

View File

@ -106,7 +106,7 @@ KepSwitchBootStack(IN ULONG_PTR Stack)
"jmp _KepStartKernel@0\n" "jmp _KepStartKernel@0\n"
: :
: "m" (Stack), : "m" (Stack),
"i" (KTRAP_FRAME_ALIGN | KTRAP_FRAME_SIZE | NPX_FRAME_SIZE), "i" (KTRAP_FRAME_ALIGN | KTRAP_FRAME_SIZE | NPX_FRAME_SIZE | KRETURN_ADDRESS_SIZE),
"i" (CR0_EM | CR0_MP | CR0_TS), "i" (CR0_EM | CR0_MP | CR0_TS),
"p" (KepStartKernel)); "p" (KepStartKernel));
} }