From 3e7e3e2467445fe3b5931c1423a36df09cc26a80 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 14 Feb 2025 10:04:10 +0000 Subject: [PATCH] MdePkg/AArch64: fix AsmMacroLib signed value handling for MOV32/MOV64 MOV32 and MOV64, defined in AsmMacrolib.h, use a combination of movz and movk instructions to fill a register with an immediate value. With each instruction supplying 16 of the bits. CLANGPDB builds have been reported to fail on the current implementation when provided with negative values with: error: immediate must be an integer in range [0, 65535]. To resolve this, add a mask for the line filling the top 16 bits, like the other lines already had. Reported-by: Michael Kubacki Signed-off-by: Leif Lindholm --- MdePkg/Include/AArch64/AsmMacroLib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MdePkg/Include/AArch64/AsmMacroLib.h b/MdePkg/Include/AArch64/AsmMacroLib.h index a5c8635840..11844c95e4 100644 --- a/MdePkg/Include/AArch64/AsmMacroLib.h +++ b/MdePkg/Include/AArch64/AsmMacroLib.h @@ -43,12 +43,12 @@ #define ASM_FUNC_ALIGN(Name, Align) \ _ASM_FUNC_ALIGN(ASM_PFX(Name), .text. ## Name, Align) -#define MOV32(Reg, Val) \ - movz Reg, (Val) >> 16, lsl #16 ; \ +#define MOV32(Reg, Val) \ + movz Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \ movk Reg, (Val) & 0xffff #define MOV64(Reg, Val) \ - movz Reg, (Val) >> 48, lsl #48 ; \ + movz Reg, ((Val) >> 48) & 0xffff, lsl #48 ; \ movk Reg, ((Val) >> 32) & 0xffff, lsl #32 ; \ movk Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \ movk Reg, (Val) & 0xffff