Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1184458pxb; Fri, 1 Apr 2022 06:54:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9S3LGewrjvLYZ0dD/4jwhcFsNMs37cH/MGkBTZ3gdumDBmCH/SQIBV1oMWGqvfT7Nd52O X-Received: by 2002:a05:6402:f16:b0:419:d9f3:f8b with SMTP id i22-20020a0564020f1600b00419d9f30f8bmr21346604eda.33.1648821280512; Fri, 01 Apr 2022 06:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648821280; cv=none; d=google.com; s=arc-20160816; b=0oafrV97ttTKeeSV3A5V7wzDcZGP9joGYZsMU4b6QtxBWZoCacWYYVU+8xxa+uDhIn B0SOAftd1RBri9l9jSfxNZasV53y+37iAYRr9zux2pER5vfxy02/PiacwjxkwPv7q4D0 3y0rnmY2OkEg/GhXof5fXO8wqxZE0g2LGTiKQ/NAlsO4aC36zoG1XUzJmr5mXY++yKjG DJIe9GZHxVC6yNakRdIBiE0eNE3xJwADWRRTHWae44bd+7vnc/JbyekLVbfz8OX/BjjL 3/TiclGqhFCTN3KY9vBjiCxfeo2MoAewDIiI1hnjZd9ynscdJ7q/OFAeICmNavn3hf1w Rw/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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GybApalVfnK7xX31E+cJKh+VwLsqPSLqKLD40LM7d6g=; b=wB7ZzHAiy10NCBDACuJWL5R/0gQ8k0ZoDLReO+AJbOAC3QWm+znijMptrZOogWcL9Q fl1yhCLo7VIHYHb0atMmGKHhYFY/8LoNVXMS6glck63sgbz/Ga/tbfMQzstEoypBeaQB oIBFLEfGkiuBl3O1Rrmeuapv9uRiw8ZbcLpGCrw4DGhhRbBlbKIs/POOBPbS5bwusXmy NmrudratASVovKiF8qxivpgigVPZOdapG6QqQzyDhMeaWRTV+xtQH24vYy6oOwDR7wEx AZKbs88/GG/C0IgrS84gXxWzqG6DUguVvvX0H6Kc9vYYkiJqKIsg2mP9zZoz7984FLuB oY0w== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v11-20020a1709062f0b00b006df76385e8asi1631164eji.810.2022.04.01.06.54.14; Fri, 01 Apr 2022 06:54:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239151AbiCaSiC (ORCPT + 99 others); Thu, 31 Mar 2022 14:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235356AbiCaSgl (ORCPT ); Thu, 31 Mar 2022 14:36:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9F8CA231AF7; Thu, 31 Mar 2022 11:34:51 -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 6A3B9139F; Thu, 31 Mar 2022 11:34:51 -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 C0DA33F718; Thu, 31 Mar 2022 11:34:50 -0700 (PDT) From: James Morse To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: james.morse@arm.com, catalin.marinas@arm.com Subject: [stable:PATCH v4.14.274 25/27] KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated Date: Thu, 31 Mar 2022 19:33:58 +0100 Message-Id: <20220331183400.73183-26-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220331183400.73183-1-james.morse@arm.com> References: <20220331183400.73183-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 virt/kvm/arm, removed fw regs ABI. Added 32bit stub ] Signed-off-by: James Morse --- arch/arm/include/asm/kvm_host.h | 6 ++++++ arch/arm64/include/asm/kvm_host.h | 5 +++++ virt/kvm/arm/psci.c | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index b60232639984..dbd9615b428c 100644 --- 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 @@ -324,4 +325,9 @@ static inline int kvm_arm_have_ssbd(void) return KVM_SSBD_UNKNOWN; } +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__ */ diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 8d94404829f0..be82119ed24a 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -450,4 +450,9 @@ static inline int kvm_arm_have_ssbd(void) } } +static inline enum mitigation_state kvm_arm_get_spectre_bhb_state(void) +{ + return arm64_get_spectre_bhb_state(); +} + #endif /* __ARM64_KVM_HOST_H__ */ diff --git a/virt/kvm/arm/psci.c b/virt/kvm/arm/psci.c index c95ab4c5a475..129b755824e1 100644 --- a/virt/kvm/arm/psci.c +++ b/virt/kvm/arm/psci.c @@ -433,6 +433,18 @@ int kvm_hvc_call_handler(struct kvm_vcpu *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: -- 2.30.2