Skip to content

Commit abf7aee

Browse files
committed
Merge remote-tracking branch 'remotes/thuth-gitlab/tags/s390x-pull-request-2021-09-07' into staging
* Some CSS related fixes * Storage key related fixes * Test SIGILL and SIGSEGV handling in usermode emulation * Fix SETPREFIX instruction * Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK to fix Alpine compilation * Add more feature to gen16 default model # gpg: Signature made Tue 07 Sep 2021 14:07:38 BST # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "[email protected]" # gpg: Good signature from "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [unknown] # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * remotes/thuth-gitlab/tags/s390x-pull-request-2021-09-07: s390x/cpumodel: Add more feature to gen16 default model s390x: Replace PAGE_SIZE, PAGE_SHIFT and PAGE_MASK hw/s390x/s390-skeys: lazy storage key enablement under TCG hw/s390x/s390-skeys: rename skeys_enabled to skeys_are_enabled hw/s390x/s390-skeys: check if an address is valid before dumping the key hw/s390x/s390-skeys: use memory mapping to detect which storage keys to dump hw/s390x/s390-skeys: use memory mapping to detect which storage keys to migrate s390x/mmu_helper: avoid setting the storage key if nothing changed s390x/mmu_helper: move address validation into mmu_translate*() s390x/mmu_helper: fixup mmu_translate() documentation s390x/mmu_helper: no need to pass access type to mmu_translate_asce() s390x/tcg: check for addressing exceptions for RRBE, SSKE and ISKE s390x/tcg: convert real to absolute address for RRBE, SSKE and ISKE s390x/tcg: fix ignoring bit 63 when setting the storage key in SSKE s390x/tcg: wrap address for RRBE s390x/ioinst: Fix wrong MSCH alignment check on little endian s390x/tcg: fix and optimize SPX (SET PREFIX) tests/tcg/s390x: Test SIGILL and SIGSEGV handling css: fix actl handling for unit exceptions vfio-ccw: forward halt/clear errors Signed-off-by: Peter Maydell <[email protected]>
2 parents f912863 + 30e398f commit abf7aee

22 files changed

+627
-151
lines changed

hw/s390x/css.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,23 +1206,53 @@ static void sch_handle_start_func_virtual(SubchDev *sch)
12061206

12071207
}
12081208

1209-
static void sch_handle_halt_func_passthrough(SubchDev *sch)
1209+
static IOInstEnding sch_handle_halt_func_passthrough(SubchDev *sch)
12101210
{
12111211
int ret;
12121212

12131213
ret = s390_ccw_halt(sch);
12141214
if (ret == -ENOSYS) {
12151215
sch_handle_halt_func(sch);
1216+
return IOINST_CC_EXPECTED;
1217+
}
1218+
/*
1219+
* Some conditions may have been detected prior to starting the halt
1220+
* function; map them to the correct cc.
1221+
* Note that we map both -ENODEV and -EACCES to cc 3 (there's not really
1222+
* anything else we can do.)
1223+
*/
1224+
switch (ret) {
1225+
case -EBUSY:
1226+
return IOINST_CC_BUSY;
1227+
case -ENODEV:
1228+
case -EACCES:
1229+
return IOINST_CC_NOT_OPERATIONAL;
1230+
default:
1231+
return IOINST_CC_EXPECTED;
12161232
}
12171233
}
12181234

1219-
static void sch_handle_clear_func_passthrough(SubchDev *sch)
1235+
static IOInstEnding sch_handle_clear_func_passthrough(SubchDev *sch)
12201236
{
12211237
int ret;
12221238

12231239
ret = s390_ccw_clear(sch);
12241240
if (ret == -ENOSYS) {
12251241
sch_handle_clear_func(sch);
1242+
return IOINST_CC_EXPECTED;
1243+
}
1244+
/*
1245+
* Some conditions may have been detected prior to starting the clear
1246+
* function; map them to the correct cc.
1247+
* Note that we map both -ENODEV and -EACCES to cc 3 (there's not really
1248+
* anything else we can do.)
1249+
*/
1250+
switch (ret) {
1251+
case -ENODEV:
1252+
case -EACCES:
1253+
return IOINST_CC_NOT_OPERATIONAL;
1254+
default:
1255+
return IOINST_CC_EXPECTED;
12261256
}
12271257
}
12281258

@@ -1265,9 +1295,9 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *sch)
12651295
SCHIB *schib = &sch->curr_status;
12661296

12671297
if (schib->scsw.ctrl & SCSW_FCTL_CLEAR_FUNC) {
1268-
sch_handle_clear_func_passthrough(sch);
1298+
return sch_handle_clear_func_passthrough(sch);
12691299
} else if (schib->scsw.ctrl & SCSW_FCTL_HALT_FUNC) {
1270-
sch_handle_halt_func_passthrough(sch);
1300+
return sch_handle_halt_func_passthrough(sch);
12711301
} else if (schib->scsw.ctrl & SCSW_FCTL_START_FUNC) {
12721302
return sch_handle_start_func_passthrough(sch);
12731303
}

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/s390-skeys-kvm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "qemu/error-report.h"
1616
#include "qemu/module.h"
1717

18-
static int kvm_s390_skeys_enabled(S390SKeysState *ss)
18+
static bool kvm_s390_skeys_are_enabled(S390SKeysState *ss)
1919
{
2020
S390SKeysClass *skeyclass = S390_SKEYS_GET_CLASS(ss);
2121
uint8_t single_key;
@@ -57,7 +57,7 @@ static void kvm_s390_skeys_class_init(ObjectClass *oc, void *data)
5757
S390SKeysClass *skeyclass = S390_SKEYS_CLASS(oc);
5858
DeviceClass *dc = DEVICE_CLASS(oc);
5959

60-
skeyclass->skeys_enabled = kvm_s390_skeys_enabled;
60+
skeyclass->skeys_are_enabled = kvm_s390_skeys_are_enabled;
6161
skeyclass->get_skeys = kvm_s390_skeys_get;
6262
skeyclass->set_skeys = kvm_s390_skeys_set;
6363

0 commit comments

Comments
 (0)