All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK
@ 2021-09-01 12:58 Thomas Huth
  2021-09-01 13:00 ` David Hildenbrand
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Thomas Huth @ 2021-09-01 12:58 UTC (permalink / raw)
  To: qemu-devel, Matthew Rosato, Eric Farman, Cornelia Huck
  Cc: Halil Pasic, Christian Borntraeger, qemu-s390x,
	Richard Henderson, David Hildenbrand

The PAGE_SIZE macro is causing trouble on Alpine Linux since it
clashes with a macro from a system header there. We already have
the TARGET_PAGE_SIZE, TARGET_PAGE_MASK and TARGET_PAGE_BITS macros
in QEMU anyway, so let's simply replace the PAGE_SIZE, PAGE_MASK
and PAGE_SHIFT macro with their TARGET_* counterparts.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/572
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/s390x/s390-pci-bus.c         | 10 +++++-----
 hw/s390x/s390-pci-inst.c        |  8 ++++----
 hw/s390x/sclp.c                 |  2 +-
 include/hw/s390x/s390-pci-bus.h |  5 +----
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 7db1c5943f..6c0225c3a0 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -330,7 +330,7 @@ static unsigned int calc_sx(dma_addr_t ptr)
 
 static unsigned int calc_px(dma_addr_t ptr)
 {
-    return ((unsigned long) ptr >> PAGE_SHIFT) & ZPCI_PT_MASK;
+    return ((unsigned long) ptr >> TARGET_PAGE_BITS) & ZPCI_PT_MASK;
 }
 
 static uint64_t get_rt_sto(uint64_t entry)
@@ -506,7 +506,7 @@ uint16_t s390_guest_io_table_walk(uint64_t g_iota, hwaddr addr,
     int8_t ett = 1;
     uint16_t error = 0;
 
-    entry->iova = addr & PAGE_MASK;
+    entry->iova = addr & TARGET_PAGE_MASK;
     entry->translated_addr = 0;
     entry->perm = IOMMU_RW;
 
@@ -526,7 +526,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr,
 {
     S390PCIIOMMU *iommu = container_of(mr, S390PCIIOMMU, iommu_mr);
     S390IOTLBEntry *entry;
-    uint64_t iova = addr & PAGE_MASK;
+    uint64_t iova = addr & TARGET_PAGE_MASK;
     uint16_t error = 0;
     IOMMUTLBEntry ret = {
         .target_as = &address_space_memory,
@@ -562,7 +562,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr,
         ret.perm = entry->perm;
     } else {
         ret.iova = iova;
-        ret.addr_mask = ~PAGE_MASK;
+        ret.addr_mask = ~TARGET_PAGE_MASK;
         ret.perm = IOMMU_NONE;
     }
 
@@ -868,7 +868,7 @@ static int s390_pci_msix_init(S390PCIBusDevice *pbdev)
 
     name = g_strdup_printf("msix-s390-%04x", pbdev->uid);
     memory_region_init_io(&pbdev->msix_notify_mr, OBJECT(pbdev),
-                          &s390_msi_ctrl_ops, pbdev, name, PAGE_SIZE);
+                          &s390_msi_ctrl_ops, pbdev, name, TARGET_PAGE_SIZE);
     memory_region_add_subregion(&pbdev->iommu->mr,
                                 pbdev->pci_group->zpci_group.msia,
                                 &pbdev->msix_notify_mr);
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 9ec277d50e..1c8ad91175 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -613,7 +613,7 @@ static uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu,
             .iova = entry->iova,
             .translated_addr = entry->translated_addr,
             .perm = entry->perm,
-            .addr_mask = ~PAGE_MASK,
+            .addr_mask = ~TARGET_PAGE_MASK,
         },
     };
 
@@ -640,7 +640,7 @@ static uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu,
         cache = g_new(S390IOTLBEntry, 1);
         cache->iova = entry->iova;
         cache->translated_addr = entry->translated_addr;
-        cache->len = PAGE_SIZE;
+        cache->len = TARGET_PAGE_SIZE;
         cache->perm = entry->perm;
         g_hash_table_replace(iommu->iotlb, &cache->iova, cache);
         dec_dma_avail(iommu);
@@ -725,8 +725,8 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra)
         while (entry.iova < start && entry.iova < end &&
                (dma_avail > 0 || entry.perm == IOMMU_NONE)) {
             dma_avail = s390_pci_update_iotlb(iommu, &entry);
-            entry.iova += PAGE_SIZE;
-            entry.translated_addr += PAGE_SIZE;
+            entry.iova += TARGET_PAGE_SIZE;
+            entry.translated_addr += TARGET_PAGE_SIZE;
         }
     }
 err:
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index edb6e3ea01..89c30a8a91 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -51,7 +51,7 @@ static bool sccb_verify_boundary(uint64_t sccb_addr, uint16_t sccb_len,
                                  uint32_t code)
 {
     uint64_t sccb_max_addr = sccb_addr + sccb_len - 1;
-    uint64_t sccb_boundary = (sccb_addr & PAGE_MASK) + PAGE_SIZE;
+    uint64_t sccb_boundary = (sccb_addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
 
     switch (code & SCLP_CMD_CODE_MASK) {
     case SCLP_CMDW_READ_SCP_INFO:
diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h
index 49ae9f03d3..aa891c178d 100644
--- a/include/hw/s390x/s390-pci-bus.h
+++ b/include/hw/s390x/s390-pci-bus.h
@@ -81,9 +81,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(S390PCIIOMMU, S390_PCI_IOMMU)
 #define ZPCI_SDMA_ADDR 0x100000000ULL
 #define ZPCI_EDMA_ADDR 0x1ffffffffffffffULL
 
-#define PAGE_SHIFT      12
-#define PAGE_SIZE       (1 << PAGE_SHIFT)
-#define PAGE_MASK       (~(PAGE_SIZE-1))
 #define PAGE_DEFAULT_ACC        0
 #define PAGE_DEFAULT_KEY        (PAGE_DEFAULT_ACC << 4)
 
@@ -137,7 +134,7 @@ enum ZpciIoatDtype {
 
 #define ZPCI_TABLE_BITS         11
 #define ZPCI_PT_BITS            8
-#define ZPCI_ST_SHIFT           (ZPCI_PT_BITS + PAGE_SHIFT)
+#define ZPCI_ST_SHIFT           (ZPCI_PT_BITS + TARGET_PAGE_BITS)
 #define ZPCI_RT_SHIFT           (ZPCI_ST_SHIFT + ZPCI_TABLE_BITS)
 
 #define ZPCI_RTE_FLAG_MASK      0x3fffULL
-- 
2.27.0



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

* Re: [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK
  2021-09-01 12:58 [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK Thomas Huth
@ 2021-09-01 13:00 ` David Hildenbrand
  2021-09-01 13:43 ` Matthew Rosato
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2021-09-01 13:00 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Matthew Rosato, Eric Farman, Cornelia Huck
  Cc: Halil Pasic, Christian Borntraeger, qemu-s390x, Richard Henderson

On 01.09.21 14:58, Thomas Huth wrote:
> The PAGE_SIZE macro is causing trouble on Alpine Linux since it
> clashes with a macro from a system header there. We already have
> the TARGET_PAGE_SIZE, TARGET_PAGE_MASK and TARGET_PAGE_BITS macros
> in QEMU anyway, so let's simply replace the PAGE_SIZE, PAGE_MASK
> and PAGE_SHIFT macro with their TARGET_* counterparts.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/572
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: David Hildenbrand <david@redhat.com>


-- 
Thanks,

David / dhildenb



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

* Re: [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK
  2021-09-01 12:58 [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK Thomas Huth
  2021-09-01 13:00 ` David Hildenbrand
