Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp805439pxb; Tue, 3 Nov 2020 13:02:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXsn9gCCQuHzeHI6/Z54Caif5ITeQ1F3Xzf7wIoUjajrXvr4x9YOlIH2meIJfS6LH+bn+A X-Received: by 2002:a05:6402:1585:: with SMTP id c5mr10260339edv.372.1604437368547; Tue, 03 Nov 2020 13:02:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437368; cv=none; d=google.com; s=arc-20160816; b=SivNPXnuRBWU+QFoXfxXCURMlWlFcDGADHBzBy8vBA37cVGFxHhZmBVnWExdXTxCCh AH2lHcGDwA59jtgzNNtLPzawHnbMKLL2ebuotaWKu2LLnpX8LVJ5Wbl5iBHxQ+3GhLX7 f8OqqB61EdN+QVAK+dMpddtuqDpUnNjCxlctGKPSHCybMZz0X3DZz5z11mLp1TCTzPIN eZRGr6CKKXXN4mEciD2xthiKUJmw7qeOA5OHoDj6V8U+TD1/yoyXS0DVWIH+qkp9Pvjj yoR4cjWPZ5qwlzxqdBL2PJfTaANFHNsommQcwU6DgGwZd03xJumqwURFy0WPerxkxhhr AlGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UMp3mVB6hbqyQxeyosJecHE3TvdtRH1CrGA0HXJLtj8=; b=fCvg4tSzdzBQYTbM97/C3eIWEbRGGxoe2aAD3gpo9pC5ANDuLxMJXuGebLXILs6SIz ZyOU4H2/4f5yyQ97FXEd69y66P//H2pV1cjFPRzZR80gd3b38AyAMSkaB/S5SKhrcqy3 M/Nc4295FfUVZoIKUpQaNPTKXRb4L7Vndu7f35WyZOs/IjhbC7VZ/pQjVPsRcsj0GNrT UKH+JyFDJU0HnW4PNbeoyaPXGHleyx5p2C5K01Pw5HYcfL/btWUFuYXgv3Zywo/oAhq4 yjubPeePZIEsxvNI51odyPQXOilwkL7f6LyYueWxQo+FdPLCUAnX9xiSnc9HfNB6uYz9 YbZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="0J/ccn2M"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k20si32397ejj.93.2020.11.03.13.02.23; Tue, 03 Nov 2020 13:02:48 -0800 (PST) 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="0J/ccn2M"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387408AbgKCVBE (ORCPT + 99 others); Tue, 3 Nov 2020 16:01:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:37176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733294AbgKCVBA (ORCPT ); Tue, 3 Nov 2020 16:01:00 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 D1F8321534; Tue, 3 Nov 2020 21:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437259; bh=l8T1BxpdWMGORtkMch0zBnZHthm9bcp8z4QUo4Yj+JU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0J/ccn2M+gwHxMebd1g851iCiBOscm04EfsmPCZPMNC2iU88GT2uTFe7WjHqiXJwr u1gYlhErJ38dTrtlSLCc3K4PnsKEDJwsKQxcwskm54DJGgPjsjjW1c+itwySHypEoR GxVf8yuo8DvXCXB8jG5bn1zYR99LG9Hxsw/eUIC4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Boyd , Marc Zyngier , Will Deacon , Andre Przywara , Steven Price Subject: [PATCH 5.4 214/214] KVM: arm64: ARM_SMCCC_ARCH_WORKAROUND_1 doesnt return SMCCC_RET_NOT_REQUIRED Date: Tue, 3 Nov 2020 21:37:42 +0100 Message-Id: <20201103203310.638169023@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephen Boyd commit 1de111b51b829bcf01d2e57971f8fd07a665fa3f upstream. According to the SMCCC spec[1](7.5.2 Discovery) the ARM_SMCCC_ARCH_WORKAROUND_1 function id only returns 0, 1, and SMCCC_RET_NOT_SUPPORTED. 0 is "workaround required and safe to call this function" 1 is "workaround not required but safe to call this function" SMCCC_RET_NOT_SUPPORTED is "might be vulnerable or might not be, who knows, I give up!" SMCCC_RET_NOT_SUPPORTED might as well mean "workaround required, except calling this function may not work because it isn't implemented in some cases". Wonderful. We map this SMC call to 0 is SPECTRE_MITIGATED 1 is SPECTRE_UNAFFECTED SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE For KVM hypercalls (hvc), we've implemented this function id to return SMCCC_RET_NOT_SUPPORTED, 0, and SMCCC_RET_NOT_REQUIRED. One of those isn't supposed to be there. Per the code we call arm64_get_spectre_v2_state() to figure out what to return for this feature discovery call. 0 is SPECTRE_MITIGATED SMCCC_RET_NOT_REQUIRED is SPECTRE_UNAFFECTED SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE Let's clean this up so that KVM tells the guest this mapping: 0 is SPECTRE_MITIGATED 1 is SPECTRE_UNAFFECTED SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE Note: SMCCC_RET_NOT_AFFECTED is 1 but isn't part of the SMCCC spec Fixes: c118bbb52743 ("arm64: KVM: Propagate full Spectre v2 workaround state to KVM guests") Signed-off-by: Stephen Boyd Acked-by: Marc Zyngier Acked-by: Will Deacon Cc: Andre Przywara Cc: Steven Price Cc: Marc Zyngier Cc: stable@vger.kernel.org Link: https://developer.arm.com/documentation/den0028/latest [1] Link: https://lore.kernel.org/r/20201023154751.1973872-1-swboyd@chromium.org Signed-off-by: Will Deacon Signed-off-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman --- include/linux/arm-smccc.h | 2 ++ virt/kvm/arm/psci.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -76,6 +76,8 @@ ARM_SMCCC_SMC_32, \ 0, 0x7fff) +#define SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED 1 + #ifndef __ASSEMBLY__ #include --- a/virt/kvm/arm/psci.c +++ b/virt/kvm/arm/psci.c @@ -408,7 +408,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu val = SMCCC_RET_SUCCESS; break; case KVM_BP_HARDEN_NOT_REQUIRED: - val = SMCCC_RET_NOT_REQUIRED; + val = SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED; break; } break;