From patchwork Sun Oct 27 21:00:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 177847 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2532200ill; Sun, 27 Oct 2019 14:10:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9TThVd2250Nmt4Au8LKwOvZ726VVtQ86KhyIaafljBZym9uF6HsewORdswWEnFiyLyNY+ X-Received: by 2002:a17:906:2cd4:: with SMTP id r20mr13386191ejr.307.1572210602179; Sun, 27 Oct 2019 14:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572210602; cv=none; d=google.com; s=arc-20160816; b=hLzToUGYpxqGTltmO0pA4CJpn/oq0ID+wxXCoQ/Nk8xt27+3f/J5dZNdlVjmmX6R3p 9KVwCuBxMFl7ml8r1QGg1rRA1hzckBhAcN1FvhPiZ3Gi5DSLiIXC4X65MOzmUUxUKdtH E1zBtqJTY9tAn0jjRyk7aO2SaFrivjaAt+gtsW3BHAiGI155ioBg34g0nWdVLb1fWbsJ ARB1DHVjx8bCW9k3PQ+iTfOQnVJucLlUChlbo6zjpLZSMvW4tb5H37mgohsJOA8sio2F 2nnmFz0lUcx1kFWucqLDLZjzFOu9NBWKc7hbk37oD2lGfudgR/g+2mXKkeD+yEXk5iL2 ErzA== 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=JMyxY32t2jO9NVpsqm511odUekqLzBoaD1JT3qpEKgY=; b=ECPDDgIZT042QgiHPB39BuaGFtYk7LiWrQHcowNoPAIJDzMdj7eoepM85s8ZeNCSGK 03byy9WQS0ptGhkyfz7Kq1SssqcVJFyd9KThtRcFfnUpeI6y3MZLoTT4/yo3Z+6XRFse np7AmmWqYwjAE1HJ9RiYYxXQNKBqQkwlXxJKmmEz+J4ppJvXKuCxzgPmDnu0ueHYlv8a jABtU0XDXEy0dbygl3IAOTHhC61fWy5MT2J/xr2+W2/rbXWDvsayLDfof4VWzAgW6Ggk us5qzIH3maiR052UFzsV1/p7h5/MaH0yddR0HEgUuMy8WaCfC0rpt4Bkfs1mym1LjCdY zPHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zwMEgEfW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 g2si5556436edn.415.2019.10.27.14.10.02; Sun, 27 Oct 2019 14:10:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=zwMEgEfW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729607AbfJ0VKA (ORCPT + 26 others); Sun, 27 Oct 2019 17:10:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:56340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729590AbfJ0VJ5 (ORCPT ); Sun, 27 Oct 2019 17:09:57 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (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 AC2C42064A; Sun, 27 Oct 2019 21:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572210596; bh=1OvOHMUWN+zQfis1W/kvZd2XpNU2os5/nufc3T6RDOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zwMEgEfWIumdONu9y8k3xVKKytxYeR8vkwrjyeDji8MCB4hM40iLdF0ImX1GcM/7C lSVJNMQ+PaqJ2i8vY0oRBsedejqHJYep0Olg+JIOQpwoS8J+PGvRwhk6uraqzX6r5i UhvLOi97RCbhM83bkIQPkCw+CR9ILv6P6va0IKNk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Christoffer Dall , Will Deacon , Catalin Marinas , Ard Biesheuvel Subject: [PATCH 4.14 070/119] KVM: arm64: Set SCTLR_EL2.DSSBS if SSBD is forcefully disabled and !vhe Date: Sun, 27 Oct 2019 22:00:47 +0100 Message-Id: <20191027203336.044367544@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203259.948006506@linuxfoundation.org> References: <20191027203259.948006506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -356,6 +356,8 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struc void __kvm_set_tpidr_el2(u64 tpidr_el2); 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) @@ -380,6 +382,15 @@ static inline void __cpu_init_hyp_mode(p - (u64)kvm_ksym_ref(kvm_host_cpu_state); kvm_call_hyp(__kvm_set_tpidr_el2, 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 void kvm_arch_hardware_unsetup(void) {} --- a/arch/arm64/kvm/hyp/sysreg-sr.c +++ b/arch/arm64/kvm/hyp/sysreg-sr.c @@ -188,3 +188,14 @@ void __hyp_text __kvm_set_tpidr_el2(u64 { asm("msr tpidr_el2, %0": : "r" (tpidr_el2)); } + +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)); +}