From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4F42F211439B6 for ; Wed, 6 Jun 2018 07:00:17 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2018 07:00:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,483,1520924400"; d="scan'208";a="205805810" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 06 Jun 2018 07:00:16 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 6 Jun 2018 07:00:04 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 6 Jun 2018 07:00:03 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.82]) with mapi id 14.03.0319.002; Wed, 6 Jun 2018 21:59:35 +0800 From: "Yao, Jiewen" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Gao, Liming" , Leif Lindholm , "Kinney, Michael D" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] MdeModulePkg/CapsulePei: clean Dcache before consuming capsule data Thread-Index: AQHT/XwtKI8ekzzfoEqnPGhdJwXSdaRSnX+AgACklKA= Date: Wed, 6 Jun 2018 13:59:34 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AC2E83E@shsmsx102.ccr.corp.intel.com> References: <20180606095235.20822-1-ard.biesheuvel@linaro.org> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGEzMWY5MTctMmNkNy00MGRmLTkxZDgtNTM5Zjg5YzhiOTBkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoia2puTGdzbzJkbFBZYnBwZ3NiOGdHTTFkK0IyRUFab0I0emNNUXE4R2M5MnRJUFNXNXFFSTRYVlBnNkxUd3FjYSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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 14:00:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks. Please also include the note in the final commit message. Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ar= d > Biesheuvel > Sent: Wednesday, June 6, 2018 5:10 AM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Ard Biesheuvel ; > Gao, Liming ; Yao, Jiewen ; L= eif > Lindholm ; Kinney, Michael D > ; Zeng, Star > Subject: Re: [edk2] [PATCH] MdeModulePkg/CapsulePei: clean Dcache before > consuming capsule data >=20 > On 6 June 2018 at 11:52, Ard Biesheuvel wrote= : > > 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 >=20 > Leif asked me to include a note why this cannot be done when > UpdateCapsule() is called. >=20 >=20 > """ > Note that this cache maintenance cannot be done during the invocation > of UpdateCapsule(), since the ScatterGatherList structures are only > identified by physical address, and at runtime, the firmware doesn't > know whether and where this memory is mapped, and cache maintenance > requires a virtual address. > """ >=20 > > --- > > 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 > > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel