Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1973683ybh; Tue, 14 Jul 2020 12:02:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCTnopbokBBmsTcilvYYQDvWre3AO6dmtH0cfSTdR8mTVIq5Owr8mswCa9wbI9ab69c2af X-Received: by 2002:a17:906:6406:: with SMTP id d6mr5767234ejm.30.1594753350486; Tue, 14 Jul 2020 12:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594753350; cv=none; d=google.com; s=arc-20160816; b=THeVbKkz+aTcdTNlrrPmCoE3rGMCVWTLgHIWqH1MztK5M6W5kXlXW6sNccZl4h11Js U+MlVMhpYzdmyyDgiCvSI+d9L3B0pIYB3ntSvw6MB7GgUp0HTwQlHVRKMyepws1x9DHq VpQ7DrBpARSFBCS+16Mq13N6yG7Hina7DJQ85VC4MB469IEGwcQEM1lNOByYTHwdwPLh zWfx/f2DVDB/SCZcGhQVovK6LoDthxFlSHVXJ71SI/uFqcREDMS0leyhIWFh3lY5iuC4 7EWAKFFiyTnwxLJ/gtGeqAqFVl/47GwmGtFE3h4dlRym7V8bL5jPqx19exFzWDzWIekI H9qQ== 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=5YLf3CuXRmc/Gouz9Z3Vo6es6MyEYb9sxkIk1pOy4AU=; b=MgyHUfeYFvVo80+dW8tM7ZEP7jOERRdvJkcb2Bu39iLn80Exy5UFe5YcDRuKLVmXcA wj4KyRVuisFreUm8Uk7nMTqXkD3wqiftUTHxLqdazx864czwIWie13cfiarfUNHkuM0X nkwCA52HuEEHgRDetxL9+g2GJDAcDJacAtHgIfaZ32n30PwLJHLWfFGys79esYxNV/X4 L4K0nbYOPogTNBhq1UzRSGnbVxKkvT+Xf1MrgjYudRbCH++UcjvnFOHF5FZjAJMaci0E 9N0hAL4yxajWnousBOPLFYLjdgS4EJvEgZ8KTatZTBmM4cW7yS6f38BrkLoHPJ2PpViz c5ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YEYY50n9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw25si11786411edb.203.2020.07.14.12.02.06; Tue, 14 Jul 2020 12:02:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YEYY50n9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731263AbgGNS6z (ORCPT + 99 others); Tue, 14 Jul 2020 14:58:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:57368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731249AbgGNS6t (ORCPT ); Tue, 14 Jul 2020 14:58:49 -0400 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 9268F207F5; Tue, 14 Jul 2020 18:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594753129; bh=xJ5eRZ2PiIgyAhVGGbcA8cN/Vr9pXMazVtnNM1VMiA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YEYY50n9aESsUhBHiji+lgAxy1b7RTNosn1vrQntH64eCmpwtgz5q0FTl3JuGUnql RB12kCtO+90PNPGgwtUvYpkTY837w9kq+HCEMSUMK9kDvUANXkRYk9l5cEjhkYwFrB DjL+gPeQ42Oy2pig/fbwrydFyXuXwx9lDthadAgY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Steven Price , Marc Zyngier , Sasha Levin Subject: [PATCH 5.7 123/166] KVM: arm64: Fix kvm_reset_vcpu() return code being incorrect with SVE Date: Tue, 14 Jul 2020 20:44:48 +0200 Message-Id: <20200714184121.724959653@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714184115.844176932@linuxfoundation.org> References: <20200714184115.844176932@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: Steven Price If SVE is enabled then 'ret' can be assigned the return value of kvm_vcpu_enable_sve() which may be 0 causing future "goto out" sites to erroneously return 0 on failure rather than -EINVAL as expected. Remove the initialisation of 'ret' and make setting the return value explicit to avoid this situation in the future. Fixes: 9a3cdf26e336 ("KVM: arm64/sve: Allow userspace to enable SVE for vcpus") Cc: stable@vger.kernel.org Reported-by: James Morse Signed-off-by: Steven Price Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20200617105456.28245-1-steven.price@arm.com Signed-off-by: Sasha Levin --- arch/arm64/kvm/reset.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -258,7 +258,7 @@ static int kvm_vcpu_enable_ptrauth(struc int kvm_reset_vcpu(struct kvm_vcpu *vcpu) { const struct kvm_regs *cpu_reset; - int ret = -EINVAL; + int ret; bool loaded; /* Reset PMU outside of the non-preemptible section */ @@ -281,15 +281,19 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu if (test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, vcpu->arch.features) || test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, vcpu->arch.features)) { - if (kvm_vcpu_enable_ptrauth(vcpu)) + if (kvm_vcpu_enable_ptrauth(vcpu)) { + ret = -EINVAL; goto out; + } } switch (vcpu->arch.target) { default: if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { - if (!cpu_has_32bit_el1()) + if (!cpu_has_32bit_el1()) { + ret = -EINVAL; goto out; + } cpu_reset = &default_regs_reset32; } else { cpu_reset = &default_regs_reset;