]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Fix nasm warning "signed byte value exceeds"
authorZhiguang Liu <zhiguang.liu@intel.com>
Wed, 6 Jul 2022 13:10:13 +0000 (21:10 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 25 Jul 2022 02:18:26 +0000 (02:18 +0000)
Currently, "push byte %[Vector]" causes nasm warning when Vector is larger
than 0x7F. This is because push accepts a signed value, and byte means
signed int8. Maximum signed int8 is 0x7F.
When Vector is larger the 0x7F, for example, when Vector is 255, byte 255
turns to -1, and causes the warning "signed byte value exceeds".
To avoid such warning, use dword instead of byte, this will increase 3 bytes
for each IdtVector.
For IA32, the size of IdtVector will increase from 10 bytes to 13 bytes.
For X64, the size of IdtVector will increase from 15 bytes to 18 bytes.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Debkumar De <debkumar.de@intel.com>
Cc: Harry Han <harry.han@intel.com>
Cc: Catharine West <catharine.west@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm

index 0f012bccde2b02c85b971ab6b76bd0dbaf98058d..fd42c4be0f0086a68ebe1673d56c7347f2ffe915 100644 (file)
@@ -22,7 +22,7 @@
 \r
 #define  CPU_EXCEPTION_NUM    32\r
 #define  CPU_INTERRUPT_NUM    256\r
-#define  HOOKAFTER_STUB_SIZE  16\r
+#define  HOOKAFTER_STUB_SIZE  18\r
 \r
 //\r
 // Exception Error Code of Page-Fault Exception\r
index 8ed2b8f45500fe3e2243b489b40b748119294905..31a00449a283c8eee0307b9bc51c111171e59d2d 100644 (file)
@@ -34,7 +34,7 @@ ALIGN   8
 AsmIdtVectorBegin:\r
 %assign Vector 0\r
 %rep  256\r
-    push    byte %[Vector];\r
+    push    strict dword %[Vector];\r
     push    eax\r
     mov     eax, ASM_PFX(CommonInterruptEntry)\r
     jmp     eax\r
@@ -43,9 +43,8 @@ AsmIdtVectorBegin:
 AsmIdtVectorEnd:\r
 \r
 HookAfterStubBegin:\r
-    db      0x6a        ; push\r
+    push    strict dword 0  ; 0 will be fixed\r
 VectorNum:\r
-    db      0          ; 0 will be fixed\r
     push    eax\r
     mov     eax, HookAfterStubHeaderEnd\r
     jmp     eax\r
@@ -453,5 +452,5 @@ global ASM_PFX(AsmVectorNumFixup)
 ASM_PFX(AsmVectorNumFixup):\r
     mov     eax, dword [esp + 8]\r
     mov     ecx, [esp + 4]\r
-    mov     [ecx + (VectorNum - HookAfterStubBegin)], al\r
+    mov     [ecx + (VectorNum - 4 - HookAfterStubBegin)], al\r
     ret\r
index 7c0e3d3b0bb47aa95ab606452c3747c9e60eedfe..957478574253e619640c95e7823dc352ca497649 100644 (file)
@@ -57,18 +57,17 @@ ALIGN   8
 AsmIdtVectorBegin:\r
 %assign Vector 0\r
 %rep  256\r
-    push    byte %[Vector]\r
+    push    strict dword %[Vector] ; This instruction pushes sign-extended 8-byte value on stack\r
     push    rax\r
-    mov     rax, strict qword 0 ;    mov     rax, ASM_PFX(CommonInterruptEntry)\r
+    mov     rax, strict qword 0    ; mov     rax, ASM_PFX(CommonInterruptEntry)\r
     jmp     rax\r
 %assign Vector Vector+1\r
 %endrep\r
 AsmIdtVectorEnd:\r
 \r
 HookAfterStubHeaderBegin:\r
-    db      0x6a        ; push\r
-@VectorNum:\r
-    db      0          ; 0 will be fixed\r
+    push    strict dword 0      ; 0 will be fixed\r
+VectorNum:\r
     push    rax\r
     mov     rax, strict qword 0 ;     mov     rax, HookAfterStubHeaderEnd\r
 JmpAbsoluteAddress:\r
@@ -478,6 +477,6 @@ ASM_PFX(AsmGetTemplateAddressMap):
 global ASM_PFX(AsmVectorNumFixup)\r
 ASM_PFX(AsmVectorNumFixup):\r
     mov     rax, rdx\r
-    mov     [rcx + (@VectorNum - HookAfterStubHeaderBegin)], al\r
+    mov     [rcx + (VectorNum - 4 - HookAfterStubHeaderBegin)], al\r
     ret\r
 \r