From patchwork Thu Feb 8 10:54:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13549607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8409CC4828F for ; Thu, 8 Feb 2024 10:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kPLUlLm808znHyIPZ2FQd/dQnyxAukSW/F6gsHZ6DiI=; b=KdQ7qD2hD5HNcZ 1aHFOuV6vtii6b6+LRVCg6EcCLtVMsPXwY8cD6I6JQujoUOxEC09CJWEFpQyLO55FSPs2sy9RXkOc aV6r16WY5A9hzsm/AJwPMNlJPIsdRkNR3o4Y/wNyXLwVcg5Esu+9OifxjAOJ12vhI/ftWd0s7uXiA vGhInqaA3u25aMfkrag5vrKAMdIHGsofSqhi/99gG+/rpwRDMBzQfcOWse+9Nwu4iOkulAZbBISag qQEuc3ALE2IktWho96wufM3N5tB1mPPGLRzTYFPrg8noAldVbNEOUg/1vvujSxfwMVn972Tpm8Baw kWD9LZm13Uudwu5AOzdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY23L-0000000DS9S-1iaT; Thu, 08 Feb 2024 10:54:47 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY23H-0000000DS5X-11sX for linux-arm-kernel@lists.infradead.org; Thu, 08 Feb 2024 10:54:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F25BDA7; Thu, 8 Feb 2024 02:55:20 -0800 (PST) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 95B113F762; Thu, 8 Feb 2024 02:54:36 -0800 (PST) From: Joey Gouly To: kvmarm@lists.linux.dev Cc: joey.gouly@arm.com, maz@kernel.org, oliver.upton@linux.dev, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , James Morse , Suzuki K Poulose , Zenghui Yu Subject: [PATCH v1 1/2] KVM: arm64: add comments to __kern_hyp_va Date: Thu, 8 Feb 2024 10:54:21 +0000 Message-Id: <20240208105422.3444159-2-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240208105422.3444159-1-joey.gouly@arm.com> References: <20240208105422.3444159-1-joey.gouly@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240208_025443_358995_5171A5C2 X-CRM114-Status: GOOD ( 12.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Document this function a little, to make it easier to understand. The assembly comments were copied from the kern_hyp_va asm macro. Signed-off-by: Joey Gouly Cc: Marc Zyngier Cc: Oliver Upton --- arch/arm64/include/asm/kvm_mmu.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index e3e793d0ec30..d248a7ae627a 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -127,14 +127,24 @@ void kvm_apply_hyp_relocations(void); #define __hyp_pa(x) (((phys_addr_t)(x)) + hyp_physvirt_offset) +/* + * Convert a kernel VA into a HYP VA. + * + * Can be called from hyp or non-hyp context. + */ static __always_inline unsigned long __kern_hyp_va(unsigned long v) { +/* + * This #ifndef is an optimisation for when this is called from VHE hyp + * context. When called from a VHE non-hyp context, kvm_update_va_mask() will + * replace the instructions with `nop`s. + */ #ifndef __KVM_VHE_HYPERVISOR__ - asm volatile(ALTERNATIVE_CB("and %0, %0, #1\n" - "ror %0, %0, #1\n" - "add %0, %0, #0\n" - "add %0, %0, #0, lsl 12\n" - "ror %0, %0, #63\n", + asm volatile(ALTERNATIVE_CB("and %0, %0, #1\n" /* mask with va_mask */ + "ror %0, %0, #1\n" /* rotate to the first tag bit */ + "add %0, %0, #0\n" /* insert the low 12 bits of the tag */ + "add %0, %0, #0, lsl 12\n" /* insert the top 12 bits of the tag */ + "ror %0, %0, #63\n", /* rotate back */ ARM64_ALWAYS_SYSTEM, kvm_update_va_mask) : "+r" (v)); From patchwork Thu Feb 8 10:54:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13549608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08A27C4829D for ; Thu, 8 Feb 2024 10:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mY0yFyHengarfWSkcaD6Sps0ohV32aeBuHbTBf1opR0=; b=K095gEo11Y9D01 pKg42r7vpLVOa0Hk5IunjgBFq0hBcDaTbKRQJPED/LuaqW7mfb5QKC4k2AdIP3v3wf2pc1xuTFqqw erUpmKQPBv+2TrbYyEWIcwqqKUbTjfIVluaigvvjgJjHJWX9hTbgv81iaNeeFhQxBMZQw71jxFIHM 9h2bxOQZ25JK/2YB20CdAaNokXCgLZoP6pFzwpgrvIXGXUYc/OschAiJTj4nkPixr1eh3SPckpAQg lm9h2po8yZE7QbUG+U+PR5SSMc+lD1WN1aWAfuknagNojRaxUsIxz285vqiVmZD3hSTrDpaC9f5HW qwB9JEP/M9m7lMKTRiMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY23K-0000000DS8f-17O8; Thu, 08 Feb 2024 10:54:46 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY23E-0000000DS5l-2hrn for linux-arm-kernel@lists.infradead.org; Thu, 08 Feb 2024 10:54:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A36501515; Thu, 8 Feb 2024 02:55:21 -0800 (PST) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 265013F762; Thu, 8 Feb 2024 02:54:38 -0800 (PST) From: Joey Gouly To: kvmarm@lists.linux.dev Cc: joey.gouly@arm.com, maz@kernel.org, oliver.upton@linux.dev, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , James Morse , Suzuki K Poulose , Zenghui Yu Subject: [PATCH v1 2/2] KVM: arm64: removed unused kern_hyp_va asm macro Date: Thu, 8 Feb 2024 10:54:22 +0000 Message-Id: <20240208105422.3444159-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240208105422.3444159-1-joey.gouly@arm.com> References: <20240208105422.3444159-1-joey.gouly@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240208_025440_764247_1CDBBEC3 X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The last usage of this macro was removed in: commit 5dc33bd199ca ("KVM: arm64: nVHE: Pass pointers consistently to hyp-init") Signed-off-by: Joey Gouly Cc: Marc Zyngier Cc: Oliver Upton --- arch/arm64/include/asm/kvm_mmu.h | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index d248a7ae627a..961d4431654b 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -53,27 +53,6 @@ #include -/* - * Convert a kernel VA into a HYP VA. - * reg: VA to be converted. - * - * The actual code generation takes place in kvm_update_va_mask, and - * the instructions below are only there to reserve the space and - * perform the register allocation (kvm_update_va_mask uses the - * specific registers encoded in the instructions). - */ -.macro kern_hyp_va reg -#ifndef __KVM_VHE_HYPERVISOR__ -alternative_cb ARM64_ALWAYS_SYSTEM, kvm_update_va_mask - and \reg, \reg, #1 /* mask with va_mask */ - ror \reg, \reg, #1 /* rotate to the first tag bit */ - add \reg, \reg, #0 /* insert the low 12 bits of the tag */ - add \reg, \reg, #0, lsl 12 /* insert the top 12 bits of the tag */ - ror \reg, \reg, #63 /* rotate back */ -alternative_cb_end -#endif -.endm - /* * Convert a hypervisor VA to a PA * reg: hypervisor address to be converted in place