Re: [PATCH v7 09/27] KVM: arm64: Add a vcpu flag to control SVE visibility for the guest

2019-04-04 Thread Andrew Jones
On Fri, Mar 29, 2019 at 01:00:34PM +, Dave Martin wrote:
> Since SVE will be enabled or disabled on a per-vcpu basis, a flag
> is needed in order to track which vcpus have it enabled.
> 
> This patch adds a suitable flag and a helper for checking it.
> 
> Signed-off-by: Dave Martin 
> Reviewed-by: Alex Bennée 
> Tested-by: zhang.lei 
> ---
>  arch/arm64/include/asm/kvm_host.h | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/kvm_host.h 
> b/arch/arm64/include/asm/kvm_host.h
> index 6d10100..ad4f7f0 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -328,6 +328,10 @@ struct kvm_vcpu_arch {
>  #define KVM_ARM64_FP_HOST(1 << 2) /* host FP regs loaded */
>  #define KVM_ARM64_HOST_SVE_IN_USE(1 << 3) /* backup for host TIF_SVE */
>  #define KVM_ARM64_HOST_SVE_ENABLED   (1 << 4) /* SVE enabled for EL0 */
> +#define KVM_ARM64_GUEST_HAS_SVE  (1 << 5) /* SVE exposed to 
> guest */
> +
> +#define vcpu_has_sve(vcpu) (system_supports_sve() && \
> + ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE))
>  
>  #define vcpu_gp_regs(v)  (&(v)->arch.ctxt.gp_regs)
>  
> -- 
> 2.1.4
>

Reviewed-by: Andrew Jones 
___
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm


Re: [PATCH v7 09/27] KVM: arm64: Add a vcpu flag to control SVE visibility for the guest

2019-04-04 Thread Dave Martin
On Thu, Apr 04, 2019 at 04:17:24AM +0100, Marc Zyngier wrote:
> On Wed, 03 Apr 2019 20:14:13 +0100,
> Andrew Jones  wrote:
> > 
> > On Fri, Mar 29, 2019 at 01:00:34PM +, Dave Martin wrote:
> > > Since SVE will be enabled or disabled on a per-vcpu basis, a flag
> > > is needed in order to track which vcpus have it enabled.
> > > 
> > > This patch adds a suitable flag and a helper for checking it.
> > > 
> > > Signed-off-by: Dave Martin 
> > > Reviewed-by: Alex Bennée 
> > > Tested-by: zhang.lei 
> > > ---
> > >  arch/arm64/include/asm/kvm_host.h | 4 
> > >  1 file changed, 4 insertions(+)
> > > 
> > > diff --git a/arch/arm64/include/asm/kvm_host.h 
> > > b/arch/arm64/include/asm/kvm_host.h
> > > index 6d10100..ad4f7f0 100644
> > > --- a/arch/arm64/include/asm/kvm_host.h
> > > +++ b/arch/arm64/include/asm/kvm_host.h
> > > @@ -328,6 +328,10 @@ struct kvm_vcpu_arch {
> > >  #define KVM_ARM64_FP_HOST(1 << 2) /* host FP regs loaded 
> > > */
> > >  #define KVM_ARM64_HOST_SVE_IN_USE(1 << 3) /* backup for host 
> > > TIF_SVE */
> > >  #define KVM_ARM64_HOST_SVE_ENABLED   (1 << 4) /* SVE enabled for EL0 
> > > */
> > > +#define KVM_ARM64_GUEST_HAS_SVE  (1 << 5) /* SVE exposed to 
> > > guest */
> > > +
> > > +#define vcpu_has_sve(vcpu) (system_supports_sve() && \
> > > + ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE))
> > 
> > We shouldn't need the system_supports_sve() here. vcpu->arch.flags can
> > only have the KVM_ARM64_GUEST_HAS_SVE flag set when system_supports_sve()
> > is true, and it can't change later.
> 
> This is a performance optimisation. system_supports_sve() results in a
> static key being emitted, and that avoids a number of loads on the
> fast path for non-SVE systems (which is likely to be the absolute
> majority for the foreseeable future).

Exactly so.  The same applies to many of the other call sites for
system_supports_sve().

Cheers
---Dave
___
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm


Re: [PATCH v7 09/27] KVM: arm64: Add a vcpu flag to control SVE visibility for the guest

