From patchwork Fri Jan 18 17:56:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristina Martsenko X-Patchwork-Id: 156037 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3535859jaa; Fri, 18 Jan 2019 09:56:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN45GxPwt/JoD/Z9aGbrAjDPJVWen0pQaE/Rbkl27ReTKEFnm/+J+SXa//+/RE3+fLux4ulS X-Received: by 2002:a62:4c:: with SMTP id 73mr20128039pfa.24.1547834191717; Fri, 18 Jan 2019 09:56:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547834191; cv=none; d=google.com; s=arc-20160816; b=NLBOmSbdny0RA2KWI2W5CQlCrt5Hn93PCttz7TrzU1L2qC+gtkdA9Op1ILzz3odjmG YCh7iKecIdMAZa9utFpN4549akiDanaco0rcJ2afJ3aX+EH0NWptkkR4Q4scz8/zgkQ5 N6rJDDY6Fd465oa3dNPn/CDssULINohaE6a4LTNCGcMnQw0FAnrp+ScqnD2MQPAUsugr NPVjlSbBJqs36axcRt/DN4nJsCNsMnEBVMtC3lxhSuSoFTNku5O9206WMDHjU+hVHLsZ JlttAg9vOtVxM0NW8yElQ4XAOYzKS8lINQjeFmXRiBa95lzaQHQuwG6np77oWYN4ZDVk UKAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=1mHW2KEEOsVSBIaQjbIwt6D4Jw1MrPQu0mYnQMZXX1g=; b=rXKOVDsxQA/CwhTBY2JNI6SdSqCrZBzwuzuJn/hu5k6fJn102rME+zaLgi5USuYyhS dUNmHhdz3ieeyWhN7qGdzfxDGiw/7hjO/Kzp0J9D2HDuEX5UroByGGWAhkNV3fpNJYXb 0WmgD8up3H9IJ6UCUw9Tvot7Cz6yJ1vH3r/aE+juL/iYV4QkYVHwPvTHALKeWq5wwZe4 RnFv3y2M72IO37lzdz9zCv6pp/uaBZ5Ag54enLC0fBdM3CVPmxaRheB0ngIXINQwgVPS BjyciXYxRnEF9qj+v46lYnz6QiX9wpRqyjuA+qa5XQcXDNTvcLA0o8wF++JAgCYYlLaV tZPg== ARC-Authentication-Results: i=1; mx.google.com; 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 11si5084692pgy.408.2019.01.18.09.56.31; Fri, 18 Jan 2019 09:56:31 -0800 (PST) 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; 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 S1728439AbfARR4b (ORCPT + 15 others); Fri, 18 Jan 2019 12:56:31 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35876 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728375AbfARR4a (ORCPT ); Fri, 18 Jan 2019 12:56:30 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B6B1180D; Fri, 18 Jan 2019 09:56:30 -0800 (PST) Received: from moonbear.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 839BF3F7BE; Fri, 18 Jan 2019 09:56:29 -0800 (PST) From: Kristina Martsenko To: stable@vger.kernel.org Cc: Catalin Marinas , Christoffer Dall , Marc Zyngier , Mark Rutland , Will Deacon Subject: [PATCH 4.9 1/2] arm64/kvm: consistently handle host HCR_EL2 flags Date: Fri, 18 Jan 2019 17:56:26 +0000 Message-Id: <20190118175627.6412-1-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <7acde9fd-242b-0850-81b3-6dbd4cc75565@arm.com> References: <7acde9fd-242b-0850-81b3-6dbd4cc75565@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Rutland [ Backport of upstream commit 4eaed6aa2c628101246bcabc91b203bfac1193f8 ] In KVM we define the configuration of HCR_EL2 for a VHE HOST in HCR_HOST_VHE_FLAGS, but we don't have a similar definition for the non-VHE host flags, and open-code HCR_RW. Further, in head.S we open-code the flags for VHE and non-VHE configurations. In future, we're going to want to configure more flags for the host, so lets add a HCR_HOST_NVHE_FLAGS defintion, and consistently use both HCR_HOST_VHE_FLAGS and HCR_HOST_NVHE_FLAGS in the kvm code and head.S. We now use mov_q to generate the HCR_EL2 value, as we use when configuring other registers in head.S. Reviewed-by: Marc Zyngier Reviewed-by: Richard Henderson Signed-off-by: Mark Rutland Reviewed-by: Christoffer Dall Cc: Catalin Marinas Cc: Marc Zyngier Cc: Will Deacon Cc: kvmarm@lists.cs.columbia.edu Signed-off-by: Will Deacon [kristina: backport to 4.9.y: adjust context] Signed-off-by: Kristina Martsenko --- arch/arm64/include/asm/kvm_arm.h | 1 + arch/arm64/kernel/head.S | 5 ++--- arch/arm64/kvm/hyp/switch.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) -- 2.11.0 diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 68dedca5a47e..352bf2f7f60a 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -82,6 +82,7 @@ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW) #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) #define HCR_INT_OVERRIDE (HCR_FMO | HCR_IMO) +#define HCR_HOST_NVHE_FLAGS (HCR_RW) #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H) /* TCR_EL2 Registers bits */ diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index fa52817d84c5..3289d1458791 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -517,10 +517,9 @@ CPU_LE( bic x0, x0, #(3 << 24) ) // Clear the EE and E0E bits for EL1 #endif /* Hyp configuration. */ - mov x0, #HCR_RW // 64-bit EL1 + mov_q x0, HCR_HOST_NVHE_FLAGS cbz x2, set_hcr - orr x0, x0, #HCR_TGE // Enable Host Extensions - orr x0, x0, #HCR_E2H + mov_q x0, HCR_HOST_VHE_FLAGS set_hcr: msr hcr_el2, x0 isb diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 12f9d1ecdf4c..115b0955715f 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -112,7 +112,7 @@ static void __hyp_text __deactivate_traps_vhe(void) static void __hyp_text __deactivate_traps_nvhe(void) { - write_sysreg(HCR_RW, hcr_el2); + write_sysreg(HCR_HOST_NVHE_FLAGS, hcr_el2); write_sysreg(CPTR_EL2_DEFAULT, cptr_el2); }