From patchwork Sun Jun 24 17:29:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 139770 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3124334lji; Sun, 24 Jun 2018 10:29:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKEbIx6M/FWhczr/4wWamkhb7bZkU4UZl7+OZcAhCbNZVENQXEp56jBenrqMrlTSVeHD+RU X-Received: by 2002:a63:383:: with SMTP id 125-v6mr8106513pgd.421.1529861382441; Sun, 24 Jun 2018 10:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529861382; cv=none; d=google.com; s=arc-20160816; b=tli+EHF4D1qGO3evREtnDy3jN0gRYk/I3w1R4d7n4lnKJnRTXMqdoP4zes4hXF4Bda awMSdR84D1rw9Bof0mEr05KpvKJ3L1HF+5WoG0UywDrdRwshemLMCZr4nDRTxesnByEy DcSYUuMwnyVp7qWZuLUS8vjoL7ynftTKVGPKPYWtpFHPgobsB0RCMEcM5Zh2HBGdvxRy x0uOhEQTf1E5Zbfr0QNedPT6VZls4dFQLfG3kskvlEEb7Es9T95WNAmEijhZYJ821OKf FuXAO5NZkmsJLlONrg2hC1s3Dtlnedxc+oWVWxYgCK/1XGPX9qYlsl5+aBT5aK8FUb53 m6/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=I5fbHdxq965Mnki52mv4T+/APIMfaFXxlp7w10rw7cU=; b=DS65EHbtXTX6kxk4ETTiFXskdVkuoEkFd3gzsMAdeTtH0XXxU7zwIRfUJPio1nKxd+ kM6o337Z8fumXqRUJBjf2rEblOSxOx/V8N36g5l635rN4gEFDWtGW9YTqE4abbz3mlir RZKmLNLcJXKJuXRAn+/sm4axmwggABs4wSwGUom6Qb4N/Ev6I5IyDU0QEReA5cP/MAvs LU+fbRCqkbpEsRB1LLXn7WLqgBrGExwxWnaRSAY3h5E65908LUh/LD+0zk3zmZRamsw9 ZT3v6rjTJQbYqXNQCIP7+ClaFp2WQFO22CwXfCAcXPjJy2iSjmVUUiUtzkpGgAJQI+Ci awwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cfWHbglg; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1-v6si1164816plb.152.2018.06.24.10.29.41; Sun, 24 Jun 2018 10:29:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cfWHbglg; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752141AbeFXR3l (ORCPT + 3 others); Sun, 24 Jun 2018 13:29:41 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51460 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751920AbeFXR3k (ORCPT ); Sun, 24 Jun 2018 13:29:40 -0400 Received: by mail-wm0-f67.google.com with SMTP id w137-v6so1448579wmw.1 for ; Sun, 24 Jun 2018 10:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=kSD/0WDVlLhISI1BSt+7g53Wsv2l2gpidMWPMnWi8EY=; b=cfWHbglggcuvGLpnJkv9LVa7Y2slJD8tMGTKOc4LJoZvQrmwZ7vbMCqTE7FXdA/7Dk +pPsaVXE+j1AwFjX6fSW2ac4pxsy7e+GgAZI5zVGt+JuxGz5CatKzys0IYSjlbCLPEWl 0OACvr9pH2bTE0nPdk6fajRzannMBs75czKhk= 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=kSD/0WDVlLhISI1BSt+7g53Wsv2l2gpidMWPMnWi8EY=; b=U1D6rg4g9aQuaZCoANYYc5WbSW+COmmWiSNhbhRDNY3xGBD/8dQAAFhApNabt3w/on wv6hKj/rCriffh5rhK9GdkHHWKyRXsQrFTmGCibaVdSOGY5j6nl5/BiT0cOnnIKKtIU2 lByGcN19WmZdyYrwENbA19uwbH0LI49+K6xLpMqjS0RDM5iBe835HtGLXPaNvF2BcrOt IOzbBJbvvNnBVLbf9u1EctBYUThHHMku5265UhC3KXTun84Q1MSWRAA6IulYfOKuC2Zi FAsBOVU6mbyzyNu1jnYcD2rvFAelJwxxFMSuOfjtv03NzYfgx7wjR6wLbD9qIpgYq4oq Xk7g== X-Gm-Message-State: APt69E1SowQMW2UoGnQS/dEQZhLbsmaYAPHzyXO5psSzmpE0dehdgdMy 3wwVsPbKQT1m/kLdbL2nJCV5gBc/06U= X-Received: by 2002:a1c:cc08:: with SMTP id h8-v6mr6773964wmb.82.1529861379063; Sun, 24 Jun 2018 10:29:39 -0700 (PDT) Received: from rev02.home ([2a01:cb1d:112:6f00:d8b7:257f:4347:bb41]) by smtp.gmail.com with ESMTPSA id b16-v6sm23416152wrm.15.2018.06.24.10.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jun 2018 10:29:38 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: Ard Biesheuvel , Wilfried Klaebe , Ingo Molnar , Thomas Gleixner , Lukas Wunner , Hans de Goede Subject: [RFC PATCH] x86/efi: remove pointless call to PciIo->Attributes() Date: Sun, 24 Jun 2018 19:29:22 +0200 Message-Id: <20180624172922.32698-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org When it was first introduced, the EFI stub code that copies the contents of PCI option ROMs originally only intended to do so if the EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM attribute was *not* set. The reason was that the UEFI spec permits PCI option ROM images to be provided by the platform directly, rather than via the ROM BAR, and in this case, the OS can only access them at runtime if they are preserved at boot time by copying them from the areas described by PciIo->RomImage and PciIo->RomSize. However, it implemented this check erroneously, as can be seen in commit dd5fc854de5fd ("EFI: Stash ROMs if they're not in the PCI BAR"): if (!attributes & EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM) continue; and given that the numeric value of EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM is 0x4000, this condition never becomes true, and so the option ROMs were copied unconditionally. This was spotted and 'fixed' by commit 886d751a2ea99a160 ("x86, efi: correct precedence of operators in setup_efi_pci"), but inadvertently inverted the logic at the same time, defeating the purpose of the code, since it now only preserves option ROM images that can be read from the ROM BAR as well. Unsurprisingly, this broke some systems, and so the check was removed entirely in commit 739701888f5d ("x86, efi: remove attribute check from setup_efi_pci"). It is debatable whether this check should have been included in the first place, since the option ROM image provided to the UEFI driver by the firmware may be different from the one that is actually present in the card's flash ROM, and so whatever PciIo->RomImage points at should be preferred regardless of whether the attribute is set. As this was the only use of the attributes field, we can remove the call to PciIo->Attributes() entirely, which is especially nice because its prototype involves uint64_t type by-value arguments which the EFI mixed mode has trouble dealing with. Cc: Wilfried Klaebe Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Lukas Wunner Cc: Hans de Goede Signed-off-by: Ard Biesheuvel --- This should fix the mixed mode issue reported by Hans after my fix for 64-bit native mode was included in v4.18-rc2. arch/x86/boot/compressed/eboot.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Tested-by: Wilfried Klaebe Tested-by: Hans de Goede diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index e57665b4ba1c..e98522ea6f09 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -114,18 +114,12 @@ __setup_efi_pci(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) struct pci_setup_rom *rom = NULL; efi_status_t status; unsigned long size; - uint64_t attributes, romsize; + uint64_t romsize; void *romimage; - status = efi_call_proto(efi_pci_io_protocol, attributes, pci, - EfiPciIoAttributeOperationGet, 0ULL, - &attributes); - if (status != EFI_SUCCESS) - return status; - /* - * Some firmware images contain EFI function pointers at the place where the - * romimage and romsize fields are supposed to be. Typically the EFI + * Some firmware images contain EFI function pointers at the place where + * the romimage and romsize fields are supposed to be. Typically the EFI * code is mapped at high addresses, translating to an unrealistically * large romsize. The UEFI spec limits the size of option ROMs to 16 * MiB so we reject any ROMs over 16 MiB in size to catch this.