Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Fuad Tabba <tabba@google.com>
Cc: kernel-team@android.com, kvm@vger.kernel.org,
	Will Deacon <will@kernel.org>, Mark Brown <broonie@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 09/18] KVM: arm64: Move vcpu debug/SPE/TRBE flags to the input flag set
Date: Wed, 08 Jun 2022 17:01:29 +0100	[thread overview]
Message-ID: <87ilpb4012.wl-maz@kernel.org> (raw)
In-Reply-To: <CA+EHjTzy99Waj8P48pbzbR2+KfgUzbZX5oj_J+JKo70VOq6yiQ@mail.gmail.com>

On Wed, 08 Jun 2022 16:16:16 +0100,
Fuad Tabba <tabba@google.com> wrote:
> 
> Hi Marc,
> 
> On Sat, May 28, 2022 at 12:38 PM Marc Zyngier <maz@kernel.org> wrote:
> >
> > The three debug flags (which deal with the debug registers, SPE and
> > TRBE) all are input flags to the hypervisor code.
> >
> > Move them into the input set and convert them to the new accessors.
> >
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > ---
> >  arch/arm64/include/asm/kvm_host.h          |  9 ++++++---
> >  arch/arm64/kvm/debug.c                     | 22 +++++++++++-----------
> >  arch/arm64/kvm/hyp/include/hyp/debug-sr.h  |  6 +++---
> >  arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h |  4 ++--
> >  arch/arm64/kvm/hyp/nvhe/debug-sr.c         |  8 ++++----
> >  arch/arm64/kvm/sys_regs.c                  |  8 ++++----
> >  6 files changed, 30 insertions(+), 27 deletions(-)
> >
> > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> > index 078567f5709c..a426cd3aaa74 100644
> > --- a/arch/arm64/include/asm/kvm_host.h
> > +++ b/arch/arm64/include/asm/kvm_host.h
> > @@ -500,6 +500,12 @@ struct kvm_vcpu_arch {
> >  #define EXCEPT_AA64_EL2_IRQ    __vcpu_except_flags(5)
> >  #define EXCEPT_AA64_EL2_FIQ    __vcpu_except_flags(6)
> >  #define EXCEPT_AA64_EL2_SERR   __vcpu_except_flags(7)
> > +/* Guest debug is live */
> > +#define DEBUG_DIRTY            __vcpu_single_flag(iflags, BIT(4))
> > +/* Save SPE context if active  */
> > +#define DEBUG_STATE_SAVE_SPE   __vcpu_single_flag(iflags, BIT(5))
> > +/* Save TRBE context if active  */
> > +#define DEBUG_STATE_SAVE_TRBE  __vcpu_single_flag(iflags, BIT(6))
> >
> >  /* Pointer to the vcpu's SVE FFR for sve_{save,load}_state() */
> >  #define vcpu_sve_pffr(vcpu) (kern_hyp_va((vcpu)->arch.sve_state) +     \
> > @@ -522,10 +528,7 @@ struct kvm_vcpu_arch {
> >  })
> >
> >  /* vcpu_arch flags field values: */
> > -#define KVM_ARM64_DEBUG_DIRTY          (1 << 0)
> >  #define KVM_ARM64_HOST_SVE_ENABLED     (1 << 4) /* SVE enabled for EL0 */
> > -#define KVM_ARM64_DEBUG_STATE_SAVE_SPE (1 << 12) /* Save SPE context if active  */
> > -#define KVM_ARM64_DEBUG_STATE_SAVE_TRBE        (1 << 13) /* Save TRBE context if active  */
> >  #define KVM_ARM64_ON_UNSUPPORTED_CPU   (1 << 15) /* Physical CPU not in supported_cpus */
> >  #define KVM_ARM64_HOST_SME_ENABLED     (1 << 16) /* SME enabled for EL0 */
> >  #define KVM_ARM64_WFIT                 (1 << 17) /* WFIT instruction trapped */
> > diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
> > index 4fd5c216c4bb..c5c4c1837bf3 100644
> > --- a/arch/arm64/kvm/debug.c
> > +++ b/arch/arm64/kvm/debug.c
> > @@ -104,11 +104,11 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu)
> >          * Trap debug register access when one of the following is true:
> >          *  - Userspace is using the hardware to debug the guest
> >          *  (KVM_GUESTDBG_USE_HW is set).
> > -        *  - The guest is not using debug (KVM_ARM64_DEBUG_DIRTY is clear).
> > +        *  - The guest is not using debug (DEBUG_DIRTY clear).
> >          *  - The guest has enabled the OS Lock (debug exceptions are blocked).
> >          */
> >         if ((vcpu->guest_debug & KVM_GUESTDBG_USE_HW) ||
> > -           !(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY) ||
> > +           !vcpu_get_flag(vcpu, DEBUG_DIRTY) ||
> >             kvm_vcpu_os_lock_enabled(vcpu))
> >                 vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA;
> >
> > @@ -147,8 +147,8 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu)
> >   * debug related registers.
> >   *
> >   * Additionally, KVM only traps guest accesses to the debug registers if
> > - * the guest is not actively using them (see the KVM_ARM64_DEBUG_DIRTY
> > - * flag on vcpu->arch.flags).  Since the guest must not interfere
> > + * the guest is not actively using them (see the DEBUG_DIRTY
> > + * flag on vcpu->arch.iflags).  Since the guest must not interfere
> >   * with the hardware state when debugging the guest, we must ensure that
> >   * trapping is enabled whenever we are debugging the guest using the
> >   * debug registers.
> > @@ -205,7 +205,7 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
> >                  *
> >                  * We simply switch the debug_ptr to point to our new
> >                  * external_debug_state which has been populated by the
> > -                * debug ioctl. The existing KVM_ARM64_DEBUG_DIRTY
> > +                * debug ioctl. The existing KVM_ARM64_IFLAG_DEBUG_DIRTY
> 
> This should be DEBUG_DIRTY.

