From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (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 5D96D2035BB13 for ; Tue, 14 Nov 2017 02:18:07 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id u40so17001970wrf.10 for ; Tue, 14 Nov 2017 02:22:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=UayRajVj+LnQPbKgWyhWWqeCD8eub+V/L1pJqQsE41U=; b=M4hytpRq/rUqQI96k3Y5RvRuK169VcN3/uPztC0hlo9miiNG2nH+vMhUyHd74R8c2d 8KaF6TcFnFAVasBp3f3ip0f32mYCYPJjburOCYsiYt8KJRhg6rh3yGU3kqHx4YqNKpD7 29dOw/AYVF93Mr9Pm6+KEsqqKn8qLfAi2PQno= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UayRajVj+LnQPbKgWyhWWqeCD8eub+V/L1pJqQsE41U=; b=bn+EpY6Je7m/004E1ZB8fb1NTMNPwH8NM7eKvRXHeX4xq2ILBqk8TB53pzGBageUv4 hAuBCHHwvrRFo3tpGdJjrXXwDYJWW3kWuL3PKpfqgJU/gyKhXT9x6DoGMqprs+zyfgYb EXFCb5HKt4u/7I3v5AzppP7VkeW8AScRW2gWD69z5L2mxF3sNva/kdyZ1C65owtDUBxn OWG8QeP2FPf3Zncroz+VLepA6oT3kn885kFyZUHlhaanAbmykzKMkbFJFaz/w3vUHBnd IVszAjk2pc1mYy65q3OQNSnPVOGvjms9qdnjGaRYSzr3oSg3OWah/+8HezGyqR0bTtED oZVQ== X-Gm-Message-State: AJaThX7PrQKz0ubc1/n//8HRgkCG0mrlhT5PknmX9lXFxfqEcQ2GhCKk z9j2kUCufOiOJWxQPwsnxoBLnUVIcK0= X-Google-Smtp-Source: AGs4zMbvZlbIC1v75qvu/G4CWaouvsgzTYTFCnPcnPKb+eUIqERj6i79EeQiT6gORVZcZt2838ao4A== X-Received: by 10.223.156.193 with SMTP id h1mr8767493wre.174.1510654932491; Tue, 14 Nov 2017 02:22:12 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id 7sm16909017wmq.46.2017.11.14.02.22.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Nov 2017 02:22:11 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Cc: zhaoshenglong@huawei.com, Ard Biesheuvel Date: Tue, 14 Nov 2017 10:22:05 +0000 Message-Id: <20171114102205.30649-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [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: Tue, 14 Nov 2017 10:18:07 -0000 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 { -- 2.11.0