2022-09-02 20:27:32 +03:00
|
|
|
/*
|
|
|
|
* s390 zPCI KVM interfaces
|
|
|
|
*
|
|
|
|
* Copyright 2022 IBM Corp.
|
|
|
|
* Author(s): Matthew Rosato <mjrosato@linux.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at
|
|
|
|
* your option) any later version. See the COPYING file in the top-level
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
|
2022-09-02 20:27:34 +03:00
|
|
|
#include <linux/kvm.h>
|
|
|
|
|
2022-09-02 20:27:32 +03:00
|
|
|
#include "kvm/kvm_s390x.h"
|
2023-06-24 23:06:44 +03:00
|
|
|
#include "target/s390x/kvm/pv.h"
|
2022-09-02 20:27:34 +03:00
|
|
|
#include "hw/s390x/s390-pci-bus.h"
|
2022-09-02 20:27:32 +03:00
|
|
|
#include "hw/s390x/s390-pci-kvm.h"
|
2022-09-02 20:27:34 +03:00
|
|
|
#include "hw/s390x/s390-pci-inst.h"
|
2022-09-02 20:27:32 +03:00
|
|
|
#include "cpu_models.h"
|
|
|
|
|
|
|
|
bool s390_pci_kvm_interp_allowed(void)
|
|
|
|
{
|
2022-11-07 19:13:48 +03:00
|
|
|
return kvm_s390_get_zpci_op() && !s390_is_pv();
|
2022-09-02 20:27:32 +03:00
|
|
|
}
|
2022-09-02 20:27:34 +03:00
|
|
|
|
|
|
|
int s390_pci_kvm_aif_enable(S390PCIBusDevice *pbdev, ZpciFib *fib, bool assist)
|
|
|
|
{
|
2024-01-18 21:51:49 +03:00
|
|
|
int rc;
|
2022-09-02 20:27:34 +03:00
|
|
|
struct kvm_s390_zpci_op args = {
|
|
|
|
.fh = pbdev->fh,
|
|
|
|
.op = KVM_S390_ZPCIOP_REG_AEN,
|
|
|
|
.u.reg_aen.ibv = fib->aibv,
|
|
|
|
.u.reg_aen.sb = fib->aisb,
|
|
|
|
.u.reg_aen.noi = FIB_DATA_NOI(fib->data),
|
|
|
|
.u.reg_aen.isc = FIB_DATA_ISC(fib->data),
|
|
|
|
.u.reg_aen.sbo = FIB_DATA_AISBO(fib->data),
|
|
|
|
.u.reg_aen.flags = (assist) ? 0 : KVM_S390_ZPCIOP_REGAEN_HOST
|
|
|
|
};
|
|
|
|
|
2024-01-18 21:51:49 +03:00
|
|
|
if (pbdev->aif) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = kvm_vm_ioctl(kvm_state, KVM_S390_ZPCI_OP, &args);
|
|
|
|
if (rc == 0) {
|
|
|
|
pbdev->aif = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
2022-09-02 20:27:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int s390_pci_kvm_aif_disable(S390PCIBusDevice *pbdev)
|
|
|
|
{
|
2024-01-18 21:51:49 +03:00
|
|
|
int rc;
|
|
|
|
|
2022-09-02 20:27:34 +03:00
|
|
|
struct kvm_s390_zpci_op args = {
|
|
|
|
.fh = pbdev->fh,
|
|
|
|
.op = KVM_S390_ZPCIOP_DEREG_AEN
|
|
|
|
};
|
|
|
|
|
2024-01-18 21:51:49 +03:00
|
|
|
if (!pbdev->aif) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = kvm_vm_ioctl(kvm_state, KVM_S390_ZPCI_OP, &args);
|
|
|
|
if (rc == 0) {
|
|
|
|
pbdev->aif = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
2022-09-02 20:27:34 +03:00
|
|
|
}
|