Skip to content

Commit ed3288f

Browse files
committed
s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK
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 Message-Id: <[email protected]> Reviewed-by: Halil Pasic <[email protected]> Reviewed-by: Matthew Rosato <[email protected]> Reviewed-by: Eric Farman <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
1 parent c356223 commit ed3288f

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

hw/s390x/s390-pci-bus.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static unsigned int calc_sx(dma_addr_t ptr)
330330

331331
static unsigned int calc_px(dma_addr_t ptr)
332332
{
333-
return ((unsigned long) ptr >> PAGE_SHIFT) & ZPCI_PT_MASK;
333+
return ((unsigned long) ptr >> TARGET_PAGE_BITS) & ZPCI_PT_MASK;
334334
}
335335

336336
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,
506506
int8_t ett = 1;
507507
uint16_t error = 0;
508508

509-
entry->iova = addr & PAGE_MASK;
509+
entry->iova = addr & TARGET_PAGE_MASK;
510510
entry->translated_addr = 0;
511511
entry->perm = IOMMU_RW;
512512

@@ -526,7 +526,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr,
526526
{
527527
S390PCIIOMMU *iommu = container_of(mr, S390PCIIOMMU, iommu_mr);
528528
S390IOTLBEntry *entry;
529-
uint64_t iova = addr & PAGE_MASK;
529+
uint64_t iova = addr & TARGET_PAGE_MASK;
530530
uint16_t error = 0;
531531
IOMMUTLBEntry ret = {
532532
.target_as = &address_space_memory,
@@ -562,7 +562,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr,
562562
ret.perm = entry->perm;
563563
} else {
564564
ret.iova = iova;
565-
ret.addr_mask = ~PAGE_MASK;
565+
ret.addr_mask = ~TARGET_PAGE_MASK;
566566
ret.perm = IOMMU_NONE;
567567
}
568568

@@ -868,7 +868,7 @@ static int s390_pci_msix_init(S390PCIBusDevice *pbdev)
868868

869869
name = g_strdup_printf("msix-s390-%04x", pbdev->uid);
870870
memory_region_init_io(&pbdev->msix_notify_mr, OBJECT(pbdev),
871-
&s390_msi_ctrl_ops, pbdev, name, PAGE_SIZE);
871+
&s390_msi_ctrl_ops, pbdev, name, TARGET_PAGE_SIZE);
872872
memory_region_add_subregion(&pbdev->iommu->mr,
873873
pbdev->pci_group->zpci_group.msia,
874874
&pbdev->msix_notify_mr);

hw/s390x/s390-pci-inst.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ static uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu,
613613
.iova = entry->iova,
614614
.translated_addr = entry->translated_addr,
615615
.perm = entry->perm,
616-
.addr_mask = ~PAGE_MASK,
616+
.addr_mask = ~TARGET_PAGE_MASK,
617617
},
618618
};
619619

@@ -640,7 +640,7 @@ static uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu,
640640
cache = g_new(S390IOTLBEntry, 1);
641641
cache->iova = entry->iova;
642642
cache->translated_addr = entry->translated_addr;
643-
cache->len = PAGE_SIZE;
643+
cache->len = TARGET_PAGE_SIZE;
644644
cache->perm = entry->perm;
645645
g_hash_table_replace(iommu->iotlb, &cache->iova, cache);
646646
dec_dma_avail(iommu);
@@ -725,8 +725,8 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra)
725725
while (entry.iova < start && entry.iova < end &&
726726
(dma_avail > 0 || entry.perm == IOMMU_NONE)) {
727727
dma_avail = s390_pci_update_iotlb(iommu, &entry);
728-
entry.iova += PAGE_SIZE;
729-
entry.translated_addr += PAGE_SIZE;
728+
entry.iova += TARGET_PAGE_SIZE;
729+
entry.translated_addr += TARGET_PAGE_SIZE;
730730
}
731731
}
732732
err:

hw/s390x/sclp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static bool sccb_verify_boundary(uint64_t sccb_addr, uint16_t sccb_len,
5151
uint32_t code)
5252
{
5353
uint64_t sccb_max_addr = sccb_addr + sccb_len - 1;
54-
uint64_t sccb_boundary = (sccb_addr & PAGE_MASK) + PAGE_SIZE;
54+
uint64_t sccb_boundary = (sccb_addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
5555

5656
switch (code & SCLP_CMD_CODE_MASK) {
5757
case SCLP_CMDW_READ_SCP_INFO:

include/hw/s390x/s390-pci-bus.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(S390PCIIOMMU, S390_PCI_IOMMU)
8181
#define ZPCI_SDMA_ADDR 0x100000000ULL
8282
#define ZPCI_EDMA_ADDR 0x1ffffffffffffffULL
8383

84-
#define PAGE_SHIFT 12
85-
#define PAGE_SIZE (1 << PAGE_SHIFT)
86-
#define PAGE_MASK (~(PAGE_SIZE-1))
8784
#define PAGE_DEFAULT_ACC 0
8885
#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
8986

@@ -137,7 +134,7 @@ enum ZpciIoatDtype {
137134

138135
#define ZPCI_TABLE_BITS 11
139136
#define ZPCI_PT_BITS 8
140-
#define ZPCI_ST_SHIFT (ZPCI_PT_BITS + PAGE_SHIFT)
137+
#define ZPCI_ST_SHIFT (ZPCI_PT_BITS + TARGET_PAGE_BITS)
141138
#define ZPCI_RT_SHIFT (ZPCI_ST_SHIFT + ZPCI_TABLE_BITS)
142139

143140
#define ZPCI_RTE_FLAG_MASK 0x3fffULL

0 commit comments

Comments
 (0)