Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp295445ybh; Wed, 15 Jul 2020 02:06:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSIKlokaeMIOx8R9GmtGE6f7o6HxuzzDti/STH+d9Q78SCUG5sMkI+yh8MpdRsKt5smBxw X-Received: by 2002:a50:f149:: with SMTP id z9mr8710130edl.167.1594804011362; Wed, 15 Jul 2020 02:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594804011; cv=none; d=google.com; s=arc-20160816; b=O6rQ+8HsQt9jvebqg4J/tFZvYUVF/PBM1sxOTjUcHaex3J8z+AHa25CU8G7hzbOPfg rISGg43q+jA+0QuydWsT0aV7q++V6eTu3w1wkQo5sL+FfZw3oGNNEV+rxiCn/FB4PPJR 8/r/NoGiUh6TEFX48ANx0FArtojl/0/VIzhlwTENOMRgUQgm+vfMe4m4AjLIk/q2XRoS fQUffL5GYv4Qfqj/T4bq3/lvVJYODHhBS+CkqfHyZe4vh1jyvUfnvwALubVZOVqxFUIr b9L6lpwa1NMZ3OyuUoegQ3j8kvnObZSUHzQMvRQwGKG9Xj2IYhRLFOE1yThV3dsv4MWm LRYQ== 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=CcLX92G/U7lVESSJByceudnGHUcvEDwi4QISBSOC8Bk=; b=cmd0h/0jh/QNcJ1RQCrthsbcEQTgXEDD0c9qrpSTD6wvtK413iOOuSyf3JYvRmh5RJ r0inCrnshA0DHM7AbreoxH3pejfRRhbP/1DzwVWxa1MGwd/0tOlXd43sfzjq4/ys08co v0vBfbhNgk97So5nPPjHl+Qep4NUiPLVB/zp7072ereg82Z1FKYyBGC1vDp7osIgoNJG HpqrCJq0oblOb0mE5lbOH78TlkwsqOoBBZ5hfQcAdvsqLZx1GgICFPX8mRmqdVrk3jYf HpF11LGj8YUxZM+yCqU/WTOguWraG4jFh+Qa2+OnXFYuKZLjQiAGQQA6cbPrzGuBZH/2 pUrA== 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 f14si851918ejq.136.2020.07.15.02.06.28; Wed, 15 Jul 2020 02:06:51 -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 S1728479AbgGOIbY (ORCPT + 99 others); Wed, 15 Jul 2020 04:31:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:4290 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726971AbgGOIbY (ORCPT ); Wed, 15 Jul 2020 04:31:24 -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 06F82j8q084016; Wed, 15 Jul 2020 04:31:18 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 329cuk68j6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jul 2020 04:31:17 -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 06F82nk0084470; Wed, 15 Jul 2020 04:31:17 -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 329cuk68gx-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 (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06F8Q8Tu028457; Wed, 15 Jul 2020 08:31:15 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04fra.de.ibm.com with ESMTP id 327527j4b5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jul 2020 08:31:14 +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 06F8VCAS44892268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jul 2020 08:31:12 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F22C252050; Wed, 15 Jul 2020 08:31:11 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.79.52]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 16E0252052; 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 1/2] virtio: let arch validate VIRTIO features Date: Wed, 15 Jul 2020 10:31:08 +0200 Message-Id: <1594801869-13365-2-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 bulkscore=0 adultscore=0 spamscore=0 priorityscore=1501 phishscore=0 malwarescore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 impostorscore=0 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 An architecture may need to validate the VIRTIO devices features based on architecture specifics. Signed-off-by: Pierre Morel Reviewed-by: Cornelia Huck Acked-by: Christian Borntraeger Acked-by: Halil Pasic --- 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..c4e14d46a5b6 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_validate_virtio_features - provide arch specific hook when finalizing + * features for VIRTIO device dev + * @dev: the VIRTIO device being added + * + * Permits the platform to handle architecture-specific requirements when + * device 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