From: Julien Grall <julien.grall@citrix.com>
To: Ian Campbell <ian.campbell@citrix.com>, xen-devel@lists.xenproject.org
Cc: Vijaya.Kumar@caviumnetworks.com, stefano.stabellini@citrix.com,
manish.jaggi@caviumnetworks.com, vijay.kilari@gmail.com
Subject: Re: [PATCH v1 3/8] xen/arm: Support sign-extension for every read access
Date: Mon, 28 Sep 2015 17:42:53 +0100 [thread overview]
Message-ID: <56096E0D.8060901@citrix.com> (raw)
In-Reply-To: <1443199485.25250.212.camel@citrix.com>
On 25/09/15 17:44, Ian Campbell wrote:
>> diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
>> index 32b2194..e1b03a2 100644
>> --- a/xen/arch/arm/io.c
>> +++ b/xen/arch/arm/io.c
>> @@ -23,6 +23,32 @@
>> #include <asm/current.h>
>> #include <asm/mmio.h>
>>
>> +static int handle_read(mmio_read_t read_cb, struct vcpu *v,
>> + mmio_info_t *info, register_t *r)
>> +{
>> + uint8_t size = (1 << info->dabt.size) * 8;
>> +
>> + if ( !read_cb(v, info, r) )
>> + return 0;
>> +
>> + /*
>> + * Extend the bit sign if required.
>
> I think you meant s/bit sign/sign bit/ but more correct would be "Sign
> extend if required".
Will fix it.
>
>> + * Note that we expect the read handler to have zeroed the bit
>> + * unused in the register.
>
> "... to have zeroed the unused bits in the register".
>
> But I think "unused" is a bit misleading, you mean the ones outside the
> requested access size, those bits are still "used" IYSWIM. I can't think of
> a terse term for "outside the requested access size I'm afraid.
>
> Did you confirm that all existing handlers meet this requirement? Perhaps
> an ASSERT would be handy?
>
>> + */
>> + if ( info->dabt.sign && (*r & (1UL << (size - 1)) ))
>> + {
>> + /*
>> + * We are relying on register_t as the same size as
>> + * an unsigned long or order to keep the 32bit some smaller
>
> "order"? I'm not sure what you meant here so I can't suggest an
> alternative.
hmmm... the end of the comment is badly written :/. I wanted to say
"We are relying on register_t using the same size as and unsigned long
in order to keep the 32-bit assembly code smaller"
>
>> + */
>> + BUILD_BUG_ON(sizeof(register_t) != sizeof(unsigned long));
>> + *r |= (~0UL) << size;
>
> I think here and in the initial if you need to be careful of the case where
> size == 32 (on arm32) or == 64 (on arm64), since a shift by >= the size of
> the variable is, I think, undefined behaviour.
>
> It's also a waste of time sign extending in that case.
>From the spec, dabt.sign is only set when smaller size than the register
size. For instance for ARMv7 spec (ARM DDI 0406C.b page B3-1433):
"SSE, Syndrome sign extend. For a byte or halfword load operation,
indicates whether
the data item must be sign extended. [...] For all other operations this
bit is 0."
So we don't have to worry about waste of time and undefined behavior.
Note that mention it in the commit message. Maybe it wasn't clear enough?
Regards,
--
Julien Grall
next prev parent reply other threads:[~2015-09-28 16:46 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-25 14:51 [PATCH v1 0/8] xen/arm: vgic: Support 32-bit access for 64-bit register Julien Grall
2015-09-25 14:51 ` [PATCH v1 1/8] xen/arm: io: remove mmio_check_t typedef Julien Grall
2015-09-25 16:33 ` Ian Campbell
2015-09-25 14:51 ` [PATCH v1 2/8] xen/arm: io: Extend write/read handler to pass the register in parameter Julien Grall
2015-09-25 16:36 ` Ian Campbell
2015-09-28 16:35 ` Julien Grall
2015-09-29 10:51 ` Ian Campbell
2015-09-29 11:00 ` Julien Grall
2015-09-29 11:09 ` Ian Campbell
2015-09-25 14:51 ` [PATCH v1 3/8] xen/arm: Support sign-extension for every read access Julien Grall
2015-09-25 16:44 ` Ian Campbell
2015-09-28 16:42 ` Julien Grall [this message]
2015-09-29 11:01 ` Ian Campbell
2015-09-29 11:07 ` Julien Grall
2015-09-28 18:22 ` Julien Grall
2015-09-29 11:03 ` Ian Campbell
2015-09-29 11:13 ` Julien Grall
2015-09-29 13:13 ` Ian Campbell
2015-09-29 13:16 ` Julien Grall
2015-09-25 14:51 ` [PATCH v1 4/8] xen/arm: vgic: ctlr stores a 32-bit hardware register so use uint32_t Julien Grall
2015-09-25 16:45 ` Ian Campbell
2015-09-25 14:51 ` [PATCH v1 5/8] xen/arm: vgic: Optimize the way to store GICD_IPRIORITYR in the rank Julien Grall
2015-09-28 10:50 ` Ian Campbell
2015-09-28 17:10 ` Julien Grall
2015-09-29 10:56 ` Ian Campbell
2015-09-28 10:52 ` Ian Campbell
2015-09-28 16:43 ` Julien Grall
2015-09-25 14:51 ` [PATCH v1 6/8] xen/arm: vgic: Optimize the way to store the target vCPU " Julien Grall
2015-09-29 13:07 ` Ian Campbell
2015-09-29 13:36 ` Julien Grall
2015-09-29 14:23 ` Ian Campbell
2015-09-30 18:11 ` Julien Grall
2015-10-01 8:30 ` Ian Campbell
2015-09-25 14:51 ` [PATCH v1 7/8] xen/arm: vgic: Introduce helpers to read/write/clear/set vGIC register Julien Grall
2015-09-29 13:23 ` Ian Campbell
2015-09-29 13:48 ` Julien Grall
2015-09-29 14:24 ` Ian Campbell
2015-10-02 9:36 ` Julien Grall
2015-09-25 14:51 ` [PATCH v1 8/8] xen/arm: vgic-v3: Support 32-bit access for 64-bit registers Julien Grall
2015-09-29 13:27 ` Ian Campbell
[not found] <1443192667-16112-1-git-send-email-julien.grall@citrix.com>
2015-09-25 14:51 ` [PATCH v1 3/8] xen/arm: Support sign-extension for every read access 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=56096E0D.8060901@citrix.com \
--to=julien.grall@citrix.com \
--cc=Vijaya.Kumar@caviumnetworks.com \
--cc=ian.campbell@citrix.com \
--cc=manish.jaggi@caviumnetworks.com \
--cc=stefano.stabellini@citrix.com \
--cc=vijay.kilari@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).