Skip to content

Commit 38cf0bb

Browse files
author
Marc Zyngier
committed
KVM: arm64: vgic-v3: Use u32 to manage the line level from userspace
Despite the userspace ABI clearly defining the bits dealt with by KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO as a __u32, the kernel uses a u64. Use a u32 to match the userspace ABI, which will subsequently lead to some simplifications. Reviewed-by: Reiji Watanabe <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent 71c3c77 commit 38cf0bb

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

arch/arm64/kvm/vgic/vgic-kvm-device.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,14 @@ static int vgic_v3_attr_regs_access(struct kvm_device *dev,
570570
info = (attr->attr & KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK) >>
571571
KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT;
572572
if (info == VGIC_LEVEL_INFO_LINE_LEVEL) {
573+
if (is_write)
574+
tmp32 = *reg;
573575
intid = attr->attr &
574576
KVM_DEV_ARM_VGIC_LINE_LEVEL_INTID_MASK;
575577
ret = vgic_v3_line_level_info_uaccess(vcpu, is_write,
576-
intid, reg);
578+
intid, &tmp32);
579+
if (!is_write)
580+
*reg = tmp32;
577581
} else {
578582
ret = -EINVAL;
579583
}

arch/arm64/kvm/vgic/vgic-mmio-v3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ int vgic_v3_redist_uaccess(struct kvm_vcpu *vcpu, bool is_write,
11541154
}
11551155

11561156
int vgic_v3_line_level_info_uaccess(struct kvm_vcpu *vcpu, bool is_write,
1157-
u32 intid, u64 *val)
1157+
u32 intid, u32 *val)
11581158
{
11591159
if (intid % 32)
11601160
return -EINVAL;

arch/arm64/kvm/vgic/vgic-mmio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,10 @@ void vgic_mmio_write_config(struct kvm_vcpu *vcpu,
775775
}
776776
}
777777

778-
u64 vgic_read_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid)
778+
u32 vgic_read_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid)
779779
{
780780
int i;
781-
u64 val = 0;
781+
u32 val = 0;
782782
int nr_irqs = vcpu->kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS;
783783

784784
for (i = 0; i < 32; i++) {
@@ -798,7 +798,7 @@ u64 vgic_read_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid)
798798
}
799799

800800
void vgic_write_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid,
801-
const u64 val)
801+
const u32 val)
802802
{
803803
int i;
804804
int nr_irqs = vcpu->kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS;

arch/arm64/kvm/vgic/vgic-mmio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ void vgic_mmio_write_config(struct kvm_vcpu *vcpu,
207207
int vgic_uaccess(struct kvm_vcpu *vcpu, struct vgic_io_device *dev,
208208
bool is_write, int offset, u32 *val);
209209

210-
u64 vgic_read_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid);
210+
u32 vgic_read_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid);
211211

212212
void vgic_write_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid,
213-
const u64 val);
213+
const u32 val);
214214

215215
unsigned int vgic_v2_init_dist_iodev(struct vgic_io_device *dev);
216216

arch/arm64/kvm/vgic/vgic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ int vgic_v3_cpu_sysregs_uaccess(struct kvm_vcpu *vcpu,
249249
struct kvm_device_attr *attr, bool is_write);
250250
int vgic_v3_has_cpu_sysregs_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr);
251251
int vgic_v3_line_level_info_uaccess(struct kvm_vcpu *vcpu, bool is_write,
252-
u32 intid, u64 *val);
252+
u32 intid, u32 *val);
253253
int kvm_register_vgic_device(unsigned long type);
254254
void vgic_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);
255255
void vgic_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);

0 commit comments

Comments
 (0)