From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=xFbJIjRI; spf=none, err=permanent DNS error (domain: merlin.srs.infradead.org, ip: 205.233.59.134, mailfrom: batv+7fd7f3ea464b53f62198+5772+infradead.org+dwmw2@merlin.srs.infradead.org) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by groups.io with SMTP; Thu, 13 Jun 2019 01:40:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uDkFxlgJnMiQVvNjt3v+Q298TL9cZM+0DvHSjY8R+dw=; b=xFbJIjRIbhV96mE/orRC+bg/Lc EyBuUMtVurrrHRmPrDvXyBnhRsoVHfLl614U4flFqBp4B9BS5OV+66vFFyXnLJe6kxYf9TtBWevZx 7YAxoxXUw/EtHPfh+aMUT+WHpAdzvjg/2tEaN0f9GLazwtDJLASdwOpSXkWzv1WGlhFE5hgkoTY4Q FgF9TuKiuvWcoEToiaiVQL6xrkhGd7YdwG1p7sZWfhB2SBAtNJ0Bwt+vzFvfVvpspONuQGMHcIHJN xzMVM3N96C05FJO2kmfHVfe91jYbzIDh58X+UoeX2bl58vwJ2MDVV6pU39nGEEr5E/Mp1B/1LBPeU g2DjBxfQ==; Received: from [2001:8b0:10b:1::425] (helo=i7.infradead.org) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbLHB-0000iP-Rm; Thu, 13 Jun 2019 08:40:05 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hbLHB-002E64-2Y; Thu, 13 Jun 2019 09:40:05 +0100 From: "David Woodhouse" To: devel@edk2.groups.io Cc: Hao A Wu , Ray Ni , Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [PATCH v2 11/10] OvmfPkg/Csm/LegacyBiosDxe: Fix Legacy16GetTableAddress call for E820 data Date: Thu, 13 Jun 2019 09:40:05 +0100 Message-Id: <20190613084005.530806-1-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <18b24dae9f4e5c022849502fc4b60ac3ba59d6f1.camel@infradead.org> References: <18b24dae9f4e5c022849502fc4b60ac3ba59d6f1.camel@infradead.org> MIME-Version: 1.0 Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Content-Transfer-Encoding: 8bit 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, -- 2.21.0