From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::d42; helo=mail-io1-xd42.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 593042194EB7D for ; Mon, 25 Mar 2019 01:25:57 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id x7so6894598ioh.4 for ; Mon, 25 Mar 2019 01:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6plRiJpLYvuuAbyF6Y9ecHyOyi0MbHMg3o4+AEmjk30=; b=dvn7azrjAYJBYD+PQChV0964tIwSW6/b9PB4ocrPKdIBEzb9O5U1NlUrckNcA4ft/6 fT3zyy+hTTEnLoCgMAX5bxLrm+uPobVN/bP/L4YZtPbqjbN3jz/wHYmlOq0NnRPFOXm8 0ZPSzwBuh73lQFeUZ6ltwNLsAk+FGwgaw6FK0OxEIlb61ev/ir5Mm1o9ncIMpqB36mLF VyHX9X4yaqcjNRlVH8xDVP/wuqcnBZD01zVmOW7o9B/PEmDuBKd25PfD4vrkGv6AIBJU MuaYKcj3Ojt8nwd+5NfpnxPf5t0ScwWxd49i5zfwwRxQifjwhNvPnYNiTC6dEAqUCx9F 8MgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6plRiJpLYvuuAbyF6Y9ecHyOyi0MbHMg3o4+AEmjk30=; b=UyC/ynliuLq1FYizbYCu/14ocv+Pl4FDJw693+HIJEam8u62XGJnb/nIhztxeSR09I nACZUTF2QhCubjnTL48ms17jfnq6IDxbi5wux9dFbUhcleseIaDnCATsvHtpGdjf2ND8 3opnTQaFAaND+4HiVFLeY4QOQczcn3DSlO4aKmusWYhjIWT8hKokFMG3rcHRnkcmC1q/ YGVuDT9+ETzu9ZPZ06WRkB9R0Moj5NSTycxf23dpdRt0CXDkuyk8K1kanAQJUfi0NlLe MGskCYRfaGfFCQah37RK09c0N0vkGi2WWp3TwbmigilFVefHSiHaWxvFDyuVSkl1R7rj RJqw== X-Gm-Message-State: APjAAAX6WK9C/8KhKkd8LSBp45GUki3CaXBkUtw7adUUHta1DiKu1/7V +TpjnkWZw74u54HnmdQAgqhRQsWz0HsWReBiV05p7g== X-Google-Smtp-Source: APXvYqy0FKCgK+xUxbGQX3xXQkUbKNuM7wlKAlFPzTtsBb+geRT/VtLHB+IoD7G9sfd0UThPoSHCS2KwI5A6IespqwY= X-Received: by 2002:a5e:8418:: with SMTP id h24mr15404610ioj.170.1553502356242; Mon, 25 Mar 2019 01:25:56 -0700 (PDT) MIME-Version: 1.0 References: <20190322030718.17676-1-zhichao.gao@intel.com> <20190322030718.17676-2-zhichao.gao@intel.com> In-Reply-To: <20190322030718.17676-2-zhichao.gao@intel.com> From: Ard Biesheuvel Date: Mon, 25 Mar 2019 09:25:43 +0100 Message-ID: To: Zhichao Gao Cc: "edk2-devel@lists.01.org" , Jian J Wang , Hao Wu , Ray Ni , Star Zeng , Liming Gao Subject: Re: [PATCH V2 1/2] MdeModulePkg/CapsuleRuntimeDxe: IA32 add cache flush function X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2019 08:25:57 -0000 Content-Type: text/plain; charset="UTF-8" On Fri, 22 Mar 2019 at 04:09, Zhichao Gao wrote: > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1462 > > The IA32 ARCH need cache flush function during capsule update. > Both arm ARCH and IA32 do not need flush cache function, so > merge the CapsuleCacheWriteBack() to one file. And add a null > version for EBC. > What is the point of being able to build a DXE_RUNTIME_DRIVER module for EBC? > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Zhichao Gao > Cc: Jian J Wang > Cc: Hao Wu > Cc: Ray Ni > Cc: Star Zeng > Cc: Liming Gao > Cc: Ard Biesheuvel > --- > .../Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c | 35 +----------- > .../Universal/CapsuleRuntimeDxe/CapsuleCache.c | 63 ++++++++++++++++++++++ > .../Universal/CapsuleRuntimeDxe/CapsuleCacheNull.c | 38 +++++++++++++ > .../Universal/CapsuleRuntimeDxe/CapsuleReset.c | 16 +----- > .../CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf | 20 ++++--- > 5 files changed, 115 insertions(+), 57 deletions(-) > create mode 100644 MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCache.c > create mode 100644 MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCacheNull.c > > diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c > index d79d2fc693..ec630ab7a8 100644 > --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c > +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c > @@ -3,6 +3,7 @@ > PersistAcrossReset capsules > > Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> + Copyright (c) 2019, Intel Corporation. All rights reserved.
> > This program and the accompanying materials are licensed and made available > under the terms and conditions of the BSD License which accompanies this > @@ -16,8 +17,6 @@ > > #include "CapsuleService.h" > > -#include > - > /** > Whether the platform supports capsules that persist across reset. Note that > some platforms only support such capsules at boot time. > @@ -41,35 +40,3 @@ IsPersistAcrossResetCapsuleSupported ( > return FeaturePcdGet (PcdSupportUpdateCapsuleReset) && !EfiAtRuntime (); > } > > -/** > - Writes Back a range of data cache lines covering a set of capsules in memory. > - > - Writes Back the data cache lines specified by ScatterGatherList. > - > - @param ScatterGatherList Physical address of the data structure that > - describes a set of capsules in memory > - > -**/ > -VOID > -CapsuleCacheWriteBack ( > - IN EFI_PHYSICAL_ADDRESS ScatterGatherList > - ) > -{ > - EFI_CAPSULE_BLOCK_DESCRIPTOR *Desc; > - > - Desc = (EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)ScatterGatherList; > - do { > - WriteBackDataCacheRange (Desc, sizeof *Desc); > - > - if (Desc->Length > 0) { > - WriteBackDataCacheRange ((VOID *)(UINTN)Desc->Union.DataBlock, > - Desc->Length > - ); > - Desc++; > - } else if (Desc->Union.ContinuationPointer > 0) { > - Desc = (EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)Desc->Union.ContinuationPointer; > - } > - } while (Desc->Length > 0 || Desc->Union.ContinuationPointer > 0); > - > - WriteBackDataCacheRange (Desc, sizeof *Desc); > -} > diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCache.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCache.c > new file mode 100644 > index 0000000000..ab81296a65 > --- /dev/null > +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCache.c > @@ -0,0 +1,63 @@ > +/** @file > + Flush the cache is required for most architectures while do capsule > + update. It is not support at Runtime. > + > + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> + Copyright (c) 2019, Intel Corporation. All rights reserved.
> + > + This program and the accompanying materials are licensed and made available > + under the terms and conditions of the BSD License which accompanies this > + distribution. The full text of the license may be found at > + http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > + > +**/ > + > +#include "CapsuleService.h" > + > +#include > + > +/** > + Writes Back a range of data cache lines covering a set of capsules in memory. > + > + Writes Back the data cache lines specified by ScatterGatherList. > + > + @param ScatterGatherList Physical address of the data structure that > + describes a set of capsules in memory > + > +**/ > +VOID > +CapsuleCacheWriteBack ( > + IN EFI_PHYSICAL_ADDRESS ScatterGatherList > + ) > +{ > + EFI_CAPSULE_BLOCK_DESCRIPTOR *Desc; > + > + if (!EfiAtRuntime ()) { > + Desc = (EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)ScatterGatherList; > + do { > + WriteBackDataCacheRange ( > + (VOID *)(UINTN)Desc, > + (UINTN)sizeof (*Desc) > + ); > + > + if (Desc->Length > 0) { > + WriteBackDataCacheRange ( > + (VOID *)(UINTN)Desc->Union.DataBlock, > + (UINTN)Desc->Length > + ); > + Desc++; > + } else if (Desc->Union.ContinuationPointer > 0) { > + Desc = (EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)Desc->Union.ContinuationPointer; > + } > + } while (Desc->Length > 0 || Desc->Union.ContinuationPointer > 0); > + > + WriteBackDataCacheRange ( > + (VOID *)(UINTN)Desc, > + (UINTN)sizeof (*Desc) > + ); > + } > +} > + > diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCacheNull.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCacheNull.c > new file mode 100644 > index 0000000000..cfb9bb1bf1 > --- /dev/null > +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCacheNull.c > @@ -0,0 +1,38 @@ > +/** @file > + Null function version of cache function. > + > + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> + Copyright (c) 2019, Intel Corporation. All rights reserved.
> + > + This program and the accompanying materials are licensed and made available > + under the terms and conditions of the BSD License which accompanies this > + distribution. The full text of the license may be found at > + http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > + > +**/ > + > +#include "CapsuleService.h" > + > +#include > + > +/** > + Writes Back a range of data cache lines covering a set of capsules in memory. > + > + Writes Back the data cache lines specified by ScatterGatherList. > + > + Null version, do nothing. > + > + @param ScatterGatherList Physical address of the data structure that > + describes a set of capsules in memory > + > +**/ > +VOID > +CapsuleCacheWriteBack ( > + IN EFI_PHYSICAL_ADDRESS ScatterGatherList > + ) > +{ > +} > + > diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleReset.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleReset.c > index 353f6f2090..8990cf2a35 100644 > --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleReset.c > +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleReset.c > @@ -3,6 +3,7 @@ > PersistAcrossReset capsules > > Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> + Copyright (c) 2019, Intel Corporation. All rights reserved.
> > This program and the accompanying materials are licensed and made available > under the terms and conditions of the BSD License which accompanies this > @@ -32,18 +33,3 @@ IsPersistAcrossResetCapsuleSupported ( > return FeaturePcdGet (PcdSupportUpdateCapsuleReset); > } > > -/** > - Writes Back a range of data cache lines covering a set of capsules in memory. > - > - Writes Back the data cache lines specified by ScatterGatherList. > - > - @param ScatterGatherList Physical address of the data structure that > - describes a set of capsules in memory > - > -**/ > -VOID > -CapsuleCacheWriteBack ( > - IN EFI_PHYSICAL_ADDRESS ScatterGatherList > - ) > -{ > -} > diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf > index ad7af5fe62..a0cb32a06f 100644 > --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf > +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf > @@ -4,7 +4,7 @@ > # It installs the Capsule Architectural Protocol defined in PI1.0a to signify > # the capsule runtime services are ready. > # > -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the BSD License > # which accompanies this distribution. The full text of the license may be found at > @@ -36,16 +36,22 @@ > > [Sources.Ia32, Sources.EBC, Sources.ARM, Sources.AARCH64] > SaveLongModeContext.c > - CapsuleReset.c > > -[Sources.X64] > - X64/SaveLongModeContext.c > +[Sources.Ia32, Sources.X64, Sources.ARM, Sources.AARCH64] > + CapsuleCache.c > + > +[Sources.Ia32, Sources.X64, Sources.EBC] > CapsuleReset.c > > [Sources.ARM, Sources.AARCH64] > - SaveLongModeContext.c > Arm/CapsuleReset.c > > +[Sources.EBC] > + CapsuleCacheNull.c > + > +[Sources.X64] > + X64/SaveLongModeContext.c > + > [Packages] > MdePkg/MdePkg.dec > MdeModulePkg/MdeModulePkg.dec > @@ -61,14 +67,12 @@ > BaseLib > PrintLib > BaseMemoryLib > + CacheMaintenanceLib > > [LibraryClasses.X64] > UefiLib > BaseMemoryLib > > -[LibraryClasses.ARM, LibraryClasses.AARCH64] > - CacheMaintenanceLib > - > [Guids] > ## SOMETIMES_PRODUCES ## Variable:L"CapsuleUpdateData" # (Process across reset capsule image) for capsule updated data > ## SOMETIMES_PRODUCES ## Variable:L"CapsuleLongModeBuffer" # The long mode buffer used by IA32 Capsule PEIM to call X64 CapsuleCoalesce code to handle >4GB capsule blocks > -- > 2.16.2.windows.1 >