From: Julien Grall <julien.grall@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, ian.campbell@citrix.com
Subject: Re: [PATCH v3 7/9] xen/arm: vgic: Optimize the way to store the target vCPU in the rank
Date: Wed, 7 Oct 2015 19:16:01 +0100 [thread overview]
Message-ID: <56156161.4090109@citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1510071821100.1179@kaball.uk.xensource.com>
On 07/10/15 18:26, Stefano Stabellini wrote:
> On Wed, 7 Oct 2015, Julien Grall wrote:
>> +/*
>> + * Store a ITARGETSR register in a convenient way and migrate the vIRQ
>> + * if necessary. This function only deals with ITARGETSR8 and onwards.
>> + *
>> + * Note the offset will be aligned to the appropriate boundary.
>> + */
>> +static void vgic_store_itargetsr(struct domain *d, struct vgic_irq_rank *rank,
>> + unsigned int offset, uint32_t itargetsr)
>> +{
>> + unsigned int i;
>> +
>> + ASSERT(spin_is_locked(&rank->lock));
>> +
>> + /*
>> + * The ITARGETSR0-7, used for SGIs/PPIs, are implemented RO in the
>> + * emulation and should never call this function.
>> + *
>> + * They all live in the first rank.
>> + */
>> + BUILD_BUG_ON(NR_INTERRUPT_PER_RANK != 32);
>> + ASSERT(rank->index >= 1);
>> +
>> + offset &= INTERRUPT_RANK_MASK;
>> + offset &= ~(NR_TARGET_PER_REG - 1);
>> +
>> + for ( i = 0; i < NR_TARGET_PER_REG; i++, offset++ )
>> + {
>> + unsigned int new_target, old_target;
>> +
>> + /*
>> + * SPIs are using the 1-N model (see 1.4.3 in ARM IHI 0048B).
>> + * While the interrupt could be set pending to all the vCPUs in
>> + * target list, it's not guarantee by the spec.
>> + * For simplicity, always route the vIRQ to the first interrupt
>> + * in the target list
>> + */
>> + new_target = ffs(itargetsr & ((1 << NR_BIT_PER_TARGET) - 1));
>> + old_target = rank->vcpu[offset];
>> +
>> + itargetsr >>= NR_BIT_PER_TARGET;
>> +
>> + /*
>> + * Ignore the write request for this interrupt if the new target
>> + * is invalid.
>> + */
>> + if ( !new_target || (new_target > d->max_vcpus) )
>> + continue;
>> +
>> + /* The vCPU ID always start from 0 */
>> + new_target--;
>> +
>> + /* Only migrate the vIRQ if the target vCPU has changed */
>> + if ( new_target != old_target )
>> + {
>> + unsigned int virq = rank->index * NR_INTERRUPT_PER_RANK + offset;
>> +
>> + vgic_migrate_irq(d->vcpu[old_target],
>> + d->vcpu[new_target],
>> + virq);
>> + }
>> +
>> + rank->vcpu[offset] = new_target;
>> + }
>> +}
>
> This introduces a behavioural change: previously 32-bit writes which
> contained one 0 byte would be ignored in their entirety. See:
>
> http://marc.info/?l=xen-devel&m=140431564123221
It's true that this may change the behavior of a guest writing the
ITARGETSR with a byte to 0. But what's the point to have a guest relying
on its write to be ignored?
Aside that, I don't think we are bound to emulate exactly the same
behavior in each version of Xen. We may decide to slightly change it
because we have to rework the code to get a common emulation or fix a bug.
>
> Even though I am not entirely sure about which one is the correct
> behaviour according to the spec, I prefer the old one because I think it
> is less surprising to users.
How ignoring the whole write would be less surprising? ;) There is no
warning at all, so it's very difficult for the user to know why the
write has been ignored.
Furthermore, based on the spec (4.3.12 in IHI 0048B.b): "A register
field corresponding to an unimplemented interrupt is RAZ/WI."
If the user knows that an interrupt is not implemented, he may decide to
write 0 in the corresponding byte. With the current solution, the whole
write access is ignored.
The solution suggested in this patch is less restrictive and will just
ignore the corresponding byte if it's 0.
On another side, nothing in the spec specified what happen if the target
field is 0 for a valid interrupt. But I think this is OK to just ignore
it and carry on. It's simpler to implement.
I didn't mention this such things in the commit message. I will update
it if we decide to carry on with this patch.
Regards,
--
Julien Grall
next prev parent reply other threads:[~2015-10-07 18:17 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-07 14:41 [PATCH v3 0/9] xen/arm: vgic: Support 32-bit access for 64-bit register Julien Grall
2015-10-07 14:41 ` [PATCH v3 1/9] xen/arm: io: remove mmio_check_t typedef Julien Grall
2015-10-07 14:41 ` [PATCH v3 2/9] xen/arm: io: Extend write/read handler to pass the register in parameter Julien Grall
2015-10-07 14:41 ` [PATCH v3 3/9] xen/arm: io: Support sign-extension for every read access Julien Grall
2015-10-07 14:41 ` [PATCH v3 4/9] xen/arm: vgic: ctlr stores a 32-bit hardware register so use uint32_t Julien Grall
2015-10-07 14:41 ` [PATCH v3 5/9] xen/arm: vgic: Optimize the way to store GICD_IPRIORITYR in the rank Julien Grall
2015-10-07 14:41 ` [PATCH v3 6/9] xen/arm: vgic: Introduce a new field to store the rank index and use it Julien Grall
2015-10-07 14:41 ` [PATCH v3 7/9] xen/arm: vgic: Optimize the way to store the target vCPU in the rank Julien Grall
2015-10-07 15:38 ` Ian Campbell
2015-10-07 15:48 ` Julien Grall
2015-10-07 16:00 ` Ian Campbell
2015-10-07 16:29 ` Julien Grall
2015-10-07 19:13 ` Julien Grall
2015-10-08 9:39 ` Ian Campbell
2015-10-08 10:43 ` Julien Grall
2015-10-07 17:26 ` Stefano Stabellini
2015-10-07 18:16 ` Julien Grall [this message]
2015-10-08 10:56 ` Ian Campbell
2015-10-08 11:36 ` Stefano Stabellini
2015-10-08 12:23 ` Ian Campbell
2015-10-08 12:34 ` Stefano Stabellini
2015-10-08 13:46 ` Julien Grall
2015-10-08 14:25 ` Ian Campbell
2015-10-08 18:36 ` Julien Grall
2015-10-09 11:24 ` Julien Grall
2015-10-09 11:38 ` Ian Campbell
2015-10-12 10:41 ` Stefano Stabellini
2015-10-12 11:00 ` Julien Grall
2015-10-12 11:07 ` Stefano Stabellini
2015-10-12 11:28 ` Julien Grall
2015-10-07 14:41 ` [PATCH v3 8/9] xen/arm: vgic: Introduce helpers to extract/update/clear/set vGIC register Julien Grall
2015-10-07 14:41 ` [PATCH v3 9/9] xen/arm: vgic-v3: Support 32-bit access for 64-bit registers Julien Grall
2015-10-08 10:44 ` [PATCH v3 0/9] xen/arm: vgic: Support 32-bit access for 64-bit register Julien Grall
2015-10-08 11:46 ` Ian Campbell
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=56156161.4090109@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.