qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1
@ 2023-02-14 17:19 Jean-Philippe Brucker
  2023-02-14 17:19 ` [PATCH v2 1/2] hw/arm/smmu-common: Support 64-bit addresses Jean-Philippe Brucker
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jean-Philippe Brucker @ 2023-02-14 17:19 UTC (permalink / raw)
  To: eric.auger
  Cc: peter.maydell, richard.henderson, qemu-devel, qemu-arm,
	ola.hugosson, Jean-Philippe Brucker

Two small changes to support TTB1. Since [v1] I removed the unused
SMMU_MAX_VA_BITS and added tags, thanks!

[v1] https://lore.kernel.org/qemu-devel/20230210163731.970130-1-jean-philippe@linaro.org/

Jean-Philippe Brucker (2):
  hw/arm/smmu-common: Support 64-bit addresses
  hw/arm/smmu-common: Fix TTB1 handling

 include/hw/arm/smmu-common.h | 2 --
 hw/arm/smmu-common.c         | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

-- 
2.39.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] hw/arm/smmu-common: Support 64-bit addresses
  2023-02-14 17:19 [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1 Jean-Philippe Brucker
@ 2023-02-14 17:19 ` Jean-Philippe Brucker
  2023-02-14 18:37   ` Eric Auger
  2023-02-14 17:19 ` [PATCH v2 2/2] hw/arm/smmu-common: Fix TTB1 handling Jean-Philippe Brucker
  2023-02-16 13:53 ` [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1 Peter Maydell
  2 siblings, 1 reply; 5+ messages in thread
From: Jean-Philippe Brucker @ 2023-02-14 17:19 UTC (permalink / raw)
  To: eric.auger
  Cc: peter.maydell, richard.henderson, qemu-devel, qemu-arm,
	ola.hugosson, Jean-Philippe Brucker

Addresses targeting the second translation table (TTB1) in the SMMU have
all upper bits set. Ensure the IOMMU region covers all 64 bits.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 include/hw/arm/smmu-common.h | 2 --
 hw/arm/smmu-common.c         | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
index c5683af07d..9fcff26357 100644
--- a/include/hw/arm/smmu-common.h
+++ b/include/hw/arm/smmu-common.h
@@ -27,8 +27,6 @@
 #define SMMU_PCI_DEVFN_MAX    256
 #define SMMU_PCI_DEVFN(sid)   (sid & 0xFF)
 
-#define SMMU_MAX_VA_BITS      48
-
 /*
  * Page table walk error types
  */
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index 733c964778..2b8c67b9a1 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -439,7 +439,7 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
 
         memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu),
                                  s->mrtypename,
-                                 OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS);
+                                 OBJECT(s), name, UINT64_MAX);
         address_space_init(&sdev->as,
                            MEMORY_REGION(&sdev->iommu), name);
         trace_smmu_add_mr(name);
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] hw/arm/smmu-common: Fix TTB1 handling
  2023-02-14 17:19 [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1 Jean-Philippe Brucker
  2023-02-14 17:19 ` [PATCH v2 1/2] hw/arm/smmu-common: Support 64-bit addresses Jean-Philippe Brucker
