From patchwork Fri Dec 7 18:39:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristina Martsenko X-Patchwork-Id: 153186 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp831323ljp; Fri, 7 Dec 2018 10:40:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/UN1Ezfr+YUaSvqZAlRndDNX4on7bNS+NeytjKaSsb0dU/NaypvxOOe4ipHkmO/n3q3GLJ7 X-Received: by 2002:a65:4904:: with SMTP id p4mr2947919pgs.384.1544208014880; Fri, 07 Dec 2018 10:40:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544208014; cv=none; d=google.com; s=arc-20160816; b=cXsSaESMQlb692yoISkCMTAs627TfpplSvodyXIkdILGRkusnARS39qV9zEWj7+4TF iqvTx9ukl3IPdWkwW9jNvOW+PAF0aUVvK5+vYHKBuEBzTQ5z8xVaaMMVV5G5lkzTZ4uE pTROroDm7GK0Q6Zh5bdBDZ+rjx6uFx4gJzisTKPCaOKkYV3RuzXwtOjhvnHsACSJa1Hk ZxEYqmEorLyP/0uq7DUAy1Bf0nBCD299o4+KEoLLG1i9GA2Xd4yoAQ0MPPuh9ZMZH5Pq 9V7hmlxJoldBv1u4qU4XuMlAz8uytCv3jwXSUhOGGsIKIEhLAx0zzh2ZbMNIOux2bA2S toxQ== 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=N7WVIGAmKd7yu0j3UiWpoA/Zmy71zbgz1UYg6bqdQH8=; b=KhxTgmjZctbxC2vV1MteSbzE3gQYXRTGiIqh3nnljXSoPPcHcPh6Mx2t7qAhk+sqk7 xBfXderW/VNFg1ciq0JnHGV29a9pNCJiHQISoHD51G4bbiK6CVeTDxsotxLDYmuFKY+E rhGvSHydtDL12pcWnq58qQGj7DsIxaluPHZPTQeOfbyeJdDVI8a7t/uts0Z4kq+MB2TW QGK59h0VbUrTSoZfSl1LLbHOBcJ2bx8A5r5hvcv0wkUwOxGeZWGjhol8aZJIrijBQgpK ylpPPs3YF0kEQmUJUt2lwoiodDnYbWOlTtPnb9ka+nW1fO34czXcCeJHz/PAoH7c7HqR s5Tg== ARC-Authentication-Results: i=1; mx.google.com; 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 k11si3428331pgf.213.2018.12.07.10.40.14; Fri, 07 Dec 2018 10:40:14 -0800 (PST) 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; 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 S1726296AbeLGSkM (ORCPT + 31 others); Fri, 7 Dec 2018 13:40:12 -0500 Received: from foss.arm.com ([217.140.101.70]:51978 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbeLGSkL (ORCPT ); Fri, 7 Dec 2018 13:40:11 -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 69403165C; Fri, 7 Dec 2018 10:40:11 -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 5188B3F5AF; Fri, 7 Dec 2018 10:40:08 -0800 (PST) From: Kristina Martsenko To: linux-arm-kernel@lists.infradead.org Cc: Adam Wallis , Amit Kachhap , Andrew Jones , Ard Biesheuvel , Catalin Marinas , Christoffer Dall , Cyrill Gorcunov , Dave P Martin , Jacob Bramley , Kees Cook , Marc Zyngier , Mark Rutland , Ramana Radhakrishnan , Richard Henderson , Suzuki K Poulose , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: [PATCH v6 03/13] arm64/kvm: consistently handle host HCR_EL2 flags Date: Fri, 7 Dec 2018 18:39:21 +0000 Message-Id: <20181207183931.4285-4-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181207183931.4285-1-kristina.martsenko@arm.com> References: <20181207183931.4285-1-kristina.martsenko@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland 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. Signed-off-by: Mark Rutland Signed-off-by: Kristina Martsenko Reviewed-by: Christoffer Dall Cc: Catalin Marinas Cc: Marc Zyngier Cc: Will Deacon Cc: kvmarm@lists.cs.columbia.edu --- 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 Reviewed-by: Marc Zyngier Reviewed-by: Richard Henderson diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 6f602af5263c..c8825c5a8dd0 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -87,6 +87,7 @@ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \ HCR_FMO | HCR_IMO) #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) +#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 4471f570a295..b207a2ce4bc6 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -496,10 +496,9 @@ ENTRY(el2_setup) #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 7cc175c88a37..f6e02cc4d856 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -157,7 +157,7 @@ static void __hyp_text __deactivate_traps_nvhe(void) mdcr_el2 |= MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT; write_sysreg(mdcr_el2, mdcr_el2); - write_sysreg(HCR_RW, hcr_el2); + write_sysreg(HCR_HOST_NVHE_FLAGS, hcr_el2); write_sysreg(CPTR_EL2_DEFAULT, cptr_el2); }