From: Julien Grall <julien.grall@citrix.com>
To: Chen Baozi <cbz@baozis.org>, xen-devel@lists.xenproject.org
Cc: Julien Grall <julien.grall@citrix.com>,
Chen Baozi <baozich@gmail.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [PATCH V5 09/10] xen/arm: make domain_max_vcpus return value from vgic_ops
Date: Sun, 31 May 2015 14:35:58 +0100 [thread overview]
Message-ID: <556B0E3E.30106@citrix.com> (raw)
In-Reply-To: <1432984051-10838-10-git-send-email-cbz@baozis.org>
Hi Chen,
On 30/05/2015 12:07, Chen Baozi wrote:
> From: Chen Baozi <baozich@gmail.com>
>
> When a guest uses vGICv2, the maximum number of vCPU it can support
> should not be as many as MAX_VIRT_CPUS, which is 128 at the moment.
> So the domain_max_vcpus should return the value according to the vGIC
> the domain uses.
>
> We didn't keep it as the old static inline form because it will break
> compilation when access the member of struct domain:
>
> In file included from xen/include/xen/domain.h:6:0,
> from xen/include/xen/sched.h:10,
> from arm64/asm-offsets.c:10:
> xen/include/asm/domain.h: In function ‘domain_max_vcpus’:
> xen/include/asm/domain.h:266:10: error: dereferencing pointer to incomplete type
> if (d->arch.vgic.version == GIC_V2)
> ^
>
> Signed-off-by: Chen Baozi <baozich@gmail.com>
> ---
> xen/arch/arm/domain.c | 5 +++++
> xen/arch/arm/domain_build.c | 2 +-
> xen/arch/arm/vgic-v2.c | 6 ++++++
> xen/arch/arm/vgic-v3.c | 6 ++++++
> xen/include/asm-arm/domain.h | 5 +----
> xen/include/asm-arm/gic.h | 3 +++
> xen/include/asm-arm/vgic.h | 2 ++
> 7 files changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 0cf147c..c638ff5 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -890,6 +890,11 @@ void vcpu_block_unless_event_pending(struct vcpu *v)
> vcpu_unblock(current);
> }
>
> +unsigned int domain_max_vcpus(const struct domain *d)
> +{
> + return d->arch.vgic.handler->get_max_vcpus();
As long as we keep MAX_VIRT_VCPUS in the common vGIC drivers, we need to
make sure that we don't return a superior value because technically,
with your changes, the vGICv3 could support more than 128 vCPUs...
I would do: return min(MAX_VIRT_CPUS, d->arch...)
> +}
> +
> /*
> * Local variables:
> * mode: C
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 5591d82..88cfcee 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -769,7 +769,7 @@ static int make_cpus_node(const struct domain *d, void *fdt,
> * is enough for the current max vcpu number.
> */
> mpidr_aff = vcpuid_to_vaffinity(cpu);
> - DPRINT("Create cpu@%x node\n", mpidr_aff);
> + DPRINT("Create cpu@%x (logical CPUID: %d) node\n", mpidr_aff, cpu);
This change belongs to patch #7...
>
> snprintf(buf, sizeof(buf), "cpu@%x", mpidr_aff);
> res = fdt_begin_node(fdt, buf);
> diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
> index 17a3c9f..206d289 100644
> --- a/xen/arch/arm/vgic-v2.c
> +++ b/xen/arch/arm/vgic-v2.c
> @@ -508,6 +508,11 @@ static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq)
> return v_target;
> }
>
> +static int vgic_v2_get_max_vcpus(void)
> +{
> + return GICV2_MAX_CPUS;
> +}
> +
> static int vgic_v2_get_irq_priority(struct vcpu *v, unsigned int irq)
> {
> int priority;
> @@ -594,6 +599,7 @@ const struct vgic_ops vgic_v2_ops = {
> .domain_init = vgic_v2_domain_init,
> .get_irq_priority = vgic_v2_get_irq_priority,
> .get_target_vcpu = vgic_v2_get_target_vcpu,
> + .get_max_vcpus = vgic_v2_get_max_vcpus,
> };
>
> /*
> diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
> index 21d8d3f..e79b010 100644
> --- a/xen/arch/arm/vgic-v3.c
> +++ b/xen/arch/arm/vgic-v3.c
> @@ -1048,6 +1048,11 @@ static int vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)
> }
> }
>
> +static int vgic_v3_get_max_vcpus(void)
> +{
> + return GICV3_MAX_CPUS;
> +};
> +
> static const struct mmio_handler_ops vgic_rdistr_mmio_handler = {
> .read_handler = vgic_v3_rdistr_mmio_read,
> .write_handler = vgic_v3_rdistr_mmio_write,
> @@ -1220,6 +1225,7 @@ const struct vgic_ops vgic_v3_ops = {
> .get_irq_priority = vgic_v3_get_irq_priority,
> .get_target_vcpu = vgic_v3_get_target_vcpu,
> .emulate_sysreg = vgic_v3_emulate_sysreg,
> + .get_max_vcpus = vgic_v3_get_max_vcpus,
> };
>
> /*
> diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
> index b7b5cd2..b525bec 100644
> --- a/xen/include/asm-arm/domain.h
> +++ b/xen/include/asm-arm/domain.h
> @@ -261,10 +261,7 @@ struct arch_vcpu
> void vcpu_show_execution_state(struct vcpu *);
> void vcpu_show_registers(const struct vcpu *);
>
> -static inline unsigned int domain_max_vcpus(const struct domain *d)
> -{
> - return MAX_VIRT_CPUS;
> -}
> +unsigned int domain_max_vcpus(const struct domain *);
>
> /*
> * Due to the restriction of GICv3, the number of vCPUs in AFF0 is
> diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
> index c6ef4bf..55f99cd 100644
> --- a/xen/include/asm-arm/gic.h
> +++ b/xen/include/asm-arm/gic.h
> @@ -18,6 +18,9 @@
> #ifndef __ASM_ARM_GIC_H__
> #define __ASM_ARM_GIC_H__
>
> +#define GICV2_MAX_CPUS 8
> +#define GICV3_MAX_CPUS 128
This doesn't need to be exported and can go in each vGIC driver.
Furthermore, technically, the vGICv3 driver is able to support more than
128 vCPUs...
> +
> #define NR_GIC_LOCAL_IRQS NR_LOCAL_IRQS
> #define NR_GIC_SGI 16
> #define MAX_RDIST_COUNT 4
> diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
> index 2f413e1..1157b04 100644
> --- a/xen/include/asm-arm/vgic.h
> +++ b/xen/include/asm-arm/vgic.h
> @@ -110,6 +110,8 @@ struct vgic_ops {
> struct vcpu *(*get_target_vcpu)(struct vcpu *v, unsigned int irq);
> /* vGIC sysreg emulation */
> int (*emulate_sysreg)(struct cpu_user_regs *regs, union hsr hsr);
> + /* Get the maximum number of vCPU supported */
> + int (*get_max_vcpus)(void);
Why did you create a function? The value never change so a field value
would have been better...
> };
>
> /* Number of ranks of interrupt registers for a domain */
>
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-05-31 13:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-30 11:07 [PATCH V5 00/10] Support more than 8 vcpus on arm64 with GICv3 Chen Baozi
2015-05-30 11:07 ` [PATCH V5 01/10] xen/arm: gic-v3: Increase the size of GICR in address space for guest Chen Baozi
2015-05-30 11:07 ` [PATCH V5 02/10] xen/arm: Add functions of mapping between vCPUID and virtual affinity Chen Baozi
2015-05-31 12:51 ` Julien Grall
2015-05-30 11:07 ` [PATCH V5 03/10] xen/arm: Use the new functions for vCPUID/vaffinity transformation Chen Baozi
2015-05-31 12:53 ` Julien Grall
2015-05-30 11:07 ` [PATCH V5 04/10] xen/arm: Use cpumask_t type for vcpu_mask in vgic_to_sgi Chen Baozi
2015-05-31 13:05 ` Julien Grall
2015-05-30 11:07 ` [PATCH V5 05/10] xen/arm64: gicv3: Use AFF1 when translating ICC_SGI1R_EL1 to cpumask Chen Baozi
2015-05-30 11:15 ` Chen Baozi
2015-05-31 13:14 ` Julien Grall
2015-05-31 15:25 ` Chen Baozi
2015-05-31 17:58 ` Julien Grall
2015-05-30 11:07 ` [PATCH V5 06/10] tools/libxl: Set 'reg' of cpu node equal to MPIDR affinity for domU Chen Baozi
2015-05-31 13:16 ` Julien Grall
2015-05-30 11:07 ` [PATCH V5 07/10] xen/arm: Set 'reg' of cpu node for dom0 to match MPIDR's affinity Chen Baozi
2015-05-31 13:20 ` Julien Grall
2015-05-30 11:07 ` [PATCH V5 08/10] xen: Call arch_domain_create() before evtchn_init() Chen Baozi
2015-05-31 13:29 ` Julien Grall
2015-05-30 11:07 ` [PATCH V5 09/10] xen/arm: make domain_max_vcpus return value from vgic_ops Chen Baozi
2015-05-31 13:35 ` Julien Grall [this message]
2015-05-31 15:31 ` Chen Baozi
2015-05-31 18:05 ` Julien Grall
2015-05-31 18:21 ` Andrew Cooper
2015-05-30 11:07 ` [PATCH V5 10/10] xen/arm64: increase MAX_VIRT_CPUS to 128 on arm64 Chen Baozi
2015-05-31 13:40 ` Julien Grall
2015-05-31 15:37 ` Chen Baozi
2015-05-31 18:21 ` Julien Grall
2015-06-01 0:56 ` Chen Baozi
2015-06-01 8:04 ` Julien Grall
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=556B0E3E.30106@citrix.com \
--to=julien.grall@citrix.com \
--cc=baozich@gmail.com \
--cc=cbz@baozis.org \
--cc=ian.campbell@citrix.com \
--cc=xen-devel@lists.xenproject.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.