Skip to content

Commit

Permalink
s390: Switch to use confidential_guest_kvm_init()
Browse files Browse the repository at this point in the history
Use unified confidential_guest_kvm_init() for consistency with
other architectures.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Message-Id: <20240229060038.606591-1-xiaoyao.li@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
calmisi authored and bonzini committed Apr 23, 2024
1 parent 00a238b commit a14a2b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
5 changes: 4 additions & 1 deletion hw/s390x/s390-virtio-ccw.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "exec/ram_addr.h"
#include "exec/confidential-guest-support.h"
#include "hw/s390x/s390-virtio-hcall.h"
#include "hw/s390x/sclp.h"
#include "hw/s390x/s390_flic.h"
Expand Down Expand Up @@ -260,7 +261,9 @@ static void ccw_init(MachineState *machine)
s390_init_cpus(machine);

/* Need CPU model to be determined before we can set up PV */
s390_pv_init(machine->cgs, &error_fatal);
if (machine->cgs) {
confidential_guest_kvm_init(machine->cgs, &error_fatal);
}

s390_flic_init();

Expand Down
10 changes: 9 additions & 1 deletion target/s390x/kvm/pv.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,17 @@ static bool s390_pv_guest_check(ConfidentialGuestSupport *cgs, Error **errp)
return s390_pv_check_cpus(errp);
}

int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
static int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
{
if (!object_dynamic_cast(OBJECT(cgs), TYPE_S390_PV_GUEST)) {
return 0;
}

if (!kvm_enabled()) {
error_setg(errp, "Protected Virtualization requires KVM");
return -1;
}

if (!s390_has_feat(S390_FEAT_UNPACK)) {
error_setg(errp,
"CPU model does not support Protected Virtualization");
Expand All @@ -364,6 +369,9 @@ OBJECT_DEFINE_TYPE_WITH_INTERFACES(S390PVGuest,

static void s390_pv_guest_class_init(ObjectClass *oc, void *data)
{
ConfidentialGuestSupportClass *klass = CONFIDENTIAL_GUEST_SUPPORT_CLASS(oc);

klass->kvm_init = s390_pv_kvm_init;
}

static void s390_pv_guest_init(Object *obj)
Expand Down
14 changes: 0 additions & 14 deletions target/s390x/kvm/pv.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,4 @@ static inline int kvm_s390_dump_mem_state(uint64_t addr, size_t len,
static inline int kvm_s390_dump_completion_data(void *buff) { return 0; }
#endif /* CONFIG_KVM */

int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp);
static inline int s390_pv_init(ConfidentialGuestSupport *cgs, Error **errp)
{
if (!cgs) {
return 0;
}
if (kvm_enabled()) {
return s390_pv_kvm_init(cgs, errp);
}

error_setg(errp, "Protected Virtualization requires KVM");
return -1;
}

#endif /* HW_S390_PV_H */

0 comments on commit a14a2b0

Please sign in to comment.