diff mbox series

[v2,03/18] arm64: KVM: define SPE data structure for each vcpu

Message ID 20191220143025.33853-4-andrew.murray@arm.com
State New
Headers show
Series [v2,01/18] dt-bindings: ARM SPE: highlight the need for PPI partitions on heterogeneous systems | expand

Commit Message

Andrew Murray Dec. 20, 2019, 2:30 p.m. UTC
From: Sudeep Holla <sudeep.holla@arm.com>


In order to support virtual SPE for guest, so define some basic structs.
This features depends on host having hardware with SPE support.

Since we can support this only on ARM64, add a separate config symbol
for the same.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

[ Add irq_level, rename irq to irq_num for kvm_spe ]
Signed-off-by: Andrew Murray <andrew.murray@arm.com>

---
 arch/arm64/include/asm/kvm_host.h |  2 ++
 arch/arm64/kvm/Kconfig            |  7 +++++++
 include/kvm/arm_spe.h             | 19 +++++++++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100644 include/kvm/arm_spe.h

-- 
2.21.0

Comments

Marc Zyngier Dec. 21, 2019, 1:19 p.m. UTC | #1
On Fri, 20 Dec 2019 14:30:10 +0000
Andrew Murray <andrew.murray@arm.com> wrote:

> From: Sudeep Holla <sudeep.holla@arm.com>

> 

> In order to support virtual SPE for guest, so define some basic structs.

> This features depends on host having hardware with SPE support.

> 

> Since we can support this only on ARM64, add a separate config symbol

> for the same.

> 

> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> [ Add irq_level, rename irq to irq_num for kvm_spe ]

> Signed-off-by: Andrew Murray <andrew.murray@arm.com>

> ---

>  arch/arm64/include/asm/kvm_host.h |  2 ++

>  arch/arm64/kvm/Kconfig            |  7 +++++++

>  include/kvm/arm_spe.h             | 19 +++++++++++++++++++

>  3 files changed, 28 insertions(+)

>  create mode 100644 include/kvm/arm_spe.h

> 

> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h

> index c61260cf63c5..f5dcff912645 100644

> --- a/arch/arm64/include/asm/kvm_host.h

> +++ b/arch/arm64/include/asm/kvm_host.h

> @@ -35,6 +35,7 @@

>  #include <kvm/arm_vgic.h>

>  #include <kvm/arm_arch_timer.h>

>  #include <kvm/arm_pmu.h>

> +#include <kvm/arm_spe.h>

>  

>  #define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS

>  

