From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Janosch Frank <frankja@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
borntraeger@linux.ibm.com
Subject: Re: [PATCH 7/9] kvm: s390: Add CPU dump functionality
Date: Tue, 10 May 2022 11:14:54 +0200 [thread overview]
Message-ID: <20220510111454.405ffc18@p-imbrenda> (raw)
In-Reply-To: <b0da2530-24b7-5002-cfe1-73080512abb8@linux.ibm.com>
On Tue, 10 May 2022 09:26:50 +0200
Janosch Frank <frankja@linux.ibm.com> wrote:
> On 5/9/22 21:11, Claudio Imbrenda wrote:
> > On Thu, 28 Apr 2022 13:01:00 +0000
> > Janosch Frank <frankja@linux.ibm.com> wrote:
> >
> >> The previous patch introduced the per-VM dump functions now let's
> >> focus on dumping the VCPU state via the newly introduced
> >> KVM_S390_PV_CPU_COMMAND ioctl which mirrors the VM UV ioctl and can be
> >> extended with new commands later.
> >>
> >> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> >> ---
> >> arch/s390/kvm/kvm-s390.c | 73 ++++++++++++++++++++++++++++++++++++++++
> >> arch/s390/kvm/kvm-s390.h | 1 +
> >> arch/s390/kvm/pv.c | 16 +++++++++
> >> include/uapi/linux/kvm.h | 5 +++
> >> 4 files changed, 95 insertions(+)
> >>
> >> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> >> index 8984e8db33b4..d15ce38bef14 100644
> >> --- a/arch/s390/kvm/kvm-s390.c
> >> +++ b/arch/s390/kvm/kvm-s390.c
> >> @@ -5149,6 +5149,52 @@ long kvm_arch_vcpu_async_ioctl(struct file *filp,
> >> return -ENOIOCTLCMD;
> >> }
> >>
> >> +static int kvm_s390_handle_pv_vcpu_dump(struct kvm_vcpu *vcpu,
> >> + struct kvm_pv_cmd *cmd)
> >> +{
> >> + struct kvm_s390_pv_dmp dmp;
> >> + void *data;
> >> + int ret;
> >> +
> >> + /* Dump initialization is a prerequisite */
> >> + if (!vcpu->kvm->arch.pv.dumping)
> >> + return -EINVAL;
> >> +
> >> + if (copy_from_user(&dmp, (__u8 __user *)cmd->data, sizeof(dmp)))
> >> + return -EFAULT;
> >> +
> >> + /* We only handle this subcmd right now */
> >> + if (dmp.subcmd != KVM_PV_DUMP_CPU)
> >> + return -EINVAL;
> >> +
> >> + /* CPU dump length is the same as create cpu storage donation. */
> >> + if (dmp.buff_len != uv_info.guest_cpu_stor_len)
> >> + return -EINVAL;
> >> +
> >> + data = vzalloc(uv_info.guest_cpu_stor_len);
> >> + if (!data)
> >> + return -ENOMEM;
> >> +
> >> + ret = kvm_s390_pv_dump_cpu(vcpu, data, &cmd->rc, &cmd->rrc);
> >> +
> >> + VCPU_EVENT(vcpu, 3, "PROTVIRT DUMP CPU %d rc %x rrc %x",
> >> + vcpu->vcpu_id, cmd->rc, cmd->rrc);
> >> +
> >> + if (ret) {
> >> + vfree(data);
> >> + return -EINVAL;
> >> + }
> >> +
> >> + /* On success copy over the dump data */
> >> + if (copy_to_user((__u8 __user *)dmp.buff_addr, data, uv_info.guest_cpu_stor_len)) {
> >> + vfree(data);
> >> + return -EFAULT;
> >> + }
> >> +
> >> + vfree(data);
> >> + return 0;
> >> +}
> >> +
> >> long kvm_arch_vcpu_ioctl(struct file *filp,
> >> unsigned int ioctl, unsigned long arg)
> >> {
> >> @@ -5313,6 +5359,33 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
> >> irq_state.len);
> >> break;
> >> }
> >> + case KVM_S390_PV_CPU_COMMAND: {
> >> + struct kvm_pv_cmd cmd;
> >> +
> >> + r = -EINVAL;
> >> + if (!is_prot_virt_host())
> >> + break;
> >> +
> >> + r = -EFAULT;
> >> + if (copy_from_user(&cmd, argp, sizeof(cmd)))
> >> + break;
> >> +
> >> + r = -EINVAL;
> >> + if (cmd.flags)
> >> + break;
> >> +
> >> + /* We only handle this cmd right now */
> >> + if (cmd.cmd != KVM_PV_DUMP)
> >> + break;
> >> +
> >> + r = kvm_s390_handle_pv_vcpu_dump(vcpu, &cmd);
> >> +
> >> + /* Always copy over UV rc / rrc data */
> >> + if (copy_to_user((__u8 __user *)argp, &cmd.rc,
> >> + sizeof(cmd.rc) + sizeof(cmd.rrc)))
> >> + r = -EFAULT;
> >> + break;
> >> + }
> >> default:
> >> r = -ENOTTY;
> >> }
> >> diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
> >> index 2868dd0bba25..a39815184350 100644
> >> --- a/arch/s390/kvm/kvm-s390.h
> >> +++ b/arch/s390/kvm/kvm-s390.h
> >> @@ -250,6 +250,7 @@ int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length, u16 *rc,
> >> int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size,
> >> unsigned long tweak, u16 *rc, u16 *rrc);
> >> int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state);
> >> +int kvm_s390_pv_dump_cpu(struct kvm_vcpu *vcpu, void *buff, u16 *rc, u16 *rrc);
> >> int kvm_s390_pv_dump_stor_state(struct kvm *kvm, void __user *buff_user,
> >> u64 *gaddr, u64 buff_user_len, u16 *rc, u16 *rrc);
> >>
> >> diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c
> >> index d1635ed50078..9ab8192b9b23 100644
> >> --- a/arch/s390/kvm/pv.c
> >> +++ b/arch/s390/kvm/pv.c
> >> @@ -299,6 +299,22 @@ int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state)
> >> return 0;
> >> }
> >>
> >> +int kvm_s390_pv_dump_cpu(struct kvm_vcpu *vcpu, void *buff, u16 *rc, u16 *rrc)
> >> +{
> >> + struct uv_cb_dump_cpu uvcb = {
> >> + .header.cmd = UVC_CMD_DUMP_CPU,
> >> + .header.len = sizeof(uvcb),
> >> + .cpu_handle = vcpu->arch.pv.handle,
> >> + .dump_area_origin = (u64)buff,
> >> + };
> >> + int cc;
> >> +
> >> + cc = uv_call_sched(0, (u64)&uvcb);
> >
> > it's a small amount of data, but you use the _sched variant?
>
> Who knows what FW will do :)
>
> >
> > and, why aren't you using the _sched variant in the previous patch (for
> > DUMP_COMPLETE)?
> >
> > to be clear: I think the right thing is to always use the _sched
> > variant unless there is a good reason not to (so please fix the previous
> > patch)
>
> Yep, will fix.
>
> It might make sense to switch the functions around and make uv_call
> always do a sched and introduce uv_call_nosched() since that's the
> special case. But that's something for the future.
I was actually thinking the same thing :)
>
> >
> >> + *rc = uvcb.header.rc;
> >> + *rrc = uvcb.header.rrc;
> >> + return cc;
> >> +}
> >> +
> >> /* Size of the cache for the storage state dump data. 1MB for now */
> >> #define DUMP_BUFF_LEN HPAGE_SIZE
> >>
> >> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> >> index b34850907291..108bc7b7a71b 100644
> >> --- a/include/uapi/linux/kvm.h
> >> +++ b/include/uapi/linux/kvm.h
> >> @@ -1144,6 +1144,7 @@ struct kvm_ppc_resize_hpt {
> >> #define KVM_CAP_S390_MEM_OP_EXTENSION 211
> >> #define KVM_CAP_PMU_CAPABILITY 212
> >> #define KVM_CAP_DISABLE_QUIRKS2 213
> >> +#define KVM_CAP_S390_PROTECTED_DUMP 214
> >>
> >> #ifdef KVM_CAP_IRQ_ROUTING
> >>
> >> @@ -1649,6 +1650,7 @@ enum pv_cmd_dmp_id {
> >> KVM_PV_DUMP_INIT,
> >> KVM_PV_DUMP_CONFIG_STOR_STATE,
> >> KVM_PV_DUMP_COMPLETE,
> >> + KVM_PV_DUMP_CPU,
> >> };
> >>
> >> struct kvm_s390_pv_dmp {
> >> @@ -2110,4 +2112,7 @@ struct kvm_stats_desc {
> >> /* Available with KVM_CAP_XSAVE2 */
> >> #define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave)
> >>
> >> +/* Available with KVM_CAP_S390_PROTECTED_DUMP */
> >> +#define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd)
> >> +
> >> #endif /* __LINUX_KVM_H */
> >
>
next prev parent reply other threads:[~2022-05-10 9:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 13:00 [PATCH 0/9] kvm: s390: Add PV dump support Janosch Frank
2022-04-28 13:00 ` [PATCH 1/9] s390x: Add SE hdr query information Janosch Frank
2022-04-28 13:00 ` [PATCH 2/9] s390: uv: Add dump fields to query Janosch Frank
2022-04-28 13:00 ` [PATCH 3/9] KVM: s390: pv: Add query interface Janosch Frank
2022-05-09 15:25 ` Claudio Imbrenda
2022-05-10 7:27 ` Janosch Frank
2022-04-28 13:00 ` [PATCH 4/9] KVM: s390: pv: Add dump support definitions Janosch Frank
2022-04-28 13:00 ` [PATCH 5/9] KVM: s390: pv: Add query dump information Janosch Frank
2022-05-09 15:28 ` Claudio Imbrenda
2022-05-10 12:36 ` Janosch Frank
2022-05-10 13:28 ` Claudio Imbrenda
2022-04-28 13:00 ` [PATCH 6/9] kvm: s390: Add configuration dump functionality Janosch Frank
2022-05-09 17:51 ` Claudio Imbrenda
2022-05-10 14:07 ` Janosch Frank
2022-04-28 13:01 ` [PATCH 7/9] kvm: s390: Add CPU " Janosch Frank
2022-05-09 19:11 ` Claudio Imbrenda
2022-05-10 7:26 ` Janosch Frank
2022-05-10 9:14 ` Claudio Imbrenda [this message]
2022-04-28 13:01 ` [PATCH 8/9] Documentation: virt: Protected virtual machine dumps Janosch Frank
2022-04-28 13:01 ` [PATCH 9/9] Documentation/virt/kvm/api.rst: Add protvirt dump/info api descriptions Janosch Frank
-- strict thread matches above, loose matches on Subject: below --
2022-02-23 9:19 [PATCH 0/9] kvm: s390: Add PV dump support Janosch Frank
2022-02-23 9:20 ` [PATCH 7/9] kvm: s390: Add CPU dump functionality Janosch Frank
2022-02-23 19:46 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220510111454.405ffc18@p-imbrenda \
--to=imbrenda@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox