From patchwork Wed Nov 15 17:16:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 165515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2686984vqg; Wed, 15 Nov 2023 09:17:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMNM+EKHhxTfUxjLoKCkZpJt5EIkqutx6JCZhLaHLCHtZRTNn5F+Fk5SL07mpW0B9v1Qoe X-Received: by 2002:a05:6a20:729a:b0:187:8bd4:e1ba with SMTP id o26-20020a056a20729a00b001878bd4e1bamr1452607pzk.37.1700068637946; Wed, 15 Nov 2023 09:17:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700068637; cv=none; d=google.com; s=arc-20160816; b=s6XC9TFabmPfuuZcGhVBc+jPWpWIiGCfqlPYd+9xs2c899Z9a5m97EYq/DpG/O+TJd B1xTlLd8D/ZbYNUa6hpF9kHZYyCx8YQvVR+8MvfSAC9Ew1YJeTTwHDLrS5v0MIWddOjZ KxA+Rj8sE7uDZvf1mj+31Fgqgm3fjPAMKmB3ZgACTmfqpbJTWpBmXnPTA78/omyBtgf1 vW8mQ+rkjH66dM7HWQikvvTc5EpkQHYmj5rkJhPXH8nYpQiA+7q5VfSUM8bh/arxVdmS YUYgHVhO11cWGm+lMo/AB8ihGpNhfixTMr3nyIB2LcpOgn8tyAfRme1JNvrBbqBECfys tWTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=tpT/Xyb5t7NIpC61c+cv5rhl4HgoVPgdS5jOtCH656U=; fh=4RXM1FFjr/2FDx2f50K7N78eRirWaG15JMQkQwGVT00=; b=YNzhmicFeGuIN+CuUoxyB12ETLVOBKS/y82WhclMlJ/TyYQJjRP157LD1pc+QQ67dH AhJsAwT3L+ETDT3T0xpROuXVIDYw+80zTzQibcKx5tBqroHmolwqPhagfqTABTNcNjFx DkeaAcMbtNr0MkMU7v1gUgs1XEb962tj7eAE7R3Rgw0EKahAdDdcbrW62UbLbEZvzKVz duJi0d2PZ5nIaExpYTMJJsT/vuI0R9ib1RktwMmJnwcvQU+t2OulVGdWnPOJlSXyN8k4 PHyLuMMmT2wqx+2+S2wwhQlukUU4LbmvY4egJhj9QK5mhyK0cAMkNZGMC3+5pXymoRy2 zgCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Gph+mQQo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j191-20020a6380c8000000b005be1ee5ef0dsi10658788pgd.15.2023.11.15.09.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 09:17:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Gph+mQQo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DF9B28218E54; Wed, 15 Nov 2023 09:17:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232555AbjKORRL (ORCPT + 29 others); Wed, 15 Nov 2023 12:17:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbjKORRI (ORCPT ); Wed, 15 Nov 2023 12:17:08 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEAD4194 for ; Wed, 15 Nov 2023 09:17:03 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da04776a869so8171333276.0 for ; Wed, 15 Nov 2023 09:17:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700068623; x=1700673423; darn=vger.kernel.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=tpT/Xyb5t7NIpC61c+cv5rhl4HgoVPgdS5jOtCH656U=; b=Gph+mQQoND5MQPj23PzD8UIK16A1pJ/KynEsR9CrHIgRcATUO0fvRf04CeLqzetKjH 5rqukNqkIZspbs2PmMMaBt1KAUSOazH4odIDDPmE4xzDdBCXXjDZm4M1JbVSWw2oPvfh 70H1I9tIawUBTHDbOLYvCGConxERmHL6e6MI6iaQlmeSUoIi9lDItSZLkRFCB0xYnupX QbEye8mzNMwkLYq4u/Lc//vjsazuMb5iCe18Fl20RCIqPE1Fy71j0RJOs9fc92I4+c8E dBSwxxu8mNEmbZHWyC1i4RQEYubzfiJ+bUvz1uS11ONZoRUAdq6ihMgyQkh3AbUI7Dbx oqeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700068623; x=1700673423; 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=tpT/Xyb5t7NIpC61c+cv5rhl4HgoVPgdS5jOtCH656U=; b=Ru68Vdj3BqCi6VmV/NgEacgWNpSubn+RbujXJ8It4OCR4azLv1BLwMrY2Jrgkn3cA3 nR7Q9+I+eh8DTgqAqQ5GYw0yAEIU0NLYTcCagidme5ge/OnjmBAc45iSUK4D3jq2SEaC kbGfFjDc7zsDxE9DV3Jnv5NiXU1Ix4RV3Wz3VfEyOBDuMj/VIhdCwnsJYhy9ayu+Eq9j SHqWCJUpyg9ZkNhWMfZBsI/K65HvrOAct98YjPgI/1HFV6ilZoM7EsX7m08pdpkCMJiM t8EUztxvdiAycC2emCwZbzrhx8F8IkR0CCtnPwlymx3/WGQvf+2BbcP7KK7v0TekxxtH fKaw== X-Gm-Message-State: AOJu0Yw37l2cjet+JiJnX31PNZfgNSgS7wLXMHUKKwmeT0jVN9PpeIML nCNZWp2aq2QIk1X/j6/EMccb47Tinugv61rrKfE= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a25:4016:0:b0:da3:b880:180e with SMTP id n22-20020a254016000000b00da3b880180emr311035yba.2.1700068623070; Wed, 15 Nov 2023 09:17:03 -0800 (PST) Date: Wed, 15 Nov 2023 17:16:34 +0000 In-Reply-To: <20231115171639.2852644-2-sebastianene@google.com> Mime-Version: 1.0 References: <20231115171639.2852644-2-sebastianene@google.com> X-Mailer: git-send-email 2.43.0.rc0.421.g78406f8d94-goog Message-ID: <20231115171639.2852644-6-sebastianene@google.com> Subject: [PATCH v3 04/10] KVM: arm64: Move pagetable definitions to common header From: Sebastian Ene To: will@kernel.org, Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vdonnefort@google.com, qperret@google.com, smostafa@google.com, Sebastian Ene X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 09:17:16 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782651172205496274 X-GMAIL-MSGID: 1782651172205496274 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 be615700f8ac..913f34d75b29 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -45,6 +45,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 46b15d74118f..65643320a6bb 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;