Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1555829pxa; Sun, 2 Aug 2020 11:47:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmnDZWaYK3L5AbMiZ5CKqDZkf3ckowb783r7DnF91kL7eLQP4BaHf9sdbNE5OsLb6orb35 X-Received: by 2002:a17:906:9356:: with SMTP id p22mr13157711ejw.119.1596394074778; Sun, 02 Aug 2020 11:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596394074; cv=none; d=google.com; s=arc-20160816; b=Yjb1pGaDg2QRRhMsiec35u1NF59A1zLiGDlp3dkOIeXZNB5lZDpS7qfMd3dxHdpgLV sQgX77JjSxL6IQ2vv5tNUyoJXoadP9R3NEKJbadhy3NrKBzXVMkl75QbwF4v01dgf2AQ uiZvaP0k5P+Pk3cZlTrAMN6mTIzDmFbKBfwXyzf3Cmd2s7pF36jH7pRsfULq2fuKDz0t SiK2GlKJDyf8rjJ8tKAzBM8oYcVvIlIfsJOUX48v74eR3u2A19tIx2IxqNRs/Y2fKAua qkPPp3ohvK5/+Qn9MKluNyzm95AjTg99ujU4n5InDkM60oyvUyy/bL9EQkvTTjqPeKoo 9N8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6tNJPljLjNx2x9QEIVJnns37NMBlLLp4EAbpTzGkx/k=; b=oSwLUBjpe7s8c+p1wgzpbKr7Fwj/aIQS8S7uibgdzaUmuJuAJ72fyDT0aYFltpNFk4 7r4pIbpdfFTR+RkAUbkDSO2sfKWzR19MYdQ6tC12XARQ3hnpYRE7pGsnUdTg/ywN0zrP HAx2GJZbV5/BzGF4f0H/eCEjvM0ITfBr2WbxjRU6scjvciJfZbAiw9Hb2FCE8qtpbBd9 DKtZ4dLA4EmBRIBRE8H0UecyY/CgrUlUbramuDCEmNrnOIRph/GndbC3J1Xv2uD7hWOd RR55Mb9Hkyqu3M329mAA+HWGuF5c9d7dXCB+k7tw3xxm3bId68hhm8agEqDVPBJQRdrf NBpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=km2ppJ9W; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si4404164eja.673.2020.08.02.11.47.25; Sun, 02 Aug 2020 11:47:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=km2ppJ9W; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726345AbgHBSrX (ORCPT + 99 others); Sun, 2 Aug 2020 14:47:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbgHBSrW (ORCPT ); Sun, 2 Aug 2020 14:47:22 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B30C06174A; Sun, 2 Aug 2020 11:47:22 -0700 (PDT) Received: from nazgul.tnic (unknown [78.130.214.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 6060E1EC027B; Sun, 2 Aug 2020 20:47:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1596394040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=6tNJPljLjNx2x9QEIVJnns37NMBlLLp4EAbpTzGkx/k=; b=km2ppJ9W1lKPkeogNByCZRPPB90pQ77y1xFpzqsz5v2Gw4jUrJuG2BUGC6FlwifBWKp5xA i/pwFuidiFCe1IAhyK7PX67NxCd1gqUPGlQREtpW/WPoHky93LT53Q3Zqf5RRY0CErhAu0 8YCnO7sm9NOsIwnrSCtwGhnf6GzAdAw= Date: Sun, 2 Aug 2020 20:46:48 +0200 From: Borislav Petkov To: Saheed Bolarinwa Cc: trix@redhat.com, helgaas@kernel.org, Kalle Valo , "David S. Miller" , Jakub Kicinski , Wolfgang Grandegger , Marc Kleine-Budde , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Joerg Roedel , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-mtd@lists.infradead.org, iommu@lists.linux-foundation.org, linux-rdma@vger.kernel.org, linux-ide@vger.kernel.org, linux-i2c@vger.kernel.org, linux-hwmon@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-gpio@vger.kernel.org, linux-fpga@vger.kernel.org, linux-edac@vger.kernel.org, dmaengine@vger.kernel.org, linux-crypto@vger.kernel.org, linux-atm-general@lists.sourceforge.net Subject: Re: [RFC PATCH 00/17] Drop uses of pci_read_config_*() return value Message-ID: <20200802184648.GA23190@nazgul.tnic> References: <20200801112446.149549-1-refactormyself@gmail.com> <20200801125657.GA25391@nazgul.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Sun, Aug 02, 2020 at 07:28:00PM +0200, Saheed Bolarinwa wrote: > Because the value ~0 has a meaning to some drivers and only No, ~0 means that the PCI read failed. For *every* PCI device I know. Here's me reading from 0xf0 offset of my hostbridge: # setpci -s 00:00.0 0xf0.l 01000000 That device doesn't have extended config space, so the last valid byte is 0xff. Let's read beyond that: # setpci -s 00:00.0 0x100.l ffffffff > Again, only the drivers can determine if ~0 is a valid value. This > information is not available inside pci_config_read*(). Of course it is. *every* change you've done in 6/17 - this is the only patch I have received - checks for == ~0. So that check can just as well be moved inside pci_config_read_*(). Here's how one could do it: #define PCI_OP_READ(size, type, len) \ int noinline pci_bus_read_config_##size \ (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ { \ int res; \ unsigned long flags; \ u32 data = 0; \ if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ pci_lock_config(flags); \ res = bus->ops->read(bus, devfn, pos, len, &data); \ /* Check we actually read something which is not all 1s.*/ if (data == ~0) return PCIBIOS_READ_FAILED; *value = (type)data; \ pci_unlock_config(flags); \ return res; \ } Also, I'd prefer a function to *not* return void but return either an error or success. In the success case, the @value argument can be consumed by the caller and otherwise not. In any case, that change is a step in the wrong direction and I don't like it, sorry. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette