* [PATCH] ARM: KVM: vgic: fix GICD_ICFGRn access
@ 2013-06-18 10:09 Marc Zyngier
2013-06-18 16:06 ` Christoffer Dall
0 siblings, 1 reply; 2+ messages in thread
From: Marc Zyngier @ 2013-06-18 10:09 UTC (permalink / raw)
To: linux-arm-kernel
All the code in handle_mmio_cfg_reg() assumes the offset has
been shifted right to accomodate for the 2:1 bit compression,
but this is only done when getting the register addess.
Shift the offset early so the code works mostly unchanged.
Reported-by: Zhaobo (Bob, ERC) <zhaobo@huawei.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
arch/arm/kvm/vgic.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm/kvm/vgic.c b/arch/arm/kvm/vgic.c
index a2d478a..902789f 100644
--- a/arch/arm/kvm/vgic.c
+++ b/arch/arm/kvm/vgic.c
@@ -541,8 +541,12 @@ static bool handle_mmio_cfg_reg(struct kvm_vcpu *vcpu,
struct kvm_exit_mmio *mmio, phys_addr_t offset)
{
u32 val;
- u32 *reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
- vcpu->vcpu_id, offset >> 1);
+ u32 *reg;
+
+ offset >>= 1;
+ reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
+ vcpu->vcpu_id, offset);
+
if (offset & 2)
val = *reg >> 16;
else
--
1.8.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] ARM: KVM: vgic: fix GICD_ICFGRn access
2013-06-18 10:09 [PATCH] ARM: KVM: vgic: fix GICD_ICFGRn access Marc Zyngier
@ 2013-06-18 16:06 ` Christoffer Dall
0 siblings, 0 replies; 2+ messages in thread
From: Christoffer Dall @ 2013-06-18 16:06 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jun 18, 2013 at 11:09:28AM +0100, Marc Zyngier wrote:
> All the code in handle_mmio_cfg_reg() assumes the offset has
> been shifted right to accomodate for the 2:1 bit compression,
> but this is only done when getting the register addess.
I personally think this is a funky assumption. The offset is called
offset, because it's the offset, not a "compressed index" value, so I'd
prefer to fix the comparison values instead.
If not, put a comment and explain the assumption, because it's not
obvious.
>
> Shift the offset early so the code works mostly unchanged.
>
> Reported-by: Zhaobo (Bob, ERC) <zhaobo@huawei.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm/kvm/vgic.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/kvm/vgic.c b/arch/arm/kvm/vgic.c
> index a2d478a..902789f 100644
> --- a/arch/arm/kvm/vgic.c
> +++ b/arch/arm/kvm/vgic.c
> @@ -541,8 +541,12 @@ static bool handle_mmio_cfg_reg(struct kvm_vcpu *vcpu,
> struct kvm_exit_mmio *mmio, phys_addr_t offset)
> {
> u32 val;
> - u32 *reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
> - vcpu->vcpu_id, offset >> 1);
> + u32 *reg;
> +
> + offset >>= 1;
> + reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
> + vcpu->vcpu_id, offset);
> +
> if (offset & 2)
> val = *reg >> 16;
> else
> --
> 1.8.2.3
>
>
>
> _______________________________________________
> kvmarm mailing list
> kvmarm at lists.cs.columbia.edu
> https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-18 16:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-18 10:09 [PATCH] ARM: KVM: vgic: fix GICD_ICFGRn access Marc Zyngier
2013-06-18 16:06 ` Christoffer Dall
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).