Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <reijiw@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>

+12 -8
+5 -1
arch/arm64/kvm/vgic/vgic-kvm-device.c
··· 570 570 info = (attr->attr & KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK) >> 571 571 KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT; 572 572 if (info == VGIC_LEVEL_INFO_LINE_LEVEL) { 573 + if (is_write) 574 + tmp32 = *reg; 573 575 intid = attr->attr & 574 576 KVM_DEV_ARM_VGIC_LINE_LEVEL_INTID_MASK; 575 577 ret = vgic_v3_line_level_info_uaccess(vcpu, is_write, 576 - intid, reg); 578 + intid, &tmp32); 579 + if (!is_write) 580 + *reg = tmp32; 577 581 } else { 578 582 ret = -EINVAL; 579 583 }
+1 -1
arch/arm64/kvm/vgic/vgic-mmio-v3.c
··· 1154 1154 } 1155 1155 1156 1156 int vgic_v3_line_level_info_uaccess(struct kvm_vcpu *vcpu, bool is_write, 1157 - u32 intid, u64 *val) 1157 + u32 intid, u32 *val) 1158 1158 { 1159 1159 if (intid % 32) 1160 1160 return -EINVAL;
+3 -3
arch/arm64/kvm/vgic/vgic-mmio.c
··· 775 775 } 776 776 } 777 777 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) 779 779 { 780 780 int i; 781 - u64 val = 0; 781 + u32 val = 0; 782 782 int nr_irqs = vcpu->kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS; 783 783 784 784 for (i = 0; i < 32; i++) { ··· 798 798 } 799 799 800 800 void vgic_write_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid, 801 - const u64 val) 801 + const u32 val) 802 802 { 803 803 int i; 804 804 int nr_irqs = vcpu->kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS;
+2 -2
arch/arm64/kvm/vgic/vgic-mmio.h
··· 207 207 int vgic_uaccess(struct kvm_vcpu *vcpu, struct vgic_io_device *dev, 208 208 bool is_write, int offset, u32 *val); 209 209 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); 211 211 212 212 void vgic_write_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid, 213 - const u64 val); 213 + const u32 val); 214 214 215 215 unsigned int vgic_v2_init_dist_iodev(struct vgic_io_device *dev); 216 216
+1 -1
arch/arm64/kvm/vgic/vgic.h
··· 249 249 struct kvm_device_attr *attr, bool is_write); 250 250 int vgic_v3_has_cpu_sysregs_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr); 251 251 int vgic_v3_line_level_info_uaccess(struct kvm_vcpu *vcpu, bool is_write, 252 - u32 intid, u64 *val); 252 + u32 intid, u32 *val); 253 253 int kvm_register_vgic_device(unsigned long type); 254 254 void vgic_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); 255 255 void vgic_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);