Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2295938pxp; Mon, 21 Mar 2022 16:10:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFl7FXKVRsM2vbNwncmNQlmIYLaFYInOeZXBfTTq0Jogvvf6dVqqZmpcvU0g04olgjl+10 X-Received: by 2002:a17:902:9345:b0:153:4d7a:53d9 with SMTP id g5-20020a170902934500b001534d7a53d9mr15590463plp.116.1647904216964; Mon, 21 Mar 2022 16:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647904216; cv=none; d=google.com; s=arc-20160816; b=XAGExJVKeV+qQ1eIshNdDUaewaM/1E5pKp5gYIod0h22QyT4XPS7z9w6amq3iKAGn4 j+ir+G8WjdA8WPUhr0+ba/iIYijG3vA8SXacaGBSs5x+RXf/58nTJsQ30ZDCDlk6ubdu +e4hzpNecpVEak6xm/O7LPWi+N7JTzgsyXjGtvYSLcBuYGIJqqiYGjD5Qai1eP09+6Vn SCccs05IvNdn8/6igX80XpFlbz2g8SPH8yQ51AxFtml9LzsrzftnzZOuil/HSc4zpZqu cXCAkiveP8IksfDgioD67sTMtpcoK+bF7yFkSW4f93xYFjPdWX597bQeVy+Oxu4XJlqD SU+g== 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=OwgN2Df0wzLfPwzhyQWPNbu7LxNFt+rQJCGWRLsIH2E=; b=lGCTwjvCB7QpJKpR9YGZqRDmQnnNVG5tA0sAk0uYeGBu+nRkJivz+Q+n1MDRaajl8B RK7WRUeU3cvsrNGOqt9+fwMFW418SKMVfdPaCu00OGJ6aUuZlurTvCJx35A6vbRFfW6n 0e3qg6TxOGN7imgcdbvR+4ViAgHYZgvxnoJbqMFS5rVtPF9o2zesCj1kiniASulST293 QnW8N276k9LTe3QflP+DYobmPbGksekGD/F0qXOXxRZlogqjXT6lYMlPrqeoI/0DKWsn NhZ8TJKS5TUBLmqWaUGbViNucVmBCtac5X1Iabatir2PqrOgdLOOO8CJ2ZKcW7sEK6P9 Q/FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=js0+YGF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x10-20020a170902ea8a00b00153b2d16435si12749585plb.61.2022.03.21.16.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=js0+YGF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4468842E3B7; Mon, 21 Mar 2022 15:08:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348503AbiCUOBe (ORCPT + 99 others); Mon, 21 Mar 2022 10:01:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348789AbiCUN6R (ORCPT ); Mon, 21 Mar 2022 09:58:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF9BE174BAA; Mon, 21 Mar 2022 06:56:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 909FCB81598; Mon, 21 Mar 2022 13:56:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D02C2C340E8; Mon, 21 Mar 2022 13:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647870989; bh=LaU3vxjYoNBfirEwBHnRQFnFf8IXd9iO7q8zwVVXGiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=js0+YGF7ps8RUY4QiGXDTx+dqNLjHVZtHFrTslvDeUjWV6ZCxmAYd0kOIUKBNC3IG ERWXonu6dxuuS/mwnnBcjylXxyq3UfzsewIVAo6kdId0UnC9813xxxrMrNg8D/0x3E XGa3zIExo7dYQdStFBdy5F6LTNLjZG5KjFXLhmdQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "Russell King (Oracle)" , Catalin Marinas , James Morse Subject: [PATCH 4.19 42/57] KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated Date: Mon, 21 Mar 2022 14:52:23 +0100 Message-Id: <20220321133223.213391721@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133221.984120927@linuxfoundation.org> References: <20220321133221.984120927@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Morse commit a5905d6af492ee6a4a2205f0d550b3f931b03d03 upstream. KVM allows the guest to discover whether the ARCH_WORKAROUND SMCCC are implemented, and to preserve that state during migration through its firmware register interface. Add the necessary boiler plate for SMCCC_ARCH_WORKAROUND_3. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas [ kvm code moved to virt/kvm/arm, removed fw regs ABI. Added 32bit stub ] Signed-off-by: James Morse Signed-off-by: Greg Kroah-Hartman --- arch/arm/include/asm/kvm_host.h | 7 +++++++ arch/arm64/include/asm/kvm_host.h | 5 +++++ virt/kvm/arm/psci.c | 12 ++++++++++++ 3 files changed, 24 insertions(+) --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #define __KVM_HAVE_ARCH_INTC_INITIALIZED @@ -367,4 +368,10 @@ void kvm_arch_free_vm(struct kvm *kvm); #define kvm_arm_vcpu_loaded(vcpu) (false) +static inline int kvm_arm_get_spectre_bhb_state(void) +{ + /* 32bit guests don't need firmware for this */ + return SPECTRE_VULNERABLE; /* aka SMCCC_RET_NOT_SUPPORTED */ +} + #endif /* __ARM_KVM_HOST_H__ */ --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -542,4 +542,9 @@ void kvm_arch_free_vm(struct kvm *kvm); #define kvm_arm_vcpu_loaded(vcpu) ((vcpu)->arch.sysregs_loaded_on_cpu) +static inline enum mitigation_state kvm_arm_get_spectre_bhb_state(void) +{ + return arm64_get_spectre_bhb_state(); +} + #endif /* __ARM64_KVM_HOST_H__ */ --- a/virt/kvm/arm/psci.c +++ b/virt/kvm/arm/psci.c @@ -429,6 +429,18 @@ int kvm_hvc_call_handler(struct kvm_vcpu break; } break; + case ARM_SMCCC_ARCH_WORKAROUND_3: + switch (kvm_arm_get_spectre_bhb_state()) { + case SPECTRE_VULNERABLE: + break; + case SPECTRE_MITIGATED: + val = SMCCC_RET_SUCCESS; + break; + case SPECTRE_UNAFFECTED: + val = SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED; + break; + } + break; } break; default: