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=sp3cYLON; 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:00:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Mime-Version:Content-Type:References: In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender:Reply-To: Content-Transfer-Encoding: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=mFUX80EqLXwg1fgbMuCJnhvgZrGfP8cB8Qla5HhdAUw=; b=sp3cYLONe7uEjjySAs6XAie7G LEm6JYiHucjUff7pzCDxPaCkG4f+d2N4pxXd4Xn6Fmr6ozMgmFuwlS2+5e7ZH6TVxNyRSQJes/cZ/ MQ43A+oVLP5dHU7xje6nzt0qFoI3qSfJK7BRDWMSBdQZRpcaVlD7J+ooWxVDxrZL8kszrt7nBID2L oGhTDCcKuiK0kwBazM7syyNwxPbJkc0x/fNgcS0SznJRQL3Jd+Rvu/cuYfGofeNliOb+IFbx5wEFN AWHXrkNQYqsKyh0D6yhVDP7UIVVZNtzXs0LIoQNkFQypoGQl7EUW28v8Yg+rbT7stGMSpvl8mgEcr MUFyZo4dQ==; Received: from [54.239.6.185] (helo=u3832b3a9db3152.ant.amazon.com) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbKfC-0000QN-JP; Thu, 13 Jun 2019 08:00:50 +0000 Message-ID: Subject: Re: [edk2-devel] [PATCH 11/10] OvmfPkg/Csm/LegacyBiosDxe: Correct Legacy16GetTableAddress call for E820 data From: "David Woodhouse" To: Jordan Justen , "Ni, Ray" , "Wu, Hao A" , "devel@edk2.groups.io" Cc: Laszlo Ersek , Ard Biesheuvel Date: Thu, 13 Jun 2019 09:00:48 +0100 In-Reply-To: <156041165954.1758.7451081062097429166@jljusten-skl> References: <20190527030350.11996-1-hao.a.wu@intel.com> <18b24dae9f4e5c022849502fc4b60ac3ba59d6f1.camel@infradead.org> <156041165954.1758.7451081062097429166@jljusten-skl> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html X-Groupsio-MsgNum: 42339 Content-Type: multipart/signed; micalg="sha-256"; protocol="application/x-pkcs7-signature"; boundary="=-LatxWpM1BXF5ULcXODAc" --=-LatxWpM1BXF5ULcXODAc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2019-06-13 at 00:40 -0700, Jordan Justen wrote: > On 2019-06-12 23:28:12, Wu, Hao A wrote: > >=20 > > > -----Original Message----- > > > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > > > David Woodhouse > > > Sent: Thursday, June 13, 2019 5:43 AM > > >=20 > > > 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, and set BX to indicate the regions > > > it's OK to allocate in too. That was already OK but let's make sure > > > it's initialised properly and not just working by chance. > > >=20 > > > Also actually return an error if the allocation fails. Instead of goi= ng > > > all the way through into the CSM and just letting it have a bogus > > > pointer to the E82o data. >=20 > 'E82o' =3D> 'E820' Yeah, spotted that just after sending and it's in my tree for v2 if there is one. Thanks. > > >=20 > > > diff --git a/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c > > > b/OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c > > > index 211750c012..e7766eb2b1 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 =3D Legacy16GetTableAddress; > > > + Regs.X.BX =3D (UINT16) 0x3; // Region > >=20 > >=20 > > According to the spec: > >=20 > > ''' > > BX =3D Allocation region > > 00 =3D Allocate from either 0xE0000 or 0xF0000 64 KB blocks. > > Bit 0 =3D 1 Allocate from 0xF0000 64 KB block > > Bit 1 =3D 1 Allocate from 0xE0000 64 KB block > > ''' > >=20 > > I think the value 0 for BX is fine which indicates the allocation can > > happen in either ranges. Not sure if setting BX to 0x11 is a valid > > operation. >=20 > Based on the spec you quote, it does seem reasonable to expect that a > CSM should treat 0 the same as 3, but it is possible that some CSM out > there made a silly choice and would blow up on 3. I think it's more likely that a CSM would blow up on zero (no bits set =E2=86=92 no regions to allocate from) than 3. In fact, I just had to doubl= e- check that SeaBIOS does the right thing for BX=3D=3D0. (It does.) In practice, Legacy16GetTableAddress only seems to be called with BX=3D=3D1 or 3, and I haven't seen any calls with 0. The setting of Regs.X.BX in this patch has no observable effect =E2=80=94 i= t was *already* 3 before this call, because whoever used it last happened to leave it like that. Setting it explicitly was just a cleanup to make sure we didn't depend on that any more. > Since David mentioned that bx=3D=3D0 works ok with SeaBIOS CSM, then mayb= e > we should just drop this change? Or, we can add a comment that bx=3D=3D0 > means either the e000 or f000 block? SeaBIOS as CSM will with with *DX* =3D=3D 0, after this goes in: https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/4PHW3O= 3Y3HJFENODFV5INBGDLZMXA5KE/ It does look like it already works with BX=3D=3D0. So I'm not entirely averse to setting it explicitly to 0 instead, if you prefer. I just wanted it to be set explicitly to *something*. --=-LatxWpM1BXF5ULcXODAc Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCCECow ggUcMIIEBKADAgECAhEA4rtJSHkq7AnpxKUY8ZlYZjANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UE BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPTA7BgNVBAMTNENPTU9ETyBSU0EgQ2xpZW50IEF1dGhl bnRpY2F0aW9uIGFuZCBTZWN1cmUgRW1haWwgQ0EwHhcNMTkwMTAyMDAwMDAwWhcNMjIwMTAxMjM1 OTU5WjAkMSIwIAYJKoZIhvcNAQkBFhNkd213MkBpbmZyYWRlYWQub3JnMIIBIjANBgkqhkiG9w0B AQEFAAOCAQ8AMIIBCgKCAQEAsv3wObLTCbUA7GJqKj9vHGf+Fa+tpkO+ZRVve9EpNsMsfXhvFpb8 RgL8vD+L133wK6csYoDU7zKiAo92FMUWaY1Hy6HqvVr9oevfTV3xhB5rQO1RHJoAfkvhy+wpjo7Q cXuzkOpibq2YurVStHAiGqAOMGMXhcVGqPuGhcVcVzVUjsvEzAV9Po9K2rpZ52FE4rDkpDK1pBK+ uOAyOkgIg/cD8Kugav5tyapydeWMZRJQH1vMQ6OVT24CyAn2yXm2NgTQMS1mpzStP2ioPtTnszIQ Ih7ASVzhV6csHb8Yrkx8mgllOyrt9Y2kWRRJFm/FPRNEurOeNV6lnYAXOymVJwIDAQABo4IB0zCC Ac8wHwYDVR0jBBgwFoAUgq9sjPjF/pZhfOgfPStxSF7Ei8AwHQYDVR0OBBYEFLfuNf820LvaT4AK xrGK3EKx1DE7MA4GA1UdDwEB/wQEAwIFoDAMBgNVHRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUF BwMEBggrBgEFBQ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