Received: by 10.192.165.148 with SMTP id m20csp2452127imm; Sun, 22 Apr 2018 07:20:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx48KT9TDnYHcAhlvti/ezv4tlLpxA3cckZp9dEF+FAXMYMcEMubYYRWhc6HzhXaG5uMgrqBh X-Received: by 2002:a17:902:96a:: with SMTP id 97-v6mr17877239plm.266.1524406831763; Sun, 22 Apr 2018 07:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524406831; cv=none; d=google.com; s=arc-20160816; b=gv2Jy6lc+Wte4bGuapOILEwSpFUGd/U9FXQ+/WdAEVk+2Xujmp18/SyHXIs1eBIx38 N1AMN4BTtfHkSlxlv7uHefSERmEHutFNQto1F2R1PI/sMFO1fu1oPIKuQYgkTuxdtvLd 5zkF/SZYF421tSOZiLRz27ieXrJVqc7qpWIhB99KY59vXQGcRYKAlSl/RsS/mLqSjkQc ScFeB0Uujjj4pMH+aR3X1IfRynekxrAJ3hjvapPN58neBhBq0C6br/bcoicoSZPuk26j BcuBhor1qFbMXhZRFIxGDdu4bgyjMoeLc/5Dqb/u9H/GpePJwUeOIolHs3E8DjlvHA4V 9cqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ZBwvVzSvlsY/ate4wU9NcOBG2+yCN0S5vsoqeTzSvMc=; b=XTmV2lb0Z6FDQNYyqk3txApxcPxoOCqLhju4FzbKhswprC5TzK3ulIWx0eGH8/iR6f EoKoMutHW5aDR+putQnk1G90AqvfbVwCi3F+WC45RU8YEGOxGuN/+cJFt7MfMfw+6er+ 91v/gpU81C0ZxeBMS5iRT375wvkTzPgzl9baW9PcbGnl0tKVAO//93iFC3PB23TAhgM6 TJSz9AFOIAn3FusbgKm/3i2BeNvpHSPZ4KAB1b7sd2fksUsfeOkmWpoXAyR1Ruv/h+8r pdM2y3khOMWhrqyqSMCP7pdRj1wy1BiKv8QktjY5GTBq7V/B9TAHi/okZTz5SVH0mIpW 45oQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q24si9061116pff.13.2018.04.22.07.20.17; Sun, 22 Apr 2018 07:20:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755175AbeDVOTR (ORCPT + 99 others); Sun, 22 Apr 2018 10:19:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59334 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932569AbeDVOTJ (ORCPT ); Sun, 22 Apr 2018 10:19:09 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 616B4D09; Sun, 22 Apr 2018 14:19:08 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Williamson , Eric Auger Subject: [PATCH 4.4 72/97] vfio/pci: Virtualize Maximum Payload Size Date: Sun, 22 Apr 2018 15:53:50 +0200 Message-Id: <20180422135309.188437852@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alex Williamson commit 523184972b282cd9ca17a76f6ca4742394856818 upstream. With virtual PCI-Express chipsets, we now see userspace/guest drivers trying to match the physical MPS setting to a virtual downstream port. Of course a lone physical device surrounded by virtual interconnects cannot make a correct decision for a proper MPS setting. Instead, let's virtualize the MPS control register so that writes through to hardware are disallowed. Userspace drivers like QEMU assume they can write anything to the device and we'll filter out anything dangerous. Since mismatched MPS can lead to AER and other faults, let's add it to the kernel side rather than relying on userspace virtualization to handle it. Signed-off-by: Alex Williamson Reviewed-by: Eric Auger Signed-off-by: Greg Kroah-Hartman --- drivers/vfio/pci/vfio_pci_config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -799,11 +799,13 @@ static int __init init_pci_cap_exp_perm( /* * Allow writes to device control fields, except devctl_phantom, - * which could confuse IOMMU, and the ARI bit in devctl2, which + * which could confuse IOMMU, MPS, which can break communication + * with other physical devices, and the ARI bit in devctl2, which * is set at probe time. FLR gets virtualized via our writefn. */ p_setw(perm, PCI_EXP_DEVCTL, - PCI_EXP_DEVCTL_BCR_FLR, ~PCI_EXP_DEVCTL_PHANTOM); + PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_PAYLOAD, + ~PCI_EXP_DEVCTL_PHANTOM); p_setw(perm, PCI_EXP_DEVCTL2, NO_VIRT, ~PCI_EXP_DEVCTL2_ARI); return 0; }