From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: Void lookup limit of 2 exceeded) identity=mailfrom; client-ip=2607:f8b0:4003:c0f::244; helo=mail-ot0-x244.google.com; envelope-from=abh@cs.unc.edu; receiver=edk2-devel@lists.01.org Received: from mail-ot0-x244.google.com (mail-ot0-x244.google.com [IPv6:2607:f8b0:4003:c0f::244]) (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 DF6162063D77E for ; Mon, 28 May 2018 22:17:49 -0700 (PDT) Received: by mail-ot0-x244.google.com with SMTP id q17-v6so4991485otg.2 for ; Mon, 28 May 2018 22:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs-unc-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=yCnj0MvO0KSqFG8D1HNR5sN4yUcKrjkAMEWv7LuTZBs=; b=w7FZbN6VLlz613kp1y5FoAhkCXjmkgwJo8zHJD7f4VHmnTnDSdlzxsaBg5Jsx+3sQM fGwjknkucfgJ6Z7Bc0SpdZZ3vzoNuciIu31PtyDIfIGrsrKBepwg4ktLYC4eocwJJG7W 7zuqUX5u0xlZyoP4dcW1z32chbIMV+5t4hdxkiFl+KwyW7MMRjuJyRG5/Cf0N7vjJ5HF QpNgbz5Xt9SE3hY0NMBTQzjIRrvaV8/o2v6LSXJpaAMkdH9LGOa259h0dnz+TJmzBEFT 8c1HOF72BEYhd7da1sB4O7Ds+9ZsS3+LGrSTeK/PKvwFvv7WochriHzwzrPkFsht+QKI sAQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=yCnj0MvO0KSqFG8D1HNR5sN4yUcKrjkAMEWv7LuTZBs=; b=t5BAWJOwKD0bUjtWTMw/8zXDFGfMPIKXVBdZzjLSPIrhsKDsr/X3yWeMRJghWqkP57 w++OmBTTFsug+7iaicw/7QTpCm+rrsXl0E6Hc158ia6OT9boNx+1T1tO1gmRQIY9PQgS +8gwrdf1JuU9dM3BDTSOLHdOBU8l7LRRgMCgc+NpoqAdW+6D2CXseKeWeweF/56wWve5 3CxO1uFXDR7lEPe/uv4uqasbZJfD7c4FaNeFq5tsPEUgznleRz24GTzmVPLX8HU5dhN4 JEIEErsEDuaQZjEcWkb16gAS+UTEwsJNDHDuq7qPfAqJ0ni7SfrGK8YM8IuUZwRtG45j KUug== X-Gm-Message-State: ALKqPwd7rlve9YLPQCrSF6OwtbqfAO25t+HrjncY/bfrAIMcIN6ceTLy XYa2acdNSn64fB+pnRePqyRr3FUdA0oFDrMY94P8Vw== X-Google-Smtp-Source: ADUXVKJ/itbnG+9oA9hnhZUZoYuUaH6i5wup+4j3L3SBW1aM1kx/jg+k6DeXKUZJWvSijoU+JmRwEk36qGZtVPHDf8I= X-Received: by 2002:a9d:2bcd:: with SMTP id u71-v6mr5335006ota.51.1527571068974; Mon, 28 May 2018 22:17:48 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2a34:0:0:0:0:0 with HTTP; Mon, 28 May 2018 22:17:48 -0700 (PDT) In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503AC13EC5@shsmsx102.ccr.corp.intel.com> References: <0C4E04D0-E863-4779-AFFA-44A0E6F8FB20@apple.com> <0b422b9a-6995-896d-4166-cd9792e818de@redhat.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BB47EC2@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AC13EC5@shsmsx102.ccr.corp.intel.com> From: Abhishek Singh Date: Tue, 29 May 2018 01:17:48 -0400 Message-ID: To: "Yao, Jiewen" Cc: "Zeng, Star" , "Marvin H?user" , "edk2-devel@lists.01.org" , Laszlo Ersek , "afish@apple.com" , "Ni, Ruiyu" , "Dong, Eric" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 Subject: Re: smm lock query 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: Tue, 29 May 2018 05:17:51 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks, Jiewen and Star. I was able to figure out that smrr was preventing me from accessing the contents of smram. It seems to me that this violates the EFI_MM_ACCESS_PROTOCOL protocol. I have talked to the edk2-platform maintainers about this on a private thread, but, of course, I may be mistaken. I agree that smm is a runtime environment, but you must also agree that there is an initialization or loading phase in which all the smi handlers are loaded into smram. Theoretically, new handlers may keep getting installed as smi's are received but I doubt that this is the case. There must be a point at which the code (not necessarily the data) is supposed to be fixed in smram. My guess is that that point is after the SMI handlers have responded to the SmmReadyToLock event, but I would like to know if you disagree. I am definitely not seeking to add the smram dumping code as a production feature. I am merely interested in using it for my research. I may have to resort to writing an smm driver, as you suggest Jiewen, but currently I am just trying to dump smram contents from smm ipl, having disabled smrr in SmmCpuFeaturesLib. The problem, in both cases, is that the smram range is quite large (around 8 MB) and cannot fit in a single UEFI variable. Do you have any suggestions on how to actually dump out this large range? Thanks again, Abhishek On Mon, May 28, 2018 at 10:21 PM, Yao, Jiewen wrote: > Let me share my thought. > > 1) From interface point of view, ReadyToLock means it is the last > time to lock. But it does not mean it must be open before. > > As implementation choice, a platform MAY lock it earlier. > > > > Also SMRR may force the SMRAM invisible to outside SMRAM, even with D_OPE= N > set. > > > > 2) Dumping SMRAM exposes the secret inside of SMRAM, I would treat > it as debug feature only, not a production. > > > > If you want to debug, you can add a debug SMM driver and expose an > interface to copy SMRAM content out. > > > > Thank you > > Yao Jiewen > > > > *From:* Zeng, Star > *Sent:* Monday, May 28, 2018 6:16 PM > *To:* Abhishek Singh ; Marvin H?user < > Marvin.Haeuser@outlook.com> > *Cc:* edk2-devel@lists.01.org; Laszlo Ersek ; > afish@apple.com; Ni, Ruiyu ; Dong, Eric < > eric.dong@intel.com>; Zeng, Star ; Yao, Jiewen < > jiewen.yao@intel.com> > *Subject:* RE: [edk2] smm lock query > > > > I do not see issue according to the spec. > > Platform should know when to signal DxeSmmReadyToLock (after EndOfDxe). > > DxeSmmReadyToLock event is to notify DXE handlers. > > Modules are responsible to lock or protect their resource and effect the > appropriate protections in their notification handlers. > > SmmIplGuidedEventNotify is used to inform SMM environment to signal > SmmReadyToLock. > > SmmReadyToLock event is to notify SMM handlers. > > > > DXE handlers could not touch SMRAM (after SMRAM is locked or even after > SMRR is configured in PiSmmCpuDxeSmm if I know it is correct). > > > > =E2=80=9CThis protocol in tandem with the *End of DXE Even*t facilitates > transition of the platform from the environment where all of the componen= ts > are under the authority of the platform manufacturer to the environment > where third party extensible modules such as UEFI drivers and UEFI > applications are executed. > > The protocol is published immediately after signaling of the *End of DXE > Event*. > > PI modules that need to lock or protect their resources in anticipation o= f > the invocation of 3rd party extensible modules should register for > notification on installation of this protocol and effect the appropriate > protections in their notification handlers. For example, PI platform code > may choose to use notification handler to lock MM by invoking *EFI_MM_ACC= ESS_PROTOCOL.Lock() > *function.=E2=80=9D > > > > > > SMM environment is a *runtime* environment. SMRAM will be even changed > after SmmReadyToLock, for example, by SMM handler for SMM communication > from DXE. > > > > > > Thanks, > > Star > > *From:* Abhishek Singh [mailto:abh@cs.unc.edu ] > *Sent:* Tuesday, May 29, 2018 2:02 AM > *To:* Marvin H=C3=A4user > *Cc:* edk2-devel@lists.01.org; Laszlo Ersek ; > afish@apple.com; Ni, Ruiyu ; Dong, Eric < > eric.dong@intel.com>; Zeng, Star > *Subject:* Re: [edk2] smm lock query > > > > Thank you everyone for your inputs and clarifications. They are helping m= e > to better understand the uefi code, to which I am very new. I do not mean > to hijack the thread: so please continue your discussions about whether t= he > implementation matches the spec. > > > > However, I want to state why I am interested in the IPL code. For my > research, I wish to dump the contents of SMRAM when it has reached steady > state, i.e., all the drivers have made changes to smram and it has been > locked. The current implementation (smm ipl) locks smram when it receives > the SmmReadyToLock event and then propagates the event to the smm drivers > that make further changes to smram. Unfortunately, I cannot take a snapsh= ot > of smram after it has been locked! Thus, I have solved this issue by > propagating the event to the smm drivers first (using > SmmIplGuidedEventNotify), then opening access to and dumping the contents > of SMRAM, and finally closing access to and locking smram. Would it be fa= ir > to say that this would give me the fully initialized contents of smram? > > > > > > > > My second observation is that despite opening access to smram, I am unabl= e > to access its contents, which is a violation of the > EFI_MM_ACCESS_PROTOCOL.Open() description in the spec, which says: "This > function =E2=80=9Copens=E2=80=9D MMRAM so that it is visible while not in= side of MM." Note > that I am working with minnowboard firmware release 0.97. So some of the > binaries like SmmAccess.efi are provided by Intel, while others have been > built from the edk source tree: thus, this may not be an EDK issue. Pleas= e > suggest further steps and/or workarounds. Should I contact edk2-platforms > maintainers, or start a new thread here for this issue? > > > > -Abhishek > > > > > > On Mon, May 28, 2018 at 10:03 AM, Marvin H=C3=A4user < > Marvin.Haeuser@outlook.com> wrote: > > Hello Andrew and Laszlo, > > Thanks for your comments! > Of course I'm with you that it is the platform that signals the > SmmReadyToLock event and therefor is aware. > However, they might rely on the protocol's description that the resources > are about(!) to be locked and code accordingly, not considering the event > characteristic of the handler in PiSmmIpl. > The code might be written by different people, not especially reviewed > against edk2's actions, or additional code might be supplied by third > parties that do not have tree code access (which, by integration, would b= e > "platform binaries" by the definition applying here). > > Therefor I would still ask everyone to consider figuring out a solution t= o > this discrepancy from the specification, such as the internal "dummy even= t" > I proposed. > > Thanks, > Marvin. > > > > -----Original Message----- > > From: Laszlo Ersek > > Sent: Monday, May 28, 2018 12:58 PM > > To: Andrew Fish ; Marvin H?user > > > > Cc: edk2-devel@lists.01.org; Abhishek Singh ; > > ruiyu.ni@intel.com; eric.dong@intel.com; star.zeng@intel.com > > Subject: Re: [edk2] smm lock query > > > > On 05/27/18 22:44, Andrew Fish wrote: > > > > > > > > >> On May 27, 2018, at 9:47 AM, Marvin H?user > > wrote: > > >> > > >> Good day Abhishek, > > >> > > >> I CC'd the MdeModulePkg maintainers, Ruiyu for the Platform BDS aspe= ct > > (exposes the ReadyToLock protocol) and Laszlo for his high-quality > answers. > > >> > > >> Strictly speaking you are, right, because of the description for the > MM > > protocol: > > >> "Indicates that MM resources and services that should not be used by > the > > third party code are about[Marvin: (!)] to be locked." > > >> Practically however, I don't see any issue with the current > > implementation. Code inside MMRAM is not affected directly by the lock, > it is > > just notified. > > >> However, either the code or the specification should be slightly > updated > > to be in sync. A code update might require review of the caller > assumptions, > > just to be sure. > > >> > > >> I have a different concern though and hope I'm actually overlooking > > something. > > >> If I understand the code correctly, it is the Platform BDS that > exposes the > > (S)MmReadyToLock protocol. PiSmmIpl seems to consume that event and > > lock SMM resources based on the event. > > >> Because of latter being an event however, I don't think it is, or ca= n > be, > > guaranteed to be the last event group member executing. > > >> When it is not the last, the "about to be locked" part is not true > for any > > subsequent callbacks, that could actually be a risky break of the > specification > > - if it is. > > >> If it is a break of the specification, I can only think of letting > Platform BDS > > expose an "internal" event group, which is only caught by PiSmmIpl, whi= ch > > then drives the actual SmmReadyToLock flow. > > >> This would require updates to all platform trees and hence I would > > propose a temporary backwards-compatibility. > > >> > > >> Any comments? Did I overlook something (I hope)? > > >> > > > > > > Mavvin, > > > > > > You are correct there is no guarantee of order in events. Thanks for > cc'ing > > the right folks, as I don't remember all the low level details... > > > > > > In general the idea behind the MM code is it only comes from the > platform, > > then by definition that code should be aware when the platform was goin= g > > to lock MM. In a practical sense any MM module that had a depex evaluat= e > > to true would have dispatched in DXE prior to BDS being launched. In > general > > BDS is the code that enumerates PCI and connects devices, thus there is > no > > chance for 3rd party software to run before that point in the boot. So > in an > > abstract sense that lock represents the end of DXE dispatch. > > > > This is my understanding as well. gEfiDxeSmmReadyToLockProtocolGuid is > > installed by Plaform BDS before any non-platform binaries get a chance = to > > run. In terms of the current PlatformBootManagerLib interfaces, that > means > > the protocol should be installed from > > PlatformBootManagerBeforeConsole() (as noted on the API declaration > > itself). > > > > Thanks > > Laszlo > > >