@ 2021-09-01 13:43 ` Matthew Rosato
  2021-09-01 14:00 ` Eric Farman
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Matthew Rosato @ 2021-09-01 13:43 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Eric Farman, Cornelia Huck
  Cc: Halil Pasic, Christian Borntraeger, qemu-s390x,
	Richard Henderson, David Hildenbrand

On 9/1/21 8:58 AM, Thomas Huth wrote:
> The PAGE_SIZE macro is causing trouble on Alpine Linux since it
> clashes with a macro from a system header there. We already have
> the TARGET_PAGE_SIZE, TARGET_PAGE_MASK and TARGET_PAGE_BITS macros
> in QEMU anyway, so let's simply replace the PAGE_SIZE, PAGE_MASK
> and PAGE_SHIFT macro with their TARGET_* counterparts.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/572
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Code looks good, also took it for a quick sanity test with s390x kvm 
host against vfio-pci and virtio-pci, works as expected.  Thanks Thomas!

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>


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

* Re: [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK
  2021-09-01 12:58 [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK Thomas Huth
  2021-09-01 13:00 ` David Hildenbrand
  2021-09-01 13:43 ` Matthew Rosato
@ 2021-09-01 14:00 ` Eric Farman
  2021-09-01 15:27 ` Philippe Mathieu-Daudé
  2021-09-02  3:59 ` Halil Pasic
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Farman @ 2021-09-01 14:00 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Matthew Rosato, Cornelia Huck
  Cc: Halil Pasic, Christian Borntraeger, qemu-s390x,
	Richard Henderson, David Hildenbrand

On Wed, 2021-09-01 at 14:58 +0200, Thomas Huth wrote:
> The PAGE_SIZE macro is causing trouble on Alpine Linux since it
> clashes with a macro from a system header there. We already have
> the TARGET_PAGE_SIZE, TARGET_PAGE_MASK and TARGET_PAGE_BITS macros
> in QEMU anyway, so let's simply replace the PAGE_SIZE, PAGE_MASK
> and PAGE_SHIFT macro with their TARGET_* counterparts.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/572
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Eric Farman <farman@linux.ibm.com>



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

* Re: [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK
  2021-09-01 12:58 [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK Thomas Huth
                   ` (2 preceding siblings ...)
  2021-09-01 14:00 ` Eric Farman
@ 2021-09-01 15:27 ` Philippe Mathieu-Daudé
  2021-09-02  3:59 ` Halil Pasic
  4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-01 15:27 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Matthew Rosato, Eric Farman, Cornelia Huck
  Cc: Halil Pasic, Christian Borntraeger, qemu-s390x,
	Richard Henderson, David Hildenbrand

On 9/1/21 2:58 PM, Thomas Huth wrote:
> The PAGE_SIZE macro is causing trouble on Alpine Linux since it
> clashes with a macro from a system header there. We already have
> the TARGET_PAGE_SIZE, TARGET_PAGE_MASK and TARGET_PAGE_BITS macros
> in QEMU anyway, so let's simply replace the PAGE_SIZE, PAGE_MASK
> and PAGE_SHIFT macro with their TARGET_* counterparts.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/572
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/s390x/s390-pci-bus.c         | 10 +++++-----
>  hw/s390x/s390-pci-inst.c        |  8 ++++----
>  hw/s390x/sclp.c                 |  2 +-
>  include/hw/s390x/s390-pci-bus.h |  5 +----
>  4 files changed, 11 insertions(+), 14 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



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

* Re: [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK
  2021-09-01 12:58 [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK Thomas Huth
                   ` (3 preceding siblings ...)
  2021-09-01 15:27 ` Philippe Mathieu-Daudé
@ 2021-09-02  3:59 ` Halil Pasic
  4 siblings, 0 replies; 6+ messages in thread
From: Halil Pasic @ 2021-09-02  3:59 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Eric Farman, Matthew Rosato, David Hildenbrand, Cornelia Huck,
	Richard Henderson, qemu-devel, Halil Pasic,
	Christian Borntraeger, qemu-s390x

On Wed,  1 Sep 2021 14:58:00 +0200
Thomas Huth <thuth@redhat.com> wrote:

> The PAGE_SIZE macro is causing trouble on Alpine Linux since it
> clashes with a macro from a system header there. We already have
> the TARGET_PAGE_SIZE, TARGET_PAGE_MASK and TARGET_PAGE_BITS macros
> in QEMU anyway, so let's simply replace the PAGE_SIZE, PAGE_MASK
> and PAGE_SHIFT macro with their TARGET_* counterparts.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/572
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>


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

end of thread, other threads:[~2021-09-02  4:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 12:58 [PATCH] s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK Thomas Huth
2021-09-01 13:00 ` David Hildenbrand
2021-09-01 13:43 ` Matthew Rosato
2021-09-01 14:00 ` Eric Farman
2021-09-01 15:27 ` Philippe Mathieu-Daudé
2021-09-02  3:59 ` Halil Pasic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.