From patchwork Sat Jun 23 21:19:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 139767 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2336943lji; Sat, 23 Jun 2018 14:19:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIPepZeqBZEGjrCk9q7LakX2dbE9WfzlivrIEKBIy4CnPmN+iM1cx4gYI8R1p8CG8AAE7pr X-Received: by 2002:a17:902:768a:: with SMTP id m10-v6mr6651452pll.293.1529788779631; Sat, 23 Jun 2018 14:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529788779; cv=none; d=google.com; s=arc-20160816; b=jfjYAPltwWnmtVu5WAzLEIGqBqZb4zA/npK+yE1XJo+lnyZlp2vDG0/r9xVWbmzncZ blvKnmyeydhGI2GNRjM9LUkzoTm9ZzV0MJAML6+OAgIcchjtclpoEOUGfX/XDMGETsBK GaynSImazro4NxDMrlYcVA78lnT1rI4dgo4xhRikRUprDhSPdkQXsW+mEy89nzVoASm6 oluyXbvDWcErZoSXnpku6WpZOLizk9KzrRL6X0PL9kpd7qM1qmMzs7laGpMjSYGdM+Tj ml12HtzJ26VD6J/ZYTR6z4vb8Gxu1kOS7J1mOXaKlUZDcGLnplAuB6QpvegTSccjkkkF +/EQ== 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=VDSeGKkIwy1iBNS6fSfnR+G0A879rVrcYorWv0v1AsI=; b=e6AN9VSLujAnvfPrWjvEAs/aW63qLd5RjS7G3tQKShu0We2MCrogNbMeGm9pKIPnYQ yPZVKM/55EpwepcHLOX7Irq6xJCliVwYF+wh+hqcK6UP3ymkju68rGLmFyUGzSLhS+Ig Zc97ByjTga8l87HuA5KxUnDdyrmxIbIeXIobNPuJRxJIYS9LIXDuUw2rrOckq+XfEz7x ML2RwBWKUD93OT9r5XJh+xWY0lp7nmbJZPjWjW/DCAW6cS4VklcQ6n5uSSTas/3r++r5 20l+SiV7nfp7JyTRAgAP504Lqk24HGfwpxwuH1KKakpPcvrZOdXu7FDBj7ROB9aVqCPp TIUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EAW1X2h6; 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 n9-v6si3385709pgd.541.2018.06.23.14.19.39; Sat, 23 Jun 2018 14:19:39 -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=EAW1X2h6; 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 S1751526AbeFWVTi (ORCPT + 3 others); Sat, 23 Jun 2018 17:19:38 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:45752 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751487AbeFWVTi (ORCPT ); Sat, 23 Jun 2018 17:19:38 -0400 Received: by mail-wr0-f196.google.com with SMTP id s7-v6so628642wro.12 for ; Sat, 23 Jun 2018 14:19:37 -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=dMc0J5U335hQzl5nFMbhH2uIypIjBiullF9ktZ4Mts8=; b=EAW1X2h6/7bC8dnvbUvQfW6fET99KI8bSwrY25YhTNHS9P+t9jh3YmOrqkzjy6UwMo 6Bco3IJMUwU12hEC6d0Czcit7izcgd3Q450IstUhFOcahq8NT3WTqTf4OOVpEfYwzgNK 519yhYYhqo3Av9YmoRETHXRTJuJsRNYicKrjA= 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=dMc0J5U335hQzl5nFMbhH2uIypIjBiullF9ktZ4Mts8=; b=q6GAxkXgSs4QIrLXGvxsbSQyjZtOwttJ8SKe0o4Ka4cZtbzQJGgh9BHYxDXHup/+7J 9EzOfz1khyrA0OrBqRLp6Ulbrv3wMH90a44k+yZjMe6yy40cVsOxZFE+wDiWhCI9fcif pE7I/VD5rPAEWemIHWfPUKDA9KkXhOy7go925B+XJAkmYfg/f5/iTAX2GXaB3pDeboPw 88jfq1Jat58/j+4q8NoUo7WaaEG6i6bWeiuXnl2UgFbwkTS6gRctlLKJteFIpSZ0ZWgu ojet1EBdcpNZnKwJbDbQ1cKKUDRdM97F43v5or6FlbFuGsZFKx/O9lLywhEhR1Z3gHMb XZEQ== X-Gm-Message-State: APt69E2bTiXq/E3p6AAxhHjgU3NzQG73xtmdJCvTi1CiGjEEnlNH6L1Y D5idSUu2zy4rdsYX1+SPKGtoeuhQhTc= X-Received: by 2002:adf:a6b8:: with SMTP id t53-v6mr5820391wrc.45.1529788776693; Sat, 23 Jun 2018 14:19:36 -0700 (PDT) Received: from mba13.home ([2a01:cb1d:112:6f00:9820:9740:2359:e53e]) by smtp.gmail.com with ESMTPSA id l7-v6sm4234921wmh.1.2018.06.23.14.19.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Jun 2018 14:19:35 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@lebenslange-mailadresse.de, mingo@kernel.org, tglx@linutronix.de, hdegoede@redhat.com, Ard Biesheuvel Subject: [PATCH] x86/efi: Fix incorrect invocation of PciIo->Attributes() Date: Sat, 23 Jun 2018 23:19:03 +0200 Message-Id: <20180623211903.4794-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Commit 2c3625cb9fa2 efi/x86: Fold __setup_efi_pci32() and __setup_efi_pci64() into one function merged the two versions of __setup_efi_pciXX(), without taking into account that the 32-bit version used a rather dodgy trick to pass an immediate 0 constant as argument for a uint64_t parameter. The issue is caused by the fact that on x86, UEFI protocol method calls are redirected via struct efi_config::call(), which is a variadic function, and so the compiler has to infer the types of the parameters from the arguments rather than from the prototype. As the 32-bit x86 calling convention passes arguments via the stack, passing the unqualified constant 0 twice is the same as passing 0ULL, which is why the 32-bit code in __setup_efi_pci32() contained the following call: status = efi_early->call(pci->attributes, pci, EfiPciIoAttributeOperationGet, 0, 0, &attributes); to invoke this UEFI protocol method: typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) ( IN EFI_PCI_IO_PROTOCOL *This, IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation, IN UINT64 Attributes, OUT UINT64 *Result OPTIONAL ); After the merge, we inadvertently ended up with this version for both 32-bit and 64-bit builds, breaking the latter. So replace the two zeroes with the explicitly typed constant 0ULL, which works as expected on both 32-bit and 64-bit builds. Reported-by: Wilfried Klaebe Tested-by: Wilfried Klaebe Signed-off-by: Ard Biesheuvel --- Wilfried tested the 64-bit build, and I checked the generated assembly of a 32-bit build with and without this patch, and they are identical. Ingo, mind applying this directly? Thanks. arch/x86/boot/compressed/eboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 -- 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 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index a8a8642d2b0b..e57665b4ba1c 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -118,7 +118,7 @@ __setup_efi_pci(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) void *romimage; status = efi_call_proto(efi_pci_io_protocol, attributes, pci, - EfiPciIoAttributeOperationGet, 0, 0, + EfiPciIoAttributeOperationGet, 0ULL, &attributes); if (status != EFI_SUCCESS) return status;