From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
xen-devel <xen-devel@lists.xenproject.org>
Cc: Keir Fraser <keir@xen.org>
Subject: Re: [PATCH] x86/vLAPIC: adjust types in internal read/write handling
Date: Mon, 22 Jun 2015 13:15:29 +0100 [thread overview]
Message-ID: <5587FC61.8090009@citrix.com> (raw)
In-Reply-To: <55881270020000780008778A@mail.emea.novell.com>
On 22/06/15 12:49, Jan Beulich wrote:
> - use 32-bit types where possible (produces slightly better code)
> - drop (now) unnecessary casts
> - avoid indirection where not needed
> - avoid duplicate log messages in vlapic_write()
> - minor other cleanup
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, with two
suggestions.
>
> @@ -847,47 +834,41 @@ static int vlapic_write(struct vcpu *v,
> * According to the IA32 Manual, all accesses should be 32 bits.
> * Some OSes do 8- or 16-byte accesses, however.
> */
> - val = (uint32_t)val;
> - if ( len != 4 )
> + if ( unlikely(len != 4) )
> {
> - unsigned int tmp;
> - unsigned char alignment;
> -
> - gdprintk(XENLOG_INFO, "Notice: Local APIC write with len = %lx\n",len);
> -
> - alignment = offset & 0x3;
> - (void)vlapic_read_aligned(vlapic, offset & ~0x3, &tmp);
> + unsigned int tmp = vlapic_read_aligned(vlapic, offset & ~3);
> + unsigned char alignment = (offset & 3) * 8;
>
> switch ( len )
> {
> case 1:
> - val = ((tmp & ~(0xff << (8*alignment))) |
> - ((val & 0xff) << (8*alignment)));
> + val = ((tmp & ~(0xff << alignment)) |
> + ((val & 0xff) << alignment));
These should probably be explicitly unsigned constants, to avoid issues
with shifting a 1 into the sign bit. (I can't quite decide whether 0xff
will be interpreted as signed or unsigned, given the integer promotion
rules.)
> break;
>
> case 2:
> if ( alignment & 1 )
> goto unaligned_exit_and_crash;
> - val = ((tmp & ~(0xffff << (8*alignment))) |
> - ((val & 0xffff) << (8*alignment)));
> + val = ((tmp & ~(0xffff << alignment)) |
> + ((val & 0xffff) << alignment));
> break;
>
> default:
> - gdprintk(XENLOG_ERR, "Local APIC write with len = %lx, "
> - "should be 4 instead\n", len);
> + gprintk(XENLOG_ERR, "LAPIC write with len %lx\n", len);
> goto exit_and_crash;
> }
> +
> + gdprintk(XENLOG_INFO, "Notice: LAPIC write with len %lx\n", len);
Probably better using %lu.
next prev parent reply other threads:[~2015-06-22 12:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 11:49 [PATCH] x86/vLAPIC: adjust types in internal read/write handling Jan Beulich
2015-06-22 12:15 ` Andrew Cooper [this message]
2015-06-22 12:55 ` Jan Beulich
2015-06-22 13:02 ` Andrew Cooper
2015-06-22 13:27 ` Jan Beulich
2015-06-22 14:06 ` Andrew Cooper
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=5587FC61.8090009@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--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.