From: Chen Baozi Subject: Re: [PATCH V5 05/10] xen/arm64: gicv3: Use AFF1 when translating ICC_SGI1R_EL1 to cpumask Date: Sun, 31 May 2015 23:25:51 +0800 Message-ID: <4F63C548-AB76-441C-9D6C-B6CCF211E09E@gmail.com> References: <1432984051-10838-1-git-send-email-cbz@baozis.org> <1432984051-10838-6-git-send-email-cbz@baozis.org> <556B092D.4020909@citrix.com> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Content-Type: multipart/mixed; boundary="===============1472542390508819615==" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yz57j-0003fs-9K for xen-devel@lists.xenproject.org; Sun, 31 May 2015 15:26:03 +0000 Received: by padj3 with SMTP id j3so26185116pad.0 for ; Sun, 31 May 2015 08:25:59 -0700 (PDT) In-Reply-To: <556B092D.4020909@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 --===============1472542390508819615== Content-Type: multipart/signed; boundary="Apple-Mail=_CABC94E6-5CB8-4F14-8FD2-59396A0DAA02"; protocol="application/pgp-signature"; micalg=pgp-sha512 --Apple-Mail=_CABC94E6-5CB8-4F14-8FD2-59396A0DAA02 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hi Julien, > On May 31, 2015, at 21:14, Julien Grall = wrote: >=20 > Hi Chen, >=20 > On 30/05/2015 12:07, Chen Baozi wrote: >> From: Chen Baozi >>=20 >> To support more than 16 vCPUs, we have to calculate cpumask with AFF1 >> field value in ICC_SGI1R_EL1. >>=20 >> Signed-off-by: Chen Baozi >> --- >> xen/arch/arm/vgic-v3.c | 9 ++++++++- >> xen/include/asm-arm/gic_v3_defs.h | 3 +++ >> 2 files changed, 11 insertions(+), 1 deletion(-) >>=20 >> diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c >> index a283c8c..21d8d3f 100644 >> --- a/xen/arch/arm/vgic-v3.c >> +++ b/xen/arch/arm/vgic-v3.c >> @@ -976,10 +976,17 @@ static inline void = gicv3_sgir_to_cpumask(cpumask_t *cpumask, >> const register_t sgir) >> { >> unsigned long target_list; >> + int aff1; >=20 > unsigned int. >=20 >>=20 >> target_list =3D sgir & ICH_SGI_TARGETLIST_MASK; >> - bitmap_copy(cpumask_bits(cpumask), &target_list, = ICH_SGI_TARGET_BITS); >> + /* We assume that only AFF1 is used in ICC_SGI1R_EL1. */ >> + aff1 =3D (sgir >> ICH_SGI_AFFINITY_LEVEL(1)) & = ICH_SGI_AFFx_MASK; >>=20 >> + BUILD_BUG_ON(sizeof(cpumask_t)*8 < MAX_VIRT_CPUS); >=20 > Ah, here is the BUILD_BUG_ON. This is not vgic-v3 specific but generic = to all the vgic. It would have been more logical to put it in the = function vgic_to_sgi in the previous patch (i.e #4). >=20 >> + BUG_ON(((aff1+1) * ICH_SGI_TARGET_BITS) > NR_CPUS); >=20 > NACK. This value is passed by the guest. With this a malicious guest = could take down Xen. >=20 >> + >> + memcpy((uint16_t *)cpumask + aff1, &target_list, >=20 > That's hackhish. You can't assume that the bitmap will be at the = beginning of cpumask_t. Sorry, I=92m not quite understand this. Why can not? Furthermore, considering that the size of cpumask_t might be greater = than any int type, do you get a better way to set the bitmap without a loop? Cheers, Baozi. --Apple-Mail=_CABC94E6-5CB8-4F14-8FD2-59396A0DAA02 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 iQIcBAEBCgAGBQJVaygAAAoJEHXZCwEKhFERt+MP/iH7RZM1vU13cVViC95EmI1R pFmSTfCoGIcxj/u2YAwTTLD/ICmEFmvlMM4uF3ydV2D6AcxXfI5metCNgnMMCtnK lnH/yg+dSsHjEUy3GA7L63T2CVk9AsMaIe2oZyzz2/7MfKEMqt6PcPKQKhIB6Dfq BTIzHLC1RX40VYs0kcf4Z0bf8gQRqT9ZESXTnHTR0IBLU2IByHV2KTFgbz6fgan8 FNBXzTq/x6sxjoUqMUpGFj9KYooVa6r2pBjmFgfESRLCtqPv94Cn6LsOVfrYm3fL WQXdPkJHv0VwbSNJh1+bgFa9A59CaZPrC5Pn0dLkWKTVmk9s7sUMadbHrsmBb0BP BTcpCA9jq2NQjqTAhH2latCDFVSbPxT+YNr55tEIT13dqQMTV0aBjK5CoBYbo7D3 wYQbvJ+o0lxbdhYb6EwrPj7YlTVE/6V6Jn3sUva/ZSMGWag7OUGywx6Jgt/AZc0D N3IynOZRXWjYbv9YyObU5ZJ0dcRCVlxyN2189INE/8Jws8FGhP0fTif/eCFoic0W U44r8whg08B79/1BoPHuNkXZNmVB2cN7JQcQnYHCbSRj+WdPaaY7CQwiKm37I09W ZUWDd9g5iqZnNIsEc1tkr1TdUcSGfrZ1jUdzGOKuF2t/lSv5TT4+DRvpPm8CNt8R IpOjxq0yVbYTDST1fQbV =Fpak -----END PGP SIGNATURE----- --Apple-Mail=_CABC94E6-5CB8-4F14-8FD2-59396A0DAA02-- --===============1472542390508819615== 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 --===============1472542390508819615==--