Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp853290ybt; Tue, 7 Jul 2020 01:45:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp6pUED+puxPY3g55PIRpuQl1wLnGve5R0EuHRxXsX/ot06buJxDDO4D7bBuYSPSrB1Ica X-Received: by 2002:a17:906:148a:: with SMTP id x10mr49392711ejc.497.1594111538922; Tue, 07 Jul 2020 01:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594111538; cv=none; d=google.com; s=arc-20160816; b=HTSNaOpdFLQwG9gzzeZsQYdSMIjFCTFPUJNmlAczfX85D94TuXcpcRPDfWNhaUvhFp w9Wulu64r6KQJxc7LKrZpt+x6EwqII2GPrslfbMqzpNSCOZV+PZ1RMkenrhMNPkIh4MZ hefbl1g4hV49Vmb2qPRKnPQvEOGxUuDVlqhak0p50mLIV19TQCE9WdgWYKVYehLyJQZn 5KHvuJyJs2DuD2PQQiJ2LRtyUA9JGaFJvr6j/ZsWCRuh2erIaQG02t73Ub0PvblU/Gg/ 10d13pF6Kk2YBNH/0lzYzv82tWw49LZExitvlkuLKoUGc81klU6s8OOBslDgwFPuhmRz /8kg== 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=D/jS8GI8Z5kQohZw2RFPWk15HOLCRPYndSyhBsE5v/8=; b=vj5CTcob6JLVHo7mOs2BXV/XvkzFETbnm1b7LQgFZoQeuWqYH3J2pe/fxEjXlQovQ3 yFpnvqVd5tlqRpbpk912LYeOcvwsmYul9XCTr6y8YkjSu6ZUmp+PCJ/ek9VXxIwnMTlp KNzvMArluVRRKybqECzuI1tHqUZLEW1VPBQk1Lw8cX7wbC5avhCk2mBgud0VXHZUvr49 Z/Ji4mBS5P0NeBnNLau/SuvYZur7bkDxSJoFZiyokJUoSfa0ln3tZvTmsj9Y2n7BTUDQ yQlPpvRYDuBYeOz7El2+EuTGlOpVy/omP4J6D5QZpJpK5iLeQQTifhTxdLguZkUPrsb7 PFqQ== 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 w17si14888504edx.522.2020.07.07.01.45.15; Tue, 07 Jul 2020 01:45:38 -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 S1727090AbgGGIo7 (ORCPT + 99 others); Tue, 7 Jul 2020 04:44:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:29812 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbgGGIo7 (ORCPT ); Tue, 7 Jul 2020 04:44:59 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0678YDQB105510; Tue, 7 Jul 2020 04:44:52 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32482kn0p1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 04:44:51 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0678a9qW112042; Tue, 7 Jul 2020 04:44:49 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 32482kn0jr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 04:44:49 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0678g2GC016988; Tue, 7 Jul 2020 08:44:43 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04fra.de.ibm.com with ESMTP id 322hd7smhe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 08:44:43 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0678ienT47579346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Jul 2020 08:44:40 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D69AA4069; Tue, 7 Jul 2020 08:44:40 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C3B1A4057; Tue, 7 Jul 2020 08:44:39 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.29.12]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 7 Jul 2020 08:44:39 +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, heiko.carstens@de.ibm.com, gor@linux.ibm.com Subject: [PATCH v4 1/2] virtio: let arch validate VIRTIO features Date: Tue, 7 Jul 2020 10:44:36 +0200 Message-Id: <1594111477-15401-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594111477-15401-1-git-send-email-pmorel@linux.ibm.com> References: <1594111477-15401-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-07_05:2020-07-07,2020-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 clxscore=1015 phishscore=0 suspectscore=1 cotscore=-2147483648 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007070066 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An architecture may need to validate the VIRTIO devices features based on architecture specificities. Signed-off-by: Pierre Morel --- drivers/virtio/virtio.c | 19 +++++++++++++++++++ include/linux/virtio_config.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index a977e32a88f2..3179a8aa76f5 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -167,6 +167,21 @@ void virtio_add_status(struct virtio_device *dev, unsigned int status) } EXPORT_SYMBOL_GPL(virtio_add_status); +/* + * arch_needs_virtio_iommu_platform - provide arch specific hook when finalizing + * features for VIRTIO device dev + * @dev: the VIRTIO device being added + * + * Permits the platform to provide architecture specific functionality when + * devices features are finalized. This is the default implementation. + * Architecture implementations can override this. + */ + +int __weak arch_validate_virtio_features(struct virtio_device *dev) +{ + return 0; +} + int virtio_finalize_features(struct virtio_device *dev) { int ret = dev->config->finalize_features(dev); @@ -176,6 +191,10 @@ int virtio_finalize_features(struct virtio_device *dev) if (ret) return ret; + ret = arch_validate_virtio_features(dev); + if (ret) + return ret; + if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) return 0; diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index bb4cc4910750..3f4117adf311 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -459,4 +459,5 @@ static inline void virtio_cwrite64(struct virtio_device *vdev, _r; \ }) +int arch_validate_virtio_features(struct virtio_device *dev); #endif /* _LINUX_VIRTIO_CONFIG_H */ -- 2.25.1