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::241; helo=mail-wr0-x241.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (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 0992D2117D773 for ; Wed, 6 Jun 2018 05:49:52 -0700 (PDT) Received: by mail-wr0-x241.google.com with SMTP id l41-v6so6164746wre.7 for ; Wed, 06 Jun 2018 05:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VVkrj4B8y1v5tzvd/JcVXXeS17WhSM0B/zD3cz9fj8w=; b=MHX/DF3Vdexguj2EYSOcpCcMSIeB38A0yNnLmUkpkjXE43Fr+O0sxzvQLho5KxfVr/ MzKyTLfoZGlzKY77TbIlcUs5vdVVCXlm+jwcqt1WSRZluU2EQqit+8V8f7IV3cKFK95b /QypdQhgs82HplwGpB3ndaa5FmtsMerKPpedE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VVkrj4B8y1v5tzvd/JcVXXeS17WhSM0B/zD3cz9fj8w=; b=EDT6tOOYKiW7J39LImGDB87p75LkO9n9Yku8knQYSBw5uPg7eli6+GV0hP6NGjMt0n vQ5Ffb0PHY7Q17TrgpupzMUSIynM32BVwP+fKRkADSQ4pn/KbgQ8cft8q16TVqe6sQaY Oj9L64CMd52pLMTgcW84Tx34agA9YSO7tpmZlg3JD7tfIpiBUzu1BkB0zgH0pJzHSzDn 94Z8rm5NOKrXN7TOoHTtsxAWl8xdb13zUT8r8ARaNogElbCVRHfEOq8EwZ6I61ZU/eDp 5/4uPVCXHCIyEftCTkDYz2IBhAc55AeF+bC9r6G5czfgMBP5NM8Wk0jQ/Av8Wn/Pvbj3 cIrg== X-Gm-Message-State: APt69E3q9lZsYt/01fW2O6UqlVdJhytjuovHMbhqlVdPeo0gY95Qkzkt J+xmu/KO48E37T0O/0ND4B17mQ== X-Google-Smtp-Source: ADUXVKLCM9DYLBts/S8X6AuOfmTLPmfKO0Gl2AvmRYff2E8E7+ct5U0yZSnuZa8ksjqAWHpY01SjgA== X-Received: by 2002:adf:b94e:: with SMTP id b14-v6mr2401455wrg.265.1528289391000; Wed, 06 Jun 2018 05:49:51 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id x5-v6sm19618395wrr.3.2018.06.06.05.49.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Jun 2018 05:49:48 -0700 (PDT) Date: Wed, 6 Jun 2018 13:49:47 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org Message-ID: <20180606124947.ccudsrrxnezdawsz@bivouac.eciton.net> References: <20180606123701.4275-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20180606123701.4275-1-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH] ArmPkg/ArmSmcPsciResetSystemLib: implement fallback for warm reboot 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 12:49:53 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jun 06, 2018 at 02:37:01PM +0200, Ard Biesheuvel wrote: > Implement ResetSystemLib's EnterS3WithImmediateWake() routine using > a jump back to the PEI entry point with interrupts and MMU+caches > disabled. This is only possible at boot time, when we are sure that > the current CPU is the only one up and running. Also, it depends on > the platform whether the PEI code is preserved in memory (it may be > copied to DRAM rather than execute in place), so also add a feature > PCD to selectively enable this feature. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel It's not pretty, but it lets us start modelling desirable behaviour on systems we alwready have. So Reviewed-by: Leif Lindholm > --- > ArmPkg/ArmPkg.dec | 4 ++++ > ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c | 21 ++++++++++++++++++-- > ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf | 9 +++++++++ > 3 files changed, 32 insertions(+), 2 deletions(-) > > diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec > index debe066b6f7b..3aa229fe2ec9 100644 > --- a/ArmPkg/ArmPkg.dec > +++ b/ArmPkg/ArmPkg.dec > @@ -85,6 +85,10 @@ [PcdsFeatureFlag.common] > # Define if the GICv3 controller should use the GICv2 legacy > gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042 > > + # Whether to implement warm reboot for capsule update using a jump back to the > + # PEI entry point with caches and interrupts disabled. > + gArmTokenSpaceGuid.PcdArmReenterPeiForCapsuleWarmReboot|FALSE|BOOLEAN|0x0000001F > + > [PcdsFeatureFlag.ARM] > # Whether to map normal memory as non-shareable. FALSE is the safe choice, but > # TRUE may be appropriate to fix performance problems if you don't care about > diff --git a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c > index d6d26bce5009..cb75e32771c2 100644 > --- a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c > +++ b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c > @@ -15,10 +15,13 @@ > > #include > > +#include > +#include > #include > #include > #include > -#include > +#include > +#include > > #include > > @@ -89,7 +92,21 @@ EnterS3WithImmediateWake ( > VOID > ) > { > - // Not implemented > + VOID (*Reset)(VOID); > + > + if (FeaturePcdGet (PcdArmReenterPeiForCapsuleWarmReboot) && > + !EfiAtRuntime ()) { > + // > + // At boot time, we are the only core running, so we can implement the > + // immediate wake (which is used by capsule update) by disabling the MMU > + // and interrupts, and jumping to the PEI entry point. > + // > + Reset = (VOID *)(UINTN)FixedPcdGet64 (PcdFvBaseAddress); > + > + gBS->RaiseTPL (TPL_HIGH_LEVEL); > + ArmDisableMmu (); > + Reset (); > + } > } > > /** > diff --git a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf > index 5a1ee976e5bc..19021cd1e8b6 100644 > --- a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf > +++ b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf > @@ -30,6 +30,15 @@ [Packages] > MdePkg/MdePkg.dec > > [LibraryClasses] > + ArmMmuLib > ArmSmcLib > BaseLib > DebugLib > + UefiBootServicesTableLib > + UefiRuntimeLib > + > +[FeaturePcd] > + gArmTokenSpaceGuid.PcdArmReenterPeiForCapsuleWarmReboot > + > +[FixedPcd] > + gArmTokenSpaceGuid.PcdFvBaseAddress > -- > 2.17.0 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel