From patchwork Wed Jun 6 09:52:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137800 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp596129lji; Wed, 6 Jun 2018 02:52:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKDYn7eGypvvfOYWjy8BW0cBSJF2xu+Od+j7jW0Whp0nnqouVXFS/IjcUTF0GMZjgdkpkYM X-Received: by 2002:a63:7a4a:: with SMTP id j10-v6mr2006815pgn.421.1528278763442; Wed, 06 Jun 2018 02:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528278763; cv=none; d=google.com; s=arc-20160816; b=sOV2NuX2df1rfnMUltJ/64QYE7RK2QVC+M6zLnPUY6KtqdG9cZZr86RMLVo5OJuH0o ivny6KkSt9UVPhO7sPmL2sr+Xmus/Dizl1U5Jr76dtI+1K+wvqLG+NNWYf26vplSV9ez /3AoMN90TOcdMXvAf8iYkhI3m/IC2w7hY5tQXNIr6lhaRIpWULwqENeI/b6sAFsqEjFa gWQZixT5+2jvSZkmtzJ+2uC7Cjj5bdOhOdf1Jj+iPn6Zn3JDz7fdPfgjdT+04kut5tjZ k2yjSLLXhBLPx9rT+gGzLHjHhqdSt8xeqON3x3inmjr+s17y+6l5n68okikU5aEZScn7 ynUg== 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=Iaq5w1wvuwQXZV7/nss5RCBquHAeR5rSFbRsUPvAuS8=; b=fo+BmM+HV5XCRZYHXSYK3qW7vWPHuwLVaggQTjqTBlFvOZtcFDL29Fg1lfcdACglIq niIkq3FNeJVoMLQ7CgVFYUny/o9+TB1ZP3LlYjChTKJzyKMdSNaITKPPIHPwggatx24f atAqJi1+gdNlqyXRiSI1+31v/xVG/eRFsDX/O6oHiSvQE9YgLwXAGICeq5M7XGXMvE4T ZHJ+wq3py2a9ptHHgYYYO86RmRLNvSK/9yU+H2pie2g3WBmQ7YGEZn5RmYYOtG/iHFsp IfaMYpnnXj3x7qoywSpsuSGE6GtxQze2R6LZ7FORgn2C4B4lQ3rUMvU9ibMvuBdPRwH7 627Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Pz0OM0SO; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id j7-v6si23348825plk.334.2018.06.06.02.52.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 02:52:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Pz0OM0SO; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 CC9F5210E12AA; Wed, 6 Jun 2018 02:52:42 -0700 (PDT) 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::244; helo=mail-wr0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (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 23FD7210E12A5 for ; Wed, 6 Jun 2018 02:52:40 -0700 (PDT) Received: by mail-wr0-x244.google.com with SMTP id w10-v6so5563771wrk.9 for ; Wed, 06 Jun 2018 02:52:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=2JHOnm7T52O3457vt1jCy/28RD4L26+NB2Wm3ma7IQM=; b=Pz0OM0SOVHsuGxLZXu6xD3RVoedu1JkKicvQq+BLab/0Srp8PWat3OPeIip1hoOP1E Gko8PFo2r134E519JLcMOpCtz+gUTcBLI7qYhDJ98czGHbg0sPldE8tAuaqMbBW3OVOs +dFgcOtdm/FJuhSTT7V9/KOj1lDPrQ4DHdeTg= 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=2JHOnm7T52O3457vt1jCy/28RD4L26+NB2Wm3ma7IQM=; b=A0Ymmsd9JXXZtsUGWYUKP6f55w391bnIUxFgXTNmAy3LnMkpdBelPwBK6WY6MZvg1j 3WlzmXHGozm3Vst1XIo4SUtyXG2Wei4yqEJicyIRvp1sMOYAocNHtvIDYwqj3/anp5jz KUY1oDvpHqQ7Om7085bSZN+AYhkJtn/ZsINypaUP591LbClrQDAiyjNpO2wJPizobMGZ aLF0Nk/MlcK4wQyLuXuwSuahFDk2TL6/fMKqrUHtz++3yGwj/MzfcHu7/BSNmwUqDfT1 sGETxk8NjN9CLMFT/N9RXcXlGxcFcfxPJ/tB3lg6A+wHBtebXcZMI5aMgF5UdFDbDkFK 710A== X-Gm-Message-State: APt69E29iDrly1wvcSdHUc5BK1Ykz2wTDByodW/Ffwi15QoAhsbrooHO VAPLZ+BqeEUIUdK83YI6rjZYwpjOU3E= X-Received: by 2002:a5d:4b4b:: with SMTP id w11-v6mr1744666wrs.87.1528278759069; Wed, 06 Jun 2018 02:52:39 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:e8af:f8ab:ef29:1cd5]) by smtp.gmail.com with ESMTPSA id 135-v6sm5060643wmx.21.2018.06.06.02.52.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 02:52:38 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 6 Jun 2018 11:52:35 +0200 Message-Id: <20180606095235.20822-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 Subject: [edk2] [PATCH] MdeModulePkg/CapsulePei: clean Dcache before consuming capsule data X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ruiyu.ni@intel.com, Ard Biesheuvel , liming.gao@intel.com, jiewen.yao@intel.com, leif.lindholm@linaro.org, michael.d.kinney@intel.com, star.zeng@intel.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" When capsule updates are staged for processing after a warm reboot, they are copied into memory with the MMU and caches enabled. When the capsule PEI gets around to coalescing the capsule, the MMU and caches may still be disabled, and so on architectures where uncached accesses are incoherent with the caches (such as ARM and AARCH64), we may read stale data if we don't clean the caches to memory first. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Universal/CapsulePei/CapsulePei.inf | 1 + MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c | 4 ++++ 2 files changed, 5 insertions(+) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jiewen.yao@intel.com diff --git a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf b/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf index c54bc21a95a8..594e110d1f8a 100644 --- a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf +++ b/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf @@ -48,6 +48,7 @@ [Packages] [LibraryClasses] BaseLib + CacheMaintenanceLib HobLib BaseMemoryLib PeiServicesLib diff --git a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c b/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c index 3e7054cd38a9..1730f925adc5 100644 --- a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c +++ b/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c @@ -27,6 +27,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include #include #include @@ -283,6 +284,9 @@ ValidateCapsuleByMemoryResource ( DEBUG ((EFI_D_INFO, "Address(0x%lx) Size(0x%lx) in MemoryResource[0x%x] - Start(0x%lx) Length(0x%lx)\n", Address, Size, Index, MemoryResource[Index].PhysicalStart, MemoryResource[Index].ResourceLength)); + + WriteBackDataCacheRange ((VOID *)(UINTN)Address, Size); + return TRUE; } }