[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 03/10] xen/arm: smmuv3: Ensure queue is read after updating prod pointer
- To: Julien Grall <julien@xxxxxxx>
- From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
- Date: Mon, 5 Sep 2022 10:23:15 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PMk4SVauaH5SMHMK2VVZThaO7HX4T+edUbNHKUIHbnY=; b=SMCcj+5tVpDZ38IpG08vUshpQy/UO7RnCt4W/wva+/YOjPfzdyQCTz+/+2boNxu9TZIok/6V/urxwJ1Si0sQwQp4fFHlc01eXd8EhTd/9E66Wq8+fq17stvP7bBVRP3AAfyNzufbqLvWHjgXV0m23qUTm1V6WvooT4fNJlhHvM4wGe3lBmJ4EyPcYJcqb53JqGXUT0AG4CCNzSrIawYRtdUlH3vouTMDQxySzPjQDr7HJVF4JgIOuTajwnt7Av1iACLVmZNbC0BIxBY6ZdwKiTuYem59jsVASEYdHNPPGi+GslVVYROSmY7yt3aa+NzOk7h9qTjdlqyHIpxnl9RdBg==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PMk4SVauaH5SMHMK2VVZThaO7HX4T+edUbNHKUIHbnY=; b=epgVZuRH4H0AP4QbYiMp3D6wKS6Z7VPTFybShTWs8TkxHzqLWkBw3k9GKgX3jrpAErAg45sf6h+PWAY0x24A16bn9u7Bdj8CG4MDKhVqd5eNsoW/n3w+lYh1flq3Dj5ubGgDGD7SsPRVrOYfOlyQCBGYJHGPapGUDonQv+pEDjgIzlt3xhM+tYlBlxSq3E+l/hJeWBcACLaGMYk0dewJHgBwM5BLNfBEq6g4fQMn72YEVFWJza4KIAxlw2UJllQppNDXl7+4mSzp8q7NbVv179gU3lvO372U4XI1bZL8scKUwP6zn2+nT9elTSmJGNWMIyr4Dn9TzNLxqizcHCHz2A==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=eQ7BizAAR6M48iJ4HXGhISHwMjg0DPp8zslSeuse62jNHchDzP64B1nDNsnYvROc9XdGoOZUeilzbuXMkTo2kMvC72bewEGlRJC3vzm6VD8uOyOcdoWScW8qU7IfdT6YaIwPpbx9yCGbX9+3gAgHZIP1/b9bsh+Xw/rGBLKPvvWxAS3OaA3y7JPZmKFqGxjKqoqNMzSXXXufFGBmBMqfPG8uwxdPKoaz7zuR5dpJ95rFSdKdt8DXMYp+kG0bIq16EC99hZAoMsHy3Il4+IlAPMtKOqQ/p+K1ViwHHC4iSftT3k1T7XlWV972xDjkS876OiA3auyGdEk+lEyGK5eBYQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lq828TaKAiJajCe1r0KFQa1p+VqS5wJ3oqUH5olclae1QZHMsL38zTcap6gTXIio+MDD2w9FcM6qH5usqkuDD+25nTawRSLFQlouIOynj1tVmUIgG2l8R2vATqkGaS338GTdfMQXfDwVADCx28QkjEdAy1dhkL1xtm8umvA31LuAF99gnRi+333IqNavE7idLLz914MZMWtiK7B6fQ9ZAUXi5IajqQJisVhxf3Cg/jUdvxfLgviDo4YygI3iHxd6iSXAWnR6nqIVRh90TrvyTlbQ5jFw6UUOq77i9GubDcDw6Qavb/jP4RTRxMThEekF3/DK9V4OXCVKa3HlT7A3bA==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Rahul Singh <Rahul.Singh@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Zhou Wang <wangzhou1@xxxxxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Will Deacon <will@xxxxxxxxxx>
- Delivery-date: Mon, 05 Sep 2022 10:23:56 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Thread-index: AQHYvtEAS2RWaHYM0E2SfKglZEy6Bq3Mx8YAgAPLlICAAAOLAIAADnwA
- Thread-topic: [PATCH v2 03/10] xen/arm: smmuv3: Ensure queue is read after updating prod pointer
Hi,
> On 5 Sep 2022, at 10:31, Julien Grall <julien@xxxxxxx> wrote:
>
>
>
> On 05/09/2022 10:18, Rahul Singh wrote:
>>> On 3 Sep 2022, at 12:21 am, Stefano Stabellini <sstabellini@xxxxxxxxxx>
>>> wrote:
>>>
>>> On Fri, 2 Sep 2022, Rahul Singh wrote:
>>>> From: Zhou Wang <wangzhou1@xxxxxxxxxxxxx>
>>>>
>>>> Backport Linux commit a76a37777f2c. This is the clean backport without
>>>> any changes.
>>>>
>>>> Reading the 'prod' MMIO register in order to determine whether or
>>>> not there is valid data beyond 'cons' for a given queue does not
>>>> provide sufficient dependency ordering, as the resulting access is
>>>> address dependent only on 'cons' and can therefore be speculated
>>>> ahead of time, potentially allowing stale data to be read by the
>>>> CPU.
>>>>
>>>> Use readl() instead of readl_relaxed() when updating the shadow copy
>>>> of the 'prod' pointer, so that all speculated memory reads from the
>>>> corresponding queue can occur only from valid slots.
>>>>
>>>> Signed-off-by: Zhou Wang <wangzhou1@xxxxxxxxxxxxx>
>>>> Link:
>>>> https://lore.kernel.org/r/1601281922-117296-1-git-send-email-wangzhou1@xxxxxxxxxxxxx
>>>> [will: Use readl() instead of explicit barrier. Update 'cons' side to
>>>> match.]
>>>> Signed-off-by: Will Deacon <will@xxxxxxxxxx>
>>>> Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>>> a76a37777f2c
>>>> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
>>>> ---
>>>> Changes in v2:
>>>> - fix commit msg
>>>> - add _iomb changes also from the origin patch
>>>> ---
>>>> xen/arch/arm/include/asm/system.h | 1 +
>>>> xen/drivers/passthrough/arm/smmu-v3.c | 11 +++++++++--
>>>> 2 files changed, 10 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/xen/arch/arm/include/asm/system.h
>>>> b/xen/arch/arm/include/asm/system.h
>>>> index 65d5c8e423..fe27cf8c5e 100644
>>>> --- a/xen/arch/arm/include/asm/system.h
>>>> +++ b/xen/arch/arm/include/asm/system.h
>>>> @@ -29,6 +29,7 @@
>>>> #endif
>>>>
>>>> #define smp_wmb() dmb(ishst)
>>>> +#define __iomb() dmb(osh)
>>>
>>> We don't have any other #define starting with __ in system.h.
>>> I wonder if we should call this macro differently or simply iomb().
>> I think either iomb() or dma_mb() will be the right name.
>> Please let me know your view on this.
>
> It is not 100% clear why Linux went with __iomb() rather than iomb(). But I
> would prefer to keep the __* version to match Linux.
>
> If the others really want to drop the __. Then I think it should be name
> iomb(). The rationale is while __iomb() is an alias to dma_mb(), the
> __iormb() behaves differently compare to dma_mb() (I haven't into details
> why).
>
> So if it was a read barrier, we would likely want to use the iormb()
> semantic. This will keep the terminology consistent with Linux (even if we
> remove the __).
We need the __iomb as “linux compatibility” in fact so I would suggest for now
to only introduce it at the beginning of smmu-v3.c with other linux
compatibility stuff to prevent adding this to Xen overall.
Cheers
Bertrand
>
> Cheers,
>
> --
> Julien Grall
|