All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: catalin.marinas@arm.com, will@kernel.org,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 5/5] KVM: arm64: uapi: Add kvm_debug_exit_arch.hsr_high
Date: Fri, 22 Apr 2022 08:30:08 +0100	[thread overview]
Message-ID: <87czh9a83j.wl-maz@kernel.org> (raw)
In-Reply-To: <YmF2mCJaEWFKS3xR@monolith.localdoman>

On Thu, 21 Apr 2022 16:22:00 +0100,
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> 
> Hi,
> 
> On Thu, Apr 21, 2022 at 01:58:52PM +0100, Marc Zyngier wrote:
> > On Thu, 21 Apr 2022 11:05:47 +0100,
> > Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> > > 
> > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> > > index 93d92130d36c..fd5b6773e3a2 100644
> > > --- a/arch/arm64/kvm/handle_exit.c
> > > +++ b/arch/arm64/kvm/handle_exit.c
> > > @@ -121,6 +121,8 @@ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu)
> > >  
> > >  	run->exit_reason = KVM_EXIT_DEBUG;
> > >  	run->debug.arch.hsr = lower_32_bits(esr);
> > > +	run->debug.arch.hsr_high = upper_32_bits(esr);
> > > +	run->flags |= KVM_DEBUG_ARCH_HSR_HIGH_VALID;
> > 
> > Who will eventually clear this flag? I'm concerned that it could be
> > misinterpreted by other userspace paths, as once you get a debug exit
> > on this vcpu, it will always be set.
> > 
> > Probably only a matter of clearing flags on all the other exit paths.
> 
> I missed this part, I was under the impression that kvm_run->flags was
> already cleared on every exit (that's why it's bitwise OR'ed with the
> flag).
> 
> kvm_arch_vcpu_ioctl_run() always sets exit_reason = KVM_EXIT_UNKNOWN, so I
> guess if we want to be consistent, kvm_run->flags should be cleared at the
> same time. Unless you want KVM to clear flags for all exit reasons *except*
> KVM_EXIT_UNKNOWN.
> 
> I prefer clearing flags in kvm_arch_vcpu_ioctl_run() as that looks to me
> like the least error prone way to do it, and if in the future an exit
> reason wants to preserve flags across KVM_RUN ioctls we can add a check for
> that particular situation.

It seems entirely reasonable to reset exit_reason and flags together.

> 
> > 
> > Also, please document the flag in the API file (only a couple of x86
> > flags are there so far).
> 
> Sure thing, will do.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: catalin.marinas@arm.com, will@kernel.org,
	linux-arm-kernel@lists.infradead.org, james.morse@arm.com,
	suzuki.poulose@arm.com, kvmarm@lists.cs.columbia.edu,
	mark.rutland@arm.com
Subject: Re: [PATCH v2 5/5] KVM: arm64: uapi: Add kvm_debug_exit_arch.hsr_high
Date: Fri, 22 Apr 2022 08:30:08 +0100	[thread overview]
Message-ID: <87czh9a83j.wl-maz@kernel.org> (raw)
In-Reply-To: <YmF2mCJaEWFKS3xR@monolith.localdoman>

On Thu, 21 Apr 2022 16:22:00 +0100,
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> 
> Hi,
> 
> On Thu, Apr 21, 2022 at 01:58:52PM +0100, Marc Zyngier wrote:
> > On Thu, 21 Apr 2022 11:05:47 +0100,
> > Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> > > 
> > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> > > index 93d92130d36c..fd5b6773e3a2 100644
> > > --- a/arch/arm64/kvm/handle_exit.c
> > > +++ b/arch/arm64/kvm/handle_exit.c
> > > @@ -121,6 +121,8 @@ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu)
> > >  
> > >  	run->exit_reason = KVM_EXIT_DEBUG;
> > >  	run->debug.arch.hsr = lower_32_bits(esr);
> > > +	run->debug.arch.hsr_high = upper_32_bits(esr);
> > > +	run->flags |= KVM_DEBUG_ARCH_HSR_HIGH_VALID;
> > 
> > Who will eventually clear this flag? I'm concerned that it could be
> > misinterpreted by other userspace paths, as once you get a debug exit
> > on this vcpu, it will always be set.
> > 
> > Probably only a matter of clearing flags on all the other exit paths.
> 
> I missed this part, I was under the impression that kvm_run->flags was
> already cleared on every exit (that's why it's bitwise OR'ed with the
> flag).
> 
> kvm_arch_vcpu_ioctl_run() always sets exit_reason = KVM_EXIT_UNKNOWN, so I
> guess if we want to be consistent, kvm_run->flags should be cleared at the
> same time. Unless you want KVM to clear flags for all exit reasons *except*
> KVM_EXIT_UNKNOWN.
> 
> I prefer clearing flags in kvm_arch_vcpu_ioctl_run() as that looks to me
> like the least error prone way to do it, and if in the future an exit
> reason wants to preserve flags across KVM_RUN ioctls we can add a check for
> that particular situation.

It seems entirely reasonable to reset exit_reason and flags together.

> 
> > 
> > Also, please document the flag in the API file (only a couple of x86
> > flags are there so far).
> 
> Sure thing, will do.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-04-22  7:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 10:05 [PATCH v2 0/5] arm64: Treat ESR_ELx as a 64-bit register Alexandru Elisei
2022-04-21 10:05 ` Alexandru Elisei
2022-04-21 10:05 ` [PATCH v2 1/5] arm64: Make ESR_ELx_xVC_IMM_MASK compatible with assembly Alexandru Elisei
2022-04-21 10:05   ` Alexandru Elisei
2022-04-21 10:05 ` [PATCH v2 2/5] arm64: compat: Do not treat syscall number as ESR_ELx for a bad syscall Alexandru Elisei
2022-04-21 10:05   ` Alexandru Elisei
2022-04-21 10:05 ` [PATCH v2 3/5] arm64: Treat ESR_ELx as a 64-bit register Alexandru Elisei
2022-04-21 10:05   ` Alexandru Elisei
2022-04-21 10:05 ` [PATCH v2 4/5] KVM: arm64: Treat ESR_EL2 " Alexandru Elisei
2022-04-21 10:05   ` Alexandru Elisei
2022-04-21 10:05 ` [PATCH v2 5/5] KVM: arm64: uapi: Add kvm_debug_exit_arch.hsr_high Alexandru Elisei
2022-04-21 10:05   ` Alexandru Elisei
2022-04-21 12:58   ` Marc Zyngier
2022-04-21 12:58     ` Marc Zyngier
2022-04-21 15:22     ` Alexandru Elisei
2022-04-21 15:22       ` Alexandru Elisei
2022-04-22  7:30       ` Marc Zyngier [this message]
2022-04-22  7:30         ` Marc Zyngier

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=87czh9a83j.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@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 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.