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::141; helo=mail-it1-x141.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x141.google.com (mail-it1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (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 D247F211DF225 for ; Wed, 20 Mar 2019 02:48:53 -0700 (PDT) Received: by mail-it1-x141.google.com with SMTP id w18so30518877itj.4 for ; Wed, 20 Mar 2019 02:48:53 -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=i4qktqogC1OFIghwiBJWwxsKmF9hs0lG03IbIMHito4=; b=op3j2sEA47oPDlXUM+XPP4ZPRD4Zg+hCyevGgZPecwrjx36L6fEvOsXcnV3wcR3Rt3 Gi1W7wg3X464LI07sg3MjZHD+Fgr+7gG/NIBOmW49g9mYx/i+jQ6fBiXY8O23knyQzO3 CN0gKF8iQd9dAlKF3AJLp05fGzB8OODO0UrCnUyz+55CZIyyh1FMjPWbYwMznO0P1G0D P/f4pdTq5hnkJfp7+YFYUNTYq3gwE+wz4HqnlBu7Dq0yVDXAXLiwfQ9aBBkHH15dwLa0 G9B8NQAUYyOQlzMOQe3ylzLa56Si8jjc04lZ+PFw2Xke8RFqj1yLCwbJpeQp+cEU71On OIeA== 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=i4qktqogC1OFIghwiBJWwxsKmF9hs0lG03IbIMHito4=; b=fWqscvxdZ+RPd7HNaMbm5EpAklm1vYdr0Qk8fDnV9mwJv/QrFA+sLzQx7BnUp+jIiu FKDRa7f0GA/WTBHFXOLjegYOw371FOV2nDu5ixPIeT7/aTHcHCk+eC3qeGnJYXZdMj7b 8Sr6ogJpTf66a6RV6tn3avfLMjZ+ty1XjnCjLPImSuR81RUCyyCz82lUmgddkNs6lDsC X6OjF6QoaafQCLRhhy0OdNBPUqswt33Ok++/AFLyeP94jCRr9ON8KiiZwrsYn+g+FTii Owyk/rBJbmJqbo4lJcsyzbEdNwNTc9byzn/22IX2jIN8jQsl4kFqqtHhGgiZ/mhJaPKl JRrw== X-Gm-Message-State: APjAAAX+9erlcwKPgVuWHWNDOuIDkyu3iGYOzZ40RFFSsJStF1JCFjRX IYrXpBdQ5Mo658sxYUSTgZyEM49VsBkXXtKgWu/HJQ== X-Google-Smtp-Source: APXvYqwigrW7OFbF5kLNIKM1fCfmcIojZ8WSzYae/ec3CqvvYoiIpNnyibjh9EM+8FXA2wEqOb2JNVfb2UstcQGfpk4= X-Received: by 2002:a05:660c:7d1:: with SMTP id e17mr99468itl.158.1553075332687; Wed, 20 Mar 2019 02:48:52 -0700 (PDT) MIME-Version: 1.0 References: <20190320014256.1224-1-zhichao.gao@intel.com> <20190320014256.1224-2-zhichao.gao@intel.com> In-Reply-To: <20190320014256.1224-2-zhichao.gao@intel.com> From: Ard Biesheuvel Date: Wed, 20 Mar 2019 10:48:41 +0100 Message-ID: To: Zhichao Gao Cc: "edk2-devel@lists.01.org" , Hao Wu , Liming Gao , Star Zeng Subject: Re: [PATCH 1/2] MdeModulePkg/CapsuleRuntimeDxe: Merge changes form arm to all ARCH 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: Wed, 20 Mar 2019 09:48:54 -0000 Content-Type: text/plain; charset="UTF-8" On Wed, 20 Mar 2019 at 02:43, Zhichao Gao wrote: > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1462 > > The arm ARCH has already to add a function CapsuleCacheWriteBack to > flush the cache data to DRAM. That is also required in IA32 ARCH. So > merge the changes. And this function do not support in runtime phase. > > 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 After this patch, platforms may return TRUE from QueryCapsuleCapabilities() while they returned FALSE before, i.e., at runtime. This behavior change will surely break ARM, but I don't see how it doesn't break IA32 as well if it now relies on this cache maintenance to occur in the context of UpdateCapsule(). > --- > .../Universal/CapsuleRuntimeDxe/CapsuleReset.c | 21 ++++++++++++++++ > .../{Arm/CapsuleReset.c => CapsuleResetNull.c} | 29 +++------------------- > .../CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf | 14 +++++------ > 3 files changed, 30 insertions(+), 34 deletions(-) > rename MdeModulePkg/Universal/CapsuleRuntimeDxe/{Arm/CapsuleReset.c => CapsuleResetNull.c} (51%) > > diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleReset.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleReset.c > index 353f6f2090..8c45f6665e 100644 > --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleReset.c > +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleReset.c > @@ -16,6 +16,8 @@ > > #include "CapsuleService.h" > > +#include > + > /** > Whether the platform supports capsules that persist across reset. Note that > some platforms only support such capsules at boot time. > @@ -46,4 +48,23 @@ CapsuleCacheWriteBack ( > IN EFI_PHYSICAL_ADDRESS ScatterGatherList > ) > { > + EFI_CAPSULE_BLOCK_DESCRIPTOR *Desc; > + > + if (!EfiAtRuntime()) { > + 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/Arm/CapsuleReset.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleResetNull.c > similarity index 51% > rename from MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c > rename to MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleResetNull.c > index d79d2fc693..3c5cfc1a16 100644 > --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/Arm/CapsuleReset.c > +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleResetNull.c > @@ -1,8 +1,9 @@ > /** @file > - ARM implementation of architecture specific routines related to > + Default implementation of architecture specific routines related to > 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 > @@ -31,14 +32,7 @@ IsPersistAcrossResetCapsuleSupported ( > VOID > ) > { > - // > - // ARM requires the capsule payload to be cleaned to the point of coherency > - // (PoC), but only permits doing so using cache maintenance instructions that > - // operate on virtual addresses. Since at runtime, we don't know the virtual > - // addresses of the data structures that make up the scatter/gather list, we > - // cannot perform the maintenance, and all we can do is give up. > - // > - return FeaturePcdGet (PcdSupportUpdateCapsuleReset) && !EfiAtRuntime (); > + return FeaturePcdGet (PcdSupportUpdateCapsuleReset); > } > > /** > @@ -55,21 +49,4 @@ 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/CapsuleRuntimeDxe.inf b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf > index ad7af5fe62..c0bdf6db3d 100644 > --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf > +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf > @@ -36,15 +36,15 @@ > > [Sources.Ia32, Sources.EBC, Sources.ARM, Sources.AARCH64] > SaveLongModeContext.c > + > +[Sources.Ia32, Sources.X64, Sources.ARM, Sources.AARCH64] > CapsuleReset.c > > +[Sources.EBC] > + CapsuleResetNull.c > + > [Sources.X64] > X64/SaveLongModeContext.c > - CapsuleReset.c > - > -[Sources.ARM, Sources.AARCH64] > - SaveLongModeContext.c > - Arm/CapsuleReset.c > > [Packages] > MdePkg/MdePkg.dec > @@ -61,14 +61,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 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel