From: Chen Baozi Subject: Re: [PATCH V5 09/10] xen/arm: make domain_max_vcpus return value from vgic_ops Date: Sun, 31 May 2015 23:31:03 +0800 Message-ID: <906BA87F-69AA-4D25-A264-5B6DD3B01C63@gmail.com> References: <1432984051-10838-1-git-send-email-cbz@baozis.org> <1432984051-10838-10-git-send-email-cbz@baozis.org> <556B0E3E.30106@citrix.com> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Content-Type: multipart/mixed; boundary="===============7423864028456651679==" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yz5Cl-0004HL-A7 for xen-devel@lists.xenproject.org; Sun, 31 May 2015 15:31:15 +0000 Received: by pdbki1 with SMTP id ki1so89514793pdb.1 for ; Sun, 31 May 2015 08:31:11 -0700 (PDT) In-Reply-To: <556B0E3E.30106@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: xen-devel@lists.xenproject.org, Chen Baozi , Campbell Ian List-Id: xen-devel@lists.xenproject.org --===============7423864028456651679== Content-Type: multipart/signed; boundary="Apple-Mail=_AB7D0647-0165-48FC-B29A-F3F13D421B4D"; protocol="application/pgp-signature"; micalg=pgp-sha512 --Apple-Mail=_AB7D0647-0165-48FC-B29A-F3F13D421B4D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On May 31, 2015, at 21:35, Julien Grall = wrote: >=20 > Hi Chen, >=20 > On 30/05/2015 12:07, Chen Baozi wrote: >> From: Chen Baozi >>=20 >> 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. >>=20 >> We didn't keep it as the old static inline form because it will break >> compilation when access the member of struct domain: >>=20 >> 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 =E2=80=98domain_max_vcpus=E2=80=99= : >> xen/include/asm/domain.h:266:10: error: dereferencing pointer to = incomplete type >> if (d->arch.vgic.version =3D=3D GIC_V2) >> ^ >>=20 >> Signed-off-by: Chen Baozi >> --- >> 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(-) >>=20 >> 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); >> } >>=20 >> +unsigned int domain_max_vcpus(const struct domain *d) >> +{ >> + return d->arch.vgic.handler->get_max_vcpus(); >=20 > 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... >=20 > I would do: return min(MAX_VIRT_CPUS, d->arch...) >=20 >> +} >> + >> /* >> * 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 =3D vcpuid_to_vaffinity(cpu); >> - DPRINT("Create cpu@%x node\n", mpidr_aff); >> + DPRINT("Create cpu@%x (logical CPUID: %d) node\n", = mpidr_aff, cpu); >=20 > This change belongs to patch #7... >=20 >>=20 >> snprintf(buf, sizeof(buf), "cpu@%x", mpidr_aff); >> res =3D 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; >> } >>=20 >> +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 =3D { >> .domain_init =3D vgic_v2_domain_init, >> .get_irq_priority =3D vgic_v2_get_irq_priority, >> .get_target_vcpu =3D vgic_v2_get_target_vcpu, >> + .get_max_vcpus =3D vgic_v2_get_max_vcpus, >> }; >>=20 >> /* >> 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) >> } >> } >>=20 >> +static int vgic_v3_get_max_vcpus(void) >> +{ >> + return GICV3_MAX_CPUS; >> +}; >> + >> static const struct mmio_handler_ops vgic_rdistr_mmio_handler =3D { >> .read_handler =3D vgic_v3_rdistr_mmio_read, >> .write_handler =3D vgic_v3_rdistr_mmio_write, >> @@ -1220,6 +1225,7 @@ const struct vgic_ops vgic_v3_ops =3D { >> .get_irq_priority =3D vgic_v3_get_irq_priority, >> .get_target_vcpu =3D vgic_v3_get_target_vcpu, >> .emulate_sysreg =3D vgic_v3_emulate_sysreg, >> + .get_max_vcpus =3D vgic_v3_get_max_vcpus, >> }; >>=20 >> /* >> 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 *); >>=20 >> -static inline unsigned int domain_max_vcpus(const struct domain *d) >> -{ >> - return MAX_VIRT_CPUS; >> -} >> +unsigned int domain_max_vcpus(const struct domain *); >>=20 >> /* >> * 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__ >>=20 >> +#define GICV2_MAX_CPUS 8 >> +#define GICV3_MAX_CPUS 128 >=20 > This doesn't need to be exported and can go in each vGIC driver. >=20 > Furthermore, technically, the vGICv3 driver is able to support more = than 128 vCPUs... >=20 >> + >> #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); >=20 > Why did you create a function? The value never change so a field value = would have been better=E2=80=A6 But is it appropriate that we define a field value in a struct called = vgic_ops? I thought =E2=80=98XXX_ops=E2=80=99 refers to a struct that is made up by = function points. (FIXME) Cheers, Baozi. --Apple-Mail=_AB7D0647-0165-48FC-B29A-F3F13D421B4D Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJVayk3AAoJEHXZCwEKhFER4P4QAInBFCK8j9eC3XouZ5EAAHiS Z0gFhMbxE7JogdawEwpyhx0L6q+CjrS7a860qC4smmJr/e8o32dewgsp/Jq+RIBK XIdWiLc4kJQw3KgOGeLk4t4e3sFo7QJ9hGjQMocr9a5tg5F4T40GqmEr9K4fp0dY 5RtwuQKR/hkB6jCYvL765gs34I5Z2IJO/E0BHGiJA08LGdcMY5Tfp9qb20KMLXa5 JGI/HsdGs7Kosn6keyBAsRRkHL0EoV6fDt0qqDzGZp8RF6kht6/aQ/b/+qub7KcU KbaGTU03HJckQOYh1dQGnGO0rasC/P6+5V51YpdjZKwuz+k7ck9AlleilQeDRf8b UDhAk7jmx8y8WZS5s+osQ4536VgG+3Ck6hqFsgM4YIhuirzWiVFL1uPQ04CFjtmA MLCHPSLe3P3f22UKCB/ABQW4owylveRPoxzKeIGUe7/2FnGEm7UARxdwuRFnC6nP H7Xr2dWFl5K2/ljlhaRgt1+KqrQ2B+xYtCR/dXX1GH1Or+t6lQP/b94PL7U3b59z a4hXnRTwhu6UKSQ5I+pks5V64IILkx4kvXuKOtv5AgitadR7vscNXggQFiPMC3Ha DTmyaVGSpfzpwTBaQ68jGXGAQYq+kSP7GD9YcWoQlldZkXLHmU9KSo81MkRwZV+A NpuuSkRTmYAlJaRa/Ok3 =GrXA -----END PGP SIGNATURE----- --Apple-Mail=_AB7D0647-0165-48FC-B29A-F3F13D421B4D-- --===============7423864028456651679== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============7423864028456651679==--