From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZOQxZ-0008GA-Tx for mharc-grub-devel@gnu.org; Sun, 09 Aug 2015 09:48:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOQxX-0008Fy-HN for grub-devel@gnu.org; Sun, 09 Aug 2015 09:48:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOQxQ-00064K-EB for grub-devel@gnu.org; Sun, 09 Aug 2015 09:48:19 -0400 Received: from mail-lb0-x235.google.com ([2a00:1450:4010:c04::235]:33193) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOQxQ-00062Y-5g for grub-devel@gnu.org; Sun, 09 Aug 2015 09:48:12 -0400 Received: by lbbyj8 with SMTP id yj8so82770911lbb.0 for ; Sun, 09 Aug 2015 06:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=FCsyi+aWE2tvUmJbSwSeFB4AuaX+h6nxsKji4fKFFFw=; b=KcPUBrRQbKnp1GDSOd9xvY7vpFpZYjbLE3yMZl54ch40P0yGOq7SA4Vne3wlou2lx+ JaZryNsrS7L7X9OR8Dx0PBJ3w72T29bBigzzQzAFOhPaCg0582DvXcdyX+GAScpjRafx ByCWov2PlZZ7cl/PQ5q76OeiSEVlDyofJewVROKwsyzYEkqf9XUvOGiL1AgcHn0y3wKe apQa4C904K1PwwWXSBDUZjA+hzWvuvKYFQx+TdtmtY1jrmGLkOWXmvMXxk7zS7jVguQK grDmoMLlm+bygcZwxOzoP3TVjP1ona/iXwytxyrTowiWrO3mWAXTmusJ391Fo9po244o 73Jw== X-Received: by 10.153.8.137 with SMTP id dk9mr16580761lad.57.1439128091174; Sun, 09 Aug 2015 06:48:11 -0700 (PDT) Received: from opensuse.site (ppp91-76-6-204.pppoe.mtu-net.ru. [91.76.6.204]) by smtp.gmail.com with ESMTPSA id ok2sm3511511lbb.0.2015.08.09.06.48.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Aug 2015 06:48:10 -0700 (PDT) Date: Sun, 9 Aug 2015 16:48:05 +0300 From: Andrei Borzenkov To: Josef Bacik Subject: Re: [PATCH V2] efinet: handle get_status() on buggy firmware properly Message-ID: <20150809164805.604ce1fa@opensuse.site> In-Reply-To: <1438883386-3043513-1-git-send-email-jbacik@fb.com> References: <1438799799-32097-1-git-send-email-jbacik@fb.com> <1438883386-3043513-1-git-send-email-jbacik@fb.com> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.28; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::235 Cc: grub-devel@gnu.org, phcoder@gmail.com X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Aug 2015 13:48:21 -0000 =D0=92 Thu, 6 Aug 2015 10:49:46 -0700 Josef Bacik =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > The EFI spec indicates that get_status() should return the address of the= buffer > we passed into transmit to indicate the the buffer was transmitted. Howe= ver we > have boxes where the firmware returns some arbitrary address instead, whi= ch > makes grub think that we've not sent anything. So since we have the SNP = stuff > opened in exclusive mode just assume any non-NULL txbuf means that our tr= ansmit > occurred properly. This makes grub able to do its networking stuff prope= rly on > our broken firmware. Thanks, >=20 Committed. Let's see if someone screams. > cc: Peter Jones > Signed-off-by: Josef Bacik > --- > V1->V2: > -updated the changelog to be more clear about what we are fixing. > -added a comment to the code to indicate why it is safe to only check for > non-NULL txbufs and why we need to do it. >=20 > grub-core/net/drivers/efi/efinet.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) >=20 > diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/e= fi/efinet.c > index f27a117..692d5ad 100644 > --- a/grub-core/net/drivers/efi/efinet.c > +++ b/grub-core/net/drivers/efi/efinet.c > @@ -47,19 +47,19 @@ send_card_buffer (struct grub_net_card *dev, > if (st !=3D GRUB_EFI_SUCCESS) > return grub_error (GRUB_ERR_IO, > N_("couldn't send network packet")); > - if (txbuf =3D=3D dev->txbuf) > + /* > + Some buggy firmware could return an arbitrary address instead of the > + txbuf address we trasmitted, so just check that txbuf is non NULL > + for success. This is ok because we open the SNP protocol in > + exclusive mode so we know we're the only ones transmitting on this > + box and since we only transmit one packet at a time we know our > + transmit was successfull. > + */ > + if (txbuf) > { > dev->txbusy =3D 0; > break; > } > - if (txbuf) > - { > - st =3D efi_call_7 (net->transmit, net, 0, dev->last_pkt_size, > - dev->txbuf, NULL, NULL, NULL); > - if (st !=3D GRUB_EFI_SUCCESS) > - return grub_error (GRUB_ERR_IO, > - N_("couldn't send network packet")); > - } > if (limit_time < grub_get_time_ms ()) > return grub_error (GRUB_ERR_TIMEOUT, > N_("couldn't send network packet")); > @@ -84,8 +84,9 @@ send_card_buffer (struct grub_net_card *dev, > we run in the GRUB_ERR_TIMEOUT case above. > Perhaps a timeout in the FW has discarded the recycle buffer. > */ > + txbuf =3D NULL; > st =3D efi_call_3 (net->get_status, net, 0, &txbuf); > - dev->txbusy =3D !(st =3D=3D GRUB_EFI_SUCCESS && txbuf =3D=3D dev->txbu= f); > + dev->txbusy =3D !(st =3D=3D GRUB_EFI_SUCCESS && txbuf); > =20 > return GRUB_ERR_NONE; > }