]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
xen/arm: vgic: Correctly emulate write when byte is used
authorJulien Grall <julien.grall@citrix.com>
Tue, 22 Sep 2015 20:18:48 +0000 (21:18 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 24 Sep 2015 10:41:16 +0000 (11:41 +0100)
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>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/include/asm-arm/vgic.h

index 41cadb12998f124f8b74bb548e6e7e0ee37d4cf2..96839f02025f93e2c68bba8ede08118e2f244e0b 100644 (file)
@@ -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;