From patchwork Tue Nov 14 10:22:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118866 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2858775qgn; Tue, 14 Nov 2017 02:22:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMZS8WUhm1hY0hXY4D4303d1Tzn/6v0U+29GYbR1gcVXcNAIfdGTEamK3WQRWw60aa0p1Gb1 X-Received: by 10.84.229.79 with SMTP id d15mr9694556pln.397.1510654937408; Tue, 14 Nov 2017 02:22:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510654937; cv=none; d=google.com; s=arc-20160816; b=GDeTvyBYe2Cvv7ACwxq1Fqun+Gba1kaJ3utED3cCm/C8pmgEPGr61bFL9lsbNR2dEx QDxYJgdLZoNhgwiXiInXOIDq/erhitRYAjowz+4wugtV+hpfkdsP9KHEUNXiOWHzman3 /exUz23z9UKBhzc3sG0pVkoiCugFkXGzeHjxP9MvHWSz9H63ZS3EZi+oM4CuqpqBcTig R13QCcAP/uxgbSMmJInDdIeQKzK3gJqarzzgn9Zh8AJyvHGBtepJBUSiNWGtMLb421i2 P5JvIkEdd53obCkJzmKwolxc8w95O1Jm2bsiAcYLYH9Fzkb904dCeVh4zPN8OODSVgTX T4Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=KoPcExLX/V6KKjkOVbPJxna4FZOuqxrEB9mFSwMzgwI=; b=LwC+1Cmnjc39RlBmiB6G2Zv1zpFowkGesTVakjBBrIcdw5cmfmKJTMhdcKQ80l6o4B KY5fK1Ass08wAfHhpmivRXrOnjM8I21dKxuP5Ieedn85DVmpCk/c+hEVx/+px3e7PBaP 9cRfyDfXaBeyt9KPLvQzy6xvLHt4RyCRjfh2uL6FtcXdDmyKnyDFL2JEfVawCUEDdnRl 5hdpxuh7ICxWmX0NMgD57W0C3H7RnhCfRY3WxSQZZXZILRMzC/U7gKftMTQ+kTtIFBbP TBxpkMPdEuNCKLKeGQDwwgV8dKjVPrx2WoROg9JVJnNOOvgxjt1dWLVTXfOTkNd0MjwV q46g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=M4hytpRq; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id p27si5076548pgc.507.2017.11.14.02.22.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Nov 2017 02:22:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=M4hytpRq; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2EFDA2035BB19; Tue, 14 Nov 2017 02:18:09 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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-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 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: [edk2] [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: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek Tested-by: Shannon Zhao 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 {