From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cnGvA-0001J6-TI for mharc-grub-devel@gnu.org; Sun, 12 Mar 2017 23:45:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnGv8-0001Ix-PJ for grub-devel@gnu.org; Sun, 12 Mar 2017 23:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnGv5-0006En-JN for grub-devel@gnu.org; Sun, 12 Mar 2017 23:45:18 -0400 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:33513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cnGv5-0006EY-Aj for grub-devel@gnu.org; Sun, 12 Mar 2017 23:45:15 -0400 Received: by mail-lf0-x242.google.com with SMTP id r36so10886692lfi.0 for ; Sun, 12 Mar 2017 20:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fnajHBvXA4m2NXXu7u+P3UhhXX82DS8M2+EActfOeaY=; b=EMwo7qfdUfBmKxPTLgsxQqV0gq8OLm5dpYz9jUR7EPc+fDic8735dgBRGEu+KOhJ7V SzyyWoS5jJKRgzyFxYFeEjesiUlTYjEMfS4/EZLmagjOCGZ5uq9WwelXqu2hWRS90YgZ iHnhnBer0H+XbZEL7EW1jb/Sg6J0uF4T98cwTKVVIUA6ajuCy5SfbPoSERsiobangI6H OCZauObtg2kJndbTaSf7pDk2itb37NhsW5AjSU+UQl9cJkJ4Jp5E652fkoeVdpmVXXWW Sc/0T5PMrvft8f0hgHTHrsZCirbiVegIAt7+bZAqPfusm0jQhL32RAXgltwQqOThRqyX ECfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fnajHBvXA4m2NXXu7u+P3UhhXX82DS8M2+EActfOeaY=; b=aK3fCPGXB7raZKxRCOfM+fHGtjVrLKrsJUp40BoFXjKlOrNsQ5r4jxk8X8XWnKN/sG BBoFJAhbFRp7lOY5987be+3qwlzHPX6gkexhbI6zfVQCLmF5f+r97BPLFYbaPty5XSQv DJYgivpuz4XmmLkxJTCT+7DClnMWd+rJm9q7tiAun6WXYkacwQFv4807N0+5LP5WPatq OrInshCulm9a7FeBpE+4gDxRy49wEilXyrX6gGa/offXPtzA+dkPMT4Ra97t9LkSWzkZ PIisYQWkP7EcFukFtwCJ9gUDJbs/M2vpJWn06ErHrSFjTcinbtN+az2rpP5ihHWCpQ6J awbQ== X-Gm-Message-State: AMke39m1oRjTCyfL6riwgcgDEv9W9edrwe6KuP1OmSUMO5T93JxchYUGB8sImVUkGxuGVw== X-Received: by 10.46.9.4 with SMTP id 4mr9502925ljj.23.1489376712306; Sun, 12 Mar 2017 20:45:12 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-90-38.pppoe.spdop.ru. [109.252.90.38]) by smtp.gmail.com with ESMTPSA id x190sm3353064lfa.13.2017.03.12.20.45.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Mar 2017 20:45:11 -0700 (PDT) From: Andrei Borzenkov To: grub-devel@gnu.org Cc: jamin.collins@gmail.com Subject: [PATCH] disk/efi: skip iPXE dummy block devices Date: Mon, 13 Mar 2017 06:45:02 +0300 Message-Id: <1489376702-5580-1-git-send-email-arvidjaar@gmail.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::242 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Mar 2017 03:45:19 -0000 iPXE adds Simple File System Protocol to loaded image handle, as side effect it also adds Block IO protocol (according to comments, to work around some bugs in EDK2). GRUB assumes that every device with Block IO is disk and skips network initialization entirely. But iPXE Block IO implementation is just a stub which always fails for every operation so cannot be used. Attempt to detect and skip such devices. We are using media ID which iPXE sets to "iPXE" and block IO size in hope that no real device would announce 1B block ... Closes: 50518 @Vladimir, @Daniel - this is probably 2.02 material. We cannot use any device that advertises block size less than 512B anyway, so it should not cause regression for disk boot. It is my fault, I have seen it earlier but was busy with another problem so just worked around it to continue testing. --- grub-core/disk/efi/efidisk.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 3b79f7b..47a4e99 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -80,6 +80,15 @@ make_devices (void) /* This should not happen... Why? */ continue; + /* iPXE adds stub Block IO protocol to loaded image device handle. It is + completely non-functional and simply returns an error for every method. + So attempt to detect and skip it. Magic number is literal "iPXE" and + check block size as well */ + /* FIXME: shoud we close it? We do not do it elsewhere */ + if (bio->media && bio->media->media_id == 0x69505845U && + bio->media->block_size == 1) + continue; + d = grub_malloc (sizeof (*d)); if (! d) { -- tg: (bcf3c55..) bug/50518 (depends on: master)