From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 CDA753346B4 for ; Fri, 31 Jul 2026 09:38:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785490694; cv=none; b=kC84PGW8/HVBoJiwlm26LEY5UrA7Sz7yHRq76lfEf9bPtVMNGijH0rUAxWxW+oxNvpL3kb7cM6btBaqGs7SybklMy5DrycbVOUwA9707dkF8nHjuqc3Q1JaKOJBflHPStMRqmI3werqVNvBPNTmbREhT2rSrUQV0Dij3lgntXCU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785490694; c=relaxed/simple; bh=2JVB5NHlGcJkRbxyYTYM1W0SpjpRQTNPaqgefsqMK44=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b5pTrof+issGIsB1wkNyvRwUZ0unXR9rYbJpicLRuKBNAJfh1/95TxZpd/swtjIWTWdsNB8Qbv17aCw34RoO+YBnOYc9bd9OfkubVbIsMHvaYExECFQe7Syzs3S+15eKjuhmpFWf1x99MdgihuEDF2dpG8dmL5/dKjxUGUxu4cE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LoOKlSMf; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Tvw5rzR3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LoOKlSMf"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Tvw5rzR3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785490691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XynOkVOU0Sg6QSEg62BZ8juSeRUPNKjmdjv0kL5gaaM=; b=LoOKlSMfxhVPbdfhN0l2DOnpFF7eolzpR1/XfJmqOrcmmPpaZIUTRTUKj2Ck4RS9q2+xLs c0PClRvMujK0Wp2s7OLNRm74ak/LomLtWLrMmOEG0i7lQx4tL66EPsGnruKJYnI8F6P44T D27lwPmRjJny8fEFaxxD95KHcvEg4sQ= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-LNF6tc0bPOafrPCRQNcYiw-1; Fri, 31 Jul 2026 05:38:10 -0400 X-MC-Unique: LNF6tc0bPOafrPCRQNcYiw-1 X-Mimecast-MFC-AGG-ID: LNF6tc0bPOafrPCRQNcYiw_1785490689 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-69c033344cdso710334a12.2 for ; Fri, 31 Jul 2026 02:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1785490689; x=1786095489; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=XynOkVOU0Sg6QSEg62BZ8juSeRUPNKjmdjv0kL5gaaM=; b=Tvw5rzR3YqVSd23egUPUIU/s1JCuFitZbI7iV9s+euhiKc/0fhvVs8yB0brHvU315I b7cMRFCOaHJ7g2z+JjxgF8isZxYk8VXT4Fed8sqztuX9CHq7R0defCkoaq9n2MBBiI3x TLXoJYSu7Em7A7W06uS5ThO73d4hTLuneV/hTqh6YwSTJdyeYlS4xyC1zPLkWWxVSJKx 8Om7IMjxhPFVAX6ETV1VhdD2p+9MUKThZoAnmPUMTwE/siOGvFGmvNyn84clYVdILcfT Bg7dGkFb4YlMs1mbHfO0sbENNLXYl3T2aNWr+U3xRzKFbY+PCkWHT4CXWOjNxRz5nN3n 7nNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785490689; x=1786095489; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XynOkVOU0Sg6QSEg62BZ8juSeRUPNKjmdjv0kL5gaaM=; b=Xi5j1mDaQ2Ttz84isSVCOiF1Mm3FSP5qbtZT6ItQbZwybFEo7uDoVfQ537D6dSlY9S 9d3Si+VFKqzDgOSY2LL/Z3ygM2kQn4MilQi1kvhevOgeOrg0svCOAMPpo5fk+DRVPJKZ I4yaOLek7HNdF8vAp9hgZKLE05hH1gE0yoa+BQMIOhmhddAs0YqRl88IFrR2ALeNXxQO EiBfKNgHbKQ7oH96EecajqDtSrplEWGIPMiERNObu15I6hBhTuu4XJCImIXpzJYAOBpt QwSnk30FDw5zvbF2FsptzhZZoykxvFLZVitAD0sQ2APayk6KDeOlkv1CDtKS1x++NwyM oynQ== X-Forwarded-Encrypted: i=1; AHgh+Rpcg9As1R015W6ITlyeFHAp0YsOsRsLjO69ed05+T5801owRgNOoVu93C57wmIiNi9f5ZvhtFpfWha1Ca4=@vger.kernel.org X-Gm-Message-State: AOJu0YxjELY8wuKOl7mEB1kUlkctLTwu3Hj8n2q4gvtcrJWBufvzQn2P bcY4nVukuUUEDDeBFwjZduE9MZt4gOTDhBbL+jRrwN5vNKMj85xXF5mNrHdmlHwzQMpvejkBrKW MWSQjR9qbza2nIQP3RJ2eYsBxUvYQ7OGzUJUgHGkICmsU8Cdxgl0wrDjqvbR1cx0o4g== X-Gm-Gg: AR+sD13g6nKRZHvH1f3A01mgXQaQakAEAxonVWmskcVWcN9mWFHMjmQfC/m+V7sMJV2 fHkDY+i0unyumtAPYDCVeXMyl/+7nIwkZoGTC5faOxVp1/tUohLl1e9phwEJRejVQWrAaDe4/7G ykryMaVk+fMq1HGJejltePPGtZrjRjcIhz55KbDQ0QmxQelyAHVc8rnE+Dfzd3nX1A44mGjh69i poSngVygslwKY1yGuHUMDWpsDBxRyLOEY35GLvIO8ElQsu+HRjWqYgz8c9+8PD2r8f20YxIianU nXp+5eEpMVZRQqrI5zprQ7WTZN/If2bim14ldtPfAIaZLrHtVwjVl3j88nVvHFZjK07+p/iEYOE 4zgNjDAmhEhhX1P/J3zDUkIw= X-Received: by 2002:a17:907:b046:20b0:c16:16b9:9907 with SMTP id a640c23a62f3a-c1fd1e9acdfmr50313466b.15.1785490689002; Fri, 31 Jul 2026 02:38:09 -0700 (PDT) X-Received: by 2002:a17:907:b046:20b0:c16:16b9:9907 with SMTP id a640c23a62f3a-c1fd1e9acdfmr50311166b.15.1785490688444; Fri, 31 Jul 2026 02:38:08 -0700 (PDT) Received: from redhat.com (ppp-94-66-118-61.home.otenet.gr. [94.66.118.61]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1fd3c5b8c7sm92699366b.9.2026.07.31.02.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2026 02:38:07 -0700 (PDT) Date: Fri, 31 Jul 2026 05:38:04 -0400 From: "Michael S. Tsirkin" To: Jia Jia Cc: stefanha@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vhost/vsock: prevent stale IOTLB after ACCESS_PLATFORM changes Message-ID: <20260731053736-mutt-send-email-mst@kernel.org> References: <20260730104857-mutt-send-email-mst@kernel.org> <20260731044145.1734317-1-physicalmtea@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260731044145.1734317-1-physicalmtea@gmail.com> On Fri, Jul 31, 2026 at 12:41:45PM +0800, Jia Jia wrote: > On Thu, Jul 30, 2026 at 10:51:15AM -0400, Michael S. Tsirkin wrote: > > I don't know if this will break anything. Why not just blow > > out the iotlb? kernel will rebuild it if it needs it afterwards > > for some reason. > > > > This part you are fixing is harmless. Let's make it a separate patch > > and document the motivation. > > Thanks. > > Yes, I considered discarding the IOTLB before choosing -EBUSY. My > hesitation was not about whether it could eventually be rebuilt, but > that doing so would no longer be only a control-plane validation > change. It would modify translation state directly used by running > virtqueues. > > The minimum synchronization I had in mind was roughly: > > vhost_vsock_set_features(features): > mutex_lock(dev.mutex) > > if (!(features & ACCESS_PLATFORM) && dev.iotlb): > lock all vq.mutex in index order > > old = dev.iotlb > dev.iotlb = NULL > > for each vq: > vq.iotlb = NULL > reset vq.meta_iotlb > vq.acked_features = features > > unlock all vq.mutex > vhost_iotlb_free(old) > > ... > > mutex_unlock(dev.mutex) > > The switch has to be serialized against all active VQs. My hesitation > was that this turns VHOST_SET_FEATURES into a datapath synchronization > point: the ioctl may wait for in-flight kick handlers, and rebuilding > an empty IOTLB may stall queues on misses until the translations are > restored. If stopping or flushing the device is also required, the > disruption is larger than a normal feature update. > > I was not sure whether VHOST_SET_FEATURES is expected to impose that > cost on a running device, or whether userspace should quiesce it first. > That is why I chose -EBUSY for v1. If synchronization with active VQs is > the intended behavior here, I can rework the patch accordingly. > > I will also split the existing-IOTLB preservation change into a > separate patch and document its motivation. thanks