public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: alex.bennee@linaro•org (Alex Bennée)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v10 09/18] KVM: arm64: Repurpose vcpu_arch.debug_flags for general-purpose flags
Date: Thu, 24 May 2018 10:21:20 +0100	[thread overview]
Message-ID: <87a7sptnn3.fsf@linaro.org> (raw)
In-Reply-To: <1527005119-6842-10-git-send-email-Dave.Martin@arm.com>


Dave Martin <Dave.Martin@arm•com> writes:

> In struct vcpu_arch, the debug_flags field is used to store
> debug-related flags about the vcpu state.
>
> Since we are about to add some more flags related to FPSIMD and
> SVE, it makes sense to add them to the existing flags field rather
> than adding new fields.  Since there is only one debug_flags flag
> defined so far, there is plenty of free space for expansion.
>
> In preparation for adding more flags, this patch renames the
> debug_flags field to simply "flags", and updates comments
> appropriately.
>
> The flag definitions are also moved to <asm/kvm_host.h>, since
> their presence in <asm/kvm_asm.h> was for purely historical
> reasons:  these definitions are not used from asm any more, and not
> very likely to be as more Hyp asm is migrated to C.
>
> KVM_ARM64_DEBUG_DIRTY_SHIFT has not been used since commit
> 1ea66d27e7b0 ("arm64: KVM: Move away from the assembly version of
> the world switch"), so this patch gets rid of that too.
>
> No functional change.
>
> Signed-off-by: Dave Martin <Dave.Martin@arm•com>
> Reviewed-by: Marc Zyngier <marc.zyngier@arm•com>
> Acked-by: Christoffer Dall <christoffer.dall@arm•com>

Reviewed-by: Alex Benn?e <alex.bennee@linaro•org>

> ---
>  arch/arm64/include/asm/kvm_asm.h  | 3 ---
>  arch/arm64/include/asm/kvm_host.h | 7 +++++--
>  arch/arm64/kvm/debug.c            | 8 ++++----
>  arch/arm64/kvm/hyp/debug-sr.c     | 6 +++---
>  arch/arm64/kvm/hyp/sysreg-sr.c    | 4 ++--
>  arch/arm64/kvm/sys_regs.c         | 9 ++++-----
>  6 files changed, 18 insertions(+), 19 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
> index f6648a3..f62ccbf 100644
> --- a/arch/arm64/include/asm/kvm_asm.h
> +++ b/arch/arm64/include/asm/kvm_asm.h
> @@ -30,9 +30,6 @@
>  /* The hyp-stub will return this for any kvm_call_hyp() call */
>  #define ARM_EXCEPTION_HYP_GONE	  HVC_STUB_ERR
>
> -#define KVM_ARM64_DEBUG_DIRTY_SHIFT	0
> -#define KVM_ARM64_DEBUG_DIRTY		(1 << KVM_ARM64_DEBUG_DIRTY_SHIFT)
> -
>  /* Translate a kernel address of @sym into its equivalent linear mapping */
>  #define kvm_ksym_ref(sym)						\
>  	({								\
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index 469de8a..146c167 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -216,8 +216,8 @@ struct kvm_vcpu_arch {
>  	/* Exception Information */
>  	struct kvm_vcpu_fault_info fault;
>
> -	/* Guest debug state */
> -	u64 debug_flags;
> +	/* Miscellaneous vcpu state flags */
> +	u64 flags;
>
>  	/*
>  	 * We maintain more than a single set of debug registers to support
> @@ -293,6 +293,9 @@ struct kvm_vcpu_arch {
>  	bool sysregs_loaded_on_cpu;
>  };
>
> +/* vcpu_arch flags field values: */
> +#define KVM_ARM64_DEBUG_DIRTY		(1 << 0)
> +
>  #define vcpu_gp_regs(v)		(&(v)->arch.ctxt.gp_regs)
>
>  /*
> diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
> index a1f4ebd..00d4223 100644
> --- a/arch/arm64/kvm/debug.c
> +++ b/arch/arm64/kvm/debug.c
> @@ -103,7 +103,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu)
>   *
>   * 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.debug_flags).  Since the guest must not interfere
> + * flag on vcpu->arch.flags).  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.
> @@ -111,7 +111,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu)
>
>  void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
>  {
> -	bool trap_debug = !(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY);
> +	bool trap_debug = !(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY);
>  	unsigned long mdscr;
>
>  	trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug);
> @@ -184,7 +184,7 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
>  			vcpu_write_sys_reg(vcpu, mdscr, MDSCR_EL1);
>
>  			vcpu->arch.debug_ptr = &vcpu->arch.external_debug_state;
> -			vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
> +			vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
>  			trap_debug = true;
>
>  			trace_kvm_arm_set_regset("BKPTS", get_num_brps(),
> @@ -206,7 +206,7 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
>
>  	/* If KDE or MDE are set, perform a full save/restore cycle. */
>  	if (vcpu_read_sys_reg(vcpu, MDSCR_EL1) & (DBG_MDSCR_KDE | DBG_MDSCR_MDE))
> -		vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
> +		vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
>
>  	trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2);
>  	trace_kvm_arm_set_dreg32("MDSCR_EL1", vcpu_read_sys_reg(vcpu, MDSCR_EL1));
> diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c
> index 3e717f6..5000976 100644
> --- a/arch/arm64/kvm/hyp/debug-sr.c
> +++ b/arch/arm64/kvm/hyp/debug-sr.c
> @@ -163,7 +163,7 @@ void __hyp_text __debug_switch_to_guest(struct kvm_vcpu *vcpu)
>  	if (!has_vhe())
>  		__debug_save_spe_nvhe(&vcpu->arch.host_debug_state.pmscr_el1);
>
> -	if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
> +	if (!(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY))
>  		return;
>
>  	host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
> @@ -185,7 +185,7 @@ void __hyp_text __debug_switch_to_host(struct kvm_vcpu *vcpu)
>  	if (!has_vhe())
>  		__debug_restore_spe_nvhe(vcpu->arch.host_debug_state.pmscr_el1);
>
> -	if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
> +	if (!(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY))
>  		return;
>
>  	host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
> @@ -196,7 +196,7 @@ void __hyp_text __debug_switch_to_host(struct kvm_vcpu *vcpu)
>  	__debug_save_state(vcpu, guest_dbg, guest_ctxt);
>  	__debug_restore_state(vcpu, host_dbg, host_ctxt);
>
> -	vcpu->arch.debug_flags &= ~KVM_ARM64_DEBUG_DIRTY;
> +	vcpu->arch.flags &= ~KVM_ARM64_DEBUG_DIRTY;
>  }
>
>  u32 __hyp_text __kvm_get_mdcr_el2(void)
> diff --git a/arch/arm64/kvm/hyp/sysreg-sr.c b/arch/arm64/kvm/hyp/sysreg-sr.c
> index b3894df..35bc168 100644
> --- a/arch/arm64/kvm/hyp/sysreg-sr.c
> +++ b/arch/arm64/kvm/hyp/sysreg-sr.c
> @@ -196,7 +196,7 @@ void __hyp_text __sysreg32_save_state(struct kvm_vcpu *vcpu)
>  	sysreg[DACR32_EL2] = read_sysreg(dacr32_el2);
>  	sysreg[IFSR32_EL2] = read_sysreg(ifsr32_el2);
>
> -	if (has_vhe() || vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY)
> +	if (has_vhe() || vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY)
>  		sysreg[DBGVCR32_EL2] = read_sysreg(dbgvcr32_el2);
>  }
>
> @@ -218,7 +218,7 @@ void __hyp_text __sysreg32_restore_state(struct kvm_vcpu *vcpu)
>  	write_sysreg(sysreg[DACR32_EL2], dacr32_el2);
>  	write_sysreg(sysreg[IFSR32_EL2], ifsr32_el2);
>
> -	if (has_vhe() || vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY)
> +	if (has_vhe() || vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY)
>  		write_sysreg(sysreg[DBGVCR32_EL2], dbgvcr32_el2);
>  }
>
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 6e3b969..a436373 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -31,7 +31,6 @@
>  #include <asm/debug-monitors.h>
>  #include <asm/esr.h>
>  #include <asm/kvm_arm.h>
> -#include <asm/kvm_asm.h>
>  #include <asm/kvm_coproc.h>
>  #include <asm/kvm_emulate.h>
>  #include <asm/kvm_host.h>
> @@ -338,7 +337,7 @@ static bool trap_debug_regs(struct kvm_vcpu *vcpu,
>  {
>  	if (p->is_write) {
>  		vcpu_write_sys_reg(vcpu, p->regval, r->reg);
> -		vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
> +		vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
>  	} else {
>  		p->regval = vcpu_read_sys_reg(vcpu, r->reg);
>  	}
> @@ -369,7 +368,7 @@ static void reg_to_dbg(struct kvm_vcpu *vcpu,
>  	}
>
>  	*dbg_reg = val;
> -	vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
> +	vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
>  }
>
>  static void dbg_to_reg(struct kvm_vcpu *vcpu,
> @@ -1441,7 +1440,7 @@ static bool trap_debug32(struct kvm_vcpu *vcpu,
>  {
>  	if (p->is_write) {
>  		vcpu_cp14(vcpu, r->reg) = p->regval;
> -		vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
> +		vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
>  	} else {
>  		p->regval = vcpu_cp14(vcpu, r->reg);
>  	}
> @@ -1473,7 +1472,7 @@ static bool trap_xvr(struct kvm_vcpu *vcpu,
>  		val |= p->regval << 32;
>  		*dbg_reg = val;
>
> -		vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
> +		vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
>  	} else {
>  		p->regval = *dbg_reg >> 32;
>  	}


--
Alex Benn?e

  reply	other threads:[~2018-05-24  9:21 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 16:05 [PATCH v10 00/18] KVM: arm64: Optimise FPSIMD context switching Dave Martin
2018-05-22 16:05 ` [PATCH v10 01/18] arm64: fpsimd: Fix TIF_FOREIGN_FPSTATE after invalidating cpu regs Dave Martin
2018-05-23 11:33   ` Christoffer Dall
2018-05-23 13:44   ` Alex Bennée
2018-05-23 13:46   ` Catalin Marinas
2018-05-22 16:05 ` [PATCH v10 02/18] thread_info: Add update_thread_flag() helpers Dave Martin
2018-05-23 13:46   ` Alex Bennée
2018-05-23 13:57     ` Dave Martin
2018-05-23 14:35       ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 03/18] arm64: Use update{,_tsk}_thread_flag() Dave Martin
2018-05-23 13:48   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 04/18] KVM: arm/arm64: Introduce kvm_arch_vcpu_run_pid_change Dave Martin
2018-05-23 14:34   ` Alex Bennée
2018-05-23 14:40     ` Dave Martin
2018-05-24  8:11       ` Christoffer Dall
2018-05-24  9:18         ` Alex Bennée
2018-05-24 10:04           ` Dave Martin
2018-05-22 16:05 ` [PATCH v10 05/18] KVM: arm64: Convert lazy FPSIMD context switch trap to C Dave Martin
2018-05-23 19:35   ` Alex Bennée
2018-05-24  8:12     ` Christoffer Dall
2018-05-24  8:54       ` Dave Martin
2018-05-24  9:14         ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 06/18] arm64: fpsimd: Generalise context saving for non-task contexts Dave Martin
2018-05-23 20:15   ` Alex Bennée
2018-05-24  9:03     ` Dave Martin
2018-05-24  9:41       ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 07/18] arm64: fpsimd: Eliminate task->mm checks Dave Martin
2018-05-23 11:48   ` Christoffer Dall
2018-05-23 13:31     ` Dave Martin
2018-05-23 14:56       ` Catalin Marinas
2018-05-23 15:03         ` Dave Martin
2018-05-23 16:42           ` Catalin Marinas
2018-05-24  8:33           ` Christoffer Dall
2018-05-24  9:16             ` Alex Bennée
2018-05-24  9:50             ` Dave Martin
2018-05-24 10:06               ` Christoffer Dall
2018-05-24 14:37                 ` Dave Martin
2018-05-25  9:00                   ` Christoffer Dall
2018-05-25  9:45                     ` Dave Martin
2018-05-25 11:28                       ` Christoffer Dall
2018-05-24  9:19   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 08/18] arm64/sve: Refactor user SVE trap maintenance for external use Dave Martin
2018-05-23 20:16   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 09/18] KVM: arm64: Repurpose vcpu_arch.debug_flags for general-purpose flags Dave Martin
2018-05-24  9:21   ` Alex Bennée [this message]
2018-05-22 16:05 ` [PATCH v10 10/18] KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing Dave Martin
2018-05-24 10:09   ` Alex Bennée
2018-05-24 10:18     ` Dave Martin
2018-05-22 16:05 ` [PATCH v10 11/18] arm64/sve: Move read_zcr_features() out of cpufeature.h Dave Martin
2018-05-24 10:12   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 12/18] arm64/sve: Switch sve_pffr() argument from task to thread Dave Martin
2018-05-24 10:12   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 13/18] arm64/sve: Move sve_pffr() to fpsimd.h and make inline Dave Martin
2018-05-24 10:20   ` Alex Bennée
2018-05-24 11:22     ` Dave Martin
2018-05-22 16:05 ` [PATCH v10 14/18] KVM: arm64: Save host SVE context as appropriate Dave Martin
2018-05-23 14:59   ` Catalin Marinas
2018-05-24  9:11   ` Christoffer Dall
2018-05-24 14:49   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 15/18] KVM: arm64: Remove eager host SVE state saving Dave Martin
2018-05-24 14:54   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 16/18] KVM: arm64: Remove redundant *exit_code changes in fpsimd_guest_exit() Dave Martin
2018-05-24  9:11   ` Christoffer Dall
2018-05-24 15:02   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 17/18] KVM: arm64: Fold redundant exit code checks out of fixup_guest_exit() Dave Martin
2018-05-24  9:12   ` Christoffer Dall
2018-05-24 15:06   ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 18/18] KVM: arm64: Invoke FPSIMD context switch trap from C Dave Martin
2018-05-24 15:09   ` 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=87a7sptnn3.fsf@linaro.org \
    --to=alex.bennee@linaro$(echo .)org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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