From patchwork Tue Oct 8 15:39:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 175503 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5864267ill; Tue, 8 Oct 2019 08:40:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRF5FcVZvBN7fxR5rcT9JiWvh12M7HVZPJNN8y8YWAryrEC0lkQJGK5MHWANMHTXmmwSGJ X-Received: by 2002:a17:906:ecb6:: with SMTP id qh22mr29082531ejb.114.1570549215426; Tue, 08 Oct 2019 08:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570549215; cv=none; d=google.com; s=arc-20160816; b=ArHAS+2q6QUfA4pwZY3StXbER5dxVP7Y4B61cz4agJpEKynBtb5WoadJ1W3RuV359Y JFx3XXXqjlqzeFsaQBSHItEJk/NvbDB2qObpj40bPr69dkAGjx9Fe19lv3lwiOlQTXQI d+E703vCzwOda9VXbjppYN14kQztjiIT3GKzGDBA8+b3HOe+sGOg/1QYe0eFw18ZyXZb 3qY9AWUKIg98jCRe9igvJ89KapEyZjiprHfXXdzw7TrkoFtobp6wsBItWDFRQ9mKzH3x 7Wa/5/1W8SP/m79RBJt9CZwGOa2jbr1jvWDOYArbV8R8QE0lATrbKPGsFWN5UDFrss7n yO4w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X9k/nqOLAylh00xkHgeHzZJoJeH5DmiWZVGTdUdx6Qk=; b=yy77aZUQH49iRIRQShyHMr3iHXIK7ND9uUUlETrji561JSrdmA2v0LHq2sNCOoqrDS hNNPPUmAClWyIH8i1I7s2zZvxrvwb7jVcl0R83k9lCdZZO6i83afhSdAmDRN5MkLx0g7 TSPC+t7UgaOfBuFgBgAXtQbNFY1/KLzMxGAiNv/p+FSuwq4In23C2J27uJF6wKFcX0pH NF03CHzovKrwwyM+7Bt8Y4gzcTTdaj0gn+zQRx6s5e6XoEQY4ORhwVyXjw7RWXJFFtjP +lrbiKBNaWciu4/uGkaGGpZuqyOCqf8JUgZ/YCLuYoYEwCsfR2mEPPuIOetED1VnJ31Z BrsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PZx2hAK0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si10919464edc.67.2019.10.08.08.40.15; Tue, 08 Oct 2019 08:40:15 -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=@linaro.org header.s=google header.b=PZx2hAK0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725966AbfJHPkO (ORCPT + 13 others); Tue, 8 Oct 2019 11:40:14 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51278 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbfJHPkO (ORCPT ); Tue, 8 Oct 2019 11:40:14 -0400 Received: by mail-wm1-f66.google.com with SMTP id 7so3708092wme.1 for ; Tue, 08 Oct 2019 08:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X9k/nqOLAylh00xkHgeHzZJoJeH5DmiWZVGTdUdx6Qk=; b=PZx2hAK0dMyPpXJk37fFKZsntkGJ+X7KJ/3wlIDhuhXMHoTHJOtmAWTPOYOx0ZrsQn F7ULkpC6+VKFX5O0jisCvPKSQ1YXeOGOZ0Srx1BZxajfM0W2Rh9uOG/FxDqz9J5Ejaxk QNpo2SF2pfz0xrFQeYRAya4EpRkvO/8ptWDMkZ4oJ+Iy4vjyDxqijIF1vK5KCgpO9hMj G5O5aAbtoNeLQMUC/p0/bdd5Ku+9OWyBllf67hEsZuIz28hqV+203WEcR+ek6Xy7HQVM R/BlGHMa1YTwBTwgH4NFLgp15KrM0wUSa3vnNQX5w9wGx4sFcOyim5WqQ4G3xvpfgiT/ zXow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X9k/nqOLAylh00xkHgeHzZJoJeH5DmiWZVGTdUdx6Qk=; b=hEyOn71gJkfbh0M11TAtT0Pse0K1sI0zDOQXmXWqQDiheSrwXYPooKlPt41DmMn4O2 1QPhyxiNaakJxvpSF2i5py4Ib4aYwmCAvkZn/vSH5xK+PjbRjrn/7o0iyR5/QBY5jGFr JDgdK40C8tW7QpNcODCehIaTAmGzEoVvX9xqHXC8zY3mXJnwVq9n4tOOyVR/rQ4PXEGE AujZiL46mUZrzaF7zyGHraFypu7W30i4fT6HPSpl6dE7elRFC+r6j09/TB1ecVRxdTGf p+xgCAQ7/XpJUT2x5eau+abJRYZk/VkFvNXrzyllbYSbhgueVP6XLYV99gwNJMY5cuI9 dsEw== X-Gm-Message-State: APjAAAV8nbLFuiDY9IZB7Hg2zKJlO6AbhU8ao7SScld8MLFd79nVFZ1a S9tSzGw2Pti4MgS+ao5NV/BqgT5+csmHgw== X-Received: by 2002:a1c:ed02:: with SMTP id l2mr4173987wmh.155.1570549211982; Tue, 08 Oct 2019 08:40:11 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id x16sm16784723wrl.32.2019.10.08.08.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 08:40:10 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: stable@vger.kernel.org, Will Deacon , Christoffer Dall , Catalin Marinas , Ard Biesheuvel Subject: [PATCH for-stable-v4.19 03/16] KVM: arm64: Set SCTLR_EL2.DSSBS if SSBD is forcefully disabled and !vhe Date: Tue, 8 Oct 2019 17:39:17 +0200 Message-Id: <20191008153930.15386-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191008153930.15386-1-ard.biesheuvel@linaro.org> References: <20191008153930.15386-1-ard.biesheuvel@linaro.org> 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 --- arch/arm64/include/asm/kvm_host.h | 11 +++++++++++ arch/arm64/kvm/hyp/sysreg-sr.c | 11 +++++++++++ 2 files changed, 22 insertions(+) -- 2.20.1 diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 6abe4002945f..367b2e0b6d76 100644 --- 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(struct kvm *kvm, unsigned long mpidr); 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(phys_addr_t pgd_ptr, */ 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) diff --git a/arch/arm64/kvm/hyp/sysreg-sr.c b/arch/arm64/kvm/hyp/sysreg-sr.c index 963d669ae3a2..7414b76191c2 100644 --- 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_vcpu *vcpu) 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)); +}