From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=45.249.212.191; helo=szxga05-in.huawei.com; envelope-from=zhaoshenglong@huawei.com; receiver=edk2-devel@lists.01.org Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6B9A9220D4BE5 for ; Wed, 15 Nov 2017 16:57:11 -0800 (PST) Received: from 172.30.72.59 (EHLO DGGEMS412-HUB.china.huawei.com) ([172.30.72.59]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DLA66027; Thu, 16 Nov 2017 09:01:18 +0800 (CST) Received: from [127.0.0.1] (10.177.16.142) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.361.1; Thu, 16 Nov 2017 09:01:02 +0800 Message-ID: <5A0CE34E.1050008@huawei.com> Date: Thu, 16 Nov 2017 09:01:02 +0800 From: Shannon Zhao User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Ard Biesheuvel , Laszlo Ersek CC: "edk2-devel@lists.01.org" References: <20171114102205.30649-1-ard.biesheuvel@linaro.org> In-Reply-To: X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.5A0CE35E.01B5, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 87734c545416ecd402491fc2bbb0b48d Subject: Re: [PATCH] ArmVirtPkg/ArmVirtQemu: use non-accelerated CopyMem for VariableRuntimeDxe X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2017 00:57:13 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On 2017/11/15 22:03, Ard Biesheuvel wrote: > On 15 November 2017 at 13:51, Laszlo Ersek wrote: >> > On 11/14/17 11:22, Ard Biesheuvel wrote: >>> >> The VariableRuntimeDxe driver may use CopyMem () on NOR flash regions, >>> >> assuming such regions always have full memory semantics. Given that >>> >> those regions cannot be mapped as ordinary memory on ARM (due to the >>> >> fact that the NOR flash requires device semantics while in write mode) >>> >> this prevents us from using BaseMemoryLibOptDxe in VariableRuntimeDxe, >>> >> since it may use unaligned accesses and/or DC ZVA instructions, both >>> >> of which are incompatible with mappings using device semantics. >>> >> >>> >> Note that there is no way we can work around this by changing the >>> >> mapping type between 'memory' and 'device' when switching from read to >>> >> write mode and back, because the runtime mapping is created by the OS, >>> >> and cannot be changed at will. >>> >> >>> >> So let's just switch to the unaccelerated version of BaseMemoryLib which >>> >> does not have the same problem. >>> >> >>> >> Contributed-under: TianoCore Contribution Agreement 1.1 >>> >> Signed-off-by: Ard Biesheuvel >>> >> --- >>> >> ArmVirtPkg/ArmVirtQemu.dsc | 2 ++ >>> >> ArmVirtPkg/ArmVirtQemuKernel.dsc | 2 ++ >>> >> 2 files changed, 4 insertions(+) >>> >> >>> >> diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc >>> >> index 8a60b61f2aa6..7b220d6e3c31 100644 >>> >> --- a/ArmVirtPkg/ArmVirtQemu.dsc >>> >> +++ b/ArmVirtPkg/ArmVirtQemu.dsc >>> >> @@ -261,6 +261,8 @@ [Components.common] >>> >> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { >>> >> >>> >> NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf >>> >> + # don't use unaligned CopyMem () on the UEFI varstore NOR flash region >>> >> + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf >>> >> } >>> >> !if $(SECURE_BOOT_ENABLE) == TRUE >>> >> MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { >>> >> diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc >>> >> index 9a31ec93ca06..7c032e1b07e0 100644 >>> >> --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc >>> >> +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc >>> >> @@ -252,6 +252,8 @@ [Components.common] >>> >> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { >>> >> >>> >> NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf >>> >> + # don't use unaligned CopyMem () on the UEFI varstore NOR flash region >>> >> + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf >>> >> } >>> >> !if $(SECURE_BOOT_ENABLE) == TRUE >>> >> MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { >>> >> >> > >> > Reviewed-by: Laszlo Ersek >> > >> > Given that we've never seen the symptom reported by Shannon, I must >> > think Shannon is using some kind of new hardware. May I ask what >> > hardware that is? >> > > I think this is equally likely to occur in any KVM hardware > virtualization context. It is simply a regression after moving to the > OptDxe BaseMemoryLib flavor. Exactly. I'm using Huawei D05. It works well when I use a older edk2 while fails when updating to UDK2017 branch. Tested-by: Shannon Zhao Thanks, -- Shannon