From nobody Sun May 19 05:51:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1595517421; cv=none; d=zohomail.com; s=zohoarc; b=E84VLW/u9P41vlqmE9S+MTeXQW9Oj0h+7zp5eeB1xtH9IaKJN2x2dMTwBy7vv9Quy7miu/Vfl8OnwENvMRzQXqML4V1xV4pn/isgcRcQDyx9mt0eS0sG63YbRVuduVtsKawAPP3TXjfGr7KDDrMNmJlStJbFEfb7BBIUbjfKrKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595517421; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=BW0pCsnpEC9U+LzfECLNkIPToHjS/IxUhT+wjlAueK4=; b=Mrr5rq4kLWaBWhdlhA5vZEY4gTy4k3wkCHliIri0my7cpxBb+X2FhPvVK34SA9GaGu66P6oGxvcHWUMaPE2SEvDdrspsdvt/Sui9M1VMRubrSeR+UXQCSxGbLE3KnlYiUHcv20tIIDnXwOf48teizQ1cDGPi3hmOlrYDtzhHQcM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595517421758450.46751671758557; Thu, 23 Jul 2020 08:17:01 -0700 (PDT) Received: from localhost ([::1]:36878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jycxw-00067U-Jy for importer@patchew.org; Thu, 23 Jul 2020 11:17:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jycvE-0003vA-43; Thu, 23 Jul 2020 11:14:12 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:21626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jycvB-0007UQ-4N; Thu, 23 Jul 2020 11:14:11 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06NF4SBV122100; Thu, 23 Jul 2020 11:14:06 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32fb9b4at0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Jul 2020 11:14:05 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06NF4Vxb122407; Thu, 23 Jul 2020 11:14:05 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 32fb9b4asm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Jul 2020 11:14:05 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06NFB9nC014158; Thu, 23 Jul 2020 15:14:05 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma02wdc.us.ibm.com with ESMTP id 32brq9n8b7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Jul 2020 15:14:04 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06NFDxej25690782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Jul 2020 15:13:59 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D5DC67805F; Thu, 23 Jul 2020 15:14:01 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D228078068; Thu, 23 Jul 2020 15:14:00 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.211.108.134]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 23 Jul 2020 15:14:00 +0000 (GMT) From: Matthew Rosato To: alex.williamson@redhat.com, pmorel@linux.ibm.com, schnelle@linux.ibm.com Subject: [RFC PATCH] s390x/pci: Enforce PCI_COMMAND_MEMORY for vfio-pci Date: Thu, 23 Jul 2020 11:13:56 -0400 Message-Id: <1595517236-17823-2-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1595517236-17823-1-git-send-email-mjrosato@linux.ibm.com> References: <1595517236-17823-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-23_06:2020-07-23, 2020-07-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007230109 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=mjrosato@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/23 10:22:03 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After kernel commit abafbc55 'vfio-pci: Invalidate mmaps and block MMIO access on disabled memory', I'm seeing qemu errors on s390x as vfio-pci devices attempt to read bar 0 because PCI_COMMAND_MEMORY is not reliably set. Ensure the value stays ON while the device is in-use. Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-inst.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 2f7a7d7..74b8796 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -555,6 +555,16 @@ int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint= 8_t r2, uintptr_t ra) } /* len =3D 1,2,4 so we do not need to test */ zpci_endian_swap(&data, len); + + /* + * vfio-pci requires PCI_COMMAND_MEMORY. Ensure that it + * stays on for an active device. + */ + if ((pbdev->fh & FH_SHM_VFIO) && (offset =3D=3D PCI_COMMAND) && + (len =3D=3D 2) && (data !=3D 0)) { + data |=3D PCI_COMMAND_MEMORY; + } + pci_host_config_write_common(pbdev->pdev, offset, pci_config_size(pbdev->pdev), data, len); --=20 1.8.3.1