Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13338573ybl; Sun, 29 Dec 2019 09:37:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwx6EzkP+AsaC9OYuysR0RGN/xHOWvMH0QaAUQjg8rNDPDj9Gd3b6/1hO8uCBgy2WknSWX3 X-Received: by 2002:a9d:7519:: with SMTP id r25mr60137636otk.284.1577641032327; Sun, 29 Dec 2019 09:37:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577641032; cv=none; d=google.com; s=arc-20160816; b=Qb43lkRAH1Nzl9Z0kuu/1DpkH6LZ97/bV/UhR19wzTyUeuB9GrP2KsOhTbiZfZh3UG 2zcdMpPzGzxgPC9131DgNKm/MW+cXjz7EilEupUPMzFG2qCLqQMTdu2/phfjeGITqqVT J1PD2lqFveZETJpTDzmRKelcbGK33NgcnYwjt3ewfaf2Zmia0nTdTQ7u3mkNUAv3nO9+ tze/4VuipGrUHDHK3DAL1btMeQ6yNTSsW8lVEz/MKTNirS2eYcGDGfjRO9cFeQBdoBWQ z9swMFndp+xASJyzyeQgxmJvEtLlnUKBuqCLYuYJPE5RE/kHtBooHWjfQw9XsO/ufKQl 3aqw== 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=aW0mvsKjg6fvMelizo1nzus8ZGh6o1sAxQqL7FZQcXc=; b=TnAA/eOmKo4aYNnM3yQ7gpEq/5g1flPZHSIgYCB7L+qziubRuyRVm6UW/5Fp8vyx6r m8LFBqV4FM8Nw/fur7kc0WzZpj33Unj8yjDWbEZxQZFLNxil17sHuVj/MVIId8VhQjcN R0wM66F1pY14DTzbY4cF1gD8lVUlXlc/AHU/J23ny+m3cQTrLJfwB9ZMomVEYNmGop9V mqQP+VGhkco0l+f8k8H5jEkztdSTjBjinKRc95LLekcWgu1EGR1k0TOac1eivkoHhhE1 vjh5cv0Rb/T76qHWprchJZH/mBmuOzv9w55v10XJmvLajBpMzQ+kTBcNc7OIUhjzYlQT OJ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OL/v4OPn"; 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 l5si18643362otn.194.2019.12.29.09.37.02; Sun, 29 Dec 2019 09:37:12 -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="OL/v4OPn"; 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 S1729974AbfL2RgB (ORCPT + 99 others); Sun, 29 Dec 2019 12:36:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:40816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729764AbfL2Rf7 (ORCPT ); Sun, 29 Dec 2019 12:35:59 -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 033FF206CB; Sun, 29 Dec 2019 17:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640958; bh=CAaJ7YqaVHX3CZcc9mY/Z28h0vyaztCdHIRznZRQQmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OL/v4OPn4kQVJ3otwz8FFtmlO7UQ9yYG4sXorLEDX+oSGcS/L+jDblkP6j7Ehiw7f oH9eh86GoiFEFFsMjCRM/sMLy/rKa2/4+5pbYq3c8NViYyD3Q051VxxOqP7rXgABmY txvrH6LXGJ/QHfATGxd/QvrhS9MCFQCPV13Y1LRA= 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.19 208/219] KVM: arm64: Ensure params is initialised when looking up sys register Date: Sun, 29 Dec 2019 18:20:10 +0100 Message-Id: <20191229162541.559477727@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@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 @@ -2174,8 +2174,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));