• James Morse's avatar
    KVM: arm64: Fix order of vcpu_write_sys_reg() arguments · 1975fa56
    James Morse authored
    A typo in kvm_vcpu_set_be()'s call:
    | vcpu_write_sys_reg(vcpu, SCTLR_EL1, sctlr)
    causes us to use the 32bit register value as an index into the sys_reg[]
    array, and sail off the end of the linear map when we try to bring up
    big-endian secondaries.
    
    | Unable to handle kernel paging request at virtual address ffff80098b982c00
    | Mem abort info:
    |  ESR = 0x96000045
    |  Exception class = DABT (current EL), IL = 32 bits
    |   SET = 0, FnV = 0
    |   EA = 0, S1PTW = 0
    | Data abort info:
    |   ISV = 0, ISS = 0x00000045
    |   CM = 0, WnR = 1
    | swapper pgtable: 4k pages, 48-bit VAs, pgdp = 000000002ea0571a
    | [ffff80098b982c00] pgd=00000009ffff8803, pud=0000000000000000
    | Internal error: Oops: 96000045 [#1] PREEMPT SMP
    | Modules linked in:
    | CPU: 2 PID: 1561 Comm: kvm-vcpu-0 Not tainted 4.17.0-rc3-00001-ga912e2261ca6-dirty #1323
    | Hardware name: ARM Juno development board (r1) (DT)
    | pstate: 60000005 (nZCv daif -PAN -UAO)
    | pc : vcpu_write_sys_reg+0x50/0x134
    | lr : vcpu_write_sys_reg+0x50/0x134
    
    | Process kvm-vcpu-0 (pid: 1561, stack limit = 0x000000006df4728b)
    | Call trace:
    |  vcpu_write_sys_reg+0x50/0x134
    |  kvm_psci_vcpu_on+0x14c/0x150
    |  kvm_psci_0_2_call+0x244/0x2a4
    |  kvm_hvc_call_handler+0x1cc/0x258
    |  handle_hvc+0x20/0x3c
    |  handle_exit+0x130/0x1ec
    |  kvm_arch_vcpu_ioctl_run+0x340/0x614
    |  kvm_vcpu_ioctl+0x4d0/0x840
    |  do_vfs_ioctl+0xc8/0x8d0
    |  ksys_ioctl+0x78/0xa8
    |  sys_ioctl+0xc/0x18
    |  el0_svc_naked+0x30/0x34
    | Code: 73620291 604d00b0 00201891 1ab10194 (957a33f8)
    |---[ end trace 4b4a4f9628596602 ]---
    
    Fix the order of the arguments.
    
    Fixes: 8d404c4c ("KVM: arm64: Rewrite system register accessors to read/write functions")
    CC: Christoffer Dall <cdall@cs.columbia.edu>
    Signed-off-by: default avatarJames Morse <james.morse@arm.com>
    Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
    1975fa56
kvm_emulate.h 10.2 KB