mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 10:34:58 -06:00
Switch non-CPU callers from ld/st*_phys to address_space_ld/st*
Switch all the uses of ld/st*_phys to address_space_ld/st*, except for those cases where the address space is the CPU's (ie cs->as). This was done with the following script which generates a Coccinelle patch. A few over-80-columns lines in the result were rewrapped by hand where Coccinelle failed to do the wrapping automatically, as well as one location where it didn't put a line-continuation '\' when wrapping lines on a change made to a match inside a macro definition. ===begin=== #!/bin/sh -e # Usage: # ./ldst-phys.spatch.sh > ldst-phys.spatch # spatch -sp_file ldst-phys.spatch -dir . | sed -e '/^+/s/\t/ /g' > out.patch # patch -p1 < out.patch for FN in ub uw_le uw_be l_le l_be q_le q_be uw l q; do cat <<EOF @ cpu_matches_ld_${FN} @ expression E1,E2; identifier as; @@ ld${FN}_phys(E1->as,E2) @ other_matches_ld_${FN} depends on !cpu_matches_ld_${FN} @ expression E1,E2; @@ -ld${FN}_phys(E1,E2) +address_space_ld${FN}(E1,E2, MEMTXATTRS_UNSPECIFIED, NULL) EOF done for FN in b w_le w_be l_le l_be q_le q_be w l q; do cat <<EOF @ cpu_matches_st_${FN} @ expression E1,E2,E3; identifier as; @@ st${FN}_phys(E1->as,E2,E3) @ other_matches_st_${FN} depends on !cpu_matches_st_${FN} @ expression E1,E2,E3; @@ -st${FN}_phys(E1,E2,E3) +address_space_st${FN}(E1,E2,E3, MEMTXATTRS_UNSPECIFIED, NULL) EOF done ===endit=== Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
parent
66b9b43c42
commit
42874d3a8c
19 changed files with 193 additions and 89 deletions
|
@ -745,20 +745,27 @@ static void css_update_chnmon(SubchDev *sch)
|
|||
/* Format 1, per-subchannel area. */
|
||||
uint32_t count;
|
||||
|
||||
count = ldl_phys(&address_space_memory, sch->curr_status.mba);
|
||||
count = address_space_ldl(&address_space_memory,
|
||||
sch->curr_status.mba,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
count++;
|
||||
stl_phys(&address_space_memory, sch->curr_status.mba, count);
|
||||
address_space_stl(&address_space_memory, sch->curr_status.mba, count,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
} else {
|
||||
/* Format 0, global area. */
|
||||
uint32_t offset;
|
||||
uint16_t count;
|
||||
|
||||
offset = sch->curr_status.pmcw.mbi << 5;
|
||||
count = lduw_phys(&address_space_memory,
|
||||
channel_subsys->chnmon_area + offset);
|
||||
count = address_space_lduw(&address_space_memory,
|
||||
channel_subsys->chnmon_area + offset,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
count++;
|
||||
stw_phys(&address_space_memory,
|
||||
channel_subsys->chnmon_area + offset, count);
|
||||
address_space_stw(&address_space_memory,
|
||||
channel_subsys->chnmon_area + offset, count,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,8 @@ static uint64_t s390_guest_io_table_walk(uint64_t guest_iota,
|
|||
px = calc_px(guest_dma_address);
|
||||
|
||||
sto_a = guest_iota + rtx * sizeof(uint64_t);
|
||||
sto = ldq_phys(&address_space_memory, sto_a);
|
||||
sto = address_space_ldq(&address_space_memory, sto_a,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
sto = get_rt_sto(sto);
|
||||
if (!sto) {
|
||||
pte = 0;
|
||||
|
@ -286,7 +287,8 @@ static uint64_t s390_guest_io_table_walk(uint64_t guest_iota,
|
|||
}
|
||||
|
||||
pto_a = sto + sx * sizeof(uint64_t);
|
||||
pto = ldq_phys(&address_space_memory, pto_a);
|
||||
pto = address_space_ldq(&address_space_memory, pto_a,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
pto = get_st_pto(pto);
|
||||
if (!pto) {
|
||||
pte = 0;
|
||||
|
@ -294,7 +296,8 @@ static uint64_t s390_guest_io_table_walk(uint64_t guest_iota,
|
|||
}
|
||||
|
||||
px_a = pto + px * sizeof(uint64_t);
|
||||
pte = ldq_phys(&address_space_memory, px_a);
|
||||
pte = address_space_ldq(&address_space_memory, px_a,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
|
||||
out:
|
||||
return pte;
|
||||
|
|
|
@ -75,10 +75,12 @@ void s390_virtio_reset_idx(VirtIOS390Device *dev)
|
|||
for (i = 0; i < num_vq; i++) {
|
||||
idx_addr = virtio_queue_get_avail_addr(dev->vdev, i) +
|
||||
VIRTIO_VRING_AVAIL_IDX_OFFS;
|
||||
stw_phys(&address_space_memory, idx_addr, 0);
|
||||
address_space_stw(&address_space_memory, idx_addr, 0,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
idx_addr = virtio_queue_get_used_addr(dev->vdev, i) +
|
||||
VIRTIO_VRING_USED_IDX_OFFS;
|
||||
stw_phys(&address_space_memory, idx_addr, 0);
|
||||
address_space_stw(&address_space_memory, idx_addr, 0,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +338,8 @@ static uint64_t s390_virtio_device_vq_token(VirtIOS390Device *dev, int vq)
|
|||
(vq * VIRTIO_VQCONFIG_LEN) +
|
||||
VIRTIO_VQCONFIG_OFFS_TOKEN;
|
||||
|
||||
return ldq_be_phys(&address_space_memory, token_off);
|
||||
return address_space_ldq_be(&address_space_memory, token_off,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
}
|
||||
|
||||
static ram_addr_t s390_virtio_device_num_vq(VirtIOS390Device *dev)
|
||||
|
@ -371,21 +374,33 @@ void s390_virtio_device_sync(VirtIOS390Device *dev)
|
|||
virtio_reset(dev->vdev);
|
||||
|
||||
/* Sync dev space */
|
||||
stb_phys(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_TYPE, dev->vdev->device_id);
|
||||
address_space_stb(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_TYPE,
|
||||
dev->vdev->device_id,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
|
||||
stb_phys(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_NUM_VQ,
|
||||
s390_virtio_device_num_vq(dev));
|
||||
stb_phys(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_FEATURE_LEN, dev->feat_len);
|
||||
address_space_stb(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_NUM_VQ,
|
||||
s390_virtio_device_num_vq(dev),
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
address_space_stb(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_FEATURE_LEN,
|
||||
dev->feat_len,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
|
||||
stb_phys(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_CONFIG_LEN, dev->vdev->config_len);
|
||||
address_space_stb(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_CONFIG_LEN,
|
||||
dev->vdev->config_len,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
|
||||
num_vq = s390_virtio_device_num_vq(dev);
|
||||
stb_phys(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_NUM_VQ, num_vq);
|
||||
address_space_stb(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_NUM_VQ, num_vq,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
|
||||
/* Sync virtqueues */
|
||||
for (i = 0; i < num_vq; i++) {
|
||||
|
@ -396,11 +411,14 @@ void s390_virtio_device_sync(VirtIOS390Device *dev)
|
|||
vring = s390_virtio_next_ring(bus);
|
||||
virtio_queue_set_addr(dev->vdev, i, vring);
|
||||
virtio_queue_set_vector(dev->vdev, i, i);
|
||||
stq_be_phys(&address_space_memory,
|
||||
vq + VIRTIO_VQCONFIG_OFFS_ADDRESS, vring);
|
||||
stw_be_phys(&address_space_memory,
|
||||
vq + VIRTIO_VQCONFIG_OFFS_NUM,
|
||||
virtio_queue_get_num(dev->vdev, i));
|
||||
address_space_stq_be(&address_space_memory,
|
||||
vq + VIRTIO_VQCONFIG_OFFS_ADDRESS, vring,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
address_space_stw_be(&address_space_memory,
|
||||
vq + VIRTIO_VQCONFIG_OFFS_NUM,
|
||||
virtio_queue_get_num(dev->vdev, i),
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
}
|
||||
|
||||
cur_offs = dev->dev_offs;
|
||||
|
@ -408,7 +426,8 @@ void s390_virtio_device_sync(VirtIOS390Device *dev)
|
|||
cur_offs += num_vq * VIRTIO_VQCONFIG_LEN;
|
||||
|
||||
/* Sync feature bitmap */
|
||||
stl_le_phys(&address_space_memory, cur_offs, dev->host_features);
|
||||
address_space_stl_le(&address_space_memory, cur_offs, dev->host_features,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
|
||||
dev->feat_offs = cur_offs + dev->feat_len;
|
||||
cur_offs += dev->feat_len * 2;
|
||||
|
@ -426,12 +445,16 @@ void s390_virtio_device_update_status(VirtIOS390Device *dev)
|
|||
VirtIODevice *vdev = dev->vdev;
|
||||
uint32_t features;
|
||||
|
||||
virtio_set_status(vdev, ldub_phys(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_STATUS));
|
||||
virtio_set_status(vdev,
|
||||
address_space_ldub(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_STATUS,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL));
|
||||
|
||||
/* Update guest supported feature bitmap */
|
||||
|
||||
features = bswap32(ldl_be_phys(&address_space_memory, dev->feat_offs));
|
||||
features = bswap32(address_space_ldl_be(&address_space_memory,
|
||||
dev->feat_offs,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL));
|
||||
virtio_set_features(vdev, features);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,9 @@ static int s390_virtio_hcall_reset(const uint64_t *args)
|
|||
return -EINVAL;
|
||||
}
|
||||
virtio_reset(dev->vdev);
|
||||
stb_phys(&address_space_memory, dev->dev_offs + VIRTIO_DEV_OFFS_STATUS, 0);
|
||||
address_space_stb(&address_space_memory,
|
||||
dev->dev_offs + VIRTIO_DEV_OFFS_STATUS, 0,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
s390_virtio_device_sync(dev);
|
||||
s390_virtio_reset_idx(dev);
|
||||
|
||||
|
|
|
@ -335,16 +335,23 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
|
|||
if (!ccw.cda) {
|
||||
ret = -EFAULT;
|
||||
} else {
|
||||
info.queue = ldq_phys(&address_space_memory, ccw.cda);
|
||||
info.align = ldl_phys(&address_space_memory,
|
||||
ccw.cda + sizeof(info.queue));
|
||||
info.index = lduw_phys(&address_space_memory,
|
||||
ccw.cda + sizeof(info.queue)
|
||||
+ sizeof(info.align));
|
||||
info.num = lduw_phys(&address_space_memory,
|
||||
ccw.cda + sizeof(info.queue)
|
||||
+ sizeof(info.align)
|
||||
+ sizeof(info.index));
|
||||
info.queue = address_space_ldq(&address_space_memory, ccw.cda,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
info.align = address_space_ldl(&address_space_memory,
|
||||
ccw.cda + sizeof(info.queue),
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
info.index = address_space_lduw(&address_space_memory,
|
||||
ccw.cda + sizeof(info.queue)
|
||||
+ sizeof(info.align),
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
info.num = address_space_lduw(&address_space_memory,
|
||||
ccw.cda + sizeof(info.queue)
|
||||
+ sizeof(info.align)
|
||||
+ sizeof(info.index),
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
ret = virtio_ccw_set_vqs(sch, info.queue, info.align, info.index,
|
||||
info.num);
|
||||
sch->curr_status.scsw.count = 0;
|
||||
|
@ -369,15 +376,20 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
|
|||
if (!ccw.cda) {
|
||||
ret = -EFAULT;
|
||||
} else {
|
||||
features.index = ldub_phys(&address_space_memory,
|
||||
ccw.cda + sizeof(features.features));
|
||||
features.index = address_space_ldub(&address_space_memory,
|
||||
ccw.cda
|
||||
+ sizeof(features.features),
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
if (features.index < ARRAY_SIZE(dev->host_features)) {
|
||||
features.features = dev->host_features[features.index];
|
||||
} else {
|
||||
/* Return zeroes if the guest supports more feature bits. */
|
||||
features.features = 0;
|
||||
}
|
||||
stl_le_phys(&address_space_memory, ccw.cda, features.features);
|
||||
address_space_stl_le(&address_space_memory, ccw.cda,
|
||||
features.features, MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
sch->curr_status.scsw.count = ccw.count - sizeof(features);
|
||||
ret = 0;
|
||||
}
|
||||
|
@ -396,9 +408,15 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
|
|||
if (!ccw.cda) {
|
||||
ret = -EFAULT;
|
||||
} else {
|
||||
features.index = ldub_phys(&address_space_memory,
|
||||
ccw.cda + sizeof(features.features));
|
||||
features.features = ldl_le_phys(&address_space_memory, ccw.cda);
|
||||
features.index = address_space_ldub(&address_space_memory,
|
||||
ccw.cda
|
||||
+ sizeof(features.features),
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
features.features = address_space_ldl_le(&address_space_memory,
|
||||
ccw.cda,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
if (features.index < ARRAY_SIZE(dev->host_features)) {
|
||||
virtio_set_features(vdev, features.features);
|
||||
} else {
|
||||
|
@ -474,7 +492,8 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
|
|||
if (!ccw.cda) {
|
||||
ret = -EFAULT;
|
||||
} else {
|
||||
status = ldub_phys(&address_space_memory, ccw.cda);
|
||||
status = address_space_ldub(&address_space_memory, ccw.cda,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
|
||||
virtio_ccw_stop_ioeventfd(dev);
|
||||
}
|
||||
|
@ -508,7 +527,8 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
|
|||
if (!ccw.cda) {
|
||||
ret = -EFAULT;
|
||||
} else {
|
||||
indicators = ldq_be_phys(&address_space_memory, ccw.cda);
|
||||
indicators = address_space_ldq_be(&address_space_memory, ccw.cda,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
dev->indicators = get_indicator(indicators, sizeof(uint64_t));
|
||||
sch->curr_status.scsw.count = ccw.count - sizeof(indicators);
|
||||
ret = 0;
|
||||
|
@ -528,7 +548,8 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
|
|||
if (!ccw.cda) {
|
||||
ret = -EFAULT;
|
||||
} else {
|
||||
indicators = ldq_be_phys(&address_space_memory, ccw.cda);
|
||||
indicators = address_space_ldq_be(&address_space_memory, ccw.cda,
|
||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
dev->indicators2 = get_indicator(indicators, sizeof(uint64_t));
|
||||
sch->curr_status.scsw.count = ccw.count - sizeof(indicators);
|
||||
ret = 0;
|
||||
|
@ -548,15 +569,21 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
|
|||
if (!ccw.cda) {
|
||||
ret = -EFAULT;
|
||||
} else {
|
||||
vq_config.index = lduw_be_phys(&address_space_memory, ccw.cda);
|
||||
vq_config.index = address_space_lduw_be(&address_space_memory,
|
||||
ccw.cda,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
if (vq_config.index >= VIRTIO_PCI_QUEUE_MAX) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
vq_config.num_max = virtio_queue_get_num(vdev,
|
||||
vq_config.index);
|
||||
stw_be_phys(&address_space_memory,
|
||||
ccw.cda + sizeof(vq_config.index), vq_config.num_max);
|
||||
address_space_stw_be(&address_space_memory,
|
||||
ccw.cda + sizeof(vq_config.index),
|
||||
vq_config.num_max,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
sch->curr_status.scsw.count = ccw.count - sizeof(vq_config);
|
||||
ret = 0;
|
||||
}
|
||||
|
@ -1068,9 +1095,13 @@ static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
|
|||
css_adapter_interrupt(dev->thinint_isc);
|
||||
}
|
||||
} else {
|
||||
indicators = ldq_phys(&address_space_memory, dev->indicators->addr);
|
||||
indicators = address_space_ldq(&address_space_memory,
|
||||
dev->indicators->addr,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
indicators |= 1ULL << vector;
|
||||
stq_phys(&address_space_memory, dev->indicators->addr, indicators);
|
||||
address_space_stq(&address_space_memory, dev->indicators->addr,
|
||||
indicators, MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
css_conditional_io_interrupt(sch);
|
||||
}
|
||||
} else {
|
||||
|
@ -1078,9 +1109,13 @@ static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
|
|||
return;
|
||||
}
|
||||
vector = 0;
|
||||
indicators = ldq_phys(&address_space_memory, dev->indicators2->addr);
|
||||
indicators = address_space_ldq(&address_space_memory,
|
||||
dev->indicators2->addr,
|
||||
MEMTXATTRS_UNSPECIFIED,
|
||||
NULL);
|
||||
indicators |= 1ULL << vector;
|
||||
stq_phys(&address_space_memory, dev->indicators2->addr, indicators);
|
||||
address_space_stq(&address_space_memory, dev->indicators2->addr,
|
||||
indicators, MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
css_conditional_io_interrupt(sch);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue