From patchwork Mon Sep 9 12:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13796988 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 84B9FECE579 for ; Mon, 9 Sep 2024 12:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SKJ1NP3DrAm45Ot6yL2cReAMG8qo73bbwYgKiOjz384=; b=4PpVRGVPywtbItslSTW0yhqcfs hSe3ofI44B5xYKNobDgyYPOgV5bK3Lm8iytBn8KKU48bIWJLaa3lXv/bM9DVxIr/iHVxzNx9B7Xe4 zMMJCCBgVFFQCCDfKdj8O8r9z3w712pMQ3/TiWnCgtky8lopuGw8lUh+3lzRKRUhGqw1EFfRttz7S xL7wCkljbNdU4Bv7cSJ/fv8HC3ila9hx0dgQjKI/j+zrAUXJ5bvfilyWd9ERL7wUMvF6rESlj/OpO ka/o46RzHGmd8Jx6d8tTQqqQopUaEdMu3fX9USzgCF96LuU2sObYlYnaJAol8EGe/tlTH/Ghg3hzK Lh3tyZRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sndrS-00000001w5c-2PUK; Mon, 09 Sep 2024 12:51:18 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sndnr-00000001uY7-0Bnz for linux-arm-kernel@bombadil.infradead.org; Mon, 09 Sep 2024 12:47:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=SKJ1NP3DrAm45Ot6yL2cReAMG8qo73bbwYgKiOjz384=; b=reNV4y1pkVPFplezSCNr8KDfDL zO55Oz5WsXFveq7plWjqyB/l5rh4cBTb66ST+XKAsGG22k0uJOBBO4b8jBki0RhuIq7JwRgzZDI0m crbm0Db9zfyO+8ar+VEXahdpSj5xdcG/w47+wBoBjbnK9MRxynmiXiOEGfhoMtShs5StT2vK8fwAt Iw9k4RNmU2UKp+I5y6VrRxWE4Twjx1TgZSW4L3F0Vgq7bj3B+KENRCNipbf81G+zE/cdkhSOw6mgL Gwx2A5CKin1bakoS8u1YTB8jALohImUoqHbDgNFkJUW+StdnOsE79kY+SQs4Oj0OLw/EPA1SAhfN/ MexJXxNA==; Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sndnm-00000000Qnq-3BVS for linux-arm-kernel@lists.infradead.org; Mon, 09 Sep 2024 12:47:33 +0000 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-42cb635b108so8842855e9.2 for ; Mon, 09 Sep 2024 05:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725886047; x=1726490847; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SKJ1NP3DrAm45Ot6yL2cReAMG8qo73bbwYgKiOjz384=; b=g+niqLk7oPUPZ2sMOzvTnHqlYaJCX6MBNkSa7PVWSSBJAA2VlcywK03hsmLJ1vJfWZ YVk+ZV/Wb7/tycvaj3IEQyFwoVtxTOvq6YXpAmk+XoTCnX/JxtzmWKgHzMqvGkmbbTj2 vn+gYqkpJtn5Vfu15LA3bYk82T8a5hInvYv5r2HxeFAIIHfJkuQz697ZdF9UZngFpIa3 m8ymOc0qZq95tdl/3Tp7HB8gvpgDbNkCW2d5KZO71jBzFSgnHazRBWkA+AdKOS2IjcAQ dXu0UX22jBHEEZDxVkLdshThJz9mU1i9DflFjiQTgoQP2nhH2aIU7QrKb+tjAPfouZbN annw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725886047; x=1726490847; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SKJ1NP3DrAm45Ot6yL2cReAMG8qo73bbwYgKiOjz384=; b=iwIokklkp2yw8kmOEJ4EY4k0FTMa8Gc0gfIq2U/Bm3+hB+wsV5VODOunChnpW7n4e1 kp8u+i/OwviIKl9kpf4BW4EKG5Yr8uqLd698ENlX5hCj6F83L/b4Mut2z1xadXr7fr9I P7k+yoDrsE4GSTcr1o6FJmPG0IA+ib+fZ14JcG3e/Sa1cyHiW28boYG0qidImfz/+LpZ l8Phn7LQb4XtAuKDhCnrprpqg94Lih9tvAGQkRQLa+GKu1r3GJvAlHSZpmsIgD9hKqFB ycF4clsswK8k6gsGL8RmvXTRJbDr1DzXIzw9613A4LVGcXqQcg2xX/QmOPa5TvvW+lx0 0imw== X-Forwarded-Encrypted: i=1; AJvYcCXSiYKATqegxtlefxYccPeWQ7EDlFROLoR9/Ea5CXKIf/3PAn42oJqgJTZJM6240S28JfMMxptXgRRovGu5Secd@lists.infradead.org X-Gm-Message-State: AOJu0YwaEIvJSe/eNmTPg3K7JWNtKN9/L3vx4OlTZkp115d2u4gUwErw NZ9uso/KxXLf1skIkhTBspflivQHiJs5UOMYW3+9tEWWfKR+qx2HysV5YKF2KMZ2ZTFRGpk7/4h 9o9AOiJXwO7InQm9nJk7/ULdS5A== X-Google-Smtp-Source: AGHT+IGB9bwzA+fwuWPOhmU2PE2PuSrdb0vA8nxugJEsLMz4E+4/m65aP47k2xrfDB7zI8uLZNKmhk8HfA0/HNK+S/I= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:68:fe9:ac10:f1b7]) (user=sebastianene job=sendgmr) by 2002:a05:600c:2d8c:b0:42c:ae30:fc33 with SMTP id 5b1f17b1804b1-42cae30fd4fmr872025e9.4.1725886046868; Mon, 09 Sep 2024 05:47:26 -0700 (PDT) Date: Mon, 9 Sep 2024 12:47:17 +0000 In-Reply-To: <20240909124721.1672199-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240909124721.1672199-1-sebastianene@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240909124721.1672199-2-sebastianene@google.com> Subject: [PATCH v10 1/5] KVM: arm64: Move pagetable definitions to common header From: Sebastian Ene To: akpm@linux-foundation.org, alexghiti@rivosinc.com, ankita@nvidia.com, ardb@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, james.morse@arm.com, vdonnefort@google.com, mark.rutland@arm.com, maz@kernel.org, oliver.upton@linux.dev, rananta@google.com, ryan.roberts@arm.com, sebastianene@google.com, shahuang@redhat.com, suzuki.poulose@arm.com, will@kernel.org, yuzenghui@huawei.com Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240909_134730_903660_3E9D3060 X-CRM114-Status: GOOD ( 12.15 ) 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 In preparation for using the stage-2 definitions in ptdump, move some of these macros in the common header. Signed-off-by: Sebastian Ene --- arch/arm64/include/asm/kvm_pgtable.h | 42 ++++++++++++++++++++++++++++ arch/arm64/kvm/hyp/pgtable.c | 42 ---------------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 19278dfe7978..03f4c3d7839c 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -59,6 +59,48 @@ typedef u64 kvm_pte_t; #define KVM_PHYS_INVALID (-1ULL) +#define KVM_PTE_LEAF_ATTR_LO GENMASK(11, 2) + +#define KVM_PTE_LEAF_ATTR_LO_S1_ATTRIDX GENMASK(4, 2) +#define KVM_PTE_LEAF_ATTR_LO_S1_AP GENMASK(7, 6) +#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RO \ + ({ cpus_have_final_cap(ARM64_KVM_HVHE) ? 2 : 3; }) +#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RW \ + ({ cpus_have_final_cap(ARM64_KVM_HVHE) ? 0 : 1; }) +#define KVM_PTE_LEAF_ATTR_LO_S1_SH GENMASK(9, 8) +#define KVM_PTE_LEAF_ATTR_LO_S1_SH_IS 3 +#define KVM_PTE_LEAF_ATTR_LO_S1_AF BIT(10) + +#define KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR GENMASK(5, 2) +#define KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R BIT(6) +#define KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W BIT(7) +#define KVM_PTE_LEAF_ATTR_LO_S2_SH GENMASK(9, 8) +#define KVM_PTE_LEAF_ATTR_LO_S2_SH_IS 3 +#define KVM_PTE_LEAF_ATTR_LO_S2_AF BIT(10) + +#define KVM_PTE_LEAF_ATTR_HI GENMASK(63, 50) + +#define KVM_PTE_LEAF_ATTR_HI_SW GENMASK(58, 55) + +#define KVM_PTE_LEAF_ATTR_HI_S1_XN BIT(54) + +#define KVM_PTE_LEAF_ATTR_HI_S2_XN BIT(54) + +#define KVM_PTE_LEAF_ATTR_HI_S1_GP BIT(50) + +#define KVM_PTE_LEAF_ATTR_S2_PERMS (KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | \ + KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \ + KVM_PTE_LEAF_ATTR_HI_S2_XN) + +#define KVM_INVALID_PTE_OWNER_MASK GENMASK(9, 2) +#define KVM_MAX_OWNER_ID 1 + +/* + * Used to indicate a pte for which a 'break-before-make' sequence is in + * progress. + */ +#define KVM_INVALID_PTE_LOCKED BIT(10) + static inline bool kvm_pte_valid(kvm_pte_t pte) { return pte & KVM_PTE_VALID; diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 9e2bbee77491..c3e9d77bba23 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -17,48 +17,6 @@ #define KVM_PTE_TYPE_PAGE 1 #define KVM_PTE_TYPE_TABLE 1 -#define KVM_PTE_LEAF_ATTR_LO GENMASK(11, 2) - -#define KVM_PTE_LEAF_ATTR_LO_S1_ATTRIDX GENMASK(4, 2) -#define KVM_PTE_LEAF_ATTR_LO_S1_AP GENMASK(7, 6) -#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RO \ - ({ cpus_have_final_cap(ARM64_KVM_HVHE) ? 2 : 3; }) -#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RW \ - ({ cpus_have_final_cap(ARM64_KVM_HVHE) ? 0 : 1; }) -#define KVM_PTE_LEAF_ATTR_LO_S1_SH GENMASK(9, 8) -#define KVM_PTE_LEAF_ATTR_LO_S1_SH_IS 3 -#define KVM_PTE_LEAF_ATTR_LO_S1_AF BIT(10) - -#define KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR GENMASK(5, 2) -#define KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R BIT(6) -#define KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W BIT(7) -#define KVM_PTE_LEAF_ATTR_LO_S2_SH GENMASK(9, 8) -#define KVM_PTE_LEAF_ATTR_LO_S2_SH_IS 3 -#define KVM_PTE_LEAF_ATTR_LO_S2_AF BIT(10) - -#define KVM_PTE_LEAF_ATTR_HI GENMASK(63, 50) - -#define KVM_PTE_LEAF_ATTR_HI_SW GENMASK(58, 55) - -#define KVM_PTE_LEAF_ATTR_HI_S1_XN BIT(54) - -#define KVM_PTE_LEAF_ATTR_HI_S2_XN BIT(54) - -#define KVM_PTE_LEAF_ATTR_HI_S1_GP BIT(50) - -#define KVM_PTE_LEAF_ATTR_S2_PERMS (KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | \ - KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \ - KVM_PTE_LEAF_ATTR_HI_S2_XN) - -#define KVM_INVALID_PTE_OWNER_MASK GENMASK(9, 2) -#define KVM_MAX_OWNER_ID 1 - -/* - * Used to indicate a pte for which a 'break-before-make' sequence is in - * progress. - */ -#define KVM_INVALID_PTE_LOCKED BIT(10) - struct kvm_pgtable_walk_data { struct kvm_pgtable_walker *walker;