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::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-Google-Smtp-Source: ADUXVKJn7rJwf5nKpFV2zSNa9UAAhbGzuWx017Aygr1Riu6yrtOBysibyIT06ZCwzw8q/OdxNgezBQ== 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 Cc: leif.lindholm@linaro.org, jiewen.yao@intel.com, ruiyu.ni@intel.com, star.zeng@intel.com, michael.d.kinney@intel.com, liming.gao@intel.com, Ard Biesheuvel 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: [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: , X-List-Received-Date: Wed, 06 Jun 2018 09:52:41 -0000 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(+) 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; } } -- 2.17.0