> @@ -302,6 +303,7 @@ struct kvm_vcpu_arch {

>  	struct vgic_cpu vgic_cpu;

>  	struct arch_timer_cpu timer_cpu;

>  	struct kvm_pmu pmu;

> +	struct kvm_spe spe;

>  

>  	/*

>  	 * Anything that is not used directly from assembly code goes

> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig

> index a475c68cbfec..af5be2c57dcb 100644

> --- a/arch/arm64/kvm/Kconfig

> +++ b/arch/arm64/kvm/Kconfig

> @@ -35,6 +35,7 @@ config KVM

>  	select HAVE_KVM_EVENTFD

>  	select HAVE_KVM_IRQFD

>  	select KVM_ARM_PMU if HW_PERF_EVENTS

> +	select KVM_ARM_SPE if (HW_PERF_EVENTS && ARM_SPE_PMU)

>  	select HAVE_KVM_MSI

>  	select HAVE_KVM_IRQCHIP

>  	select HAVE_KVM_IRQ_ROUTING

> @@ -61,6 +62,12 @@ config KVM_ARM_PMU

>  	  Adds support for a virtual Performance Monitoring Unit (PMU) in

>  	  virtual machines.

>  

> +config KVM_ARM_SPE

> +	bool

> +	---help---

> +	  Adds support for a virtual Statistical Profiling Extension(SPE) in

> +	  virtual machines.

> +

>  config KVM_INDIRECT_VECTORS

>         def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)

>  

> diff --git a/include/kvm/arm_spe.h b/include/kvm/arm_spe.h

> new file mode 100644

> index 000000000000..48d118fdb174

> --- /dev/null

> +++ b/include/kvm/arm_spe.h

> @@ -0,0 +1,19 @@

> +// SPDX-License-Identifier: GPL-2.0

> +/*

> + * Copyright (C) 2019 ARM Ltd.

> + */

> +

> +#ifndef __ASM_ARM_KVM_SPE_H

> +#define __ASM_ARM_KVM_SPE_H

> +

> +#include <uapi/linux/kvm.h>

> +#include <linux/kvm_host.h>


I don't believe these are required at this stage.

> +

> +struct kvm_spe {

> +	int irq_num;


'irq' was the right name *if* this represents a Linux irq. If this
instead represents a guest PPI, then it should be named 'intid'.

In either case, please document what this represents.

> +	bool ready; /* indicates that SPE KVM instance is ready for use */

> +	bool created; /* SPE KVM instance is created, may not be ready yet */

> +	bool irq_level;


What does this represent? The state of the interrupt on the host? The
guest? Something else? Also, please consider grouping related fields
together.

> +};


If you've added a config option that controls the selection of the SPE
feature, why doesn't this result in an empty structure when it isn't
selected?

> +

> +#endif /* __ASM_ARM_KVM_SPE_H */


Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...
Andrew Murray Dec. 24, 2019, 12:01 p.m. UTC | #2
On Sat, Dec 21, 2019 at 01:19:36PM +0000, Marc Zyngier wrote:
> On Fri, 20 Dec 2019 14:30:10 +0000

> Andrew Murray <andrew.murray@arm.com> wrote:

> 

> > From: Sudeep Holla <sudeep.holla@arm.com>

> > 

> > In order to support virtual SPE for guest, so define some basic structs.

> > This features depends on host having hardware with SPE support.

> > 

> > Since we can support this only on ARM64, add a separate config symbol

> > for the same.

> > 

> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> > [ Add irq_level, rename irq to irq_num for kvm_spe ]

> > Signed-off-by: Andrew Murray <andrew.murray@arm.com>

> > ---

> >  arch/arm64/include/asm/kvm_host.h |  2 ++

> >  arch/arm64/kvm/Kconfig            |  7 +++++++

> >  include/kvm/arm_spe.h             | 19 +++++++++++++++++++

> >  3 files changed, 28 insertions(+)

> >  create mode 100644 include/kvm/arm_spe.h

> > 

> > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h

> > index c61260cf63c5..f5dcff912645 100644

> > --- a/arch/arm64/include/asm/kvm_host.h

> > +++ b/arch/arm64/include/asm/kvm_host.h

> > @@ -35,6 +35,7 @@

> >  #include <kvm/arm_vgic.h>

> >  #include <kvm/arm_arch_timer.h>

> >  #include <kvm/arm_pmu.h>

> > +#include <kvm/arm_spe.h>

> >  

> >  #define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS

> >  

> > @@ -302,6 +303,7 @@ struct kvm_vcpu_arch {

> >  	struct vgic_cpu vgic_cpu;

> >  	struct arch_timer_cpu timer_cpu;

> >  	struct kvm_pmu pmu;

> > +	struct kvm_spe spe;

> >  

> >  	/*

> >  	 * Anything that is not used directly from assembly code goes

> > diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig

> > index a475c68cbfec..af5be2c57dcb 100644

> > --- a/arch/arm64/kvm/Kconfig

> > +++ b/arch/arm64/kvm/Kconfig

> > @@ -35,6 +35,7 @@ config KVM

> >  	select HAVE_KVM_EVENTFD

> >  	select HAVE_KVM_IRQFD

> >  	select KVM_ARM_PMU if HW_PERF_EVENTS

> > +	select KVM_ARM_SPE if (HW_PERF_EVENTS && ARM_SPE_PMU)

> >  	select HAVE_KVM_MSI

> >  	select HAVE_KVM_IRQCHIP

> >  	select HAVE_KVM_IRQ_ROUTING

> > @@ -61,6 +62,12 @@ config KVM_ARM_PMU

> >  	  Adds support for a virtual Performance Monitoring Unit (PMU) in

> >  	  virtual machines.

> >  

> > +config KVM_ARM_SPE

> > +	bool

> > +	---help---

> > +	  Adds support for a virtual Statistical Profiling Extension(SPE) in

> > +	  virtual machines.

> > +

> >  config KVM_INDIRECT_VECTORS

> >         def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)

> >  

> > diff --git a/include/kvm/arm_spe.h b/include/kvm/arm_spe.h

> > new file mode 100644

> > index 000000000000..48d118fdb174

> > --- /dev/null

> > +++ b/include/kvm/arm_spe.h

> > @@ -0,0 +1,19 @@

> > +// SPDX-License-Identifier: GPL-2.0

> > +/*

> > + * Copyright (C) 2019 ARM Ltd.

> > + */

> > +

> > +#ifndef __ASM_ARM_KVM_SPE_H

> > +#define __ASM_ARM_KVM_SPE_H

> > +

> > +#include <uapi/linux/kvm.h>

> > +#include <linux/kvm_host.h>

> 

> I don't believe these are required at this stage.

> 

> > +

> > +struct kvm_spe {

> > +	int irq_num;

> 

> 'irq' was the right name *if* this represents a Linux irq. If this

> instead represents a guest PPI, then it should be named 'intid'.

> 

> In either case, please document what this represents.

> 

> > +	bool ready; /* indicates that SPE KVM instance is ready for use */

> > +	bool created; /* SPE KVM instance is created, may not be ready yet */

> > +	bool irq_level;

> 

> What does this represent? The state of the interrupt on the host? The

> guest? Something else? Also, please consider grouping related fields

> together.


It should be the state of the interrupt on the guest.

> 

> > +};

> 

> If you've added a config option that controls the selection of the SPE

> feature, why doesn't this result in an empty structure when it isn't

> selected?


OK, all noted.

Andrew Murray

> 

> > +

> > +#endif /* __ASM_ARM_KVM_SPE_H */

> 

> Thanks,

> 

> 	M.

> -- 

> Jazz is not dead. It just smells funny...
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index c61260cf63c5..f5dcff912645 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -35,6 +35,7 @@ 
 #include <kvm/arm_vgic.h>
 #include <kvm/arm_arch_timer.h>
 #include <kvm/arm_pmu.h>
+#include <kvm/arm_spe.h>
 
 #define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS
 
@@ -302,6 +303,7 @@  struct kvm_vcpu_arch {
 	struct vgic_cpu vgic_cpu;
 	struct arch_timer_cpu timer_cpu;
 	struct kvm_pmu pmu;
+	struct kvm_spe spe;
 
 	/*
 	 * Anything that is not used directly from assembly code goes
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index a475c68cbfec..af5be2c57dcb 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -35,6 +35,7 @@  config KVM
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
 	select KVM_ARM_PMU if HW_PERF_EVENTS
+	select KVM_ARM_SPE if (HW_PERF_EVENTS && ARM_SPE_PMU)
 	select HAVE_KVM_MSI
 	select HAVE_KVM_IRQCHIP
 	select HAVE_KVM_IRQ_ROUTING
@@ -61,6 +62,12 @@  config KVM_ARM_PMU
 	  Adds support for a virtual Performance Monitoring Unit (PMU) in
 	  virtual machines.
 
+config KVM_ARM_SPE
+	bool
+	---help---
+	  Adds support for a virtual Statistical Profiling Extension(SPE) in
+	  virtual machines.
+
 config KVM_INDIRECT_VECTORS
        def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
 
diff --git a/include/kvm/arm_spe.h b/include/kvm/arm_spe.h
new file mode 100644
index 000000000000..48d118fdb174
--- /dev/null
+++ b/include/kvm/arm_spe.h
@@ -0,0 +1,19 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 ARM Ltd.
+ */
+
+#ifndef __ASM_ARM_KVM_SPE_H
+#define __ASM_ARM_KVM_SPE_H
+
+#include <uapi/linux/kvm.h>
+#include <linux/kvm_host.h>
+
+struct kvm_spe {
+	int irq_num;
+	bool ready; /* indicates that SPE KVM instance is ready for use */
+	bool created; /* SPE KVM instance is created, may not be ready yet */
+	bool irq_level;
+};
+
+#endif /* __ASM_ARM_KVM_SPE_H */