From: Julien Grall <julien.grall@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Julien Grall <julien.grall@citrix.com>,
Wei.Liu2@citrix.com, stefano.stabellini@citrix.com,
ian.campbell@citrix.com
Subject: [PATCH for 4.6] xen/arm: vgic: Correctly emulate write when byte is used
Date: Tue, 22 Sep 2015 21:18:48 +0100 [thread overview]
Message-ID: <1442953128-4669-1-git-send-email-julien.grall@citrix.com> (raw)
When a guest is writing a byte, the value will be located in bits[7:0]
of the register.
Although the current implementation is expecting the byte at the Nth
byte of the register where N = address & 4;
When the address is not 4-byte aligned, the corresponding byte in the
internal state will always be set to zero rather.
Note that byte access are only used for GICD_IPRIORITYR and
GICD_ITARGETSR. So the worst things that could happen is not setting the
priority correctly and ignore the target vCPU written.
Signed-off-by: Julien Grall <julien.grall@citrix.com>
---
This patch is a candidate for Xen 4.6 and backport to Xen 4.5 and Xen
4.4. Without it, write a byte to a register won't work as expected.
Spotted while doing some test on the vGICv2 driver. FWIW, Linux doesn't
use byte access in both GICv3 and GICv2 driver.
Note that Xen 4.4 will require a different patch because the function
was living in vgic.c at that time.
---
xen/include/asm-arm/vgic.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index 41cadb1..96839f0 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -174,10 +174,10 @@ static inline void vgic_byte_write(uint32_t *reg, uint32_t var, int offset)
{
int byte = offset & 0x3;
- var &= (0xff << (8*byte));
+ var &= 0xff;
*reg &= ~(0xff << (8*byte));
- *reg |= var;
+ *reg |= (var << (8*byte));
}
enum gic_sgi_mode;
--
2.1.4
next reply other threads:[~2015-09-22 20:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 20:18 Julien Grall [this message]
2015-09-23 13:23 ` [PATCH for 4.6] xen/arm: vgic: Correctly emulate write when byte is used Wei Liu
2015-09-24 11:30 ` 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=1442953128-4669-1-git-send-email-julien.grall@citrix.com \
--to=julien.grall@citrix.com \
--cc=Wei.Liu2@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@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 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).