From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Thu, 13 Jun 2019 07:23:29 -0700 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E5A737F7C0; Thu, 13 Jun 2019 14:23:23 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-127.ams2.redhat.com [10.36.117.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id A672A541F8; Thu, 13 Jun 2019 14:23:21 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 11/10] OvmfPkg/Csm/LegacyBiosDxe: Fix Legacy16GetTableAddress call for E820 data To: devel@edk2.groups.io, dwmw2@infradead.org Cc: Hao A Wu , Ray Ni , Jordan Justen , Ard Biesheuvel References: <18b24dae9f4e5c022849502fc4b60ac3ba59d6f1.camel@infradead.org> <20190613084005.530806-1-dwmw2@infradead.org> From: "Laszlo Ersek" Message-ID: <8cb5b90f-c9bc-428a-9fee-f8d4e4360f85@redhat.com> Date: Thu, 13 Jun 2019 16:23:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190613084005.530806-1-dwmw2@infradead.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 13 Jun 2019 14:23:24 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 06/13/19 10:40, David Woodhouse wrote: > The DX register is supposed to contain the required alignment for the > allocation. It was zero, and SeaBIOS doesn't (well, didn't) cope well > with that. Set it appropriately. > > Also set BX to indicate the regions it's OK to allocate in too. That > wasn't being initialised and was just using whatever the previous user > of the structure had left there. > > Finally, actually return an error if the allocation fails. Instead of > going all the way through into the CSM and just letting it have a bogus > pointer to the E820 data. > > Signed-off-by: David Woodhouse > Reviewed-by: Hao A Wu > --- > OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c > index 211750c012..cd4cd24f42 100644 > --- a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c > +++ b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c > @@ -928,7 +928,9 @@ GenericLegacyBoot ( > if (CopySize > Private->Legacy16Table->E820Length) { > ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET)); > Regs.X.AX = Legacy16GetTableAddress; > + Regs.X.BX = (UINT16) 0x0; // Any region > Regs.X.CX = (UINT16) CopySize; > + Regs.X.DX = (UINT16) 0x4; // Alignment > Private->LegacyBios.FarCall86 ( > &Private->LegacyBios, > Private->Legacy16Table->Compatibility16CallSegment, > @@ -942,6 +944,7 @@ GenericLegacyBoot ( > Private->Legacy16Table->E820Length = (UINT32) CopySize; > if (Regs.X.AX != 0) { > DEBUG ((EFI_D_ERROR, "Legacy16 E820 length insufficient\n")); > + return EFI_OUT_OF_RESOURCES; > } else { > CopyMem ( > (VOID *)(UINTN) Private->Legacy16Table->E820Pointer, > Acked-by: Laszlo Ersek