2 * s390 PCI instructions
4 * Copyright 2014 IBM Corp.
5 * Author(s): Frank Blaschka <frank.blaschka@de.ibm.com>
6 * Hong Bo Li <lihbbj@cn.ibm.com>
7 * Yi Min Zhao <zyimin@cn.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or (at
10 * your option) any later version. See the COPYING file in the top-level
14 #include "qemu/osdep.h"
15 #include "exec/memop.h"
16 #include "exec/memory.h"
17 #include "qemu/error-report.h"
18 #include "sysemu/hw_accel.h"
19 #include "hw/pci/pci_device.h"
20 #include "hw/s390x/s390-pci-inst.h"
21 #include "hw/s390x/s390-pci-bus.h"
22 #include "hw/s390x/s390-pci-kvm.h"
23 #include "hw/s390x/s390-pci-vfio.h"
24 #include "hw/s390x/tod.h"
28 static inline void inc_dma_avail(S390PCIIOMMU
*iommu
)
30 if (iommu
->dma_limit
) {
31 iommu
->dma_limit
->avail
++;
35 static inline void dec_dma_avail(S390PCIIOMMU
*iommu
)
37 if (iommu
->dma_limit
) {
38 iommu
->dma_limit
->avail
--;
42 static void s390_set_status_code(CPUS390XState
*env
,
43 uint8_t r
, uint64_t status_code
)
45 env
->regs
[r
] &= ~0xff000000ULL
;
46 env
->regs
[r
] |= (status_code
& 0xff) << 24;
49 static int list_pci(ClpReqRspListPci
*rrb
, uint8_t *cc
)
51 S390PCIBusDevice
*pbdev
= NULL
;
52 S390pciState
*s
= s390_get_phb();
53 uint32_t res_code
, initial_l2
, g_l2
;
55 uint64_t resume_token
;
58 if (lduw_p(&rrb
->request
.hdr
.len
) != 32) {
59 res_code
= CLP_RC_LEN
;
64 if ((ldl_p(&rrb
->request
.fmt
) & CLP_MASK_FMT
) != 0) {
65 res_code
= CLP_RC_FMT
;
70 if ((ldl_p(&rrb
->request
.fmt
) & ~CLP_MASK_FMT
) != 0 ||
71 ldq_p(&rrb
->request
.reserved1
) != 0) {
72 res_code
= CLP_RC_RESNOT0
;
77 resume_token
= ldq_p(&rrb
->request
.resume_token
);
80 pbdev
= s390_pci_find_dev_by_idx(s
, resume_token
);
82 res_code
= CLP_RC_LISTPCI_BADRT
;
87 pbdev
= s390_pci_find_next_avail_dev(s
, NULL
);
90 if (lduw_p(&rrb
->response
.hdr
.len
) < 48) {
96 initial_l2
= lduw_p(&rrb
->response
.hdr
.len
);
97 if ((initial_l2
- LIST_PCI_HDR_LEN
) % sizeof(ClpFhListEntry
)
99 res_code
= CLP_RC_LEN
;
105 stl_p(&rrb
->response
.fmt
, 0);
106 stq_p(&rrb
->response
.reserved1
, 0);
107 stl_p(&rrb
->response
.mdd
, FH_MASK_SHM
);
108 stw_p(&rrb
->response
.max_fn
, PCI_MAX_FUNCTIONS
);
109 rrb
->response
.flags
= UID_CHECKING_ENABLED
;
110 rrb
->response
.entry_size
= sizeof(ClpFhListEntry
);
113 g_l2
= LIST_PCI_HDR_LEN
;
114 while (g_l2
< initial_l2
&& pbdev
) {
115 stw_p(&rrb
->response
.fh_list
[i
].device_id
,
116 pci_get_word(pbdev
->pdev
->config
+ PCI_DEVICE_ID
));
117 stw_p(&rrb
->response
.fh_list
[i
].vendor_id
,
118 pci_get_word(pbdev
->pdev
->config
+ PCI_VENDOR_ID
));
119 /* Ignore RESERVED devices. */
120 stl_p(&rrb
->response
.fh_list
[i
].config
,
121 pbdev
->state
== ZPCI_FS_STANDBY
? 0 : 1 << 31);
122 stl_p(&rrb
->response
.fh_list
[i
].fid
, pbdev
->fid
);
123 stl_p(&rrb
->response
.fh_list
[i
].fh
, pbdev
->fh
);
125 g_l2
+= sizeof(ClpFhListEntry
);
126 /* Add endian check for DPRINTF? */
127 trace_s390_pci_list_entry(g_l2
,
128 lduw_p(&rrb
->response
.fh_list
[i
].vendor_id
),
129 lduw_p(&rrb
->response
.fh_list
[i
].device_id
),
130 ldl_p(&rrb
->response
.fh_list
[i
].fid
),
131 ldl_p(&rrb
->response
.fh_list
[i
].fh
));
132 pbdev
= s390_pci_find_next_avail_dev(s
, pbdev
);
139 resume_token
= pbdev
->fh
& FH_MASK_INDEX
;
141 stq_p(&rrb
->response
.resume_token
, resume_token
);
142 stw_p(&rrb
->response
.hdr
.len
, g_l2
);
143 stw_p(&rrb
->response
.hdr
.rsp
, CLP_RC_OK
);
146 trace_s390_pci_list(rc
);
147 stw_p(&rrb
->response
.hdr
.rsp
, res_code
);
152 int clp_service_call(S390CPU
*cpu
, uint8_t r2
, uintptr_t ra
)
156 S390PCIBusDevice
*pbdev
;
159 uint8_t buffer
[4096 * 2];
161 CPUS390XState
*env
= &cpu
->env
;
162 S390pciState
*s
= s390_get_phb();
165 if (env
->psw
.mask
& PSW_MASK_PSTATE
) {
166 s390_program_interrupt(env
, PGM_PRIVILEGED
, ra
);
170 if (s390_cpu_virt_mem_read(cpu
, env
->regs
[r2
], r2
, buffer
, sizeof(*reqh
))) {
171 s390_cpu_virt_mem_handle_exc(cpu
, ra
);
174 reqh
= (ClpReqHdr
*)buffer
;
175 req_len
= lduw_p(&reqh
->len
);
176 if (req_len
< 16 || req_len
> 8184 || (req_len
% 8 != 0)) {
177 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
181 if (s390_cpu_virt_mem_read(cpu
, env
->regs
[r2
], r2
, buffer
,
182 req_len
+ sizeof(*resh
))) {
183 s390_cpu_virt_mem_handle_exc(cpu
, ra
);
186 resh
= (ClpRspHdr
*)(buffer
+ req_len
);
187 res_len
= lduw_p(&resh
->len
);
188 if (res_len
< 8 || res_len
> 8176 || (res_len
% 8 != 0)) {
189 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
192 if ((req_len
+ res_len
) > 8192) {
193 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
197 if (s390_cpu_virt_mem_read(cpu
, env
->regs
[r2
], r2
, buffer
,
198 req_len
+ res_len
)) {
199 s390_cpu_virt_mem_handle_exc(cpu
, ra
);
204 stw_p(&resh
->rsp
, CLP_RC_LEN
);
208 switch (lduw_p(&reqh
->cmd
)) {
210 ClpReqRspListPci
*rrb
= (ClpReqRspListPci
*)buffer
;
214 case CLP_SET_PCI_FN
: {
215 ClpReqSetPci
*reqsetpci
= (ClpReqSetPci
*)reqh
;
216 ClpRspSetPci
*ressetpci
= (ClpRspSetPci
*)resh
;
218 pbdev
= s390_pci_find_dev_by_fh(s
, ldl_p(&reqsetpci
->fh
));
220 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_SETPCIFN_FH
);
224 switch (reqsetpci
->oc
) {
225 case CLP_SET_ENABLE_PCI_FN
:
226 switch (reqsetpci
->ndas
) {
228 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_SETPCIFN_DMAAS
);
233 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_SETPCIFN_RES
);
237 if (pbdev
->fh
& FH_MASK_ENABLE
) {
238 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_SETPCIFN_FHOP
);
243 * Take this opportunity to make sure we still have an accurate
244 * host fh. It's possible part of the handle changed while the
245 * device was disabled to the guest (e.g. vfio hot reset for
249 /* Take this opportunity to make sure we are sync'd with host */
250 if (!s390_pci_get_host_fh(pbdev
, &pbdev
->fh
) ||
251 !(pbdev
->fh
& FH_MASK_ENABLE
)) {
252 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_SETPCIFN_FH
);
256 pbdev
->fh
|= FH_MASK_ENABLE
;
257 pbdev
->state
= ZPCI_FS_ENABLED
;
258 stl_p(&ressetpci
->fh
, pbdev
->fh
);
259 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_OK
);
261 case CLP_SET_DISABLE_PCI_FN
:
262 if (!(pbdev
->fh
& FH_MASK_ENABLE
)) {
263 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_SETPCIFN_FHOP
);
266 device_cold_reset(DEVICE(pbdev
));
267 pbdev
->fh
&= ~FH_MASK_ENABLE
;
268 pbdev
->state
= ZPCI_FS_DISABLED
;
269 stl_p(&ressetpci
->fh
, pbdev
->fh
);
270 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_OK
);
273 trace_s390_pci_unknown("set-pci", reqsetpci
->oc
);
274 stw_p(&ressetpci
->hdr
.rsp
, CLP_RC_SETPCIFN_FHOP
);
279 case CLP_QUERY_PCI_FN
: {
280 ClpReqQueryPci
*reqquery
= (ClpReqQueryPci
*)reqh
;
281 ClpRspQueryPci
*resquery
= (ClpRspQueryPci
*)resh
;
283 pbdev
= s390_pci_find_dev_by_fh(s
, ldl_p(&reqquery
->fh
));
285 trace_s390_pci_nodev("query", ldl_p(&reqquery
->fh
));
286 stw_p(&resquery
->hdr
.rsp
, CLP_RC_SETPCIFN_FH
);
290 stq_p(&resquery
->sdma
, pbdev
->zpci_fn
.sdma
);
291 stq_p(&resquery
->edma
, pbdev
->zpci_fn
.edma
);
292 stw_p(&resquery
->pchid
, pbdev
->zpci_fn
.pchid
);
293 stw_p(&resquery
->vfn
, pbdev
->zpci_fn
.vfn
);
294 resquery
->flags
= pbdev
->zpci_fn
.flags
;
295 resquery
->pfgid
= pbdev
->zpci_fn
.pfgid
;
296 resquery
->pft
= pbdev
->zpci_fn
.pft
;
297 resquery
->fmbl
= pbdev
->zpci_fn
.fmbl
;
298 stl_p(&resquery
->fid
, pbdev
->zpci_fn
.fid
);
299 stl_p(&resquery
->uid
, pbdev
->zpci_fn
.uid
);
300 memcpy(resquery
->pfip
, pbdev
->zpci_fn
.pfip
, CLP_PFIP_NR_SEGMENTS
);
301 memcpy(resquery
->util_str
, pbdev
->zpci_fn
.util_str
, CLP_UTIL_STR_LEN
);
303 for (i
= 0; i
< PCI_BAR_COUNT
; i
++) {
304 uint32_t data
= pci_get_long(pbdev
->pdev
->config
+
305 PCI_BASE_ADDRESS_0
+ (i
* 4));
307 stl_p(&resquery
->bar
[i
], data
);
308 resquery
->bar_size
[i
] = pbdev
->pdev
->io_regions
[i
].size
?
309 ctz64(pbdev
->pdev
->io_regions
[i
].size
) : 0;
310 trace_s390_pci_bar(i
,
311 ldl_p(&resquery
->bar
[i
]),
312 pbdev
->pdev
->io_regions
[i
].size
,
313 resquery
->bar_size
[i
]);
316 stw_p(&resquery
->hdr
.rsp
, CLP_RC_OK
);
319 case CLP_QUERY_PCI_FNGRP
: {
320 ClpRspQueryPciGrp
*resgrp
= (ClpRspQueryPciGrp
*)resh
;
322 ClpReqQueryPciGrp
*reqgrp
= (ClpReqQueryPciGrp
*)reqh
;
325 group
= s390_group_find(reqgrp
->g
);
327 /* We do not allow access to unknown groups */
328 /* The group must have been obtained with a vfio device */
329 stw_p(&resgrp
->hdr
.rsp
, CLP_RC_QUERYPCIFG_PFGID
);
332 resgrp
->fr
= group
->zpci_group
.fr
;
333 stq_p(&resgrp
->dasm
, group
->zpci_group
.dasm
);
334 stq_p(&resgrp
->msia
, group
->zpci_group
.msia
);
335 stw_p(&resgrp
->mui
, group
->zpci_group
.mui
);
336 stw_p(&resgrp
->i
, group
->zpci_group
.i
);
337 stw_p(&resgrp
->maxstbl
, group
->zpci_group
.maxstbl
);
338 resgrp
->version
= group
->zpci_group
.version
;
339 resgrp
->dtsm
= group
->zpci_group
.dtsm
;
340 stw_p(&resgrp
->hdr
.rsp
, CLP_RC_OK
);
344 trace_s390_pci_unknown("clp", lduw_p(&reqh
->cmd
));
345 stw_p(&resh
->rsp
, CLP_RC_CMD
);
350 if (s390_cpu_virt_mem_write(cpu
, env
->regs
[r2
], r2
, buffer
,
351 req_len
+ res_len
)) {
352 s390_cpu_virt_mem_handle_exc(cpu
, ra
);
360 * Swap data contained in s390x big endian registers to little endian
363 * @ptr: a pointer to a uint64_t data field
364 * @len: the length of the valid data, must be 1,2,4 or 8
366 static int zpci_endian_swap(uint64_t *ptr
, uint8_t len
)
368 uint64_t data
= *ptr
;
374 data
= bswap16(data
);
377 data
= bswap32(data
);
380 data
= bswap64(data
);
389 static MemoryRegion
*s390_get_subregion(MemoryRegion
*mr
, uint64_t offset
,
392 MemoryRegion
*subregion
;
393 uint64_t subregion_size
;
395 QTAILQ_FOREACH(subregion
, &mr
->subregions
, subregions_link
) {
396 subregion_size
= int128_get64(subregion
->size
);
397 if ((offset
>= subregion
->addr
) &&
398 (offset
+ len
) <= (subregion
->addr
+ subregion_size
)) {
406 static MemTxResult
zpci_read_bar(S390PCIBusDevice
*pbdev
, uint8_t pcias
,
407 uint64_t offset
, uint64_t *data
, uint8_t len
)
411 mr
= pbdev
->pdev
->io_regions
[pcias
].memory
;
412 mr
= s390_get_subregion(mr
, offset
, len
);
414 return memory_region_dispatch_read(mr
, offset
, data
,
415 size_memop(len
) | MO_BE
,
416 MEMTXATTRS_UNSPECIFIED
);
419 int pcilg_service_call(S390CPU
*cpu
, uint8_t r1
, uint8_t r2
, uintptr_t ra
)
421 CPUS390XState
*env
= &cpu
->env
;
422 S390PCIBusDevice
*pbdev
;
430 if (env
->psw
.mask
& PSW_MASK_PSTATE
) {
431 s390_program_interrupt(env
, PGM_PRIVILEGED
, ra
);
436 s390_program_interrupt(env
, PGM_SPECIFICATION
, ra
);
440 fh
= env
->regs
[r2
] >> 32;
441 pcias
= (env
->regs
[r2
] >> 16) & 0xf;
442 len
= env
->regs
[r2
] & 0xf;
443 offset
= env
->regs
[r2
+ 1];
445 if (!(fh
& FH_MASK_ENABLE
)) {
446 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
450 pbdev
= s390_pci_find_dev_by_fh(s390_get_phb(), fh
);
452 trace_s390_pci_nodev("pcilg", fh
);
453 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
457 switch (pbdev
->state
) {
458 case ZPCI_FS_PERMANENT_ERROR
:
460 setcc(cpu
, ZPCI_PCI_LS_ERR
);
461 s390_set_status_code(env
, r2
, ZPCI_PCI_ST_BLOCKED
);
468 case ZPCI_IO_BAR_MIN
...ZPCI_IO_BAR_MAX
:
469 if (!len
|| (len
> (8 - (offset
& 0x7)))) {
470 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
473 result
= zpci_read_bar(pbdev
, pcias
, offset
, &data
, len
);
474 if (result
!= MEMTX_OK
) {
475 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
479 case ZPCI_CONFIG_BAR
:
480 if (!len
|| (len
> (4 - (offset
& 0x3))) || len
== 3) {
481 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
484 data
= pci_host_config_read_common(
485 pbdev
->pdev
, offset
, pci_config_size(pbdev
->pdev
), len
);
487 if (zpci_endian_swap(&data
, len
)) {
488 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
493 trace_s390_pci_invalid("pcilg", fh
);
494 setcc(cpu
, ZPCI_PCI_LS_ERR
);
495 s390_set_status_code(env
, r2
, ZPCI_PCI_ST_INVAL_AS
);
499 pbdev
->fmb
.counter
[ZPCI_FMB_CNT_LD
]++;
501 env
->regs
[r1
] = data
;
502 setcc(cpu
, ZPCI_PCI_LS_OK
);
506 static MemTxResult
zpci_write_bar(S390PCIBusDevice
*pbdev
, uint8_t pcias
,
507 uint64_t offset
, uint64_t data
, uint8_t len
)
511 mr
= pbdev
->pdev
->io_regions
[pcias
].memory
;
512 mr
= s390_get_subregion(mr
, offset
, len
);
514 return memory_region_dispatch_write(mr
, offset
, data
,
515 size_memop(len
) | MO_BE
,
516 MEMTXATTRS_UNSPECIFIED
);
519 int pcistg_service_call(S390CPU
*cpu
, uint8_t r1
, uint8_t r2
, uintptr_t ra
)
521 CPUS390XState
*env
= &cpu
->env
;
522 uint64_t offset
, data
;
523 S390PCIBusDevice
*pbdev
;
529 if (env
->psw
.mask
& PSW_MASK_PSTATE
) {
530 s390_program_interrupt(env
, PGM_PRIVILEGED
, ra
);
535 s390_program_interrupt(env
, PGM_SPECIFICATION
, ra
);
539 fh
= env
->regs
[r2
] >> 32;
540 pcias
= (env
->regs
[r2
] >> 16) & 0xf;
541 len
= env
->regs
[r2
] & 0xf;
542 offset
= env
->regs
[r2
+ 1];
543 data
= env
->regs
[r1
];
545 if (!(fh
& FH_MASK_ENABLE
)) {
546 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
550 pbdev
= s390_pci_find_dev_by_fh(s390_get_phb(), fh
);
552 trace_s390_pci_nodev("pcistg", fh
);
553 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
557 switch (pbdev
->state
) {
558 /* ZPCI_FS_RESERVED, ZPCI_FS_STANDBY and ZPCI_FS_DISABLED
559 * are already covered by the FH_MASK_ENABLE check above
561 case ZPCI_FS_PERMANENT_ERROR
:
563 setcc(cpu
, ZPCI_PCI_LS_ERR
);
564 s390_set_status_code(env
, r2
, ZPCI_PCI_ST_BLOCKED
);
571 /* A ZPCI PCI card may use any BAR from BAR 0 to BAR 5 */
572 case ZPCI_IO_BAR_MIN
...ZPCI_IO_BAR_MAX
:
574 * A length of 0 is invalid and length should not cross a double word
576 if (!len
|| (len
> (8 - (offset
& 0x7)))) {
577 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
581 result
= zpci_write_bar(pbdev
, pcias
, offset
, data
, len
);
582 if (result
!= MEMTX_OK
) {
583 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
587 case ZPCI_CONFIG_BAR
:
588 /* ZPCI uses the pseudo BAR number 15 as configuration space */
589 /* possible access lengths are 1,2,4 and must not cross a word */
590 if (!len
|| (len
> (4 - (offset
& 0x3))) || len
== 3) {
591 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
594 /* len = 1,2,4 so we do not need to test */
595 zpci_endian_swap(&data
, len
);
596 pci_host_config_write_common(pbdev
->pdev
, offset
,
597 pci_config_size(pbdev
->pdev
),
601 trace_s390_pci_invalid("pcistg", fh
);
602 setcc(cpu
, ZPCI_PCI_LS_ERR
);
603 s390_set_status_code(env
, r2
, ZPCI_PCI_ST_INVAL_AS
);
607 pbdev
->fmb
.counter
[ZPCI_FMB_CNT_ST
]++;
609 setcc(cpu
, ZPCI_PCI_LS_OK
);
613 static uint32_t s390_pci_update_iotlb(S390PCIIOMMU
*iommu
,
614 S390IOTLBEntry
*entry
)
616 S390IOTLBEntry
*cache
= g_hash_table_lookup(iommu
->iotlb
, &entry
->iova
);
617 IOMMUTLBEvent event
= {
618 .type
= entry
->perm
? IOMMU_NOTIFIER_MAP
: IOMMU_NOTIFIER_UNMAP
,
620 .target_as
= &address_space_memory
,
622 .translated_addr
= entry
->translated_addr
,
624 .addr_mask
= ~TARGET_PAGE_MASK
,
628 if (event
.type
== IOMMU_NOTIFIER_UNMAP
) {
632 g_hash_table_remove(iommu
->iotlb
, &entry
->iova
);
633 inc_dma_avail(iommu
);
634 /* Don't notify the iommu yet, maybe we can bundle contiguous unmaps */
638 if (cache
->perm
== entry
->perm
&&
639 cache
->translated_addr
== entry
->translated_addr
) {
643 event
.type
= IOMMU_NOTIFIER_UNMAP
;
644 event
.entry
.perm
= IOMMU_NONE
;
645 memory_region_notify_iommu(&iommu
->iommu_mr
, 0, event
);
646 event
.type
= IOMMU_NOTIFIER_MAP
;
647 event
.entry
.perm
= entry
->perm
;
650 cache
= g_new(S390IOTLBEntry
, 1);
651 cache
->iova
= entry
->iova
;
652 cache
->translated_addr
= entry
->translated_addr
;
653 cache
->len
= TARGET_PAGE_SIZE
;
654 cache
->perm
= entry
->perm
;
655 g_hash_table_replace(iommu
->iotlb
, &cache
->iova
, cache
);
656 dec_dma_avail(iommu
);
660 * All associated iotlb entries have already been cleared, trigger the
663 memory_region_notify_iommu(&iommu
->iommu_mr
, 0, event
);
666 return iommu
->dma_limit
? iommu
->dma_limit
->avail
: 1;
669 static void s390_pci_batch_unmap(S390PCIIOMMU
*iommu
, uint64_t iova
,
672 uint64_t remain
= len
, start
= iova
, end
= start
+ len
- 1, mask
, size
;
673 IOMMUTLBEvent event
= {
674 .type
= IOMMU_NOTIFIER_UNMAP
,
676 .target_as
= &address_space_memory
,
677 .translated_addr
= 0,
682 while (remain
>= TARGET_PAGE_SIZE
) {
683 mask
= dma_aligned_pow2_mask(start
, end
, 64);
685 event
.entry
.iova
= start
;
686 event
.entry
.addr_mask
= mask
;
687 memory_region_notify_iommu(&iommu
->iommu_mr
, 0, event
);
693 int rpcit_service_call(S390CPU
*cpu
, uint8_t r1
, uint8_t r2
, uintptr_t ra
)
695 CPUS390XState
*env
= &cpu
->env
;
696 uint64_t iova
, coalesce
= 0;
699 S390PCIBusDevice
*pbdev
;
701 S390IOTLBEntry entry
;
702 hwaddr start
, end
, sstart
;
706 if (env
->psw
.mask
& PSW_MASK_PSTATE
) {
707 s390_program_interrupt(env
, PGM_PRIVILEGED
, ra
);
712 s390_program_interrupt(env
, PGM_SPECIFICATION
, ra
);
716 fh
= env
->regs
[r1
] >> 32;
717 sstart
= start
= env
->regs
[r2
];
718 end
= start
+ env
->regs
[r2
+ 1];
720 pbdev
= s390_pci_find_dev_by_fh(s390_get_phb(), fh
);
722 trace_s390_pci_nodev("rpcit", fh
);
723 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
727 switch (pbdev
->state
) {
728 case ZPCI_FS_RESERVED
:
729 case ZPCI_FS_STANDBY
:
730 case ZPCI_FS_DISABLED
:
731 case ZPCI_FS_PERMANENT_ERROR
:
732 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
735 setcc(cpu
, ZPCI_PCI_LS_ERR
);
736 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_ERROR_RECOVER
);
742 iommu
= pbdev
->iommu
;
743 if (iommu
->dma_limit
) {
744 dma_avail
= iommu
->dma_limit
->avail
;
748 if (!iommu
->g_iota
) {
749 error
= ERR_EVENT_INVALAS
;
753 if (end
< iommu
->pba
|| start
> iommu
->pal
) {
754 error
= ERR_EVENT_OORANGE
;
761 while (start
< end
) {
762 error
= s390_guest_io_table_walk(iommu
->g_iota
, start
, &entry
);
768 * If this is an unmap of a PTE, let's try to coalesce multiple unmaps
769 * into as few notifier events as possible.
771 if (entry
.perm
== IOMMU_NONE
&& entry
.len
== TARGET_PAGE_SIZE
) {
775 coalesce
+= entry
.len
;
776 } else if (coalesce
> 0) {
777 /* Unleash the coalesced unmap before processing a new map */
778 s390_pci_batch_unmap(iommu
, iova
, coalesce
);
783 while (entry
.iova
< start
&& entry
.iova
< end
) {
784 if (dma_avail
> 0 || entry
.perm
== IOMMU_NONE
) {
785 dma_avail
= s390_pci_update_iotlb(iommu
, &entry
);
786 entry
.iova
+= TARGET_PAGE_SIZE
;
787 entry
.translated_addr
+= TARGET_PAGE_SIZE
;
790 * We are unable to make a new mapping at this time, continue
791 * on and hopefully free up more space. Then attempt another
800 /* Unleash the coalesced unmap before finishing rpcit */
801 s390_pci_batch_unmap(iommu
, iova
, coalesce
);
804 if (again
&& dma_avail
> 0)
808 pbdev
->state
= ZPCI_FS_ERROR
;
809 setcc(cpu
, ZPCI_PCI_LS_ERR
);
810 s390_set_status_code(env
, r1
, ZPCI_PCI_ST_FUNC_IN_ERR
);
811 s390_pci_generate_error_event(error
, pbdev
->fh
, pbdev
->fid
, start
, 0);
813 pbdev
->fmb
.counter
[ZPCI_FMB_CNT_RPCIT
]++;
815 setcc(cpu
, ZPCI_PCI_LS_OK
);
817 /* vfio DMA mappings are exhausted, trigger a RPCIT */
818 setcc(cpu
, ZPCI_PCI_LS_ERR
);
819 s390_set_status_code(env
, r1
, ZPCI_RPCIT_ST_INSUFF_RES
);
825 int pcistb_service_call(S390CPU
*cpu
, uint8_t r1
, uint8_t r3
, uint64_t gaddr
,
826 uint8_t ar
, uintptr_t ra
)
828 CPUS390XState
*env
= &cpu
->env
;
829 S390PCIBusDevice
*pbdev
;
839 if (env
->psw
.mask
& PSW_MASK_PSTATE
) {
840 s390_program_interrupt(env
, PGM_PRIVILEGED
, ra
);
844 fh
= env
->regs
[r1
] >> 32;
845 pcias
= (env
->regs
[r1
] >> 16) & 0xf;
846 len
= env
->regs
[r1
] & 0x1fff;
847 offset
= env
->regs
[r3
];
849 if (!(fh
& FH_MASK_ENABLE
)) {
850 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
854 pbdev
= s390_pci_find_dev_by_fh(s390_get_phb(), fh
);
856 trace_s390_pci_nodev("pcistb", fh
);
857 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
861 switch (pbdev
->state
) {
862 case ZPCI_FS_PERMANENT_ERROR
:
864 setcc(cpu
, ZPCI_PCI_LS_ERR
);
865 s390_set_status_code(env
, r1
, ZPCI_PCI_ST_BLOCKED
);
871 if (pcias
> ZPCI_IO_BAR_MAX
) {
872 trace_s390_pci_invalid("pcistb", fh
);
873 setcc(cpu
, ZPCI_PCI_LS_ERR
);
874 s390_set_status_code(env
, r1
, ZPCI_PCI_ST_INVAL_AS
);
878 /* Verify the address, offset and length */
879 /* offset must be a multiple of 8 */
881 goto specification_error
;
883 /* Length must be greater than 8, a multiple of 8 */
884 /* and not greater than maxstbl */
885 if ((len
<= 8) || (len
% 8) ||
886 (len
> pbdev
->pci_group
->zpci_group
.maxstbl
)) {
887 goto specification_error
;
889 /* Do not cross a 4K-byte boundary */
890 if (((offset
& 0xfff) + len
) > 0x1000) {
891 goto specification_error
;
893 /* Guest address must be double word aligned */
894 if (gaddr
& 0x07UL
) {
895 goto specification_error
;
898 mr
= pbdev
->pdev
->io_regions
[pcias
].memory
;
899 mr
= s390_get_subregion(mr
, offset
, len
);
902 for (i
= 0; i
< len
; i
+= 8) {
903 if (!memory_region_access_valid(mr
, offset
+ i
, 8, true,
904 MEMTXATTRS_UNSPECIFIED
)) {
905 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
910 if (s390_cpu_virt_mem_read(cpu
, gaddr
, ar
, buffer
, len
)) {
911 s390_cpu_virt_mem_handle_exc(cpu
, ra
);
915 for (i
= 0; i
< len
/ 8; i
++) {
916 result
= memory_region_dispatch_write(mr
, offset
+ i
* 8,
917 ldq_p(buffer
+ i
* 8),
918 MO_64
, MEMTXATTRS_UNSPECIFIED
);
919 if (result
!= MEMTX_OK
) {
920 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
925 pbdev
->fmb
.counter
[ZPCI_FMB_CNT_STB
]++;
927 setcc(cpu
, ZPCI_PCI_LS_OK
);
931 s390_program_interrupt(env
, PGM_SPECIFICATION
, ra
);
935 static int reg_irqs(CPUS390XState
*env
, S390PCIBusDevice
*pbdev
, ZpciFib fib
)
938 uint8_t isc
= FIB_DATA_ISC(ldl_p(&fib
.data
));
940 pbdev
->routes
.adapter
.adapter_id
= css_get_adapter_id(
941 CSS_IO_ADAPTER_PCI
, isc
);
942 pbdev
->summary_ind
= get_indicator(ldq_p(&fib
.aisb
), sizeof(uint64_t));
943 len
= BITS_TO_LONGS(FIB_DATA_NOI(ldl_p(&fib
.data
))) * sizeof(unsigned long);
944 pbdev
->indicator
= get_indicator(ldq_p(&fib
.aibv
), len
);
946 ret
= map_indicator(&pbdev
->routes
.adapter
, pbdev
->summary_ind
);
951 ret
= map_indicator(&pbdev
->routes
.adapter
, pbdev
->indicator
);
956 pbdev
->routes
.adapter
.summary_addr
= ldq_p(&fib
.aisb
);
957 pbdev
->routes
.adapter
.summary_offset
= FIB_DATA_AISBO(ldl_p(&fib
.data
));
958 pbdev
->routes
.adapter
.ind_addr
= ldq_p(&fib
.aibv
);
959 pbdev
->routes
.adapter
.ind_offset
= FIB_DATA_AIBVO(ldl_p(&fib
.data
));
961 pbdev
->noi
= FIB_DATA_NOI(ldl_p(&fib
.data
));
962 pbdev
->sum
= FIB_DATA_SUM(ldl_p(&fib
.data
));
964 trace_s390_pci_irqs("register", pbdev
->routes
.adapter
.adapter_id
);
967 release_indicator(&pbdev
->routes
.adapter
, pbdev
->summary_ind
);
968 release_indicator(&pbdev
->routes
.adapter
, pbdev
->indicator
);
969 pbdev
->summary_ind
= NULL
;
970 pbdev
->indicator
= NULL
;
974 int pci_dereg_irqs(S390PCIBusDevice
*pbdev
)
976 release_indicator(&pbdev
->routes
.adapter
, pbdev
->summary_ind
);
977 release_indicator(&pbdev
->routes
.adapter
, pbdev
->indicator
);
979 pbdev
->summary_ind
= NULL
;
980 pbdev
->indicator
= NULL
;
981 pbdev
->routes
.adapter
.summary_addr
= 0;
982 pbdev
->routes
.adapter
.summary_offset
= 0;
983 pbdev
->routes
.adapter
.ind_addr
= 0;
984 pbdev
->routes
.adapter
.ind_offset
= 0;
989 trace_s390_pci_irqs("unregister", pbdev
->routes
.adapter
.adapter_id
);
993 static int reg_ioat(CPUS390XState
*env
, S390PCIBusDevice
*pbdev
, ZpciFib fib
,
996 S390PCIIOMMU
*iommu
= pbdev
->iommu
;
997 uint64_t pba
= ldq_p(&fib
.pba
);
998 uint64_t pal
= ldq_p(&fib
.pal
);
999 uint64_t g_iota
= ldq_p(&fib
.iota
);
1000 uint8_t dt
= (g_iota
>> 2) & 0x7;
1001 uint8_t t
= (g_iota
>> 11) & 0x1;
1005 if (pba
> pal
|| pba
< pbdev
->zpci_fn
.sdma
|| pal
> pbdev
->zpci_fn
.edma
) {
1006 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
1010 /* currently we only support designation type 1 with translation */
1011 if (!(dt
== ZPCI_IOTA_RTTO
&& t
)) {
1012 error_report("unsupported ioat dt %d t %d", dt
, t
);
1013 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
1019 iommu
->g_iota
= g_iota
;
1021 s390_pci_iommu_enable(iommu
);
1026 void pci_dereg_ioat(S390PCIIOMMU
*iommu
)
1028 s390_pci_iommu_disable(iommu
);
1034 void fmb_timer_free(S390PCIBusDevice
*pbdev
)
1036 if (pbdev
->fmb_timer
) {
1037 timer_free(pbdev
->fmb_timer
);
1038 pbdev
->fmb_timer
= NULL
;
1040 pbdev
->fmb_addr
= 0;
1041 memset(&pbdev
->fmb
, 0, sizeof(ZpciFmb
));
1044 static int fmb_do_update(S390PCIBusDevice
*pbdev
, int offset
, uint64_t val
,
1048 uint64_t dst
= pbdev
->fmb_addr
+ offset
;
1052 address_space_stq_be(&address_space_memory
, dst
, val
,
1053 MEMTXATTRS_UNSPECIFIED
,
1057 address_space_stl_be(&address_space_memory
, dst
, val
,
1058 MEMTXATTRS_UNSPECIFIED
,
1062 address_space_stw_be(&address_space_memory
, dst
, val
,
1063 MEMTXATTRS_UNSPECIFIED
,
1067 address_space_stb(&address_space_memory
, dst
, val
,
1068 MEMTXATTRS_UNSPECIFIED
,
1075 if (ret
!= MEMTX_OK
) {
1076 s390_pci_generate_error_event(ERR_EVENT_FMBA
, pbdev
->fh
, pbdev
->fid
,
1077 pbdev
->fmb_addr
, 0);
1078 fmb_timer_free(pbdev
);
1084 static void fmb_update(void *opaque
)
1086 S390PCIBusDevice
*pbdev
= opaque
;
1087 int64_t t
= qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL
);
1091 pbdev
->fmb
.last_update
*= 2;
1092 pbdev
->fmb
.last_update
|= UPDATE_U_BIT
;
1093 if (fmb_do_update(pbdev
, offsetof(ZpciFmb
, last_update
),
1094 pbdev
->fmb
.last_update
,
1095 sizeof(pbdev
->fmb
.last_update
))) {
1099 /* Update FMB sample count */
1100 if (fmb_do_update(pbdev
, offsetof(ZpciFmb
, sample
),
1101 pbdev
->fmb
.sample
++,
1102 sizeof(pbdev
->fmb
.sample
))) {
1106 /* Update FMB counters */
1107 for (i
= 0; i
< ZPCI_FMB_CNT_MAX
; i
++) {
1108 if (fmb_do_update(pbdev
, offsetof(ZpciFmb
, counter
[i
]),
1109 pbdev
->fmb
.counter
[i
],
1110 sizeof(pbdev
->fmb
.counter
[0]))) {
1115 /* Clear U bit and update the time */
1116 pbdev
->fmb
.last_update
= time2tod(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
));
1117 pbdev
->fmb
.last_update
*= 2;
1118 if (fmb_do_update(pbdev
, offsetof(ZpciFmb
, last_update
),
1119 pbdev
->fmb
.last_update
,
1120 sizeof(pbdev
->fmb
.last_update
))) {
1123 timer_mod(pbdev
->fmb_timer
, t
+ pbdev
->pci_group
->zpci_group
.mui
);
1126 static int mpcifc_reg_int_interp(S390PCIBusDevice
*pbdev
, ZpciFib
*fib
)
1130 rc
= s390_pci_kvm_aif_enable(pbdev
, fib
, pbdev
->forwarding_assist
);
1132 trace_s390_pci_kvm_aif("enable");
1139 static int mpcifc_dereg_int_interp(S390PCIBusDevice
*pbdev
, ZpciFib
*fib
)
1143 rc
= s390_pci_kvm_aif_disable(pbdev
);
1145 trace_s390_pci_kvm_aif("disable");
1152 int mpcifc_service_call(S390CPU
*cpu
, uint8_t r1
, uint64_t fiba
, uint8_t ar
,
1155 CPUS390XState
*env
= &cpu
->env
;
1159 S390PCIBusDevice
*pbdev
;
1160 uint64_t cc
= ZPCI_PCI_LS_OK
;
1162 if (env
->psw
.mask
& PSW_MASK_PSTATE
) {
1163 s390_program_interrupt(env
, PGM_PRIVILEGED
, ra
);
1167 oc
= env
->regs
[r1
] & 0xff;
1168 dmaas
= (env
->regs
[r1
] >> 16) & 0xff;
1169 fh
= env
->regs
[r1
] >> 32;
1172 s390_program_interrupt(env
, PGM_SPECIFICATION
, ra
);
1176 pbdev
= s390_pci_find_dev_by_fh(s390_get_phb(), fh
);
1178 trace_s390_pci_nodev("mpcifc", fh
);
1179 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
1183 switch (pbdev
->state
) {
1184 case ZPCI_FS_RESERVED
:
1185 case ZPCI_FS_STANDBY
:
1186 case ZPCI_FS_DISABLED
:
1187 case ZPCI_FS_PERMANENT_ERROR
:
1188 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
1194 if (s390_cpu_virt_mem_read(cpu
, fiba
, ar
, (uint8_t *)&fib
, sizeof(fib
))) {
1195 s390_cpu_virt_mem_handle_exc(cpu
, ra
);
1200 s390_program_interrupt(env
, PGM_OPERAND
, ra
);
1205 case ZPCI_MOD_FC_REG_INT
:
1206 if (pbdev
->interp
) {
1207 if (mpcifc_reg_int_interp(pbdev
, &fib
)) {
1208 cc
= ZPCI_PCI_LS_ERR
;
1209 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1211 } else if (pbdev
->summary_ind
) {
1212 cc
= ZPCI_PCI_LS_ERR
;
1213 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1214 } else if (reg_irqs(env
, pbdev
, fib
)) {
1215 cc
= ZPCI_PCI_LS_ERR
;
1216 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_RES_NOT_AVAIL
);
1219 case ZPCI_MOD_FC_DEREG_INT
:
1220 if (pbdev
->interp
) {
1221 if (mpcifc_dereg_int_interp(pbdev
, &fib
)) {
1222 cc
= ZPCI_PCI_LS_ERR
;
1223 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1225 } else if (!pbdev
->summary_ind
) {
1226 cc
= ZPCI_PCI_LS_ERR
;
1227 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1229 pci_dereg_irqs(pbdev
);
1232 case ZPCI_MOD_FC_REG_IOAT
:
1234 cc
= ZPCI_PCI_LS_ERR
;
1235 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_DMAAS_INVAL
);
1236 } else if (pbdev
->iommu
->enabled
) {
1237 cc
= ZPCI_PCI_LS_ERR
;
1238 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1239 } else if (reg_ioat(env
, pbdev
, fib
, ra
)) {
1240 cc
= ZPCI_PCI_LS_ERR
;
1241 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_INSUF_RES
);
1244 case ZPCI_MOD_FC_DEREG_IOAT
:
1246 cc
= ZPCI_PCI_LS_ERR
;
1247 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_DMAAS_INVAL
);
1248 } else if (!pbdev
->iommu
->enabled
) {
1249 cc
= ZPCI_PCI_LS_ERR
;
1250 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1252 pci_dereg_ioat(pbdev
->iommu
);
1255 case ZPCI_MOD_FC_REREG_IOAT
:
1257 cc
= ZPCI_PCI_LS_ERR
;
1258 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_DMAAS_INVAL
);
1259 } else if (!pbdev
->iommu
->enabled
) {
1260 cc
= ZPCI_PCI_LS_ERR
;
1261 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1263 pci_dereg_ioat(pbdev
->iommu
);
1264 if (reg_ioat(env
, pbdev
, fib
, ra
)) {
1265 cc
= ZPCI_PCI_LS_ERR
;
1266 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_INSUF_RES
);
1270 case ZPCI_MOD_FC_RESET_ERROR
:
1271 switch (pbdev
->state
) {
1272 case ZPCI_FS_BLOCKED
:
1274 pbdev
->state
= ZPCI_FS_ENABLED
;
1277 cc
= ZPCI_PCI_LS_ERR
;
1278 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1281 case ZPCI_MOD_FC_RESET_BLOCK
:
1282 switch (pbdev
->state
) {
1284 pbdev
->state
= ZPCI_FS_BLOCKED
;
1287 cc
= ZPCI_PCI_LS_ERR
;
1288 s390_set_status_code(env
, r1
, ZPCI_MOD_ST_SEQUENCE
);
1291 case ZPCI_MOD_FC_SET_MEASURE
: {
1292 uint64_t fmb_addr
= ldq_p(&fib
.fmb_addr
);
1294 if (fmb_addr
& FMBK_MASK
) {
1295 cc
= ZPCI_PCI_LS_ERR
;
1296 s390_pci_generate_error_event(ERR_EVENT_FMBPRO
, pbdev
->fh
,
1297 pbdev
->fid
, fmb_addr
, 0);
1298 fmb_timer_free(pbdev
);
1303 /* Stop updating FMB. */
1304 fmb_timer_free(pbdev
);
1308 if (!pbdev
->fmb_timer
) {
1309 pbdev
->fmb_timer
= timer_new_ms(QEMU_CLOCK_VIRTUAL
,
1311 } else if (timer_pending(pbdev
->fmb_timer
)) {
1312 /* Remove pending timer to update FMB address. */
1313 timer_del(pbdev
->fmb_timer
);
1315 pbdev
->fmb_addr
= fmb_addr
;
1316 timer_mod(pbdev
->fmb_timer
,
1317 qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL
) +
1318 pbdev
->pci_group
->zpci_group
.mui
);
1322 s390_program_interrupt(&cpu
->env
, PGM_OPERAND
, ra
);
1323 cc
= ZPCI_PCI_LS_ERR
;
1330 int stpcifc_service_call(S390CPU
*cpu
, uint8_t r1
, uint64_t fiba
, uint8_t ar
,
1333 CPUS390XState
*env
= &cpu
->env
;
1337 S390PCIBusDevice
*pbdev
;
1339 uint64_t cc
= ZPCI_PCI_LS_OK
;
1341 if (env
->psw
.mask
& PSW_MASK_PSTATE
) {
1342 s390_program_interrupt(env
, PGM_PRIVILEGED
, ra
);
1346 fh
= env
->regs
[r1
] >> 32;
1347 dmaas
= (env
->regs
[r1
] >> 16) & 0xff;
1350 setcc(cpu
, ZPCI_PCI_LS_ERR
);
1351 s390_set_status_code(env
, r1
, ZPCI_STPCIFC_ST_INVAL_DMAAS
);
1356 s390_program_interrupt(env
, PGM_SPECIFICATION
, ra
);
1360 pbdev
= s390_pci_find_dev_by_idx(s390_get_phb(), fh
& FH_MASK_INDEX
);
1362 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
1366 memset(&fib
, 0, sizeof(fib
));
1368 switch (pbdev
->state
) {
1369 case ZPCI_FS_RESERVED
:
1370 case ZPCI_FS_STANDBY
:
1371 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
1373 case ZPCI_FS_DISABLED
:
1374 if (fh
& FH_MASK_ENABLE
) {
1375 setcc(cpu
, ZPCI_PCI_LS_INVAL_HANDLE
);
1379 /* BLOCKED bit is set to one coincident with the setting of ERROR bit.
1380 * FH Enabled bit is set to one in states of ENABLED, BLOCKED or ERROR. */
1384 case ZPCI_FS_BLOCKED
:
1387 case ZPCI_FS_ENABLED
:
1389 if (pbdev
->iommu
->enabled
) {
1392 if (!(fh
& FH_MASK_ENABLE
)) {
1393 env
->regs
[r1
] |= 1ULL << 63;
1396 case ZPCI_FS_PERMANENT_ERROR
:
1397 setcc(cpu
, ZPCI_PCI_LS_ERR
);
1398 s390_set_status_code(env
, r1
, ZPCI_STPCIFC_ST_PERM_ERROR
);
1402 stq_p(&fib
.pba
, pbdev
->iommu
->pba
);
1403 stq_p(&fib
.pal
, pbdev
->iommu
->pal
);
1404 stq_p(&fib
.iota
, pbdev
->iommu
->g_iota
);
1405 stq_p(&fib
.aibv
, pbdev
->routes
.adapter
.ind_addr
);
1406 stq_p(&fib
.aisb
, pbdev
->routes
.adapter
.summary_addr
);
1407 stq_p(&fib
.fmb_addr
, pbdev
->fmb_addr
);
1409 data
= ((uint32_t)pbdev
->isc
<< 28) | ((uint32_t)pbdev
->noi
<< 16) |
1410 ((uint32_t)pbdev
->routes
.adapter
.ind_offset
<< 8) |
1411 ((uint32_t)pbdev
->sum
<< 7) | pbdev
->routes
.adapter
.summary_offset
;
1412 stl_p(&fib
.data
, data
);
1415 if (s390_cpu_virt_mem_write(cpu
, fiba
, ar
, (uint8_t *)&fib
, sizeof(fib
))) {
1416 s390_cpu_virt_mem_handle_exc(cpu
, ra
);