Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13331723ybl; Sun, 29 Dec 2019 09:28:59 -0800 (PST) X-Google-Smtp-Source: APXvYqyznH3v4NCBMGZt+Fi9N/Qsp4qhbh2hlyz7LhZNybSUgL7t5PwHW4jcCsyV3jYRotDT2g3W X-Received: by 2002:a9d:4f18:: with SMTP id d24mr65812211otl.179.1577640539575; Sun, 29 Dec 2019 09:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640539; cv=none; d=google.com; s=arc-20160816; b=uLuHxCQgiEdegtbCggDbScpkoaAKSubrDAKN8rSsXF9L0psqEvg8U2JAQViQcocTgx OpOd2yu7lCiAUzd4ifR27woqq6q+4WU69ay3oin/v0GC063NsBGkk/rtrrmz9CV/s+QP iVRZkEalhN3kbYNlvBM++xVjU4x6YfXTu72o57qlbZAVla0jh4K3kvRXgzhBvqT6Hx1l KWCtdNZcPDiYEhNq54pP7lP7XPViTyz+jdzPwHtSs3RjteikC6dL+IoqPv9Bg8jx72j9 b8CIS2W89/tuFBi/0T10qjKFkH3O1E0Hdgdk8WpWjyhHUJejxCW/cWomrf7zMPhNMwkh UfFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uch/GC2EQ+mJE1Ov2XRjQmMr6zLjufM/BY/bkFTaWmo=; b=ouXevgJe6T8h29CWAU8LldP3fMs0T33eITdl1oif8bFKL8bAvUyh72us3xknsaj1Zv bvJKXfQv9uHKsCrctdLhaJFl5sCzk4cQIAU7NSC1vmAkV0ZuJWwGFUGVk5rvK6tZdGQw 6T+rA4CZk9mFmwLmiMewP+y3vMjD+0Esw/wxkuR1GZxuHuv/fm+n7k8begvE1JBQZ0z2 EmkMMcL7b4QwzFXwUkjGvC2WmLdaA+HlKg1Xs4wRBH+R/hyrgyY0pJ38KPn1KqKB53yj cLUUGPktTXYwT++SMLBMqS+Dn8xnEUozkq6J1IKsKy6hSszAsUQZNU9dUQCGofDVL1z7 dxdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gmhdMeBl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a29si22625132otd.268.2019.12.29.09.28.47; Sun, 29 Dec 2019 09:28:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gmhdMeBl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbfL2R1O (ORCPT + 99 others); Sun, 29 Dec 2019 12:27:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:49140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728060AbfL2R1L (ORCPT ); Sun, 29 Dec 2019 12:27:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 54C83207FF; Sun, 29 Dec 2019 17:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640430; bh=CFq7QeTcEXfVevTxoQrg/wPsOlCDpo63+EilV2uVLvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gmhdMeBlPZNx5Z+C+/0+EPDidP08z2c1GeYxHN/M2UEvc5h25QGQXuCecqz6vAPGj myuSBZ9E5r43flLMkF10XHrOTS8Qs/Fd4TdPTLvmDOXDSahlPOba9EGVlqlDkTUFaf QF8hzcOQl2+jHe+h9RtUvivsAILiHP3YhA3MU0dM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Marc Zyngier Subject: [PATCH 4.14 154/161] KVM: arm64: Ensure params is initialised when looking up sys register Date: Sun, 29 Dec 2019 18:20:02 +0100 Message-Id: <20191229162448.691821033@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon 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 Signed-off-by: Marc Zyngier Cc: Link: https://lore.kernel.org/r/20191212094049.12437-1-will@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/sys_regs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1785,8 +1785,11 @@ static const struct sys_reg_desc *index_ if ((id & KVM_REG_ARM_COPROC_MASK) != KVM_REG_ARM64_SYSREG) return NULL; + if (!index_to_params(id, ¶ms)) + return NULL; + table = get_target_table(vcpu->arch.target, true, &num); - r = find_reg_by_id(id, ¶ms, table, num); + r = find_reg(¶ms, table, num); if (!r) r = find_reg(¶ms, sys_reg_descs, ARRAY_SIZE(sys_reg_descs));