Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3131098rwb; Tue, 8 Nov 2022 00:34:55 -0800 (PST) X-Google-Smtp-Source: AMsMyM4oBdUk0hmaZlaYqE1HaNiT2Qsrq43iEV7/azeuHkAUggzuTQgOEEIGiNEv3+0tVUx+Gwqn X-Received: by 2002:a63:9c3:0:b0:46f:897a:78a4 with SMTP id 186-20020a6309c3000000b0046f897a78a4mr43656011pgj.624.1667896495222; Tue, 08 Nov 2022 00:34:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667896495; cv=none; d=google.com; s=arc-20160816; b=gBwvmZYO7m3OMBb3QePFKcWxr/r0kNlZ2/sx8KnyFMfG48Bu6dqXLewrukdvIcDhZM O2Hf1ESh+22nqmX3VWkxv13VBfNS0jgs/dTywH08r7JDfrHfgGPmENpq2Xv1DNOkHJaY tKhLjZrwBktC4Q58NO5xaTbbIIuzdbkGVCr8JWgpLnDXFRbnYUuNbFiWQASRx8rur8ID 6kDDsz9KqqakSPnPGRYB90KuT+nNHdGOL9CgnIdQLFaQxrsdiKZ3tOfsa/4XxYddZsAL kj8Qbn3/C2qUBEZu4aWVlSmZo9gP53xQLUh3y4ItgkGUMIE7j6mmiN+xTCNLnpnPGakO 4r6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:reply-to:user-agent :mime-version:date:message-id:dkim-signature; bh=qMzkFr5wWO2ErYRr9fFrSjmX0hB7P0RxUcl1SJ2pD3Q=; b=lmdiLQnJXjvB4yocMhJDY4Ivqz6Jyx+XudhXSMhNaHFbxb0ePGyUHgYz/ytmJNTIzB FdsIiF6/kgb/+3rcYXXtTZbtCUzRIgR3NXOrFPvSoI3CCmIjEZfVb5awA/SdL46+9i5z Wvvvz2siWXJtZASM8LlvwK7p3vckEUveP0qdEQOsSOXpaqgCxdwnq9jNVi84Hf2EwYuO VWm+pSbRMjtGPuGJJrmcpmgKhf3GWeDFi/mhGJYkpmZG/gaf53EunWEVsFCyX0FSyqa0 wSct1crWfX1EPBDtOVE2VCixOUB9v6KUq9Q33PMp2rdlhbnsc4n/ftketHANAZW3XXj1 sPzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JyOLAYpb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a6551c3000000b004700981177dsi13552831pgq.528.2022.11.08.00.34.40; Tue, 08 Nov 2022 00:34:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JyOLAYpb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233511AbiKHHdA (ORCPT + 90 others); Tue, 8 Nov 2022 02:33:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233517AbiKHHc5 (ORCPT ); Tue, 8 Nov 2022 02:32:57 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50F4E167EE for ; Mon, 7 Nov 2022 23:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667892714; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qMzkFr5wWO2ErYRr9fFrSjmX0hB7P0RxUcl1SJ2pD3Q=; b=JyOLAYpbqNaZdTzilppZo430FuG7OeppYzE7PsHsgjJ4iKmh0zIujvcUEiptcWQ+8aGZ7c Z50xEcFoX7fvNm8PFYTXpZtufIG5pR/TUdLjZ5m+lvUG7PfblDshygub2awXCRcq4rbIK6 vEA2fPT9SpT1BjZDn+getXtUcMzCZyA= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-616-sLd_oTq3NbmOL_jiXycHGQ-1; Tue, 08 Nov 2022 02:31:51 -0500 X-MC-Unique: sLd_oTq3NbmOL_jiXycHGQ-1 Received: by mail-wr1-f69.google.com with SMTP id k1-20020adfb341000000b00238745c9b1aso3607864wrd.5 for ; Mon, 07 Nov 2022 23:31:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qMzkFr5wWO2ErYRr9fFrSjmX0hB7P0RxUcl1SJ2pD3Q=; b=cDACFtYzWviKwVxz17juvWQC59qGtcqcr+cSSUd8eEJmCcOfZsDtRcIrsLjOKDuDGa sh/3esAIdCdg4vkER4zc82qBgGJxCxEN0N+mVZD13cha7FbLaYx7o4MwNJf5bNDnt8cw op4aiUSFxIDDuVV/hWxCmWhnvadS7CoRsSlFi8sf3zhW6ucXUxmKupROQ5liwkAp2YVN HOmt2yJ/k47TpDHY3lkHWEf37TNkFGSZBPN3bD6RS9DAXMRVCZrI3fJNJBNO0u3StUo6 IeLLVPR4cMQamFd1EOLAMk920sJQLNPOsRAT2EWWjxGwQiIjr3SOENUyeYHWKYlTlocD MI0g== X-Gm-Message-State: ANoB5pn9VPeAM705rCQfrCvc3u+cDco/Da9+qpgIU72UFwyQr7mC5Uxu lVcRNSiYaVeOUCm3A/g7n8/AumwKkOWLnmUx7mOLOoYsx4mUKVeS2Ps30BaVutYEaXwgwSaJx1/ yDhlpKY7leyqQY1MFNeu+O3ud X-Received: by 2002:a1c:a1c4:0:b0:3cf:a616:cc8d with SMTP id k187-20020a1ca1c4000000b003cfa616cc8dmr8088678wme.62.1667892710086; Mon, 07 Nov 2022 23:31:50 -0800 (PST) X-Received: by 2002:a1c:a1c4:0:b0:3cf:a616:cc8d with SMTP id k187-20020a1ca1c4000000b003cfa616cc8dmr8088667wme.62.1667892709861; Mon, 07 Nov 2022 23:31:49 -0800 (PST) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id p4-20020a05600c1d8400b003b497138093sm10405740wms.47.2022.11.07.23.31.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Nov 2022 23:31:49 -0800 (PST) Message-ID: Date: Tue, 8 Nov 2022 08:31:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Reply-To: eric.auger@redhat.com Subject: Re: [RFC] vhost: Clear the pending messages on vhost_init_device_iotlb() Content-Language: en-US To: Jason Wang , "Michael S. Tsirkin" Cc: eric.auger.pro@gmail.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, peterx@redhat.com References: <20221107203431.368306-1-eric.auger@redhat.com> <20221107153924-mutt-send-email-mst@kernel.org> <20221107180022-mutt-send-email-mst@kernel.org> From: Eric Auger In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/8/22 04:09, Jason Wang wrote: > On Tue, Nov 8, 2022 at 7:06 AM Michael S. Tsirkin wrote: >> On Mon, Nov 07, 2022 at 10:10:06PM +0100, Eric Auger wrote: >>> Hi Michael, >>> On 11/7/22 21:42, Michael S. Tsirkin wrote: >>>> On Mon, Nov 07, 2022 at 09:34:31PM +0100, Eric Auger wrote: >>>>> When the vhost iotlb is used along with a guest virtual iommu >>>>> and the guest gets rebooted, some MISS messages may have been >>>>> recorded just before the reboot and spuriously executed by >>>>> the virtual iommu after the reboot. Despite the device iotlb gets >>>>> re-initialized, the messages are not cleared. Fix that by calling >>>>> vhost_clear_msg() at the end of vhost_init_device_iotlb(). >>>>> >>>>> Signed-off-by: Eric Auger >>>>> --- >>>>> drivers/vhost/vhost.c | 1 + >>>>> 1 file changed, 1 insertion(+) >>>>> >>>>> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c >>>>> index 40097826cff0..422a1fdee0ca 100644 >>>>> --- a/drivers/vhost/vhost.c >>>>> +++ b/drivers/vhost/vhost.c >>>>> @@ -1751,6 +1751,7 @@ int vhost_init_device_iotlb(struct vhost_dev *d, bool enabled) >>>>> } >>>>> >>>>> vhost_iotlb_free(oiotlb); >>>>> + vhost_clear_msg(d); >>>>> >>>>> return 0; >>>>> } >>>> Hmm. Can't messages meanwhile get processes and affect the >>>> new iotlb? >>> Isn't the msg processing stopped at the moment this function is called >>> (VHOST_SET_FEATURES)? >>> >>> Thanks >>> >>> Eric >> It's pretty late here I'm not sure. You tell me what prevents it. > So the proposed code assumes that Qemu doesn't process device IOTLB > before VHOST_SET_FEAETURES. Consider there's no reset in the general > vhost uAPI, I wonder if it's better to move the clear to device code > like VHOST_NET_SET_BACKEND. So we can clear it per vq? OK I will look at this alternative > >> BTW vhost_init_device_iotlb gets enabled parameter but ignores >> it, we really should drop that. > Yes. Yes I saw that too. I will send a patch. > >> Also, it looks like if features are set with VIRTIO_F_ACCESS_PLATFORM >> and then cleared, iotlb is not properly cleared - bug? > Not sure, old IOTLB may still work. But for safety, we need to disable > device IOTLB in this case. OK Thanks Eric > > Thanks > >> >>>> >>>>> -- >>>>> 2.37.3