From patchwork Thu Oct 10 08:36:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 175728 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1984470ill; Thu, 10 Oct 2019 01:49:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyl6ij8xC6Eseoaeae97HcLcWRcl6Y4qkgEByiwbBGZvmqumDgxMt5PTzUafpP9DL7vNuO6 X-Received: by 2002:a05:6402:64f:: with SMTP id u15mr6842897edx.231.1570697380732; Thu, 10 Oct 2019 01:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697380; cv=none; d=google.com; s=arc-20160816; b=jUXNctirr/+lvAnBjKvJljR1AeEXke/jdA/aK1Q4QepQ6Fkb8I8vYScOU3kdfkjvQN DHudjDRTMZyj5flUaQnSPRZ8+/P8mhZGoRiwKHHw8uQr1gpi+a9jvbE69FoKGCAml1dH 4VoaGV50pOaf19ggOKUldg+B3pWmnp+svO2PtqjDGyshNGDro/OkOA5m1eAd/RQyJ3ZQ AaDLOwqOOty/SQ1n0C0yFP2Nikx705BT1HyANa8UFcdO8Xw+myWpfjy7UYI8Rw5E8Kmn 8EKMldMoBdvufHD3G+k49kLg0XCW6mwl7oGiUIeCBvbJDPoJxl4SScCuSFGi2E6lGJlw tMPQ== 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=N/wg6319JSnpZMmBK/fXEGOumuSZDlvq0+EFLxU/itA=; b=U1nm78ivvc/CUc7AxBI04P1Yn8DTves2/kvXSIxCQ3h9JsQVo7OICYH4l8MIZs8iUi by9KvrtXRFNOD6cNuWSHr8xuApbJ8H/1Xr9m0zS1VS79WME1npkHzi2Xw86dBv0JvaEp tBHjPKj3HQg+GkUQdep7sJlO9uvKagf7bG1VFQEZNXgzpZ1e7uDqje6M5lR93Njas03G HV6wkelV/GY7QYi4Cad961NbZ7BQ/vPToQdGS3KCNp2QsRY0XEmMST8dFYVMsRNDPOz2 kkkppBBtsNDMs2GDt6qqmsZOzCByt0h0E4kaXTWtyz7XaKf54oY2VQMY+vSK2lczOzTy c6BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OgV3+TdH; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si2730182eju.357.2019.10.10.01.49.40; Thu, 10 Oct 2019 01:49:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OgV3+TdH; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389838AbfJJIth (ORCPT + 13 others); Thu, 10 Oct 2019 04:49:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:56242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388033AbfJJItg (ORCPT ); Thu, 10 Oct 2019 04:49:36 -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 55BA321D71; Thu, 10 Oct 2019 08:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697375; bh=7DZ5PjMP7b5x4rM5b1G+HAZcSZk95Iof1H4TK11oOBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgV3+TdHf56LRix19LdyEVUQk9q3aArPackt6x2bHqIVoJhOhSJeYSWyhQj2iJTQN SCaw56zS7QtSVjCE4IVzXFTsJmOd3yVcCxQ0WKSv+aSDvhu7gdSN+2c8tqGXKoRedg k/+E/RzXfxKAA15fRHZouuPN6MEBni7PiwVqVuPg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoffer Dall , Will Deacon , Catalin Marinas , Ard Biesheuvel Subject: [PATCH 4.19 090/114] KVM: arm64: Set SCTLR_EL2.DSSBS if SSBD is forcefully disabled and !vhe Date: Thu, 10 Oct 2019 10:36:37 +0200 Message-Id: <20191010083612.834026878@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083544.711104709@linuxfoundation.org> References: <20191010083544.711104709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Will Deacon [ Upstream commit 7c36447ae5a090729e7b129f24705bb231a07e0b ] When running without VHE, it is necessary to set SCTLR_EL2.DSSBS if SSBD has been forcefully disabled on the kernel command-line. Acked-by: Christoffer Dall Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/kvm_host.h | 11 +++++++++++ arch/arm64/kvm/hyp/sysreg-sr.c | 11 +++++++++++ 2 files changed, 22 insertions(+) --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -398,6 +398,8 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struc DECLARE_PER_CPU(kvm_cpu_context_t, kvm_host_cpu_state); +void __kvm_enable_ssbs(void); + static inline void __cpu_init_hyp_mode(phys_addr_t pgd_ptr, unsigned long hyp_stack_ptr, unsigned long vector_ptr) @@ -418,6 +420,15 @@ static inline void __cpu_init_hyp_mode(p */ BUG_ON(!static_branch_likely(&arm64_const_caps_ready)); __kvm_call_hyp((void *)pgd_ptr, hyp_stack_ptr, vector_ptr, tpidr_el2); + + /* + * Disabling SSBD on a non-VHE system requires us to enable SSBS + * at EL2. + */ + if (!has_vhe() && this_cpu_has_cap(ARM64_SSBS) && + arm64_get_ssbd_state() == ARM64_SSBD_FORCE_DISABLE) { + kvm_call_hyp(__kvm_enable_ssbs); + } } static inline bool kvm_arch_check_sve_has_vhe(void) --- a/arch/arm64/kvm/hyp/sysreg-sr.c +++ b/arch/arm64/kvm/hyp/sysreg-sr.c @@ -293,3 +293,14 @@ void kvm_vcpu_put_sysregs(struct kvm_vcp vcpu->arch.sysregs_loaded_on_cpu = false; } + +void __hyp_text __kvm_enable_ssbs(void) +{ + u64 tmp; + + asm volatile( + "mrs %0, sctlr_el2\n" + "orr %0, %0, %1\n" + "msr sctlr_el2, %0" + : "=&r" (tmp) : "L" (SCTLR_ELx_DSSBS)); +}