@ 2023-02-14 17:19 ` Jean-Philippe Brucker
  2023-02-16 13:53 ` [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1 Peter Maydell
  2 siblings, 0 replies; 5+ messages in thread
From: Jean-Philippe Brucker @ 2023-02-14 17:19 UTC (permalink / raw)
  To: eric.auger
  Cc: peter.maydell, richard.henderson, qemu-devel, qemu-arm,
	ola.hugosson, Jean-Philippe Brucker

Addresses targeting the second translation table (TTB1) in the SMMU have
all upper bits set (except for the top byte when TBI is enabled). Fix
the TTB1 check.

Reported-by: Ola Hugosson <ola.hugosson@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 hw/arm/smmu-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index 2b8c67b9a1..0a5a60ca1e 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -249,7 +249,7 @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova)
         /* there is a ttbr0 region and we are in it (high bits all zero) */
         return &cfg->tt[0];
     } else if (cfg->tt[1].tsz &&
-           !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) {
+        sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) {
         /* there is a ttbr1 region and we are in it (high bits all one) */
         return &cfg->tt[1];
     } else if (!cfg->tt[0].tsz) {
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] hw/arm/smmu-common: Support 64-bit addresses
  2023-02-14 17:19 ` [PATCH v2 1/2] hw/arm/smmu-common: Support 64-bit addresses Jean-Philippe Brucker
@ 2023-02-14 18:37   ` Eric Auger
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Auger @ 2023-02-14 18:37 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: peter.maydell, richard.henderson, qemu-devel, qemu-arm,
	ola.hugosson

Hi Jean,

On 2/14/23 18:19, Jean-Philippe Brucker wrote:
> Addresses targeting the second translation table (TTB1) in the SMMU have
> all upper bits set. Ensure the IOMMU region covers all 64 bits.
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
>  include/hw/arm/smmu-common.h | 2 --
>  hw/arm/smmu-common.c         | 2 +-
>  2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
> index c5683af07d..9fcff26357 100644
> --- a/include/hw/arm/smmu-common.h
> +++ b/include/hw/arm/smmu-common.h
> @@ -27,8 +27,6 @@
>  #define SMMU_PCI_DEVFN_MAX    256
>  #define SMMU_PCI_DEVFN(sid)   (sid & 0xFF)
>  
> -#define SMMU_MAX_VA_BITS      48
> -
>  /*
>   * Page table walk error types
>   */
> diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
> index 733c964778..2b8c67b9a1 100644
> --- a/hw/arm/smmu-common.c
> +++ b/hw/arm/smmu-common.c
> @@ -439,7 +439,7 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
>  
>          memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu),
>                                   s->mrtypename,
> -                                 OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS);
> +                                 OBJECT(s), name, UINT64_MAX);
>          address_space_init(&sdev->as,
>                             MEMORY_REGION(&sdev->iommu), name);
>          trace_smmu_add_mr(name);



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1
  2023-02-14 17:19 [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1 Jean-Philippe Brucker
  2023-02-14 17:19 ` [PATCH v2 1/2] hw/arm/smmu-common: Support 64-bit addresses Jean-Philippe Brucker
  2023-02-14 17:19 ` [PATCH v2 2/2] hw/arm/smmu-common: Fix TTB1 handling Jean-Philippe Brucker
@ 2023-02-16 13:53 ` Peter Maydell
  2 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2023-02-16 13:53 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: eric.auger, richard.henderson, qemu-devel, qemu-arm, ola.hugosson

On Tue, 14 Feb 2023 at 17:21, Jean-Philippe Brucker
<jean-philippe@linaro.org> wrote:
>
> Two small changes to support TTB1. Since [v1] I removed the unused
> SMMU_MAX_VA_BITS and added tags, thanks!
>
> [v1] https://lore.kernel.org/qemu-devel/20230210163731.970130-1-jean-philippe@linaro.org/
>
> Jean-Philippe Brucker (2):
>   hw/arm/smmu-common: Support 64-bit addresses
>   hw/arm/smmu-common: Fix TTB1 handling



Applied to target-arm.next, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-16 13:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-14 17:19 [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1 Jean-Philippe Brucker
2023-02-14 17:19 ` [PATCH v2 1/2] hw/arm/smmu-common: Support 64-bit addresses Jean-Philippe Brucker
2023-02-14 18:37   ` Eric Auger
2023-02-14 17:19 ` [PATCH v2 2/2] hw/arm/smmu-common: Fix TTB1 handling Jean-Philippe Brucker
2023-02-16 13:53 ` [PATCH v2 0/2] hw/arm/smmu: Fixes for TTB1 Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).