mbox series

[v4,00/10] xen/arm: smmuv3: Merge Linux fixes to Xen

Message ID cover.1662455798.git.rahul.singh@arm.com (mailing list archive)
Headers show
Series xen/arm: smmuv3: Merge Linux fixes to Xen | expand

Message

Rahul Singh Sept. 6, 2022, 9:55 a.m. UTC
This patch series merge the applicable Linux fixes to Xen.

Bixuan Cui (1):
  xen/arm: smmuv3: Change *array into *const array

Christophe JAILLET (1):
  xen/arm: smmuv3: Avoid open coded arithmetic in memory allocation

Gustavo A. R. Silva (1):
  xen/arm: smmuv3: Fix fall-through warning for Clang

Jean-Philippe Brucker (2):
  xen/arm: smmuv3: Fix endianness annotations
  xen/arm: smmuv3: Move definitions to a header

Robin Murphy (1):
  xen/arm: smmuv3: Remove the page 1 fixup

Zenghui Yu (2):
  xen/arm: smmuv3: Fix l1 stream table size in the error message
  xen/arm: smmuv3: Remove the unused fields for PREFETCH_CONFIG command

Zhen Lei (1):
  xen/arm: smmuv3: Remove unnecessary oom message

Zhou Wang (1):
  xen/arm: smmuv3: Ensure queue is read after updating prod pointer

 xen/drivers/passthrough/arm/smmu-v3.c | 741 ++------------------------
 xen/drivers/passthrough/arm/smmu-v3.h | 672 +++++++++++++++++++++++
 2 files changed, 708 insertions(+), 705 deletions(-)
 create mode 100644 xen/drivers/passthrough/arm/smmu-v3.h

Comments

Bertrand Marquis Sept. 6, 2022, 2:45 p.m. UTC | #1
Hi Rahul,