2019-04-03 Thread Marc Zyngier
On Wed, 03 Apr 2019 20:14:13 +0100,
Andrew Jones  wrote:
> 
> On Fri, Mar 29, 2019 at 01:00:34PM +, Dave Martin wrote:
> > Since SVE will be enabled or disabled on a per-vcpu basis, a flag
> > is needed in order to track which vcpus have it enabled.
> > 
> > This patch adds a suitable flag and a helper for checking it.
> > 
> > Signed-off-by: Dave Martin 
> > Reviewed-by: Alex Bennée 
> > Tested-by: zhang.lei 
> > ---
> >  arch/arm64/include/asm/kvm_host.h | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/arch/arm64/include/asm/kvm_host.h 
> > b/arch/arm64/include/asm/kvm_host.h
> > index 6d10100..ad4f7f0 100644
> > --- a/arch/arm64/include/asm/kvm_host.h
> > +++ b/arch/arm64/include/asm/kvm_host.h
> > @@ -328,6 +328,10 @@ struct kvm_vcpu_arch {
> >  #define KVM_ARM64_FP_HOST  (1 << 2) /* host FP regs loaded */
> >  #define KVM_ARM64_HOST_SVE_IN_USE  (1 << 3) /* backup for host TIF_SVE */
> >  #define KVM_ARM64_HOST_SVE_ENABLED (1 << 4) /* SVE enabled for EL0 */
> > +#define KVM_ARM64_GUEST_HAS_SVE(1 << 5) /* SVE exposed to 
> > guest */
> > +
> > +#define vcpu_has_sve(vcpu) (system_supports_sve() && \
> > +   ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE))
> 
> We shouldn't need the system_supports_sve() here. vcpu->arch.flags can
> only have the KVM_ARM64_GUEST_HAS_SVE flag set when system_supports_sve()
> is true, and it can't change later.

This is a performance optimisation. system_supports_sve() results in a
static key being emitted, and that avoids a number of loads on the
fast path for non-SVE systems (which is likely to be the absolute
majority for the foreseeable future).

Thanks,

M.

-- 
Jazz is not dead, it just smell funny.
___
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm


Re: [PATCH v7 09/27] KVM: arm64: Add a vcpu flag to control SVE visibility for the guest

2019-04-03 Thread Andrew Jones
On Fri, Mar 29, 2019 at 01:00:34PM +, Dave Martin wrote:
> Since SVE will be enabled or disabled on a per-vcpu basis, a flag
> is needed in order to track which vcpus have it enabled.
> 
> This patch adds a suitable flag and a helper for checking it.
> 
> Signed-off-by: Dave Martin 
> Reviewed-by: Alex Bennée 
> Tested-by: zhang.lei 
> ---
>  arch/arm64/include/asm/kvm_host.h | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/kvm_host.h 
> b/arch/arm64/include/asm/kvm_host.h
> index 6d10100..ad4f7f0 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -328,6 +328,10 @@ struct kvm_vcpu_arch {
>  #define KVM_ARM64_FP_HOST(1 << 2) /* host FP regs loaded */
>  #define KVM_ARM64_HOST_SVE_IN_USE(1 << 3) /* backup for host TIF_SVE */
>  #define KVM_ARM64_HOST_SVE_ENABLED   (1 << 4) /* SVE enabled for EL0 */
> +#define KVM_ARM64_GUEST_HAS_SVE  (1 << 5) /* SVE exposed to 
> guest */
> +
> +#define vcpu_has_sve(vcpu) (system_supports_sve() && \
> + ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE))

We shouldn't need the system_supports_sve() here. vcpu->arch.flags can
only have the KVM_ARM64_GUEST_HAS_SVE flag set when system_supports_sve()
is true, and it can't change later.

Thanks,
drew

>  
>  #define vcpu_gp_regs(v)  (&(v)->arch.ctxt.gp_regs)
>  
> -- 
> 2.1.4
> 
> ___
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
___
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm


[PATCH v7 09/27] KVM: arm64: Add a vcpu flag to control SVE visibility for the guest

2019-03-29 Thread Dave Martin
Since SVE will be enabled or disabled on a per-vcpu basis, a flag
is needed in order to track which vcpus have it enabled.

This patch adds a suitable flag and a helper for checking it.

Signed-off-by: Dave Martin 
Reviewed-by: Alex Bennée 
Tested-by: zhang.lei 
---
 arch/arm64/include/asm/kvm_host.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/include/asm/kvm_host.h 
b/arch/arm64/include/asm/kvm_host.h
index 6d10100..ad4f7f0 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -328,6 +328,10 @@ struct kvm_vcpu_arch {
 #define KVM_ARM64_FP_HOST  (1 << 2) /* host FP regs loaded */
 #define KVM_ARM64_HOST_SVE_IN_USE  (1 << 3) /* backup for host TIF_SVE */
 #define KVM_ARM64_HOST_SVE_ENABLED (1 << 4) /* SVE enabled for EL0 */
+#define KVM_ARM64_GUEST_HAS_SVE(1 << 5) /* SVE exposed to 
guest */
+
+#define vcpu_has_sve(vcpu) (system_supports_sve() && \
+   ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE))
 
 #define vcpu_gp_regs(v)(&(v)->arch.ctxt.gp_regs)
 
-- 
2.1.4

___
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm