From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from ws5-mx01.kavi.com (ws5-mx01.kavi.com [34.193.7.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14926C46CA1 for ; Mon, 18 Sep 2023 14:03:11 +0000 (UTC) Received: from lists.oasis-open.org (oasis.ws5.connectedcommunity.org [10.110.1.242]) by ws5-mx01.kavi.com (Postfix) with ESMTP id 71C4D7E988 for ; Mon, 18 Sep 2023 14:03:11 +0000 (UTC) Received: from lists.oasis-open.org (oasis-open.org [10.110.1.242]) by lists.oasis-open.org (Postfix) with ESMTP id 55BC0986466 for ; Mon, 18 Sep 2023 14:03:11 +0000 (UTC) Received: from host09.ws5.connectedcommunity.org (host09.ws5.connectedcommunity.org [10.110.1.97]) by lists.oasis-open.org (Postfix) with QMQP id 3CD879863D8; Mon, 18 Sep 2023 14:03:11 +0000 (UTC) Mailing-List: contact virtio-dev-help@lists.oasis-open.org; run by ezmlm List-ID: Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Received: from lists.oasis-open.org (oasis-open.org [10.110.1.242]) by lists.oasis-open.org (Postfix) with ESMTP id 2CF309863D7; Mon, 18 Sep 2023 14:03:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at kavi.com X-IronPort-AV: E=Sophos;i="6.02,156,1688428800"; d="scan'208";a="239337058" Message-ID: Date: Mon, 18 Sep 2023 16:02:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "Michael S. Tsirkin" CC: , , "Cali, Marco" , "Graf (AWS), Alexander" , "Jason A. Donenfeld" , References: <20221121162756.350032-1-mst@redhat.com> <20221121162756.350032-4-mst@redhat.com> <0abb7518-16e0-4227-bfe1-a29bd27124e8@amazon.es> <20230912170032-mutt-send-email-mst@kernel.org> <20230913053707-mutt-send-email-mst@kernel.org> <20230918083722-mutt-send-email-mst@kernel.org> <20230918091506-mutt-send-email-mst@kernel.org> From: Babis Chalios Autocrypt: addr=bchalios@amazon.es; keydata= xsFNBGIonY4BEACl1/Qf/fYoDawcFfvjckR5H2yDxlBvKoFT4m5KYiRUivcf5nwCijrM3Fij d38MBpMb9kvwN7lAXOXPCBZMhaNH3J3NuFpUCIZ+UZtf5JgDGiKd/Obli/c0m+7du8wEysCD Z1ldpDeW3c9aENw/uUChQkTEEh0Cmj83uVYEz+BMJKmeA/1Qz0kzGp/MkW8mZYVY5ts4PcBq UmH8Qm5x9NqspTMqIj/yUyxFgxRcKzBOPCF7KiabuCNGCWJAL3EN4SQIQ4MsLBJOSyk5RazC 5x4Vdt9+oCq+jD6H5S19FBSiXKDZCFitIQYd9Xj3Stw6jgrObWrn4ll3aT/XCMYF0Ja8x9+S /UfYEGEPOJkrelKqAu1721LcBwG1rPp12uzyTmtwWBIeDp15/ZnxZ5IG1HuNSsoZzjjnhiLY ECfIymLMya2ofSk4ENCbAdmCAmuI5Fe5ZcUR5zjKHIN5aTgPYEf0H17iZMZlhJ7tAFFKnaGR gMzPiJaff1B8fJjaRd6S73f+4hK0elXAAphoeg8nM2EQQAEzIqSocAZgiktsTbfDSuvCFjrc NP3/R5gWdJDbhlMGP+bhs6HclywzkahskxEQtHo4C1tjP5XFxmUhYlJWJHncDJa4jlouo3zo 1h1NE3OPbT1HDj8O69GXcNZop10hMbnlrIYb3HfJEpTIudYPGwARAQABzSJCYWJpcyBDaGFs aW9zIDxiY2hhbGlvc0BhbWF6b24uZXM+wsGSBBMBCAA8FiEEDnV+NQfr1LBsLB/GjBB7GAqe ZsQFAmIonY4CGwMFCwkIBwIDIgIBBhUKCQgLAgQWAgMBAh4HAheAAAoJEIwQexgKnmbEK2AP /3E4c+xwberE/Sczr5YtO2NZDOnJ0ksumNBJYwJxVNvZEKG1tzJ03oxAE7v0xNylC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CeJSYZxpPILdCVWn tntD+h22IJFHgXihCYPYkHa//Nyb2+Alh2hBsRulQWNRyubG+HZvW/Mre7kyVbJi+ajEkx6K /pbxWbJlDp2ozgnDRTf+7/xCKVP9jO2Y6JjrRx8WAlqYSjK16ML9w1hxZepekeOXhNxGxhEH Z5lzVEVdbHQUN69ZFOcjZnf87vMZBcPxzebcydzRs96CFYsEkT34C9SnElejzuNmN5fMfrJ9 713Mj0/MdpcjPwARAQABwsF2BBgBCAAgFiEEDnV+NQfr1LBsLB/GjBB7GAqeZsQFAmIonY4C GwwACgkQjBB7GAqeZsR2Lg/8CIRvePonn3me+500Zdyv3Z3yaIkHv9mArCLPOzh0mhwrWQWh e5oLnTx51ynU5kUow0i3Owj6xu972naqpV/c0olGdNrwrYboKM3DMHrdZr/pqGhWckU+8S2T uCVB3c/b8YRxqXww5GhwV1WwFC4sndc86tl1yKpxpDdQ858uZYs33Ur+WmxJJQ5BD6sQ48OD 5hEseFrcbikSKk/eVD1FrT3lzbaVqqvQ71soCYYuo2VKxmShuQxUeeFp8hnDw3TR5SO1KJft CT6sQ4dS3vUDeKzVu8E2ofGyOQZ9j6KlFz9daBiRHowFON1vZKS/k8A7ZCZ5Co3Skx538GW8 jDNZJgnSbaam8FVDT1z2H6irmEHz1/vb3hZns0bAmqgwWONTW/gO5jcPbzbTqPfIlmCEtBDf qGaQH7uIyC5kPMTQCNvEMKKn/R2hV3al2/gLvRYFI1GGFE/QdLXiYXmtkDBaz/niHxUUGqO4 LbSF+KYpZYewC8Wx5gTr4Glj+9+RcDWzdkGBd+Kthh0VIOdalbjbnv2jmt5gvLoeLDNpIZRQ AQ+HulTHw5frK1j8+AHIKQYXIE8xXzVkssNuX0Hc7ecC5jm/XlGr5IuQkJpFyVtiXfjkd6tq 9CfKbXmQEUz/yWPkXerBltQSv7ePqJHPFMwJrFAqFftGK6t9nvzGjQB91RM= In-Reply-To: <20230918091506-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.1.212.40] X-ClientProxiedBy: EX19D036UWB001.ant.amazon.com (10.13.139.133) To EX19D037EUB003.ant.amazon.com (10.252.61.119) Subject: Re: [virtio-dev] [PATCH RFC 3/3] rng: leak detection support On 18/9/23 15:58, Michael S. Tsirkin wrote: > On Mon, Sep 18, 2023 at 03:00:43PM +0200, Babis Chalios wrote: >>>> Right, so I think that there is a race condition between the time the driver >>>> sees the used buffers of the first >>>> batch and until it adds the second batch on the next leak queue. >>>> >>>> 1. driver adds batch 1 >>>> 2. leak event >>>> 3. device uses batch 1 >>>> 4. driver sees the used buffers and >>>> a. switches leak queues >>>> b. adds batch 2. >>>> 5. devices finds initial leak queue empty and sees buffers in second leak >>>> queue. >>>> >>>> If a second leak event happens after step 3 above and before all of steps 4 >>>> complete then batch 2 will not >>>> be processed as part of the second leak event. >>> driver can just pre-add buffers in the second queue. >>> >>> 1. available buffers to queue 1-X >>> 2. available buffers to queue X >>> >>> >>> 3. poll queue X >>> 4. used buffers in queue X >>> 5. avail buffers in queue X >>> 6. poll queue 1-X >>> 7. used buffers in queue X >>> 8. avail buffers in queue X >>> 9. goto 3 >>> >> Yes, that's what the driver does now in the RFC patch. However, this just >> decreases >> the race window, it doesn't eliminate it. If a third leak event happens it >> might not >> find any buffers to use: >> >> 1. available buffers to queue 1-X >> 2. available buffers to queue X >> >> >> 3. poll queue X >> 4. used buffers in queue X <- leak event 1 will use buffers in X >> 5. avail buffers in queue X >> 6. poll queue 1-X <- leak event 2 will use buffers in 1-X >> 7. used buffers in queue 1-X >> 8. avail buffers in queue 1-X >> <- leak event 3 (it needs buffers in X, race with step 5) >> 9. goto 3 > > I don't get it. we added buffers in step 5. What if the leak event 3 arrives before step 5 had time to actually add the buffers in X and make them visible to the device? > >> >> If, instead, we define a single leak queue and require that VMM should refuse to take a snapshot >> if that queue is empty, we avoid the race condition in all cases and IMHO the protocol becomes >> much simpler. >> >> >> Cheers, >> Babis >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org > --------------------------------------------------------------------- To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org