From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web12.5622.1606353805449332795 for ; Wed, 25 Nov 2020 17:23:27 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Thu, 26 Nov 2020 09:23:19 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Laszlo Ersek'" , Cc: , "'Bret Barkelew'" , "'Ard Biesheuvel \(ARM address\)'" , "'Hao A Wu'" , "'Jian J Wang'" References: <414b7574bf8249de0cecd16fb422c711feb76e1a.camel@linux.ibm.com> <3090ce8d-74de-0fc7-985e-c4831091e478@redhat.com> In-Reply-To: <3090ce8d-74de-0fc7-985e-c4831091e478@redhat.com> Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0hdIE1kZU1vZHVsZVBrZzogRml4IHJ1bnRpbWUgcGFuaWMgaW4gVmFsaWRhdGVTZXRWYXJpYWJsZSgp?= Date: Thu, 26 Nov 2020 09:23:18 +0800 Message-ID: <000301d6c392$b8b29080$2a17b180$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHEHZ7xPGRdaqQEbcSTEtE68Ioj3wGDriwPqfLK/AA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Laszlo and James: Thanks for your root cause. The fix is clear. It works on runtime = version and smm version. Reviewed-by: Liming Gao = =20 I agree to merge this hot fix for this stable tag 202011. I will add = Laszlo tag and update subject title when I merge this patch.=20 Thanks Liming > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > =E5=8F=91=E4=BB=B6=E4=BA=BA: Laszlo Ersek > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: = 2020=E5=B9=B411=E6=9C=8826=E6=97=A5 5:01 > =E6=94=B6=E4=BB=B6=E4=BA=BA: jejb@linux.ibm.com; Liming Gao (Byosoft = address) > > =E6=8A=84=E9=80=81: devel@edk2.groups.io; Bret Barkelew = ; Ard > Biesheuvel (ARM address) ; Hao A Wu > ; Jian J Wang > =E4=B8=BB=E9=A2=98: Re: [PATCH] MdeModulePkg: Fix runtime panic in = ValidateSetVariable() >=20 > On 11/25/20 21:13, James Bottomley wrote: > > The current variable policy is allocated by AllocatePool(), which is > > boot time only. This means that if you do any variable setting in = the > > runtime, the policy has been freed. Ordinarily this isn't detected > > because freed memory is still there, but when you boot the Linux > > kernel, it's been remapped so the actual memory no longer exists in > > the memory map causing a page fault. > > > > Fix this by making it AllocateRuntimePool(). For SMM drivers, the > > platform DSC is responsible for resolving the MemoryAllocationLib > > class to the SmmMemoryAllocationLib instance. In the > > SmmMemoryAllocationLib instance, AllocatePool() and > > AllocateRuntimePool() are implemented identically. Therefore this > > change is a no-op when the RegisterVariablePolicy() function is = built > > into an SMM driver. The fix affects runtime DXE drivers only. > > > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3092 > > Signed-off-by: James Bottomley > > --- > > MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git = a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c > b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c > > index 5029ddb96adb..12944ac7ea81 100644 > > --- a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c > > +++ b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c > > @@ -411,7 +411,7 @@ RegisterVariablePolicy ( > > } > > > > // Reallocate and copy the table. > > - NewTable =3D AllocatePool( NewSize ); > > + NewTable =3D AllocateRuntimePool( NewSize ); > > if (NewTable =3D=3D NULL) { > > return EFI_OUT_OF_RESOURCES; > > } > > >=20 > (1) CC'ing Jian and Hao: >=20 > $ python BaseTools/Scripts/GetMaintainer.py \ > -l MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c >=20 > Jian J Wang > Hao A Wu > Liming Gao > devel@edk2.groups.io >=20 >=20 > (2) My feedback: >=20 > Fixes: 355b181f74050cdf2f09b1755c1a5ee4affb1faf > Reviewed-by: Laszlo Ersek > Tested-by: Laszlo Ersek >=20 > (I tested the actual bugfix with SMM-less OVMF. I also > regression-tested the patch, namely with SMM OVMF, and ArmVirtQemu = too.) >=20 >=20 > (3) I suggest updating the subject line as follows: >=20 > MdeModulePkg/VariablePolicyLib: Fix runtime panic in > ValidateSetVariable() >=20 > 74 characters, so it's not overlong. >=20 > No need to repost because of this. >=20 >=20 > Liming, can you please pick up my feedback tags from (2), in addition = to > your own review, and refresh the subject as requested in (3), and then > merge this patch -- before releasing edk2-stable202011? >=20 > Thank you all, > Laszlo