> On 6 Sep 2022, at 10:55, Rahul Singh <Rahul.Singh@arm.com> wrote:
> 
> From: Zhou Wang <wangzhou1@hisilicon.com>
> 
> Backport Linux commit a76a37777f2c. Introduce __iomb() in the smmu-v3.c
> file with other Linux compatibility definitions.
> 
> 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@hisilicon.com>
> Link: https://lore.kernel.org/r/1601281922-117296-1-git-send-email-wangzhou1@hisilicon.com
> [will: Use readl() instead of explicit barrier. Update 'cons' side to match.]
> Signed-off-by: Will Deacon <will@kernel.org>
> Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a76a37777f2c
> Signed-off-by: Rahul Singh <rahul.singh@arm.com>

Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> Changes in v4:
> - rename iomb() to __iomb()
> Changes in v3:
> - rename __iomb() to iomb() and also move it from common file to
>   smmu-v3.c file
> Changes in v2:
> - fix commit msg
> - add __iomb changes also from the origin patch
> ---
> xen/drivers/passthrough/arm/smmu-v3.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c
> index 64d39bb4d3..229b9a4b0d 100644
> --- a/xen/drivers/passthrough/arm/smmu-v3.c
> +++ b/xen/drivers/passthrough/arm/smmu-v3.c
> @@ -107,6 +107,8 @@ typedef paddr_t		dma_addr_t;
> typedef paddr_t		phys_addr_t;
> typedef unsigned int		gfp_t;
> 
> +#define __iomb()		dmb(osh)
> +
> #define platform_device		device
> 
> #define GFP_KERNEL		0
> @@ -951,7 +953,7 @@ static void queue_sync_cons_out(struct arm_smmu_queue *q)
> 	 * Ensure that all CPU accesses (reads and writes) to the queue
> 	 * are complete before we update the cons pointer.
> 	 */
> -	mb();
> +	__iomb();
> 	writel_relaxed(q->llq.cons, q->cons_reg);
> }
> 
> @@ -963,8 +965,15 @@ static void queue_inc_cons(struct arm_smmu_ll_queue *q)
> 
> static int queue_sync_prod_in(struct arm_smmu_queue *q)
> {
> +	u32 prod;
> 	int ret = 0;
> -	u32 prod = readl_relaxed(q->prod_reg);
> +
> +	/*
> +	 * We can't use the _relaxed() variant here, as we must prevent
> +	 * speculative reads of the queue before we have determined that
> +	 * prod has indeed moved.
> +	 */
> +	prod = readl(q->prod_reg);
> 
> 	if (Q_OVF(prod) != Q_OVF(q->llq.prod))
> 		ret = -EOVERFLOW;
> -- 
> 2.25.1
>
Julien Grall Sept. 6, 2022, 4:49 p.m. UTC | #2
Hi,

On 06/09/2022 10:55, Rahul Singh wrote:
> This patch series merge the applicable Linux fixes to Xen.
> 
> Bixuan Cui (1):
>    xen/arm: smmuv3: Change *array into *const array
> 
> Christophe JAILLET (1):
>    xen/arm: smmuv3: Avoid open coded arithmetic in memory allocation
> 
> Gustavo A. R. Silva (1):
>    xen/arm: smmuv3: Fix fall-through warning for Clang
> 
> Jean-Philippe Brucker (2):
>    xen/arm: smmuv3: Fix endianness annotations
>    xen/arm: smmuv3: Move definitions to a header
> 
> Robin Murphy (1):
>    xen/arm: smmuv3: Remove the page 1 fixup
> 
> Zenghui Yu (2):
>    xen/arm: smmuv3: Fix l1 stream table size in the error message
>    xen/arm: smmuv3: Remove the unused fields for PREFETCH_CONFIG command
> 
> Zhen Lei (1):
>    xen/arm: smmuv3: Remove unnecessary oom message
> 
> Zhou Wang (1):
>    xen/arm: smmuv3: Ensure queue is read after updating prod pointer

I didn't get the full series in my inbox. So I used the branch Bertrand 
pushed on gitlab [1]. That said, I had to tweak all the commit messages 
to remove the tags Issue-Id and Change-Id.

I have also added Bertrand's reviewed-by tag on patch #3.

It is now fully committed.

Cheers,

[1] 
https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc/-/tree/temp/smmuv3-fixes

> 
>   xen/drivers/passthrough/arm/smmu-v3.c | 741 ++------------------------
>   xen/drivers/passthrough/arm/smmu-v3.h | 672 +++++++++++++++++++++++
>   2 files changed, 708 insertions(+), 705 deletions(-)
>   create mode 100644 xen/drivers/passthrough/arm/smmu-v3.h
>
Rahul Singh Sept. 6, 2022, 5:07 p.m. UTC | #3
Hi Julien,

> On 6 Sep 2022, at 5:49 pm, Julien Grall <julien@xen.org> wrote:
> 
> Hi,
> 
> On 06/09/2022 10:55, Rahul Singh wrote:
>> This patch series merge the applicable Linux fixes to Xen.
>> Bixuan Cui (1):
>>   xen/arm: smmuv3: Change *array into *const array
>> Christophe JAILLET (1):
>>   xen/arm: smmuv3: Avoid open coded arithmetic in memory allocation
>> Gustavo A. R. Silva (1):
>>   xen/arm: smmuv3: Fix fall-through warning for Clang
>> Jean-Philippe Brucker (2):
>>   xen/arm: smmuv3: Fix endianness annotations
>>   xen/arm: smmuv3: Move definitions to a header
>> Robin Murphy (1):
>>   xen/arm: smmuv3: Remove the page 1 fixup
>> Zenghui Yu (2):
>>   xen/arm: smmuv3: Fix l1 stream table size in the error message
>>   xen/arm: smmuv3: Remove the unused fields for PREFETCH_CONFIG command
>> Zhen Lei (1):
>>   xen/arm: smmuv3: Remove unnecessary oom message
>> Zhou Wang (1):
>>   xen/arm: smmuv3: Ensure queue is read after updating prod pointer
> 
> I didn't get the full series in my inbox. So I used the branch Bertrand pushed on gitlab [1]. That said, I had to tweak all the commit messages to remove the tags Issue-Id and Change-Id.
> 
> I have also added Bertrand's reviewed-by tag on patch #3.
> 
> It is now fully committed.
 
Thanks for committing the series. 

Regards,
Rahul
Bertrand Marquis Sept. 7, 2022, 7:50 a.m. UTC | #4
Hi Julien

> On 6 Sep 2022, at 17:49, Julien Grall <julien@xen.org> wrote:
> 
> Hi,
> 
> On 06/09/2022 10:55, Rahul Singh wrote:
>> This patch series merge the applicable Linux fixes to Xen.
>> Bixuan Cui (1):
>>   xen/arm: smmuv3: Change *array into *const array
>> Christophe JAILLET (1):
>>   xen/arm: smmuv3: Avoid open coded arithmetic in memory allocation
>> Gustavo A. R. Silva (1):
>>   xen/arm: smmuv3: Fix fall-through warning for Clang
>> Jean-Philippe Brucker (2):
>>   xen/arm: smmuv3: Fix endianness annotations
>>   xen/arm: smmuv3: Move definitions to a header
>> Robin Murphy (1):
>>   xen/arm: smmuv3: Remove the page 1 fixup
>> Zenghui Yu (2):
>>   xen/arm: smmuv3: Fix l1 stream table size in the error message
>>   xen/arm: smmuv3: Remove the unused fields for PREFETCH_CONFIG command
>> Zhen Lei (1):
>>   xen/arm: smmuv3: Remove unnecessary oom message
>> Zhou Wang (1):
>>   xen/arm: smmuv3: Ensure queue is read after updating prod pointer
> 
> I didn't get the full series in my inbox. So I used the branch Bertrand pushed on gitlab [1]. That said, I had to tweak all the commit messages to remove the tags Issue-Id and Change-Id.

Very sorry for that (should never do things in background during meetings).

> 
> I have also added Bertrand's reviewed-by tag on patch #3.
> 
> It is now fully committed.

Thanks a lot
Cheers
Bertrand

> 
> Cheers,
> 
> [1] https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc/-/tree/temp/smmuv3-fixes
> 
>>  xen/drivers/passthrough/arm/smmu-v3.c | 741 ++------------------------
>>  xen/drivers/passthrough/arm/smmu-v3.h | 672 +++++++++++++++++++++++
>>  2 files changed, 708 insertions(+), 705 deletions(-)
>>  create mode 100644 xen/drivers/passthrough/arm/smmu-v3.h
> 
> -- 
> Julien Grall