Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1211731pxb; Wed, 6 Apr 2022 11:26:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ5JLyL33IB10X9p9IM0mkw4m/349hvMVYm10CR/vAF7O7f0+lZTzTlhk19qX+WyHeMYU0 X-Received: by 2002:a17:90b:4a88:b0:1c7:9bc:a72e with SMTP id lp8-20020a17090b4a8800b001c709bca72emr11284329pjb.112.1649269588940; Wed, 06 Apr 2022 11:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649269588; cv=none; d=google.com; s=arc-20160816; b=HnDFTpgoXqv2iJzsVoBDY9vmngZlCneISKLrIzww39K4q4Zyd/u7/4l/0N7CfOHsCe kE7mtiV7C+93+6MlAwcCbEvYzUEwM71cZHfarYw7TUqdVnpr3KosCvMmrL99KUPlSpWt uVexsEmihi1FubuafhuP8HF+fxr1By08qbrDMt7rINdrHZFRhZqrUhSFMKcPmYlVRXSp rs/gVlwu6mjRlQBxr+P1OvMClbxWP3yPOWtLDNN4tk5sLDNXZ2NmxMVpMnl0szBkez54 APjfBYSKnBRy6FJmDcBmzmiS+vZN+NssiUuZ111vLLIZjxAq+eHNDM9oPA0P6rQizyxj LgJg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=F+grup9EFhV7yZaUbYYwJ0zEMeQA9fDpzRTGmipq6kQ=; b=U8DgCf0xpk/n99aktp00NvIODSclEoMmI+1avuYgh8SJls7XgslS4+DHp7TB9g90uC +sc4UxLIhra7mmwXSObHzbs3u8gO2FXjzosliE6EPBj4HVzS9IcNbn8CUZZTWnxhfj3b 53XFXFMqlOGtQmVr3OFKVlE7bkudvD633+n/eHD+6k//Jk0de0PllokA5jeQHXr1vDxf dg5Fsdn/o9NTiDHF0NI15hT7QBAGRPR0XUSTiiWC3U1KWQts/3HHVbmK0EqBmKX6iqe6 wRmqFBQONlt2Bd4ivQE5T7Zi/TCkDg6eEWbg23EAC/w9t0GCEehATOo/B3Q0S4wXq5z4 ZQsg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f6-20020a056a00238600b004fa3a8e00a7si18570279pfc.350.2022.04.06.11.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:26:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C69AC264C17; Wed, 6 Apr 2022 11:09:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240189AbiDFSL0 (ORCPT + 99 others); Wed, 6 Apr 2022 14:11:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240114AbiDFSIz (ORCPT ); Wed, 6 Apr 2022 14:08:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFC3C1A8446; Wed, 6 Apr 2022 09:46:38 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B0AAE12FC; Wed, 6 Apr 2022 09:46:38 -0700 (PDT) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0F5B03F73B; Wed, 6 Apr 2022 09:46:37 -0700 (PDT) From: James Morse To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: James Morse , Catalin Marinas Subject: [stable:PATCH v4.9.309 41/43] KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated Date: Wed, 6 Apr 2022 17:45:44 +0100 Message-Id: <20220406164546.1888528-41-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220406164546.1888528-1-james.morse@arm.com> References: <0220406164217.1888053-1-james.morse@arm.com> <20220406164546.1888528-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 arch/arm/kvm, removed fw regs ABI. Added 32bit stub ] Signed-off-by: James Morse --- arch/arm/include/asm/kvm_host.h | 5 +++++ arch/arm/kvm/psci.c | 4 ++++ arch/arm64/include/asm/kvm_host.h | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 2fda7e905754..82c71a147f21 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -349,4 +349,9 @@ static inline int kvm_arm_have_ssbd(void) return KVM_SSBD_UNKNOWN; } +static inline bool kvm_arm_spectre_bhb_mitigated(void) +{ + /* 32bit guests don't need firmware for this */ + return false; +} #endif /* __ARM_KVM_HOST_H__ */ diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index 83365bec04b6..a262c175456d 100644 --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -431,6 +431,10 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) break; } break; + case ARM_SMCCC_ARCH_WORKAROUND_3: + if (kvm_arm_spectre_bhb_mitigated()) + val = SMCCC_RET_SUCCESS; + break; } break; default: diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index a152a7bbc85a..a75f02e5f0fd 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -452,4 +452,8 @@ static inline int kvm_arm_have_ssbd(void) } } +static inline bool kvm_arm_spectre_bhb_mitigated(void) +{ + return arm64_get_spectre_bhb_state() == SPECTRE_MITIGATED; +} #endif /* __ARM64_KVM_HOST_H__ */ -- 2.30.2