From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F9B91A209A for ; Thu, 22 Sep 2016 22:04:03 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 22 Sep 2016 22:04:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,380,1470726000"; d="scan'208";a="172251248" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga004.fm.intel.com with ESMTP; 22 Sep 2016 22:04:03 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Sep 2016 22:04:03 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Sep 2016 22:04:02 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.15]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.101]) with mapi id 14.03.0248.002; Fri, 23 Sep 2016 13:04:00 +0800 From: "Gao, Liming" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "lersek@redhat.com" , "leif.lindholm@linaro.org" Thread-Topic: [PATCH] MdePkg/BaseMemoryLibOptDxe ARM AARCH64: fix thinko in SetMem## Thread-Index: AQHSFK74VBurFDLsqESedjHTurA/9KCGhmlg Date: Fri, 23 Sep 2016 05:03:59 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14B47C035@shsmsx102.ccr.corp.intel.com> References: <1474534469-18442-1-git-send-email-ard.biesheuvel@linaro.org> In-Reply-To: <1474534469-18442-1-git-send-email-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg/BaseMemoryLibOptDxe ARM AARCH64: fix thinko in SetMem## X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Sep 2016 05:04:03 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Thursday, September 22, 2016 4:54 PM > To: edk2-devel@lists.01.org; Gao, Liming > Cc: lersek@redhat.com; leif.lindholm@linaro.org; Ard Biesheuvel > > Subject: [PATCH] MdePkg/BaseMemoryLibOptDxe ARM AARCH64: fix thinko > in SetMem## >=20 > 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. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel > --- > MdePkg/Library/BaseMemoryLibOptDxe/AArch64/SetMem.S | 3 ++ > MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S | 32 > +++++++++++++------- > MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.asm | 28 > ++++++++++++----- > 3 files changed, 44 insertions(+), 19 deletions(-) >=20 > diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/AArch64/SetMem.S > b/MdePkg/Library/BaseMemoryLibOptDxe/AArch64/SetMem.S > index 7f361110d4fe..ec58f759d7b6 100644 > --- a/MdePkg/Library/BaseMemoryLibOptDxe/AArch64/SetMem.S > +++ b/MdePkg/Library/BaseMemoryLibOptDxe/AArch64/SetMem.S > @@ -78,16 +78,19 @@ > ASM_GLOBAL ASM_PFX(InternalMemSetMem16) > ASM_PFX(InternalMemSetMem16): > dup v0.8H, valw > + lsl count, count, #1 > b 0f >=20 > ASM_GLOBAL ASM_PFX(InternalMemSetMem32) > ASM_PFX(InternalMemSetMem32): > dup v0.4S, valw > + lsl count, count, #2 > b 0f >=20 > ASM_GLOBAL ASM_PFX(InternalMemSetMem64) > ASM_PFX(InternalMemSetMem64): > dup v0.2D, val > + lsl count, count, #3 > b 0f >=20 > ASM_GLOBAL ASM_PFX(InternalMemZeroMem) > diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S > b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S > index c1755539d36a..add04443b2e9 100644 > --- a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S > +++ b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S > @@ -16,27 +16,37 @@ > .thumb > .syntax unified > .align 5 > -ASM_GLOBAL ASM_PFX(InternalMemZeroMem) > -ASM_PFX(InternalMemZeroMem): > - movs r2, #0 > - > -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 > + lsl r1, r1, #1 > orr r2, r2, r2, lsl #16 > + b 0f >=20 > ASM_GLOBAL ASM_PFX(InternalMemSetMem32) > ASM_PFX(InternalMemSetMem32): > - mov r3, r2 > + lsl r1, r1, #2 > + b 0f >=20 > ASM_GLOBAL ASM_PFX(InternalMemSetMem64) > ASM_PFX(InternalMemSetMem64): > - push {r4, lr} > + 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 > + orr r2, r2, r2, lsl #16 > + b 0f > + > +ASM_GLOBAL ASM_PFX(InternalMemZeroMem) > +ASM_PFX(InternalMemZeroMem): > + movs r2, #0 > +0: mov r3, r2 > + > +1: push {r4, lr} > cmp r1, #16 // fewer than 16 bytes of input? > add r1, r1, r0 // r1 :=3D dst + length > add lr, r0, #16 > diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.asm > b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.asm > index 2a8dc7d019f4..c2e2842a6323 100644 > --- a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.asm > +++ b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.asm > @@ -21,21 +21,33 @@ > AREA SetMem, CODE, READONLY, CODEALIGN, ALIGN=3D5 > THUMB >=20 > -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 >=20 > + ALIGN 32 > InternalMemSetMem > uxtb r2, r2 > orr r2, r2, r2, lsl #8 > + orr r2, r2, r2, lsl #16 > + b B0 >=20 > -InternalMemSetMem16 > - uxth r2, r2 > - orr r2, r2, r2, lsr #16 > - > -InternalMemSetMem32 > +InternalMemZeroMem > + movs r2, #0 > +B0 > mov r3, r2 >=20 > -InternalMemSetMem64 > +B1 > push {r4, lr} > cmp r1, #16 ; fewer than 16 bytes of input? > add r1, r1, r0 ; r1 :=3D dst + length > -- > 2.7.4