Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1633855ybt; Mon, 15 Jun 2020 05:41:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfsvtqQKqlOw4GBKs7HmlSHCpn83KxQaSgPXXC/nw+Q2qWH40a5wpyP6Pr71uPitUx3BAX X-Received: by 2002:a17:906:fc20:: with SMTP id ov32mr24149664ejb.531.1592224908133; Mon, 15 Jun 2020 05:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592224908; cv=none; d=google.com; s=arc-20160816; b=FOrxdGAfUcca/3at4IWDoW3N3D4uzjZubbhuM/ch6RXWerrCovwtxuIY9RlzhqgUsL PEoz834a2K0b9aDz3/Q4Rx/sBAhA9UZzMUlZ/J5G98ktx4EbudvMTtDCaDyW/cCpsPF5 7UKrVToIijZDxgn+nsRKwGWZdrI33XU82g3EQ18OKVAAZ5d2C2CXnWxiWpnIYhwDUWdE 4NWGEoAuz8jU7M7lFwCuJ/5SZWYe6DiAlTmorMWw4GzSjiX7tM24hYcBpruhOl27clxT oC1qsI7Nh2ZpOZX7gKdyBa/afXJrKi/oTDiUfo3gbosJQ6KsRjWz6n1ToZQ+O4t/PW3E zcng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7TAxjM4OZGpu31egHmtUjv0murzPgjSuacf8zxvscEY=; b=04hhl0PKiVXgRGAZ3b2SU3fxVs0cpkPjLXCH0rjOkjjm5Q84i2etjC1BM/xXVFf2zb O3tVR6/iWBW0vuRBgVM/LQX6No9sLm9Tgq/B3PNO2wUiKdXXukgbjHsjV/9rG6kd31ES Jb1AeZasfqXed1iQO2buMyMf2gW5W3wgY+TtBq9ip1l9ejPOc18QUejAyrG4qpKL08YA fFM3piDELBCNmPUwmyBKq/ghOhEs2BuLiFle7M3m9W+vfa5AWbqi7O4zTVuqRODFDe2/ z+T3xKyMTsJTzyV39zKsx15FxTh+8C7iwAz1VSO7qNxfKNk+CCS4Du4Oi+ZcsS60ZweX PpQQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si8841393ejj.708.2020.06.15.05.41.25; Mon, 15 Jun 2020 05:41:48 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729931AbgFOMji (ORCPT + 99 others); Mon, 15 Jun 2020 08:39:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:30254 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728326AbgFOMjf (ORCPT ); Mon, 15 Jun 2020 08:39:35 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05FBVRG0024033; Mon, 15 Jun 2020 08:39:32 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 31mx4p2mr6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jun 2020 08:39:32 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05FCCg4K177670; Mon, 15 Jun 2020 08:39:32 -0400 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 31mx4p2mqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jun 2020 08:39:31 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05FCLkmd000950; Mon, 15 Jun 2020 12:39:30 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 31mpe89esy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jun 2020 12:39:29 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05FCdRj463701102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Jun 2020 12:39:27 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27CC3A405F; Mon, 15 Jun 2020 12:39:27 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 959D3A4054; Mon, 15 Jun 2020 12:39:26 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.1.141]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 15 Jun 2020 12:39:26 +0000 (GMT) From: Pierre Morel To: linux-kernel@vger.kernel.org Cc: pasic@linux.ibm.com, borntraeger@de.ibm.com, frankja@linux.ibm.com, mst@redhat.com, jasowang@redhat.com, cohuck@redhat.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v2 1/1] s390: virtio: let arch accept devices without IOMMU feature Date: Mon, 15 Jun 2020 14:39:24 +0200 Message-Id: <1592224764-1258-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1592224764-1258-1-git-send-email-pmorel@linux.ibm.com> References: <1592224764-1258-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-15_01:2020-06-15,2020-06-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 mlxlogscore=906 suspectscore=1 impostorscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 cotscore=-2147483648 spamscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006150093 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An architecture protecting the guest memory against unauthorized host access may want to enforce VIRTIO I/O device protection through the use of VIRTIO_F_IOMMU_PLATFORM. Let's give a chance to the architecture to accept or not devices without VIRTIO_F_IOMMU_PLATFORM. Signed-off-by: Pierre Morel --- arch/s390/mm/init.c | 6 ++++++ drivers/virtio/virtio.c | 9 +++++++++ include/linux/virtio.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 87b2d024e75a..3f04ad09650f 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -46,6 +46,7 @@ #include #include #include +#include pgd_t swapper_pg_dir[PTRS_PER_PGD] __section(.bss..swapper_pg_dir); @@ -162,6 +163,11 @@ bool force_dma_unencrypted(struct device *dev) return is_prot_virt_guest(); } +int arch_needs_iommu_platform(struct virtio_device *dev) +{ + return is_prot_virt_guest(); +} + /* protected virtualization */ static void pv_init(void) { diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index a977e32a88f2..30091089bee8 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -167,6 +167,11 @@ void virtio_add_status(struct virtio_device *dev, unsigned int status) } EXPORT_SYMBOL_GPL(virtio_add_status); +int __weak arch_needs_iommu_platform(struct virtio_device *dev) +{ + return 0; +} + int virtio_finalize_features(struct virtio_device *dev) { int ret = dev->config->finalize_features(dev); @@ -179,6 +184,10 @@ int virtio_finalize_features(struct virtio_device *dev) if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) return 0; + if (arch_needs_iommu_platform(dev) && + !virtio_has_feature(dev, VIRTIO_F_IOMMU_PLATFORM)) + return -EIO; + virtio_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); status = dev->config->get_status(dev); if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) { diff --git a/include/linux/virtio.h b/include/linux/virtio.h index a493eac08393..2c46b310c38c 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -195,4 +195,6 @@ void unregister_virtio_driver(struct virtio_driver *drv); #define module_virtio_driver(__virtio_driver) \ module_driver(__virtio_driver, register_virtio_driver, \ unregister_virtio_driver) + +int arch_needs_iommu_platform(struct virtio_device *dev); #endif /* _LINUX_VIRTIO_H */ -- 2.25.1