Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp295053ybh; Wed, 15 Jul 2020 02:06:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEX0WANke4Gtz9ua1pKU3Jir2vyUPsCQtmisJ9cVghePZpzYsD62pFdglhRQDNfhkY6sB8 X-Received: by 2002:a05:6402:c06:: with SMTP id co6mr8645601edb.142.1594803978231; Wed, 15 Jul 2020 02:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594803978; cv=none; d=google.com; s=arc-20160816; b=fzk8JNZvjBNTI2ORvuoOK7DXFuyrKj32jKxiw9DNPFP7UaiVXDAjDwAt7UmJRNUcv7 k39/LMtw7SV5KTbNp3Ekzm28u+D0OD57nLZid6k98uhn4KXrYG2MjvaoK5AC5hQ838Mg D1fF5eawV41poIY3mN6pGesKDCmiisih+05NVroneTcB+PjGWVaeEJK8uioIb7BGzUJz FWXb728u9uMzpgbS4Ovm2OEyUMz4LrAb5Aa42zbfHF3YB9jpV3pQwD4c2ltFC0Z1pNUl sL8XmAQMdcWeTF3WJT9mPOVJGBmwxNZnMoeikXK55w3xKlvnZRsq/J7UIdfybIsEQBms khXA== 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=x5ZXGjKE8gRiSO/YyBtdLkcf+rW6G4UnXr+mAWtR/cM=; b=0L7Py1IE1IJ0r1rOmbVzgKwTyR1H1yX5tQFcgiiO4uBitNLxFK1A6XWhhEAHRHxbc4 v2wNwqvj9EivvPT1dzDa9jqxmXmUYAsmxKM2AcXKnGZZDGbGU5bwFAU+9CxMAHqNGQIz rNeZWjYTKyIp7YLZ6Tv3WPWbpEzOyTLyUw1A8HatNg6uvdJaC12LW/hXyFA6onTwfZoG AuHTGkW4XDwP3/OayMr3uj5YAXdLNL4sPs/zCCLoH6zyZPKX6uqcq/yMSKoucAylZB/3 iKZUh9MXgW8Sn6D2JW3nkcfMHVt/1AaNlgOylWS7qVsqWtVvLBjZd141YWUwHmvP+h1l mhEw== 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 b18si863257eju.78.2020.07.15.02.05.54; Wed, 15 Jul 2020 02:06:18 -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 S1728639AbgGOIbZ (ORCPT + 99 others); Wed, 15 Jul 2020 04:31:25 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:24270 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727925AbgGOIbZ (ORCPT ); Wed, 15 Jul 2020 04:31:25 -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 06F82Ape195078; Wed, 15 Jul 2020 04:31:18 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 329r1hj68q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jul 2020 04:31:18 -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 06F82BB1195254; Wed, 15 Jul 2020 04:31:17 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 329r1hj682-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jul 2020 04:31:17 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06F8Polw007759; Wed, 15 Jul 2020 08:31:16 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04ams.nl.ibm.com with ESMTP id 329nmygdpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jul 2020 08:31:15 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06F8VCiU64618744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jul 2020 08:31:13 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC6F152057; Wed, 15 Jul 2020 08:31:12 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.79.52]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0AF4552054; Wed, 15 Jul 2020 08:31:11 +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, thomas.lendacky@amd.com, david@gibson.dropbear.id.au, linuxram@us.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com Subject: [PATCH v7 2/2] s390: virtio: PV needs VIRTIO I/O device protection Date: Wed, 15 Jul 2020 10:31:09 +0200 Message-Id: <1594801869-13365-3-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594801869-13365-1-git-send-email-pmorel@linux.ibm.com> References: <1594801869-13365-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.235,18.0.687 definitions=2020-07-15_05:2020-07-15,2020-07-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007150063 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If protected virtualization is active on s390, the virtio queues are not accessible to the host, unless VIRTIO_F_IOMMU_PLATFORM has been negotiated. Use the new arch_validate_virtio_features() interface to fail probe if that's not the case, preventing a host error on access attempt. Signed-off-by: Pierre Morel Reviewed-by: Cornelia Huck Acked-by: Halil Pasic Acked-by: Christian Borntraeger --- arch/s390/mm/init.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 6dc7c3b60ef6..d39af6554d4f 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -45,6 +45,7 @@ #include #include #include +#include pgd_t swapper_pg_dir[PTRS_PER_PGD] __section(.bss..swapper_pg_dir); @@ -161,6 +162,33 @@ bool force_dma_unencrypted(struct device *dev) return is_prot_virt_guest(); } +/* + * arch_validate_virtio_features + * @dev: the VIRTIO device being added + * + * Return an error if required features are missing on a guest running + * with protected virtualization. + */ +int arch_validate_virtio_features(struct virtio_device *dev) +{ + if (!is_prot_virt_guest()) + return 0; + + if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) { + dev_warn(&dev->dev, + "legacy virtio not supported with protected virtualization\n"); + return -ENODEV; + } + + if (!virtio_has_feature(dev, VIRTIO_F_IOMMU_PLATFORM)) { + dev_warn(&dev->dev, + "support for limited memory access required for protected virtualization\n"); + return -ENODEV; + } + + return 0; +} + /* protected virtualization */ static void pv_init(void) { -- 2.25.1