Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp181286imm; Fri, 5 Oct 2018 01:52:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV60f039QlQH0F+NxZ/f1gUHPlOsdnSnywSdAMpfF2u2fX8Q+PW+3Oz9WaJE1qROUu3yXJLpX X-Received: by 2002:a17:902:8eca:: with SMTP id x10-v6mr10538651plo.336.1538729555821; Fri, 05 Oct 2018 01:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538729555; cv=none; d=google.com; s=arc-20160816; b=iDxqQcwGTTFZoA1WTCjyXgej5+v4x8y2vKNoOd6lBTEFCfAc3xrOd553iUsApmk/6S nsxqqKVQuFidwjOy2iqxZbHtrGewK5IL+4mmyMYg3c3betnYlg6gMFtxysvOPpdO8EsO SVbvx3TMPaJvw9wjQWqjC3n0LwoL2Pqx7pYteCFn79eTzEf5gTOapnjbhLIg/JzQ3Jbu 2WMQ8Vpc4AWEU6nyzMD9Yy5kvnzUICjF9t8rrl0z55DZvHAuO857dTiGp+akG9Q6WPnp hSA1zqmkWSZ6YEX3HsNJ4eag1JFhamieBYkWMapk5veyB+ieTVDetv7dC5srZQQHyg2U re+w== 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=IrxRymgqHeuWohaz6kfcl7WFW6fKoYRB41sVbsYy63M=; b=q8jdxF4dw/ppRmsutWMdSL8aPa8lJEutHjGlzb5hiPbuapRozo0EuBBcD5sjcsan6f RQtviFoH8Zypv+ZbS262FEQiLXnVbPPGnswR5uv6VvXIZrJdRGa+z9ZcKztdTbTogoBS 296hio237IRFQLPIbFxqm1ZOLpIFASXeMrmtLuWnHBi4YuChtXci2oDUCdZpvFYa2fti Ksbsf7TUXKKUFWlnOTgTQMtf0Vg7GRrxLVdnS8GT7ldMoCPR9B6vrX3DitVXLqzTlrjO Te/fn6AfYzGvUhod2YBfF0MPMm610e71Xkq59MBEhhjBpdHgnYJhSDOzt+1rqbSKnhNW At8g== 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 v33-v6si7540147pga.450.2018.10.05.01.52.20; Fri, 05 Oct 2018 01:52:35 -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; 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 S1728716AbeJEPre (ORCPT + 99 others); Fri, 5 Oct 2018 11:47:34 -0400 Received: from foss.arm.com ([217.140.101.70]:47772 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728283AbeJEPre (ORCPT ); Fri, 5 Oct 2018 11:47:34 -0400 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 A4D36ED1; Fri, 5 Oct 2018 01:49:49 -0700 (PDT) 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 700DC3F5B3; Fri, 5 Oct 2018 01:49:46 -0700 (PDT) From: Kristina Martsenko To: linux-arm-kernel@lists.infradead.org Cc: Adam Wallis , Amit Kachhap , Andrew Jones , Ard Biesheuvel , Arnd Bergmann , Catalin Marinas , Christoffer Dall , Dave P Martin , Jacob Bramley , Kees Cook , Marc Zyngier , Mark Rutland , Ramana Radhakrishnan , "Suzuki K . Poulose" , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 02/17] arm64/kvm: consistently handle host HCR_EL2 flags Date: Fri, 5 Oct 2018 09:47:39 +0100 Message-Id: <20181005084754.20950-3-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181005084754.20950-1-kristina.martsenko@arm.com> References: <20181005084754.20950-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(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index aa45df752a16..f885f4e96002 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 b0853069702f..651a06b1980f 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -494,10 +494,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 ca46153d7915..a1c32c1f2267 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); } -- 2.11.0