public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kinney, Michael D" <michael.d.kinney@intel.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	"Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH v2 1/5] MdeModulePkg/CapsulePei: clean Dcache before consuming capsule data
Date: Tue, 12 Jun 2018 15:02:17 +0000	[thread overview]
Message-ID: <E92EE9817A31E24EB0585FDF735412F5B8A6D0E7@ORSMSX113.amr.corp.intel.com> (raw)
In-Reply-To: <CAKv+Gu-sGQ=BM-or4VfPa4qucOmg5JC77p4cZ4nLrDBTa-ntqw@mail.gmail.com>

Ard,

The UEFI Spec allows UpdateCapsule() to return EFI_UNSUPPORTED.
So after ExitBootServices() UpdateCapsule() can return EFI_UNSUPPORTED for any capsule that has the CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.

Mike

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: Tuesday, June 12, 2018 3:32 AM
> To: Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; edk2-
> devel@lists.01.org; Leif Lindholm
> <leif.lindholm@linaro.org>; Zeng, Star
> <star.zeng@intel.com>
> Subject: Re: [PATCH v2 1/5] MdeModulePkg/CapsulePei:
> clean Dcache before consuming capsule data
> 
> On 12 June 2018 at 11:01, Ard Biesheuvel
> <ard.biesheuvel@linaro.org> wrote:
> > On 12 June 2018 at 02:54, Kinney, Michael D
> <michael.d.kinney@intel.com> wrote:
> >> Ard,
> >>
> >> What about memory init when the memory HOBs are
> >> created.  Could you flush all the ranges of
> >> initialized memory by HOB as the HOBs are created?
> >>
> >> PEI and DXE can not use memory not described by
> >> the HOBs.  More memory can be added in DXE phase
> >> through the GCD services, and additional flush
> >> could be done as added.
> >>
> >
> > CapsuleCoalesce() goes and finds the capsule data
> wherever it was left
> > in memory by the OS. This is independent of what the
> HOBs may describe
> > or which memory was added at which point.
> >
> 
> As it turns out, relying on the state of the caches to
> be preserved
> across a reboot and cleaning them afterwards is
> something that cannot
> be architecturally guaranteed either. So I will withdraw
> this patch,
> and propose another approach that cleans the capsule
> during the call
> to UpdateCapsule(). For the time being, that only works
> at boot time,
> but given that both Windows and Linux perform capsule
> updates before
> ExitBootServices(), this is something we should be able
> to live with.
> 
> 
> >
> >>> -----Original Message-----
> >>> From: Ard Biesheuvel
> [mailto:ard.biesheuvel@linaro.org]
> >>> Sent: Monday, June 11, 2018 3:01 PM
> >>> To: Kinney, Michael D <michael.d.kinney@intel.com>
> >>> Cc: Yao, Jiewen <jiewen.yao@intel.com>; edk2-
> >>> devel@lists.01.org; Leif Lindholm
> >>> <leif.lindholm@linaro.org>; Zeng, Star
> >>> <star.zeng@intel.com>
> >>> Subject: Re: [PATCH v2 1/5] MdeModulePkg/CapsulePei:
> >>> clean Dcache before consuming capsule data
> >>>
> >>> On 11 June 2018 at 23:40, Kinney, Michael D
> >>> <michael.d.kinney@intel.com> wrote:
> >>> > Hi Ard,
> >>> >
> >>> > I would still prefer the cache maintenance be done
> >>> independent
> >>> > of capsules in case there is other memory ranges
> that
> >>> need to
> >>> > be flushed for other features.
> >>> >
> >>> > The CacheMaintenanceLib for ARM has several
> services
> >>> that are
> >>> > not implemented and ASSERT().  I found some ARM
> >>> documentation
> >>> > that says that caches can be flushed by looping
> >>> through the
> >>> > indexes.
> >>> >
> >>> >
> >>>
> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.
> >>> doc.ddi0201d/ch03s03s05.html
> >>> >
> >>>
> >>> Please don't quote severely outdated documentation
> out
> >>> of context.
> >>> ARM9 is a ~15 year old core that predates SMP on ARM
> by
> >>> several years.
> >>>
> >>> > implementations that may not work with that
> algorithm.
> >>> However
> >>> > that could require a customized
> CacheMaintenanceLib.
> >>> Can you
> >>> > provide the flush all using the documented
> algorithm
> >>> and use that
> >>> > instance for systems that are compatible with the
> >>> documented algorithm.
> >>>
> >>> None of the ARM cores we support in EDK2 today
> (ARMv7
> >>> and later) are
> >>> compatible with the documented algorithm.
> >>>
> >>> > Then, the flush all API can be used in
> ResetSystem()
> >>> or SEC Phase
> >>> > when the boot mode is warm reset.
> >>> >
> >>>
> >>> Flushing the entire cache is simply not possible.
> The
> >>> set/way
> >>> operations are only intended to be used before the
> core
> >>> enters the
> >>> coherency domain or after it leaves it again (i.e.,
> when
> >>> cores are
> >>> powered up or down). Those set/way operations are
> not
> >>> broadcast to
> >>> other cores (or other masters such as DMA capable
> >>> peripherals with
> >>> caches), which means that a cache line that is
> cleaned
> >>> by set/way may
> >>> simply end up in another cache and never make it to
> main
> >>> memory. In
> >>> other words, set/way operations manage the cache
> itself
> >>> rather than
> >>> the contents of the caches.
> >>>
> >>> The only way to perform cache maintenance in a way
> to
> >>> ensure that the
> >>> *content* makes it to main memory is to use cache
> >>> maintenance by
> >>> virtual address. This requires that you know the
> virtual
> >>> address to
> >>> begin with, and obviously requires that a mapping
> exists
> >>> for that
> >>> virtual address when executed with the MMU on.
> >>>
> >>> The bottom line is that there is no flush all API,
> and
> >>> we will have to
> >>> work around that (and believe me, this is not the
> first
> >>> time we are
> >>> struggling to deal with this limitation).
> >>>
> >>> So to summarize again, we have the following
> options,
> >>> - UpdateCapsule - problematic because it may be
> called
> >>> at runtime and
> >>> the firmware has no means of translating the
> physical
> >>> addresses
> >>> - ResetSystem - same as above: it is a runtime
> service,
> >>> and so it
> >>> cannot rely on a mapping to exist for those physical
> >>> addresses
> >>> - SEC - lacks the information about where the
> capsule
> >>> resides
> >>> - CapsulePei - already extracts the information
> about
> >>> the capsule
> >>> address in memory, and can perform the cache
> maintenance
> >>> right before
> >>> consuming the data.

  reply	other threads:[~2018-06-12 15:02 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08  6:58 [PATCH v2 0/5] MdeModulePkg ArmPkg: support for persistent capsules and progress reporting Ard Biesheuvel
2018-06-08  6:58 ` [PATCH v2 1/5] MdeModulePkg/CapsulePei: clean Dcache before consuming capsule data Ard Biesheuvel
2018-06-11 21:24   ` Ard Biesheuvel
2018-06-11 21:27     ` Yao, Jiewen
2018-06-11 21:28       ` Ard Biesheuvel
2018-06-11 21:40         ` Kinney, Michael D
2018-06-11 22:01           ` Ard Biesheuvel
2018-06-12  0:54             ` Kinney, Michael D
2018-06-12  9:01               ` Ard Biesheuvel
2018-06-12 10:31                 ` Ard Biesheuvel
2018-06-12 15:02                   ` Kinney, Michael D [this message]
2018-06-08  6:58 ` [PATCH v2 2/5] MdeModulePkg/DxeCapsuleLibFmp: permit ProcessCapsules () to be called once Ard Biesheuvel
2018-06-08 12:34   ` Yao, Jiewen
2018-06-08 12:37     ` Ard Biesheuvel
2018-06-10  5:38       ` Yao, Jiewen
2018-06-10  5:41         ` Ard Biesheuvel
2018-06-10 15:57           ` Kinney, Michael D
2018-06-10 19:01             ` Yao, Jiewen
2018-06-10 19:21               ` Yao, Jiewen
2018-06-11  7:27                 ` Ard Biesheuvel
2018-06-11 12:37                   ` Yao, Jiewen
2018-06-11 12:40                     ` Ard Biesheuvel
2018-06-11 13:55                       ` Yao, Jiewen
2018-06-11 14:06                         ` Ard Biesheuvel
2018-06-11 15:12                           ` Yao, Jiewen
2018-06-12  9:41                             ` Zeng, Star
2018-06-11 15:12                         ` Kinney, Michael D
2018-06-18 10:35     ` Udit Kumar
2018-06-18 14:59       ` Yao, Jiewen
2018-06-08  6:58 ` [PATCH v2 3/5] MdeModulePkg/DxeCapsuleLibFmp: pass progress callback only if it works Ard Biesheuvel
2018-06-08  6:58 ` [PATCH v2 4/5] ArmPkg/PlatformBootManagerLib: call ProcessCapsules() only once Ard Biesheuvel
2018-06-08  6:58 ` [PATCH v2 5/5] ArmPkg/ArmSmcPsciResetSystemLib: implement fallback for warm reboot Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E92EE9817A31E24EB0585FDF735412F5B8A6D0E7@ORSMSX113.amr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox