From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.208.67; helo=mail-ed1-f67.google.com; envelope-from=philmd@redhat.com; receiver=edk2-devel@lists.01.org Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 58CCD2118D938 for ; Wed, 7 Nov 2018 08:47:32 -0800 (PST) Received: by mail-ed1-f67.google.com with SMTP id b34-v6so1730719ede.13 for ; Wed, 07 Nov 2018 08:47:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=O1ZjRin4tuG0LCRkMBnxCJ6oeWVoVJFDSpxsQUOq9yU=; b=r4iAHjUzgKszbkQfrGuLbDPb8uWMJRubbEsxd0qFfSvJaH73roAWBrT0eKmpiDoduc hbKjvlOtzNPWWWTVyErwXdoL907xxo/+MhBBfYxigwfy1eJkv4IUXAHQ94maA84mVGAg jPQAvpOn8rEUdw4SrE5SXXdL8Wt4nMMJXpL236shTRAeOvPRMe8di22vK5QHEbmcKB1t c1fyj3icFQhSvOzwKfeIVQKbYvj6pNdZFYJN1Av1nRf0LUxStV1HifxauasOkk2zqTyX sR+DNLJLwGkFj6dja53rLP7QK2Py2yRTQ6eabXTepwAHMupDVT0fXXbbpJUnQl2MGkVz hh1A== X-Gm-Message-State: AGRZ1gKto6GporQkuc0gMhFfhMUFlxGKQT8Fwac8eBdL4tGAGY4tm/ql nKfZmJDTvioEmvVkGkJUBzp0YQ== X-Google-Smtp-Source: AJdET5ftOwDgTflmmh3NrFjoX+QmdbhOreDNiW3ACcyu4poax1xE7ZCJqSpJHu+/SG1tFCrIZYySRg== X-Received: by 2002:a50:9ac6:: with SMTP id p64-v6mr779434edb.5.1541609251294; Wed, 07 Nov 2018 08:47:31 -0800 (PST) Received: from [10.0.0.124] ([185.102.219.36]) by smtp.gmail.com with ESMTPSA id y14-v6sm208203ejq.11.2018.11.07.08.47.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 08:47:30 -0800 (PST) To: Ard Biesheuvel , "edk2-devel@lists.01.org" Cc: Marc Zyngier , "Gao, Liming" , "Kinney, Michael D" , Laszlo Ersek References: <20181107131301.15852-1-ard.biesheuvel@linaro.org> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: Date: Wed, 7 Nov 2018 17:47:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: 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 16:47:33 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit 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é >> 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 >