All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: Chen Baozi <baozich@gmail.com>, Julien Grall <julien.grall@citrix.com>
Cc: xen-devel@lists.xenproject.org, Chen Baozi <cbz@baozis.org>,
	Campbell Ian <ian.campbell@citrix.com>
Subject: Re: [PATCH V5 05/10] xen/arm64: gicv3: Use AFF1 when translating ICC_SGI1R_EL1 to cpumask
Date: Sun, 31 May 2015 18:58:12 +0100	[thread overview]
Message-ID: <556B4BB4.5020801@citrix.com> (raw)
In-Reply-To: <4F63C548-AB76-441C-9D6C-B6CCF211E09E@gmail.com>



On 31/05/2015 16:25, Chen Baozi wrote:
>> On May 31, 2015, at 21:14, Julien Grall <julien.grall@citrix.com> wrote:
>> On 30/05/2015 12:07, Chen Baozi wrote:
>>> From: Chen Baozi <baozich@gmail.com>
>>>
>>> To support more than 16 vCPUs, we have to calculate cpumask with AFF1
>>> field value in ICC_SGI1R_EL1.
>>>
>>> Signed-off-by: Chen Baozi <baozich@gmail.com>
>>> ---
>>>   xen/arch/arm/vgic-v3.c            | 9 ++++++++-
>>>   xen/include/asm-arm/gic_v3_defs.h | 3 +++
>>>   2 files changed, 11 insertions(+), 1 deletion(-)
>>>
>>> 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;
>>
>> unsigned int.
>>
>>>
>>>       target_list = 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 = (sgir >> ICH_SGI_AFFINITY_LEVEL(1)) & ICH_SGI_AFFx_MASK;
>>>
>>> +    BUILD_BUG_ON(sizeof(cpumask_t)*8 < MAX_VIRT_CPUS);
>>
>> 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).
>>
>>> +    BUG_ON(((aff1+1) * ICH_SGI_TARGET_BITS) > NR_CPUS);
>>
>> NACK. This value is passed by the guest. With this a malicious guest could take down Xen.
>>
>>> +
>>> +    memcpy((uint16_t *)cpumask + aff1, &target_list,
>>
>> That's hackhish. You can't assume that the bitmap will be at the beginning of cpumask_t.
>
> Sorry, I’m not quite understand this. Why can not?

cpumask_t is a structure containing a bitmap. You are assuming that the 
address of cpumask_t is always equal to cpumask_t.bitmap.
There is helper to get the correct address (see cpumask_bits(cpumask)).

Furthermore, there is function to copy a bitmap (see bitmap_copy). 
Although it will require more than 1 line of code.

If you don't want to use it please use a direct assignation (it's only a 
16 bits data) which will always be faster than a memcpy.

Regards,

-- 
Julien Grall

  reply	other threads:[~2015-05-31 17:58 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 [this message]
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
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=556B4BB4.5020801@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.