mirror of https://github.com/acidanthera/audk.git
MdePkg/BaseMemoryLibOptDxe ARM AARCH64: fix thinko in SetMem##
The new InternalMemSetMem##() implementations for ARM and AARCH64 in BaseMemoryLibOptDxe fail to take into account that the 'length' argument is not in bytes, but in number of items to be copied. So multiply by the item size before proceeding. Reported-by: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
fe882c0112
commit
8b4ca351dd
|
@ -78,16 +78,19 @@
|
|||
ASM_GLOBAL ASM_PFX(InternalMemSetMem16)
|
||||
ASM_PFX(InternalMemSetMem16):
|
||||
dup v0.8H, valw
|
||||
lsl count, count, #1
|
||||
b 0f
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
|
||||
ASM_PFX(InternalMemSetMem32):
|
||||
dup v0.4S, valw
|
||||
lsl count, count, #2
|
||||
b 0f
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem64)
|
||||
ASM_PFX(InternalMemSetMem64):
|
||||
dup v0.2D, val
|
||||
lsl count, count, #3
|
||||
b 0f
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalMemZeroMem)
|
||||
|
|
|
@ -16,27 +16,37 @@
|
|||
.thumb
|
||||
.syntax unified
|
||||
.align 5
|
||||
ASM_GLOBAL ASM_PFX(InternalMemZeroMem)
|
||||
ASM_PFX(InternalMemZeroMem):
|
||||
movs r2, #0
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem16)
|
||||
ASM_PFX(InternalMemSetMem16):
|
||||
uxth r2, r2
|
||||
lsl r1, r1, #1
|
||||
orr r2, r2, r2, lsl #16
|
||||
b 0f
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
|
||||
ASM_PFX(InternalMemSetMem32):
|
||||
lsl r1, r1, #2
|
||||
b 0f
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem64)
|
||||
ASM_PFX(InternalMemSetMem64):
|
||||
lsl r1, r1, #3
|
||||
b 1f
|
||||
|
||||
.align 5
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem)
|
||||
ASM_PFX(InternalMemSetMem):
|
||||
uxtb r2, r2
|
||||
orr r2, r2, r2, lsl #8
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem16)
|
||||
ASM_PFX(InternalMemSetMem16):
|
||||
uxth r2, r2
|
||||
orr r2, r2, r2, lsl #16
|
||||
b 0f
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
|
||||
ASM_PFX(InternalMemSetMem32):
|
||||
mov r3, r2
|
||||
ASM_GLOBAL ASM_PFX(InternalMemZeroMem)
|
||||
ASM_PFX(InternalMemZeroMem):
|
||||
movs r2, #0
|
||||
0: mov r3, r2
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalMemSetMem64)
|
||||
ASM_PFX(InternalMemSetMem64):
|
||||
push {r4, lr}
|
||||
1: push {r4, lr}
|
||||
cmp r1, #16 // fewer than 16 bytes of input?
|
||||
add r1, r1, r0 // r1 := dst + length
|
||||
add lr, r0, #16
|
||||
|
|
|
@ -21,21 +21,33 @@
|
|||
AREA SetMem, CODE, READONLY, CODEALIGN, ALIGN=5
|
||||
THUMB
|
||||
|
||||
InternalMemZeroMem
|
||||
movs r2, #0
|
||||
InternalMemSetMem16
|
||||
uxth r2, r2
|
||||
lsl r1, r1, #1
|
||||
orr r2, r2, r2, lsl #16
|
||||
b B0
|
||||
|
||||
InternalMemSetMem32
|
||||
lsl r1, r1, #2
|
||||
b B0
|
||||
|
||||
InternalMemSetMem64
|
||||
lsl r1, r1, #3
|
||||
b B1
|
||||
|
||||
ALIGN 32
|
||||
InternalMemSetMem
|
||||
uxtb r2, r2
|
||||
orr r2, r2, r2, lsl #8
|
||||
orr r2, r2, r2, lsl #16
|
||||
b B0
|
||||
|
||||
InternalMemSetMem16
|
||||
uxth r2, r2
|
||||
orr r2, r2, r2, lsr #16
|
||||
|
||||
InternalMemSetMem32
|
||||
InternalMemZeroMem
|
||||
movs r2, #0
|
||||
B0
|
||||
mov r3, r2
|
||||
|
||||
InternalMemSetMem64
|
||||
B1
|
||||
push {r4, lr}
|
||||
cmp r1, #16 ; fewer than 16 bytes of input?
|
||||
add r1, r1, r0 ; r1 := dst + length
|
||||
|
|
Loading…
Reference in New Issue