Message ID | 20191024114059.102802-33-frankja@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: s390: Add support for protected VMs | expand |
On 24/10/2019 13.40, Janosch Frank wrote: > Signed-off-by: Janosch Frank <frankja@linux.ibm.com> > --- > arch/s390/include/asm/uv.h | 25 +++++++++++++++++++++++++ > arch/s390/kvm/diag.c | 1 + > arch/s390/kvm/kvm-s390.c | 20 ++++++++++++++++++++ > arch/s390/kvm/kvm-s390.h | 2 ++ > arch/s390/kvm/pv.c | 19 +++++++++++++++++++ > include/uapi/linux/kvm.h | 2 ++ > 6 files changed, 69 insertions(+) Add at least a short patch description what this patch is all about? Thomas
On 11/15/19 11:07 AM, Thomas Huth wrote: > On 24/10/2019 13.40, Janosch Frank wrote: >> Signed-off-by: Janosch Frank <frankja@linux.ibm.com> >> --- >> arch/s390/include/asm/uv.h | 25 +++++++++++++++++++++++++ >> arch/s390/kvm/diag.c | 1 + >> arch/s390/kvm/kvm-s390.c | 20 ++++++++++++++++++++ >> arch/s390/kvm/kvm-s390.h | 2 ++ >> arch/s390/kvm/pv.c | 19 +++++++++++++++++++ >> include/uapi/linux/kvm.h | 2 ++ >> 6 files changed, 69 insertions(+) > > Add at least a short patch description what this patch is all about? > > Thomas > I'm thinking about taking out the set cpu state changes and move it into a later patch. How about: diag 308 subcode 0 and 1 require KVM and Ultravisor interaction, since the cpus have to be set into multiple reset states. * All cpus need to be stopped * The unshare all UVC needs to be executed * The perform reset UVC needs to be executed * The cpus need to be reset via the set cpu state UVC * The issuing cpu needs to set state 5 via set cpu state
On 15/11/2019 12.39, Janosch Frank wrote: > On 11/15/19 11:07 AM, Thomas Huth wrote: >> On 24/10/2019 13.40, Janosch Frank wrote: >>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com> >>> --- >>> arch/s390/include/asm/uv.h | 25 +++++++++++++++++++++++++ >>> arch/s390/kvm/diag.c | 1 + >>> arch/s390/kvm/kvm-s390.c | 20 ++++++++++++++++++++ >>> arch/s390/kvm/kvm-s390.h | 2 ++ >>> arch/s390/kvm/pv.c | 19 +++++++++++++++++++ >>> include/uapi/linux/kvm.h | 2 ++ >>> 6 files changed, 69 insertions(+) >> >> Add at least a short patch description what this patch is all about? >> >> Thomas >> > > I'm thinking about taking out the set cpu state changes and move it into > a later patch. > > > How about: > diag 308 subcode 0 and 1 require KVM and Ultravisor interaction, since > the cpus have to be set into multiple reset states. > > * All cpus need to be stopped > * The unshare all UVC needs to be executed > * The perform reset UVC needs to be executed > * The cpus need to be reset via the set cpu state UVC > * The issuing cpu needs to set state 5 via set cpu state Could you put the UVC names into quotes? Like: * The "unshare all" UVC needs to be executed ... I first had to read the sentence three times to really understand it. Thomas
On 11/15/19 2:30 PM, Thomas Huth wrote: > On 15/11/2019 12.39, Janosch Frank wrote: >> On 11/15/19 11:07 AM, Thomas Huth wrote: >>> On 24/10/2019 13.40, Janosch Frank wrote: >>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com> >>>> --- >>>> arch/s390/include/asm/uv.h | 25 +++++++++++++++++++++++++ >>>> arch/s390/kvm/diag.c | 1 + >>>> arch/s390/kvm/kvm-s390.c | 20 ++++++++++++++++++++ >>>> arch/s390/kvm/kvm-s390.h | 2 ++ >>>> arch/s390/kvm/pv.c | 19 +++++++++++++++++++ >>>> include/uapi/linux/kvm.h | 2 ++ >>>> 6 files changed, 69 insertions(+) >>> >>> Add at least a short patch description what this patch is all about? >>> >>> Thomas >>> >> >> I'm thinking about taking out the set cpu state changes and move it into >> a later patch. >> >> >> How about: >> diag 308 subcode 0 and 1 require KVM and Ultravisor interaction, since >> the cpus have to be set into multiple reset states. >> >> * All cpus need to be stopped >> * The unshare all UVC needs to be executed >> * The perform reset UVC needs to be executed >> * The cpus need to be reset via the set cpu state UVC >> * The issuing cpu needs to set state 5 via set cpu state > > Could you put the UVC names into quotes? Like: > > * The "unshare all" UVC needs to be executed > > ... I first had to read the sentence three times to really understand it. > > Thomas > Sure, just did
diff --git a/arch/s390/include/asm/uv.h b/arch/s390/include/asm/uv.h index 9ce9363aee1c..33b52ba306af 100644 --- a/arch/s390/include/asm/uv.h +++ b/arch/s390/include/asm/uv.h @@ -35,6 +35,12 @@ #define UVC_CMD_SET_SEC_CONF_PARAMS 0x0300 #define UVC_CMD_UNPACK_IMG 0x0301 #define UVC_CMD_VERIFY_IMG 0x0302 +#define UVC_CMD_CPU_RESET 0x0310 +#define UVC_CMD_CPU_RESET_INITIAL 0x0311 +#define UVC_CMD_PERF_CONF_CLEAR_RESET 0x0320 +#define UVC_CMD_CPU_RESET_CLEAR 0x0321 +#define UVC_CMD_CPU_SET_STATE 0x0330 +#define UVC_CMD_SET_UNSHARED_ALL 0x0340 #define UVC_CMD_SET_SHARED_ACCESS 0x1000 #define UVC_CMD_REMOVE_SHARED_ACCESS 0x1001 @@ -53,6 +59,12 @@ enum uv_cmds_inst { BIT_UVC_CMD_SET_SEC_PARMS = 11, BIT_UVC_CMD_UNPACK_IMG = 13, BIT_UVC_CMD_VERIFY_IMG = 14, + BIT_UVC_CMD_CPU_RESET = 15, + BIT_UVC_CMD_CPU_RESET_INITIAL = 16, + BIT_UVC_CMD_CPU_SET_STATE = 17, + BIT_UVC_CMD_PREPARE_CLEAR_RESET = 18, + BIT_UVC_CMD_CPU_PERFORM_CLEAR_RESET = 19, + BIT_UVC_CMD_REMOVE_SHARED_ACCES = 20, }; struct uv_cb_header { @@ -148,6 +160,19 @@ struct uv_cb_unp { u64 reserved28[3]; } __packed __aligned(8); +#define PV_CPU_STATE_OPR 1 +#define PV_CPU_STATE_STP 2 +#define PV_CPU_STATE_CHKSTP 3 + +struct uv_cb_cpu_set_state { + struct uv_cb_header header; + u64 reserved08[2]; + u64 cpu_handle; + u8 reserved20[7]; + u8 state; + u64 reserved28[5]; +}; + /* * A common UV call struct for the following calls: * Destroy cpu/config diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c index b951dbdcb6a0..1c53eb7ba152 100644 --- a/arch/s390/kvm/diag.c +++ b/arch/s390/kvm/diag.c @@ -13,6 +13,7 @@ #include <asm/pgalloc.h> #include <asm/gmap.h> #include <asm/virtio-ccw.h> +#include <asm/uv.h> #include "kvm-s390.h" #include "trace.h" #include "trace-s390.h" diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 8947f1812b12..d3fd3ad1d09b 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2256,6 +2256,26 @@ static int kvm_s390_handle_pv(struct kvm *kvm, struct kvm_pv_cmd *cmd) ret >> 16, ret & 0x0000ffff); break; } + case KVM_PV_VM_PERF_CLEAR_RESET: { + u32 ret; + + r = uv_cmd_nodata(kvm_s390_pv_handle(kvm), + UVC_CMD_PERF_CONF_CLEAR_RESET, + &ret); + VM_EVENT(kvm, 3, "PROTVIRT PERF CLEAR: rc %x rrc %x", + ret >> 16, ret & 0x0000ffff); + break; + } + case KVM_PV_VM_UNSHARE: { + u32 ret; + + r = uv_cmd_nodata(kvm_s390_pv_handle(kvm), + UVC_CMD_SET_UNSHARED_ALL, + &ret); + VM_EVENT(kvm, 3, "PROTVIRT UNSHARE: %d rc %x rrc %x", + r, ret >> 16, ret & 0x0000ffff); + break; + } default: return -ENOTTY; } diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 0d61dcc51f0e..8cd2e978363d 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -209,6 +209,7 @@ int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length); int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size, unsigned long tweak); int kvm_s390_pv_verify(struct kvm *kvm); +int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state); static inline bool kvm_s390_pv_is_protected(struct kvm *kvm) { @@ -238,6 +239,7 @@ static inline int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size, unsigned long tweak) { return 0; } static inline int kvm_s390_pv_verify(struct kvm *kvm) { return 0; } +static inline int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state) { return 0; } static inline bool kvm_s390_pv_is_protected(struct kvm *kvm) { return 0; } static inline u64 kvm_s390_pv_handle(struct kvm *kvm) { return 0; } static inline u64 kvm_s390_pv_handle_cpu(struct kvm_vcpu *vcpu) { return 0; } diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c index be7d558ab897..cf79a6503e1c 100644 --- a/arch/s390/kvm/pv.c +++ b/arch/s390/kvm/pv.c @@ -280,3 +280,22 @@ int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size, uvcb.header.rc, uvcb.header.rrc); return rc; } + +int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state) +{ + int rc; + struct uv_cb_cpu_set_state uvcb = { + .header.cmd = UVC_CMD_CPU_SET_STATE, + .header.len = sizeof(uvcb), + .cpu_handle = kvm_s390_pv_handle_cpu(vcpu), + .state = state, + }; + + if (!kvm_s390_pv_handle_cpu(vcpu)) + return -EINVAL; + + rc = uv_call(0, (u64)&uvcb); + if (rc) + return -EINVAL; + return 0; +} diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index bb37d5710c89..f75a051a7705 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1479,6 +1479,8 @@ enum pv_cmd_id { KVM_PV_VM_SET_SEC_PARMS, KVM_PV_VM_UNPACK, KVM_PV_VM_VERIFY, + KVM_PV_VM_PERF_CLEAR_RESET, + KVM_PV_VM_UNSHARE, KVM_PV_VCPU_CREATE, KVM_PV_VCPU_DESTROY, };
Signed-off-by: Janosch Frank <frankja@linux.ibm.com> --- arch/s390/include/asm/uv.h | 25 +++++++++++++++++++++++++ arch/s390/kvm/diag.c | 1 + arch/s390/kvm/kvm-s390.c | 20 ++++++++++++++++++++ arch/s390/kvm/kvm-s390.h | 2 ++ arch/s390/kvm/pv.c | 19 +++++++++++++++++++ include/uapi/linux/kvm.h | 2 ++ 6 files changed, 69 insertions(+)