From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759441AbbGHQTq (ORCPT ); Wed, 8 Jul 2015 12:19:46 -0400 Received: from foss.arm.com ([217.140.101.70]:42149 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759395AbbGHQTg (ORCPT ); Wed, 8 Jul 2015 12:19:36 -0400 From: Marc Zyngier To: Catalin Marinas , Will Deacon , Christoffer Dall Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH 05/13] arm64: KVM: VHE: macroize VTCR_EL2 setup Date: Wed, 8 Jul 2015 17:19:08 +0100 Message-Id: <1436372356-30410-6-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436372356-30410-1-git-send-email-marc.zyngier@arm.com> References: <1436372356-30410-1-git-send-email-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On a VHE-capable system, there is no point in setting VTCR_EL2 at KVM init time. We can perfectly set it up when the kernel boots, removing the need for a more complicated configuration. In order to allow this, turn VTCR_EL2 setup into a macro that we'll be able to reuse at boot time. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_mmu.h | 14 ++++++++++++++ arch/arm64/kvm/hyp-init.S | 9 +-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 6150567..b525cd2 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -55,6 +55,20 @@ #ifdef __ASSEMBLY__ +#include + +.macro setup_vtcr tmp1, tmp2 + mov \tmp1, #(VTCR_EL2_FLAGS & 0xffff) + movk \tmp1, #(VTCR_EL2_FLAGS >> 16), lsl #16 + /* + * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in + * VTCR_EL2. + */ + mrs \tmp2, id_aa64mmfr0_el1 + bfi \tmp1, \tmp2, #16, #3 + msr vtcr_el2, \tmp1 + isb +.endm /* * Convert a kernel VA into a HYP VA. * reg: VA to be converted. diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index 178ba22..4143e2c 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -87,14 +87,7 @@ __do_hyp_init: #endif msr tcr_el2, x4 - ldr x4, =VTCR_EL2_FLAGS - /* - * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in - * VTCR_EL2. - */ - mrs x5, ID_AA64MMFR0_EL1 - bfi x4, x5, #16, #3 - msr vtcr_el2, x4 + setup_vtcr x4, x5 mrs x4, mair_el1 msr mair_el2, x4 -- 2.1.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Zyngier Subject: [PATCH 05/13] arm64: KVM: VHE: macroize VTCR_EL2 setup Date: Wed, 8 Jul 2015 17:19:08 +0100 Message-ID: <1436372356-30410-6-git-send-email-marc.zyngier@arm.com> References: <1436372356-30410-1-git-send-email-marc.zyngier@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org To: Catalin Marinas , Will Deacon , Christoffer Dall Return-path: In-Reply-To: <1436372356-30410-1-git-send-email-marc.zyngier@arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org On a VHE-capable system, there is no point in setting VTCR_EL2 at KVM init time. We can perfectly set it up when the kernel boots, removing the need for a more complicated configuration. In order to allow this, turn VTCR_EL2 setup into a macro that we'll be able to reuse at boot time. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_mmu.h | 14 ++++++++++++++ arch/arm64/kvm/hyp-init.S | 9 +-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 6150567..b525cd2 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -55,6 +55,20 @@ #ifdef __ASSEMBLY__ +#include + +.macro setup_vtcr tmp1, tmp2 + mov \tmp1, #(VTCR_EL2_FLAGS & 0xffff) + movk \tmp1, #(VTCR_EL2_FLAGS >> 16), lsl #16 + /* + * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in + * VTCR_EL2. + */ + mrs \tmp2, id_aa64mmfr0_el1 + bfi \tmp1, \tmp2, #16, #3 + msr vtcr_el2, \tmp1 + isb +.endm /* * Convert a kernel VA into a HYP VA. * reg: VA to be converted. diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index 178ba22..4143e2c 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -87,14 +87,7 @@ __do_hyp_init: #endif msr tcr_el2, x4 - ldr x4, =VTCR_EL2_FLAGS - /* - * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in - * VTCR_EL2. - */ - mrs x5, ID_AA64MMFR0_EL1 - bfi x4, x5, #16, #3 - msr vtcr_el2, x4 + setup_vtcr x4, x5 mrs x4, mair_el1 msr mair_el2, x4 -- 2.1.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: marc.zyngier@arm.com (Marc Zyngier) Date: Wed, 8 Jul 2015 17:19:08 +0100 Subject: [PATCH 05/13] arm64: KVM: VHE: macroize VTCR_EL2 setup In-Reply-To: <1436372356-30410-1-git-send-email-marc.zyngier@arm.com> References: <1436372356-30410-1-git-send-email-marc.zyngier@arm.com> Message-ID: <1436372356-30410-6-git-send-email-marc.zyngier@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On a VHE-capable system, there is no point in setting VTCR_EL2 at KVM init time. We can perfectly set it up when the kernel boots, removing the need for a more complicated configuration. In order to allow this, turn VTCR_EL2 setup into a macro that we'll be able to reuse at boot time. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_mmu.h | 14 ++++++++++++++ arch/arm64/kvm/hyp-init.S | 9 +-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 6150567..b525cd2 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -55,6 +55,20 @@ #ifdef __ASSEMBLY__ +#include + +.macro setup_vtcr tmp1, tmp2 + mov \tmp1, #(VTCR_EL2_FLAGS & 0xffff) + movk \tmp1, #(VTCR_EL2_FLAGS >> 16), lsl #16 + /* + * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in + * VTCR_EL2. + */ + mrs \tmp2, id_aa64mmfr0_el1 + bfi \tmp1, \tmp2, #16, #3 + msr vtcr_el2, \tmp1 + isb +.endm /* * Convert a kernel VA into a HYP VA. * reg: VA to be converted. diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index 178ba22..4143e2c 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -87,14 +87,7 @@ __do_hyp_init: #endif msr tcr_el2, x4 - ldr x4, =VTCR_EL2_FLAGS - /* - * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in - * VTCR_EL2. - */ - mrs x5, ID_AA64MMFR0_EL1 - bfi x4, x5, #16, #3 - msr vtcr_el2, x4 + setup_vtcr x4, x5 mrs x4, mair_el1 msr mair_el2, x4 -- 2.1.4