From: Christoffer Dall <christoffer.dall@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com,
peter.maydell@linaro.org, agraf@suse.de, drjones@redhat.com,
pbonzini@redhat.com, zhichao.huang@linaro.org,
jan.kiszka@siemens.com, dahi@linux.vnet.ibm.com,
r65777@freescale.com, bp@suse.de, Gleb Natapov <gleb@kernel.org>,
Russell King <linux@arm.linux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Richard Weinberger <richard@nod.at>,
Andre Przywara <andre.przywara@arm.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v7 08/11] KVM: arm64: introduce vcpu->arch.debug_ptr
Date: Fri, 3 Jul 2015 23:46:47 +0200 [thread overview]
Message-ID: <20150703214647.GD10878@cbox> (raw)
In-Reply-To: <87mvzdsoer.fsf@linaro.org>
On Fri, Jul 03, 2015 at 08:14:52AM +0100, Alex Bennée wrote:
>
> Christoffer Dall <christoffer.dall@linaro.org> writes:
>
> > On Wed, Jul 01, 2015 at 07:29:00PM +0100, Alex Bennée wrote:
> >> This introduces a level of indirection for the debug registers. Instead
> >> of using the sys_regs[] directly we store registers in a structure in
> >> the vcpu. The new kvm_arm_reset_debug_ptr() sets the debug ptr to the
> >> guest context.
> >>
> >> This also entails updating the sys_regs code to access this new
> >> structure. New access function have been added for each set of debug
> >> registers. The generic functions are still used for the few registers
> >> stored in the main context.
> >>
> >> New access function pointers have been added to the sys_reg_desc
> >> structure to support the GET/SET_ONE_REG ioctl operations.
> >
> > Why is this needed?
>
> Previously I had a hacky:
>
> if (r->access == trap_debug64)
> return debug_get64(vcpu, r, reg, uaddr);
>
> Which used the same offset information. Now we have a cleaner:
>
> if (r->set)
> return (r->set)(vcpu, r, reg, uaddr);
>
> Which accesses the structure directly, as the trap functions do:
>
> __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
> if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> return -EFAULT;
> return 0;
I get it now, had to take another look at sys_regs.c.
I think this commit message needs a littel tweaking saying "Because we
no longer give the sys_regs offset for the sys_reg_desc->reg field, but
instead the index into a debug-specific struct, the generic user-space
access code no longer works, and we are therefore forced to add specific
user_set/get functions for these registers."
At least it was hard for me to understand the rationale without this,
and I think it would be good to have for someone doing git blame later.
>
> <snip>
> >> +#if 0
> >> +static int debug_set64(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> >> + const struct kvm_one_reg *reg, void __user *uaddr)
> >> +{
> >> + __u64 *r = (__u64 *) ((void * )&vcpu->arch.vcpu_debug_state + rd->reg);
> >> + if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> >> + return -EFAULT;
> >> + return 0;
> >> +}
> >> +
> >> +static int debug_get64(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> >> + const struct kvm_one_reg *reg, void __user *uaddr)
> >> +{
> >> + __u64 *r = (__u64 *) ((void * )&vcpu->arch.vcpu_debug_state + rd->reg);
> >> + if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> >> + return -EFAULT;
> >> + return 0;
> >> +}
> >> +#endif
> >> +
> >
> > what is this ifdef'ed block of code doing here?
>
> Oops. Yeah looks like I missed removing that after I finished the
> re-factor. These where the old get/set functions I used.
>
> >
> >> int kvm_arm_sys_reg_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> >> {
> >> const struct sys_reg_desc *r;
> >> @@ -1303,6 +1530,9 @@ int kvm_arm_sys_reg_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg
> >> if (!r)
> >> return get_invariant_sys_reg(reg->id, uaddr);
> >>
> >> + if (r->get)
> >> + return (r->get)(vcpu, r, reg, uaddr);
> >> +
> >> return reg_to_user(uaddr, &vcpu_sys_reg(vcpu, r->reg), reg->id);
> >> }
> >>
> >> @@ -1321,6 +1551,9 @@ int kvm_arm_sys_reg_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg
> >> if (!r)
> >> return set_invariant_sys_reg(reg->id, uaddr);
> >>
> >> + if (r->set)
> >> + return (r->set)(vcpu, r, reg, uaddr);
> >> +
> >> return reg_from_user(&vcpu_sys_reg(vcpu, r->reg), uaddr, reg->id);
> >> }
> >>
> >> diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h
> >> index d411e25..9265e7d 100644
> >> --- a/arch/arm64/kvm/sys_regs.h
> >> +++ b/arch/arm64/kvm/sys_regs.h
> >> @@ -55,6 +55,12 @@ struct sys_reg_desc {
> >>
> >> /* Value (usually reset value) */
> >> u64 val;
> >> +
> >> + /* Get/Set functions, fallback if NULL */
> >
> > Is this only meant for usersapce access or when should one use these?
>
> Yes for GET/SET
>
ok, see other mail for potential rename to get_user / set_user if you
like the idea.
Thanks,
-Christoffer
WARNING: multiple messages have this Message-ID (diff)
From: christoffer.dall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 08/11] KVM: arm64: introduce vcpu->arch.debug_ptr
Date: Fri, 3 Jul 2015 23:46:47 +0200 [thread overview]
Message-ID: <20150703214647.GD10878@cbox> (raw)
In-Reply-To: <87mvzdsoer.fsf@linaro.org>
On Fri, Jul 03, 2015 at 08:14:52AM +0100, Alex Benn?e wrote:
>
> Christoffer Dall <christoffer.dall@linaro.org> writes:
>
> > On Wed, Jul 01, 2015 at 07:29:00PM +0100, Alex Benn?e wrote:
> >> This introduces a level of indirection for the debug registers. Instead
> >> of using the sys_regs[] directly we store registers in a structure in
> >> the vcpu. The new kvm_arm_reset_debug_ptr() sets the debug ptr to the
> >> guest context.
> >>
> >> This also entails updating the sys_regs code to access this new
> >> structure. New access function have been added for each set of debug
> >> registers. The generic functions are still used for the few registers
> >> stored in the main context.
> >>
> >> New access function pointers have been added to the sys_reg_desc
> >> structure to support the GET/SET_ONE_REG ioctl operations.
> >
> > Why is this needed?
>
> Previously I had a hacky:
>
> if (r->access == trap_debug64)
> return debug_get64(vcpu, r, reg, uaddr);
>
> Which used the same offset information. Now we have a cleaner:
>
> if (r->set)
> return (r->set)(vcpu, r, reg, uaddr);
>
> Which accesses the structure directly, as the trap functions do:
>
> __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
> if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> return -EFAULT;
> return 0;
I get it now, had to take another look at sys_regs.c.
I think this commit message needs a littel tweaking saying "Because we
no longer give the sys_regs offset for the sys_reg_desc->reg field, but
instead the index into a debug-specific struct, the generic user-space
access code no longer works, and we are therefore forced to add specific
user_set/get functions for these registers."
At least it was hard for me to understand the rationale without this,
and I think it would be good to have for someone doing git blame later.
>
> <snip>
> >> +#if 0
> >> +static int debug_set64(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> >> + const struct kvm_one_reg *reg, void __user *uaddr)
> >> +{
> >> + __u64 *r = (__u64 *) ((void * )&vcpu->arch.vcpu_debug_state + rd->reg);
> >> + if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> >> + return -EFAULT;
> >> + return 0;
> >> +}
> >> +
> >> +static int debug_get64(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> >> + const struct kvm_one_reg *reg, void __user *uaddr)
> >> +{
> >> + __u64 *r = (__u64 *) ((void * )&vcpu->arch.vcpu_debug_state + rd->reg);
> >> + if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> >> + return -EFAULT;
> >> + return 0;
> >> +}
> >> +#endif
> >> +
> >
> > what is this ifdef'ed block of code doing here?
>
> Oops. Yeah looks like I missed removing that after I finished the
> re-factor. These where the old get/set functions I used.
>
> >
> >> int kvm_arm_sys_reg_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> >> {
> >> const struct sys_reg_desc *r;
> >> @@ -1303,6 +1530,9 @@ int kvm_arm_sys_reg_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg
> >> if (!r)
> >> return get_invariant_sys_reg(reg->id, uaddr);
> >>
> >> + if (r->get)
> >> + return (r->get)(vcpu, r, reg, uaddr);
> >> +
> >> return reg_to_user(uaddr, &vcpu_sys_reg(vcpu, r->reg), reg->id);
> >> }
> >>
> >> @@ -1321,6 +1551,9 @@ int kvm_arm_sys_reg_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg
> >> if (!r)
> >> return set_invariant_sys_reg(reg->id, uaddr);
> >>
> >> + if (r->set)
> >> + return (r->set)(vcpu, r, reg, uaddr);
> >> +
> >> return reg_from_user(&vcpu_sys_reg(vcpu, r->reg), uaddr, reg->id);
> >> }
> >>
> >> diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h
> >> index d411e25..9265e7d 100644
> >> --- a/arch/arm64/kvm/sys_regs.h
> >> +++ b/arch/arm64/kvm/sys_regs.h
> >> @@ -55,6 +55,12 @@ struct sys_reg_desc {
> >>
> >> /* Value (usually reset value) */
> >> u64 val;
> >> +
> >> + /* Get/Set functions, fallback if NULL */
> >
> > Is this only meant for usersapce access or when should one use these?
>
> Yes for GET/SET
>
ok, see other mail for potential rename to get_user / set_user if you
like the idea.
Thanks,
-Christoffer
next prev parent reply other threads:[~2015-07-03 21:46 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-01 18:28 [PATCH v7 00/11] KVM Guest Debug support for arm64 Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` [PATCH v7 01/11] KVM: add comments for kvm_debug_exit_arch struct Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` [PATCH v7 02/11] KVM: arm64: guest debug, define API headers Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` [PATCH v7 03/11] KVM: arm: guest debug, add stub KVM_SET_GUEST_DEBUG ioctl Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` [PATCH v7 04/11] KVM: arm: introduce kvm_arm_init/setup/clear_debug Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` [PATCH v7 05/11] KVM: arm64: guest debug, add SW break point support Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` [PATCH v7 06/11] KVM: arm64: guest debug, add support for single-step Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` [PATCH v7 07/11] KVM: arm64: re-factor hyp.S debug register code Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:28 ` Alex Bennée
2015-07-01 18:29 ` [PATCH v7 08/11] KVM: arm64: introduce vcpu->arch.debug_ptr Alex Bennée
2015-07-01 18:29 ` Alex Bennée
2015-07-01 18:29 ` Alex Bennée
2015-07-02 18:34 ` Christoffer Dall
2015-07-02 18:34 ` Christoffer Dall
2015-07-03 7:14 ` Alex Bennée
2015-07-03 7:14 ` Alex Bennée
2015-07-03 7:14 ` Alex Bennée
2015-07-03 21:46 ` Christoffer Dall [this message]
2015-07-03 21:46 ` Christoffer Dall
2015-07-03 21:43 ` Christoffer Dall
2015-07-03 21:43 ` Christoffer Dall
2015-07-03 21:43 ` Christoffer Dall
2015-07-01 18:29 ` [PATCH v7 09/11] KVM: arm64: guest debug, HW assisted debug support Alex Bennée
2015-07-01 18:29 ` Alex Bennée
2015-07-01 18:29 ` Alex Bennée
[not found] ` <1435775343-20034-10-git-send-email-alex.bennee-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-07-02 8:48 ` Will Deacon
2015-07-02 8:48 ` Will Deacon
2015-07-02 8:48 ` Will Deacon
2015-07-02 8:48 ` Will Deacon
2015-07-02 13:50 ` Alex Bennée
2015-07-02 13:50 ` Alex Bennée
2015-07-02 13:50 ` Alex Bennée
2015-07-02 13:50 ` Alex Bennée
2015-07-03 9:23 ` Will Deacon
2015-07-03 9:23 ` Will Deacon
2015-07-03 9:23 ` Will Deacon
2015-07-03 9:23 ` Will Deacon
2015-07-03 16:07 ` Alex Bennée
2015-07-03 16:07 ` Alex Bennée
2015-07-03 16:07 ` Alex Bennée
2015-07-06 8:51 ` Will Deacon
2015-07-06 8:51 ` Will Deacon
2015-07-06 8:51 ` Will Deacon
2015-07-06 8:51 ` Will Deacon
2015-07-06 9:02 ` Alex Bennée
2015-07-06 9:02 ` Alex Bennée
2015-07-06 9:02 ` Alex Bennée
2015-07-06 9:02 ` Alex Bennée
2015-07-06 9:31 ` Christoffer Dall
2015-07-06 9:31 ` Christoffer Dall
2015-07-06 9:31 ` Christoffer Dall
2015-07-01 18:29 ` [PATCH v7 10/11] KVM: arm64: enable KVM_CAP_SET_GUEST_DEBUG Alex Bennée
2015-07-01 18:29 ` Alex Bennée
2015-07-01 18:29 ` Alex Bennée
2015-07-01 18:29 ` [PATCH v7 11/11] KVM: arm64: add trace points for guest_debug debug Alex Bennée
2015-07-01 18:29 ` Alex Bennée
2015-07-01 18:29 ` Alex Bennée
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=20150703214647.GD10878@cbox \
--to=christoffer.dall@linaro.org \
--cc=agraf@suse.de \
--cc=alex.bennee@linaro.org \
--cc=andre.przywara@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=bp@suse.de \
--cc=catalin.marinas@arm.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=drjones@redhat.com \
--cc=gleb@kernel.org \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=lorenzo.pieralisi@arm.com \
--cc=marc.zyngier@arm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=r65777@freescale.com \
--cc=richard@nod.at \
--cc=will.deacon@arm.com \
--cc=zhichao.huang@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.