All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: Ian Campbell <ian.campbell@citrix.com>, xen-devel@lists.xenproject.org
Cc: stefano.stabellini@eu.citrix.com
Subject: Re: [PATCH v4 1/5] xen/arm: vgic-v2: Handle correctly byte write in ITARGETSR
Date: Thu, 22 Oct 2015 17:36:49 +0100	[thread overview]
Message-ID: <562910A1.5000606@citrix.com> (raw)
In-Reply-To: <1445529185.2374.25.camel@citrix.com>

Hi Ian,

On 22/10/15 16:53, Ian Campbell wrote:
> On Mon, 2015-10-12 at 15:22 +0100, Julien Grall wrote:
> 
> Subject: "correctly handle" and "writes"
> 
>> During a store, the byte is always in the low part of the register (i.e
>> [0:7]).
>>
>> Although, we are masking the register by using a shift of the
>> byte offset in the ITARGETSR. This will result to get a target list
>> equal to 0 which is ignored by the emulation.
> 
> I'm afraid I can't parse this.
> 
> I think instead of "Although" you might mean "incorrectly" as in "we are
> incorrectly...", but that would really then want the sentence to end
> "instead of <the right thing>". So perhaps:
> 
>     We are incorrectly masking the register by using a shift of the byte
>     offset in the ITARGETSR instead of <...something...>. This will result
>     in a target list equal to 0 which is ignored by the emulation.

Rather than "instead of..." what about "while the byte is always in r[0:7]"?

> (note also s/to get/in a/ in the second sentence)
> 
>> Because of that a guest won't be able to modify the any ITARGETSR using
>> byte access. Note that the first byte of each register will still be
>> writeable.
> 
> "Because of that the guest will only be able to modify the first byte in
> each ITARGETSR"
> 
> In your version the "any ITARGETSR" in the first sentence is immediately
> contradicted by the second sentence with gives an example of an ITARGETSR
> which it can modify.

Right, I will update the commit message.

>>
>> Furthermore, the body of the loop is retrieving the old target list
>> using the index of the byte.
>>
>> To avoid modifying too much the loop, shift the byte stored to the correct
>> offset.
> 
> That might have meant a smaller patch, but it's a lot harder to understand
> either the result or the diff.

The size of the patch would have been the same. Although, it requires to
modify the call to vgic_byte_read in the loop to access the correct
interrupt.

I didn't try to spend to much time to modify the loop because the
follow-up patch (#2) will rewrite the loop.

[...]

>>  xen/arch/arm/vgic-v2.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
>> index 2d63e12..665afeb 100644
>> --- a/xen/arch/arm/vgic-v2.c
>> +++ b/xen/arch/arm/vgic-v2.c
>> @@ -346,11 +346,11 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info,
>>          /* 8-bit vcpu mask for this domain */
>>          BUG_ON(v->domain->max_vcpus > 8);
>>          target = (1 << v->domain->max_vcpus) - 1;
>> -        if ( dabt.size == 2 )
>> -            target = target | (target << 8) | (target << 16) | (target << 24);
>> +        target = target | (target << 8) | (target << 16) | (target << 24);
>> +        if ( dabt.size == DABT_WORD )
>> +            target &= r;
>>          else
>> -            target = (target << (8 * (gicd_reg & 0x3)));
>> -        target &= r;
>> +            target &= (r << (8 * (gicd_reg & 0x3)));
> 
> At this point do you not now have 3 bytes of
>     (1 << v->domain->max_vcpus) - 1;
> and 1 byte of that masked with the write?
> 
> IOW isn't this modifying the 3 bytes which aren't written?

No, the current loop search for bit set to 1. As the target variable
will only contain one byte with some bit set to 1, only the IRQ
associated to this byte will be updated.

Regards,

-- 
Julien Grall

  reply	other threads:[~2015-10-22 16:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 14:22 [PATCH v4 0/5] xen/arm: vgic: Support 32-bit access for 64-bit register Julien Grall
2015-10-12 14:22 ` [PATCH v4 1/5] xen/arm: vgic-v2: Handle correctly byte write in ITARGETSR Julien Grall
2015-10-22 15:53   ` Ian Campbell
2015-10-22 16:36     ` Julien Grall [this message]
2015-10-23  9:33       ` Ian Campbell
2015-10-23  9:58         ` Julien Grall
2015-10-23 10:12           ` Ian Campbell
2015-10-12 14:22 ` [PATCH v4 2/5] xen/arm: vgic-v2: Don't ignore a write in ITARGETSR if one field is 0 Julien Grall
2015-10-22 16:07   ` Ian Campbell
2015-10-22 16:51     ` Julien Grall
2015-10-23  9:30       ` Ian Campbell
2015-10-23  9:37         ` Julien Grall
2015-10-23  9:53           ` Ian Campbell
2015-10-12 14:22 ` [PATCH v4 3/5] xen/arm: vgic: Optimize the way to store the target vCPU in the rank Julien Grall
2015-10-22 16:17   ` Ian Campbell
2015-10-22 17:15     ` Julien Grall
2015-10-23  9:34       ` Ian Campbell
2015-10-23 10:01         ` Julien Grall
2015-10-23 10:14           ` Ian Campbell
2015-10-23 10:15             ` Julien Grall
2015-10-12 14:22 ` [PATCH v4 4/5] xen/arm: vgic: Introduce helpers to extract/update/clear/set vGIC register Julien Grall
2015-10-12 14:22 ` [PATCH v4 5/5] xen/arm: vgic-v3: Support 32-bit access for 64-bit registers 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=562910A1.5000606@citrix.com \
    --to=julien.grall@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@eu.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.