Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1226505ybt; Thu, 9 Jul 2020 01:40:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmgv5/GdyPZPh3BRkLSm1/TaRjcdhgGGABEzvyqsR0HWV1Mz3UvsUblBeVLLZMJyqKtNaI X-Received: by 2002:aa7:cd50:: with SMTP id v16mr63841118edw.252.1594284059804; Thu, 09 Jul 2020 01:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594284059; cv=none; d=google.com; s=arc-20160816; b=CDf+wUMv4AV08wKjFlvOjLL6sxj6fq6d2sFgRvWolQrfrNIARBXrjDNdsnkWQRMddh 315xYailTd1D9OB64ePWl4P9NNItX1mefWXpRhoHyL8FsPqHlQM92HmZ0++nfVi/uUCv NnzjCQjexmrtvxXN/Rup1UKiJA6oboPuj6wQf6RDHI1iZaQxF1nq/qQ3FysYemq6CL8T uYI0cm5B6e08+W++LvTH9p+ONjlDEXo+zqWMJJ/P4WgqrMdCY+OEb7euOXZ+tEUoMv+m wT7MBFHUVVocK7sS4fDEXPyjYQD8xo2Z35KrrnYKWAkan4qDiyYN/wn0uESXO5DXH0CD XgeA== 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=BjGwmtFb4aSgDIA6X3nm0/6IDp673iLgqaZGjXZlfQg=; b=AFigEpDlEmL+Jll/VGbKVb/Hp/aze1DdRlKtiXgg6pzV2+9jLRyWWy3EJd6KHZYvzB TZMkkIGyBX9AsyiC67FOY4ic61mtyk8R5LKQMS0Yo+c/Wis0puuWUPQK9abKWkqqsGss qdjZZOAz1LmkQ5o23d3EnOz/2LPU/9TdHFImi9VLEF8tfs2He6Kp976XKM/6JW46XJA1 Mrkw/FaH+1f5k+DGYWRBCXbVW4d8H7v/E8lcSndvDWTFft/MSK55kwBINBsPt7AIyvF3 bOkl3PFf0g77TFnZbA3NUNIQomk1DXx41kPlnpCplUAQLGbAl5EirQtX3vNPTRyB4JFz 2ixw== 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 do22si1875860ejc.79.2020.07.09.01.40.36; Thu, 09 Jul 2020 01:40:59 -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 S1726533AbgGIIjg (ORCPT + 99 others); Thu, 9 Jul 2020 04:39:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41962 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbgGIIjf (ORCPT ); Thu, 9 Jul 2020 04:39:35 -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 0698WMR9001243; Thu, 9 Jul 2020 04:39:27 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 325n5xfr89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jul 2020 04:39:27 -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 0698WtY7004285; Thu, 9 Jul 2020 04:39:27 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 325n5xfr7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jul 2020 04:39:27 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0698a6Jp031658; Thu, 9 Jul 2020 08:39:25 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 325k1vgm6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jul 2020 08:39:25 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0698c0Nu62456312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Jul 2020 08:38:01 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EDA04204B; Thu, 9 Jul 2020 08:39:22 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FA6942049; Thu, 9 Jul 2020 08:39:21 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.34.67]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 9 Jul 2020 08:39:21 +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 v5 1/2] virtio: let arch validate VIRTIO features Date: Thu, 9 Jul 2020 10:39:18 +0200 Message-Id: <1594283959-13742-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594283959-13742-1-git-send-email-pmorel@linux.ibm.com> References: <1594283959-13742-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-09_04:2020-07-08,2020-07-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=1 bulkscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007090064 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 --- 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