[edk2-devel] VariablePolicy support in StandaloneMM

Yao, Jiewen jiewen.yao at intel.com
Wed Dec 2 12:06:12 UTC 2020


There are two issues:

1) Current VarCheckPolicyLib.inf does have DxeServicesLib, although the VarCheckPolicyLib.c does not include DxeServicesLib.h.

2) The current lib construction is traditional MM style.
EFI_STATUS
EFIAPI
VarCheckPolicyLibConstructor (
  IN EFI_HANDLE             ImageHandle,
  IN EFI_SYSTEM_TABLE       *SystemTable
  )

===============================

I agree with Liming that we need StandaloneMM instance. 
We can do below:
0) Remove DxeServicesLib from INF.

1) Redefine
EFI_STATUS
EFIAPI
VarCheckPolicyLibConstructor (
  IN EFI_HANDLE             ImageHandle,
  IN EFI_SYSTEM_TABLE       *SystemTable
  )
{}
to 
EFI_STATUS
EFIAPI
VarCheckPolicyLibCommonConstructor (
  VOID
  )
{}

2) Create a VarCheckPolicyLibTraditional.c, with below
EFI_STATUS
EFIAPI
VarCheckPolicyLibConstructor (
  IN EFI_HANDLE             ImageHandle,
  IN EFI_SYSTEM_TABLE       *SystemTable
  )
{
  return VarCheckPolicyLibCommonConstructor();
}

3) Create VarCheckPolicyLibStandaloneMm.inf and VarCheckPolicyLibStandaloneMm.c under MdeModulePkg\Library\VarCheckPolicyLib (same dir)
With below
EFI_STATUS
EFIAPI
VarCheckPolicyLibStandaloneConstructor (
  IN EFI_HANDLE             ImageHandle,
  IN EFI_MM_SYSTEM_TABLE       *MmSystemTable
  )
{
  return VarCheckPolicyLibCommonConstructor();
}

Maybe there is some other clean up needed.

===============================

At same time, we may need think about how to avoid the similar issue.
1) Maybe we should enable StandaloneMmPkg for CI build ?
2) I am a little surprised, why this is a runtime error instead of a build error ?

Thank you
Yao Jiewen


> -----Original Message-----
> From: gaoliming <gaoliming at byosoft.com.cn>
> Sent: Wednesday, December 2, 2020 5:42 PM
> To: 'Ard Biesheuvel' <ard.biesheuvel at arm.com>; 'Masahisa Kojima'
> <masahisa.kojima at linaro.org>; 'edk2-devel-groups-io'
> <devel at edk2.groups.io>
> Cc: Bret.Barkelew at microsoft.com; Wang, Jian J <jian.j.wang at intel.com>;
> Wu, Hao A <hao.a.wu at intel.com>; 'Sami Mujawar'
> <sami.mujawar at arm.com>; Yao, Jiewen <jiewen.yao at intel.com>; 'Laszlo
> Ersek' <lersek at redhat.com>
> Subject: 回复: VariablePolicy support in StandaloneMM
> 
> I just quick check. VarCheckPolicyLib doesn't consume DxeServicesLib. But,
> VarCheckPolicyLib library doesn't StandaloneMM type.
> 
> So, I think StandaloneMM version VarCheckPolicyLib is required.
> 
> Thanks
> Liming
> > -----邮件原件-----
> > 发件人: Ard Biesheuvel <ard.biesheuvel at arm.com>
> > 发送时间: 2020年12月2日 17:02
> > 收件人: Masahisa Kojima <masahisa.kojima at linaro.org>;
> > edk2-devel-groups-io <devel at edk2.groups.io>
> > 抄送: Bret.Barkelew at microsoft.com; jian.j.wang at intel.com;
> > hao.a.wu at intel.com; gaoliming at byosoft.com.cn; Sami Mujawar
> > <sami.mujawar at arm.com>; jiewen.yao at intel.com; Laszlo Ersek
> > <lersek at redhat.com>
> > 主题: Re: VariablePolicy support in StandaloneMM
> >
> > (+ Laszlo)
> >
> > On 12/2/20 9:57 AM, Masahisa Kojima wrote:
> > > Hello All,
> > >
> > > VariablePolicy was introduced in November.
> > > When Developerbox(aarch64 platform) boots with UEFI secure boot
> > enabled,
> > > the following error appears.
> > > Note that this platform supports UEFI secure boot using the standalone
> > > MM framework.
> > >
> > > --- StandaloneMM log ---
> > > VariableLockRequestToLock - Failed to lock variable CapsuleMax! Not
> Ready
> > >
> > > ASSERT_EFI_ERROR (Status = Not Ready)
> > > ASSERT [VariableStandaloneMm]
> > >
> >
> /home/ubuntu/src/uefi/edk2/MdeModulePkg/Universal/Variable/RuntimeD
> x
> > e/VariableLockRequestToLock.c(64):
> > > !EFI_ERROR (Status)
> > > MmEntryPoint Done
> > > ---
> > >
> > > In my check, this is simply because
> > >
> >
> MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c::InitVariablePol
> i
> > cyLib()
> > > is not called.
> > >
> > > InitVariablePolicyLib() is called from the following two files.
> > > ---
> > >   MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLib.c:
> > Status
> > > = InitVariablePolicyLib( VariableServiceGetVariable );
> > >   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c:  Status
> > =
> > > InitVariablePolicyLib (VariableServiceGetVariable);
> > > ---
> > > VariableDxe.c is not for MM_STANDALONE, so I tried to use
> > > "VarCheckPolicyLib" as VarCheckLib,
> > > but "VarCheckPolicyLib" requires
> > > DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf and
> > > DxeServicesLib.inf is not for MM_STANDALONE, I am stuck here.
> > >
> > > Could you please take a look at this error?
> > >
> >
> > Thanks for the report.
> >
> > Bret, could you please suggest a fix here?
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#68176): https://edk2.groups.io/g/devel/message/68176
Mute This Topic: https://groups.io/mt/78657683/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list