]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
KVM: arm64: Ensure 'params' is initialised when looking up sys register
authorWill Deacon <will@kernel.org>
Thu, 12 Dec 2019 09:40:49 +0000 (09:40 +0000)
committerSeth Forshee <seth.forshee@canonical.com>
Mon, 6 Jan 2020 14:17:39 +0000 (08:17 -0600)
commitbcc1f238a11111c04c982507a7ce29bdf0ec4e26
treeae1414d538a20dcc521b027dc0121257789e59b9
parentd20f51836dd7e1bb3bbc8660d3047d7dbdc589eb
KVM: arm64: Ensure 'params' is initialised when looking up sys register

BugLink: https://bugs.launchpad.net/bugs/1858428
commit 1ce74e96c2407df2b5867e5d45a70aacb8923c14 upstream.

Commit 4b927b94d5df ("KVM: arm/arm64: vgic: Introduce find_reg_by_id()")
introduced 'find_reg_by_id()', which looks up a system register only if
the 'id' index parameter identifies a valid system register. As part of
the patch, existing callers of 'find_reg()' were ported over to the new
interface, but this breaks 'index_to_sys_reg_desc()' in the case that the
initial lookup in the vCPU target table fails because we will then call
into 'find_reg()' for the system register table with an uninitialised
'param' as the key to the lookup.

GCC 10 is bright enough to spot this (amongst a tonne of false positives,
but hey!):

  | arch/arm64/kvm/sys_regs.c: In function ‘index_to_sys_reg_desc.part.0.isra’:
  | arch/arm64/kvm/sys_regs.c:983:33: warning: ‘params.Op2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  |   983 |   (u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2);
  | [...]

Revert the hunk of 4b927b94d5df which breaks 'index_to_sys_reg_desc()' so
that the old behaviour of checking the index upfront is restored.

Fixes: 4b927b94d5df ("KVM: arm/arm64: vgic: Introduce find_reg_by_id()")
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20191212094049.12437-1-will@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
arch/arm64/kvm/sys_regs.c