Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3617461pxb; Mon, 24 Jan 2022 13:37:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwuSIGwFIAb/qlVNHqsVoNeKeU9jAPkvWOVrSG1RCxejrXffqLEQsZKzG92Ru8rGQlKRWVF X-Received: by 2002:a63:1d5:: with SMTP id 204mr13161620pgb.623.1643060242207; Mon, 24 Jan 2022 13:37:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060242; cv=none; d=google.com; s=arc-20160816; b=wA7AobyZaMNgpVpzY12C9pvmGEQOpulngJQ5lfjlSGUswYS/QK7sq8kQWMqGEcFqyD 4idY5pNGD24bzGM9M5F3qKDmAkXtPmnMnNq8c70r+ivYxPAoBnGZi12gtU9qbnLNV0XM Kt0SFI0fyON1SCBk5tZ2SMmR5NmUdZ+jtNqlIDDtSWp9jTaLvArZdPR0MamPliQN5+al e9Vi3nufw43eksF2+dfO2cqC68RMWA4iS66PTqq/4ycs7PDOOu7C78LVx0YcIQNs/Typ mAL8K1g5eBd9TJy7pgQO2lraSRLtzTobQIkNmVoksHQSusuMF6RmfA3vpvx9hbBK+yLJ gYzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qVy9da6fwdxmUKnpiv6iLSEixvcZNDQKZP1BttUmJTA=; b=VMSnSsSvDfHpQPOQ9RwkD8pOTFlp7y/n0X4ezBmbGU3LoYo4t8Se9al3DC2VrrD+CF ENDCUb7Y4NCEjOJ8EAmPFHmFfpoHHygJWya36Pyc4aRSxszRyXTYFOIBFlDSDYkf2MVB yMGnltk0NmuFvt9z006NzTgSCCsnTpZpbnbsB9FzosfHfCkUdIpAAL+mmL1ajzpkOVgY nn07fT/2EmoLGihOESOZm9dR4bZUgh0+kw4PLZriDuSZ6CYM9SoJK5Htt3mT+Z7H4ZI0 X203BTL/5djh0AqosNfmTcskwMKAZ0n/CDLW/2kJB9Sg9oGTf2ejnhxtnm2MVDmhj6EH gXIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vr8nuGnv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si13966981pgb.725.2022.01.24.13.37.09; Mon, 24 Jan 2022 13:37:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=vr8nuGnv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1448057AbiAXVL4 (ORCPT + 99 others); Mon, 24 Jan 2022 16:11:56 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:40536 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1390341AbiAXUpJ (ORCPT ); Mon, 24 Jan 2022 15:45:09 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 12B4960B21; Mon, 24 Jan 2022 20:45:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E23DCC340E5; Mon, 24 Jan 2022 20:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057108; bh=O/8B47WCHt/7NggE2om+s/HBijeVuMCAcR01gd/vuYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vr8nuGnv8ozx1pGz8sad8Br5TvaFNhMZeZy5wqmhgooetgMwGXW+fiL6pG1+bYydP FwpkRy3q4dQLGAxJ6pfltUBS/uC+jzgqAyE6eav6PMa6v+nSigt8t5ABMZjWdHEv5s b2vjKKJNzqjJTCX1r6Hutz+z+mxlDl9j5ChrKFpo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi Subject: [PATCH 5.15 704/846] PCI: pci-bridge-emul: Properly mark reserved PCIe bits in PCI config space Date: Mon, 24 Jan 2022 19:43:41 +0100 Message-Id: <20220124184125.337976707@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Rohár commit 7b067ac63a5730d2fae18399fed7e45f23d36912 upstream. Some bits in PCI config space are reserved when device is PCIe. Properly define behavior of PCI registers for PCIe emulated bridge and ensure that it would not be possible change these reserved bits. Link: https://lore.kernel.org/r/20211124155944.1290-3-pali@kernel.org Fixes: 23a5fba4d941 ("PCI: Introduce PCI bridge emulated config space common logic") Signed-off-by: Pali Rohár Signed-off-by: Lorenzo Pieralisi Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci-bridge-emul.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) --- a/drivers/pci/pci-bridge-emul.c +++ b/drivers/pci/pci-bridge-emul.c @@ -295,6 +295,27 @@ int pci_bridge_emul_init(struct pci_brid kfree(bridge->pci_regs_behavior); return -ENOMEM; } + /* These bits are applicable only for PCI and reserved on PCIe */ + bridge->pci_regs_behavior[PCI_CACHE_LINE_SIZE / 4].ro &= + ~GENMASK(15, 8); + bridge->pci_regs_behavior[PCI_COMMAND / 4].ro &= + ~((PCI_COMMAND_SPECIAL | PCI_COMMAND_INVALIDATE | + PCI_COMMAND_VGA_PALETTE | PCI_COMMAND_WAIT | + PCI_COMMAND_FAST_BACK) | + (PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK | + PCI_STATUS_DEVSEL_MASK) << 16); + bridge->pci_regs_behavior[PCI_PRIMARY_BUS / 4].ro &= + ~GENMASK(31, 24); + bridge->pci_regs_behavior[PCI_IO_BASE / 4].ro &= + ~((PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK | + PCI_STATUS_DEVSEL_MASK) << 16); + bridge->pci_regs_behavior[PCI_INTERRUPT_LINE / 4].rw &= + ~((PCI_BRIDGE_CTL_MASTER_ABORT | + BIT(8) | BIT(9) | BIT(11)) << 16); + bridge->pci_regs_behavior[PCI_INTERRUPT_LINE / 4].ro &= + ~((PCI_BRIDGE_CTL_FAST_BACK) << 16); + bridge->pci_regs_behavior[PCI_INTERRUPT_LINE / 4].w1c &= + ~(BIT(10) << 16); } if (flags & PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR) {