KVM: s390: Add new reset vcpu API
Subsystems (4)
Janosch Frank
maintainerPATCH v5 1/1 KVM: s390: Add new reset vcpu API
The architecture states that we need to reset local IRQs for all CPU resets. Because the old reset interface did not support the normal CPU reset we never did that on a normal reset.
Let's implement an interface for the missing normal and clear resets and reset all local IRQs, registers and control structures as stated in the architecture.
Userspace might already reset the registers via the vcpu run struct, but as we need the interface for the interrupt clearing part anyway, we implement the resets fully and don't rely on userspace to reset the rest.
--- Documentation/virt/kvm/api.txt | 45 +++++++++++++ arch/s390/kvm/kvm-s390.c | 111 +++++++++++++++++++++++---------- include/uapi/linux/kvm.h | 5 ++ 3 files changed, 127 insertions(+), 34 deletions(-)
Documentation/virt/kvm/api.txt +45 -0
@@ -4168,6 +4168,44 @@ This ioctl issues an ultravisor call to terminate the secure guest, unpins the VPA pages and releases all the device pages that are used to track the secure pages by hypervisor. +4.122 KVM_S390_NORMAL_RESET + +Capability: KVM_CAP_S390_VCPU_RESETS +Architectures: s390 +Type: vcpu ioctl +Parameters: none +Returns: 0 + +This ioctl resets VCPU registers and control structures according to +the cpu reset definition in the POP (Principles Of Operation). + +4.123 KVM_S390_INITIAL_RESET + +Capability: none +Architectures: s390 +Type: vcpu ioctl +Parameters: none +Returns: 0 + +This ioctl resets VCPU registers and control structures according to +the initial cpu reset definition in the POP (Principles Of +Operation). However, the cpu is not put into ESA mode. This reset is a +superset of the normal reset. + +4.124 KVM_S390_CLEAR_RESET + +Capability: KVM_CAP_S390_VCPU_RESETS +Architectures: s390 +Type: vcpu ioctl +Parameters: none +Returns: 0 + +This ioctl resets VCPU registers and control structures according to +the clear cpu reset definition in the POP (Principles Of Operation). +However, the cpu is not put into ESA mode. This reset is a superset +of the initial reset. + + 5. The kvm_run structure ------------------------
@@ -5396,3 +5434,10 @@ handling by KVM (as some KVM hypercall may be mistakenly treated as TLB flush hypercalls by Hyper-V) so userspace should disable KVM identification in CPUID and only exposes Hyper-V identification. In this case, guest thinks it's running on Hyper-V and only use Hyper-V hypercalls. + +8.22 KVM_CAP_S390_VCPU_RESETS + +Architectures: s390 + +This capability indicates that the KVM_S390_NORMAL_RESET and +KVM_S390_CLEAR_RESET ioctls are available.
arch/s390/kvm/kvm-s390.c +77 -34
143 lines not on this page · raw message
include/uapi/linux/kvm.h +5 -0
@@ -1009,6 +1009,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176#define KVM_CAP_ARM_NISV_TO_USER 177#define KVM_CAP_ARM_INJECT_EXT_DABT 178 +#define KVM_CAP_S390_VCPU_RESETS 179#ifdef KVM_CAP_IRQ_ROUTING
@@ -1473,6 +1474,10 @@ struct kvm_enc_region {/* Available with KVM_CAP_ARM_SVE */ #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) +/* Available with KVM_CAP_S390_VCPU_RESETS */ +#define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3) +#define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4) +/* Secure Encrypted Virtualization command */ enum sev_cmd_id {/* Guest initialization commands */
Signature · 1 line
2.20.1
Quoted 40 lines · Janosch Frank
The architecture states that we need to reset local IRQs for all CPU resets. Because the old reset interface did not support the normal CPU reset we never did that on a normal reset.
Let's implement an interface for the missing normal and clear resets and reset all local IRQs, registers and control structures as stated in the architecture.
Userspace might already reset the registers via the vcpu run struct, but as we need the interface for the interrupt clearing part anyway, we implement the resets fully and don't rely on userspace to reset the rest.
Signed-off-by Janosch Frank <[email protected]>--- Documentation/virt/kvm/api.txt | 45 +++++++++++++ arch/s390/kvm/kvm-s390.c | 111 +++++++++++++++++++++++---------- include/uapi/linux/kvm.h | 5 ++ 3 files changed, 127 insertions(+), 34 deletions(-)Documentation/virt/kvm/api.txt +12
-0@@ -4168,6 +4168,44 @@ This ioctl issues an ultravisor call to terminate the secure guest, unpins the VPA pages and releases all the device pages that are used to track the secure pages by hypervisor. +4.122 KVM_S390_NORMAL_RESET + +Capability: KVM_CAP_S390_VCPU_RESETS +Architectures: s390 +Type: vcpu ioctl +Parameters: none +Returns: 0 + +This ioctl resets VCPU registers and control structures according to +the cpu reset definition in the POP (Principles Of Operation). + +4.123 KVM_S390_INITIAL_RESET
Documentation/virt/kvm/api.txt This ioctl issues an ultravisor call to terminate the secure guest, · line 4192
Quoted 10 lines
Documentation/virt/kvm/api.txt +10
-0+ +Capability: none +Architectures: s390 +Type: vcpu ioctl +Parameters: none +Returns: 0 + +This ioctl resets VCPU registers and control structures according to +the initial cpu reset definition in the POP (Principles Of +Operation).
Nit: You "defined" POP already in the NORMAL_RESET section, so I'd either only use the abbreviation here, or spell it out completely, but not both again.
Documentation/virt/kvm/api.txt This ioctl issues an ultravisor call to terminate the secure guest, · line 4204
Quoted 13 lines
However, the cpu is not put into ESA mode. This reset is a
Documentation/virt/kvm/api.txt +12
-0+superset of the normal reset. + +4.124 KVM_S390_CLEAR_RESET + +Capability: KVM_CAP_S390_VCPU_RESETS +Architectures: s390 +Type: vcpu ioctl +Parameters: none +Returns: 0 + +This ioctl resets VCPU registers and control structures according to +the clear cpu reset definition in the POP (Principles Of Operation).
dito
Thomas