Ah, nice catch. That's a left-over from a previous implementation that
didn't have the notion of flag-set built-in.

There is also another one of these in kvm_host.h, which I will fix as
well.

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

  reply	other threads:[~2022-06-08 16:01 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-28 11:38 [PATCH 00/18] KVM/arm64: Refactoring the vcpu flags Marc Zyngier
2022-05-28 11:38 ` [PATCH 01/18] KVM: arm64: Always start with clearing SVE flag on load Marc Zyngier
2022-05-30 14:41   ` Mark Brown
2022-06-06 11:28     ` Marc Zyngier
2022-06-06 12:16       ` Mark Brown
2022-05-28 11:38 ` [PATCH 02/18] KVM: arm64: Always start with clearing SME " Marc Zyngier
2022-05-30 14:51   ` Mark Brown
2022-05-28 11:38 ` [PATCH 03/18] KVM: arm64: Drop FP_FOREIGN_STATE from the hypervisor code Marc Zyngier
2022-06-03  5:23   ` Reiji Watanabe
2022-06-04  8:10     ` Marc Zyngier
2022-06-07  4:47       ` Reiji Watanabe
2022-06-03  9:09   ` Mark Brown
2022-05-28 11:38 ` [PATCH 04/18] KVM: arm64: Move FP state ownership from flag to a tristate Marc Zyngier
2022-06-03  9:14   ` Mark Brown
2022-06-06  8:41     ` Marc Zyngier
2022-06-06 10:31       ` Mark Brown
2022-06-04  8:16   ` Reiji Watanabe
2022-05-28 11:38 ` [PATCH 05/18] KVM: arm64: Add helpers to manipulate vcpu flags among a set Marc Zyngier
2022-06-08  5:26   ` Reiji Watanabe
2022-06-08  6:51     ` Marc Zyngier
2022-06-09  2:25       ` Reiji Watanabe
2022-05-28 11:38 ` [PATCH 06/18] KVM: arm64: Add three sets of flags to the vcpu state Marc Zyngier
2022-06-08 15:23   ` Fuad Tabba
2022-06-09  6:10   ` Reiji Watanabe
2022-06-09  7:46     ` Marc Zyngier
2022-06-09 17:24       ` Reiji Watanabe
2022-06-10  7:48         ` Marc Zyngier
2022-05-28 11:38 ` [PATCH 07/18] KVM: arm64: Move vcpu configuration flags into their own set Marc Zyngier
2022-06-09  6:15   ` Reiji Watanabe
2022-05-28 11:38 ` [PATCH 08/18] KVM: arm64: Move vcpu PC/Exception flags to the input flag set Marc Zyngier
2022-06-10  6:13   ` Reiji Watanabe
2022-05-28 11:38 ` [PATCH 09/18] KVM: arm64: Move vcpu debug/SPE/TRBE " Marc Zyngier
2022-06-08 15:16   ` Fuad Tabba
2022-06-08 16:01     ` Marc Zyngier [this message]
2022-05-28 11:38 ` [PATCH 10/18] KVM: arm64: Move vcpu SVE/SME flags to the state " Marc Zyngier
2022-05-28 11:38 ` [PATCH 11/18] KVM: arm64: Move vcpu ON_UNSUPPORTED_CPU flag " Marc Zyngier
2022-05-28 11:38 ` [PATCH 12/18] KVM: arm64: Move vcpu WFIT " Marc Zyngier
2022-05-28 11:38 ` [PATCH 13/18] KVM: arm64: Kill unused vcpu flags field Marc Zyngier
2022-05-28 11:38 ` [PATCH 14/18] KVM: arm64: Convert vcpu sysregs_loaded_on_cpu to a state flag Marc Zyngier
2022-05-28 11:38 ` [PATCH 15/18] KVM: arm64: Warn when PENDING_EXCEPTION and INCREMENT_PC are set together Marc Zyngier
2022-06-08 15:16   ` Fuad Tabba
2022-06-08 16:42     ` Marc Zyngier
2022-05-28 11:38 ` [PATCH 16/18] KVM: arm64: Add build-time sanity checks for flags Marc Zyngier
2022-05-28 11:38 ` [PATCH 17/18] KVM: arm64: Reduce the size of the vcpu flag members Marc Zyngier
2022-05-28 11:38 ` [PATCH 18/18] KVM: arm64: Document why pause cannot be turned into a flag Marc Zyngier
2022-05-30  8:28 ` [PATCH 00/18] KVM/arm64: Refactoring the vcpu flags Marc Zyngier
2022-06-07 13:43 ` 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=87ilpb4012.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=broonie@kernel.org \
    --cc=kernel-team@android.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=tabba@google.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox