From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0681621B02822 for ; Wed, 7 Nov 2018 11:30:59 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FCFF394D48; Wed, 7 Nov 2018 19:30:58 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-90.rdu2.redhat.com [10.10.120.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3730648AE; Wed, 7 Nov 2018 19:30:53 +0000 (UTC) To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , Ard Biesheuvel , "edk2-devel@lists.01.org" Cc: Marc Zyngier , "Gao, Liming" , "Kinney, Michael D" References: <20181107131301.15852-1-ard.biesheuvel@linaro.org> From: Laszlo Ersek Message-ID: <258200d6-0c53-d6e1-2605-3f92c8f5f917@redhat.com> Date: Wed, 7 Nov 2018 20:30:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 07 Nov 2018 19:30:58 +0000 (UTC) Subject: Re: [PATCH] MdePkg/BaseIoLibIntrinsicArmVirt ARM: avoid double word loads and stores X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Nov 2018 19:30:59 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 11/07/18 17:47, Philippe Mathieu-Daudé wrote: > On 7/11/18 14:38, Ard Biesheuvel wrote: >> On 7 November 2018 at 14:13, Ard Biesheuvel >> wrote: >>> BaseIoLibIntrinsicArmVirt was created to prevent LTO from merging >>> accesses to MMIO regions, resulting in instructions with multiple >>> output registers that KVM on ARM cannot emulate (since the exception >>> syndrome information that KVM relies on can only describe a single >>> output register) >>> >>> However, using double word loads on ARM amounts to the same thing, >>> and so code that relies on doing 64-bit MMIO to regions that are >>> emulated under KVM (such as the GICv3 TYPER register) will still >>> suffer from the original issue. >>> >>> So replace ldrd and strd with equivalent two instruction sequences. >>> >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Ard Biesheuvel >> >> Please consider this patch with the hunk below appended >> >>> --- >>>   MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.S | 6 ++++-- >>>   1 file changed, 4 insertions(+), 2 deletions(-) >>> >>> diff --git a/MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.S >>> b/MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.S >>> index 3ad22bd5706d..0d802d6928d6 100644 >>> --- a/MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.S >>> +++ b/MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.S >>> @@ -125,7 +125,8 @@ ASM_PFX(MmioWrite32Internal): >>>   //  @return The value read. >>>   // >>>   ASM_PFX(MmioRead64Internal): >>> -  ldrd    r0, r1, [r0] >>> +  ldr     r1, [r0, #4] >>> +  ldr     r0, [r0] > > Ard remembered me UEFI is little-endian only :) > Thus this code is safe. > > With the hunk appended: > Reviewed-by: Philippe Mathieu-Daudé So, this is for 32-bit ARM only, IIUC. (Supported also by the pathnames of the files being modified.) The commit message makes sense, and the patch looks plausible. (I didn't go to the ARM ARM to verify the syntax, and I admit I don't know the syntax without looking it up.) Acked-by: Laszlo Ersek Thanks! Laszlo > >>>     dmb >>>     bx      lr >>> >>> @@ -141,5 +142,6 @@ ASM_PFX(MmioRead64Internal): >>>   // >>>   ASM_PFX(MmioWrite64Internal): >>>     dmb     st >>> -  strd    r2, r3, [r0] >>> +  str     r2, [r0] >>> +  str     r3, [r0, #4] >>>     bx      lr >> >> diff --git a/MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.asm >> b/MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.asm >> index e1a3d68a430c..deba8c1f0c59 100644 >> --- a/MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.asm >> +++ b/MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.asm >> @@ -127,7 +127,8 @@ MmioWrite32Internal >>   ;  @return The value read. >>   ; >>   MmioRead64Internal >> -  ldrd    r0, r1, [r0] >> +  ldr     r1, [r0, #4] >> +  ldr     r0, [r0] >>     dmb >>     bx      lr >> >> @@ -143,7 +144,8 @@ MmioRead64Internal >>   ; >>   MmioWrite64Internal >>     dmb     st >> -  strd    r2, r3, [r0] >> +  str     r2, [r0] >> +  str     r3, [r0, #4] >>     bx      lr >> >>     END >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel >>