From patchwork Wed Jan 10 20:40:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 187073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1044599dyi; Wed, 10 Jan 2024 12:44:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEebRJ8iG++zKfbLyo6q2eGiSDMLJZiXh48o1QsJoYV5E+obY02TN464hpq4fMUdB1RGF68 X-Received: by 2002:aa7:d754:0:b0:558:655d:7219 with SMTP id a20-20020aa7d754000000b00558655d7219mr19920eds.112.1704919494474; Wed, 10 Jan 2024 12:44:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704919494; cv=none; d=google.com; s=arc-20160816; b=De7I8sZMROUQUwRXyLATzAmdDBqddK4vbRInZsh2AXvci5SCk4/kxvBuAF2+2Qk3mk caDVKPPCOkL+O+J2GPBSvxz1plATyHp3j4RQkY56i3qcnBfM9p6Fg0kbnOT54Oe1DONp HxXeaZJwsVMAoSU50Bfd9VWklz4EyoVNKzcH5BljKrm//6L9+o096MTZu+WoabXgcq3x np8GLbeXNy+tP2XcgV6Xm8UkzdXWF3ELxT+wNl+Sh56+vXNPKUV6IoqMqHQlUFbJL3To fTBcEuNuSiZi3AU3hMCSOzRVVkqxIIylI+9sU9CLyLD67Zb4VQSBLf5qQMdoxdq2nYA5 R7/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=89vnNv40odEsIYEKtdQ3B5jHeyloLMbotUzx7nKsXSE=; fh=NLOUc4UpZ/0A9JrieYT9bxhjFpxay5qeZXON7PgxqoM=; b=fXzAQ/6kVWUxjiXX2TrYi9HgaP9uAmooOVXoLCIFzire1g8RgtGocsvWPvawZrirxq s5qBxmfsuZPB0OR0Twm39XAPmnGqPkxRDjO5wEycLLyYW2Rm2nA2eCwThTlKf16yUoDx STOaKbe7QpxHqhqdeBqguaALnRv6CXcIw9WjZ1gq+CmCEfrwy3UJTIF1KeTvgI1EvCGO 2ISngO+jMNtAPxU7713rEFp2StpNb/IFVQIANgCa76dmC/ns1/cQH0ziLoWbae3LtZUi LcqxxRmjPsicehLRgiQezV+DmBK+d6ulUtFMmedhPU2nMB5/Htcotx31yd2JOjtHjfSs xfIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=YBIbjuLQ; spf=pass (google.com: domain of linux-kernel+bounces-22761-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22761-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e10-20020a50d4ca000000b00557dc12f7f7si2058737edj.610.2024.01.10.12.44.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 12:44:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22761-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=YBIbjuLQ; spf=pass (google.com: domain of linux-kernel+bounces-22761-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22761-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0FEE01F232B0 for ; Wed, 10 Jan 2024 20:44:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74A445677D; Wed, 10 Jan 2024 20:40:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YBIbjuLQ" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A1294F885 for ; Wed, 10 Jan 2024 20:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40AJfwkn023889; Wed, 10 Jan 2024 20:40:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=89vnNv40odEsIYEKtdQ3B5jHeyloLMbotUzx7nKsXSE=; b=YBIbjuLQ1HpFrExWVf1gyNml6J1/psthAgyOlc2WnbkasD+qrTiK4Z8BD67l9/t/HBFp CpKg1vk9w5ut+svEjlcV8etkQY189WX4Ng+I3gjXbf46Tnr0cYIT6eEVYxh4vKYVJaQJ EO8OG8eI5eo1SVnuYTxJsM1FI4WS4Cix9PUFr6Hoct1PFVuhIGezEquXgLcYI+Ncx5pO W4Duux6rDeJuV+zbb2jgO863ILhxDXuihnU8T8IgfmS2yCM/iytoud+nrO7HZNk9SmZg qevvN86FKmIYqzQpvHYhGyq1akBBlD00MBVmwN8u0SxFDPmrXDgIB77dh4C+aoXDHQqV Gg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vj1m5r496-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:25 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40AJW0k8030071; Wed, 10 Jan 2024 20:40:24 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vfutp5xbs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:24 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40AKeGrh005067; Wed, 10 Jan 2024 20:40:23 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vfutp5x5e-10; Wed, 10 Jan 2024 20:40:23 +0000 From: Steve Sistare To: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: "Michael S. Tsirkin" , Jason Wang , Si-Wei Liu , Eugenio Perez Martin , Xuan Zhuo , Dragos Tatulea , Eli Cohen , Xie Yongji , Steve Sistare Subject: [RFC V1 09/13] vdpa_sim: reset must not run Date: Wed, 10 Jan 2024 12:40:11 -0800 Message-Id: <1704919215-91319-10-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704919215-91319-1-git-send-email-steven.sistare@oracle.com> References: <1704919215-91319-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-10_10,2024-01-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401100163 X-Proofpoint-ORIG-GUID: q-Rtur_15lquKQ2NCJ_uyoEGBjDEaIDr X-Proofpoint-GUID: q-Rtur_15lquKQ2NCJ_uyoEGBjDEaIDr Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787737663794235448 X-GMAIL-MSGID: 1787737663794235448 vdpasim_do_reset sets running to true, which is wrong, as it allows vdpasim_kick_vq to post work requests before the device has been configured. To fix, do not set running until VIRTIO_CONFIG_S_FEATURES_OK is set. Signed-off-by: Steve Sistare Reviewed-by: Eugenio PĂ©rez --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index be2925d0d283..6304cb0b4770 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -160,7 +160,7 @@ static void vdpasim_do_reset(struct vdpasim *vdpasim, u32 flags) } } - vdpasim->running = true; + vdpasim->running = false; spin_unlock(&vdpasim->iommu_lock); vdpasim->features = 0; @@ -483,6 +483,7 @@ static void vdpasim_set_status(struct vdpa_device *vdpa, u8 status) mutex_lock(&vdpasim->mutex); vdpasim->status = status; + vdpasim->running = (status & VIRTIO_CONFIG_S_FEATURES_OK) != 0; mutex_unlock(&vdpasim->mutex); }