Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp400286rdb; Thu, 19 Oct 2023 07:42:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3t5BvIEPLpxoEYAo/Fd1GBzZ7PZVE5nq3I8VkHh12GJTqXmaOowtBSKPP5fw/dW0rfW7n X-Received: by 2002:a05:6a21:6d99:b0:14c:d494:77d1 with SMTP id wl25-20020a056a216d9900b0014cd49477d1mr2756524pzb.10.1697726555696; Thu, 19 Oct 2023 07:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697726555; cv=none; d=google.com; s=arc-20160816; b=PvCBbrCHnmyZVNmcnRwxR6I2SojX78JrPK44UXcpJXFzuR6ZZ8UcQxSr51OJutPT9V GTj0ZfHnPG899M5ghN58mbZGueWcwo2ds0ZR6wUklTNXwjkPIV0pq2FHVQBfeXwNr5F6 fJNMQvb9De8qpFnuaCwU0tqKaprSbwcHh5ilbhg94Kmm0JSzhKUZwZK0RFG3tqs1LwBy KsNDmbYpFmXlNUaldSq7mvz4wSMcmFoYy66/PAOeCJjcWNyrVyt9LU1lv6SjXNPJ76H8 GF/YWl45QzI7zf52Rg9065yb7BiMPUiAjFfFxzr+x/iygXMS3pomsq8agMFjhg7AtqlG Y0ng== 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=W058w3G2hIt8CMXfrmWr4+cXGEYq83hG+O1xXrw0XI4=; fh=t9YKxUPg1Kt5PJ3n0c95aaxkMlch/EFXblRJVyulW1I=; b=XoFioViG6SgI16sodtJCtiSeBeZOjM13/S5RM15CkOeGB8vk3OEWp6cyudtlCi4J7A FEMzZ4gQwLrIEF9+8WIAllzc0RRbxZilPwRuUZAluqa89epE8L07GFF4fWcHc1R3yzqN cwJ8nCw4jHr9Nk9vM2dOWOjo6sjQ0B+Lvmfy4Piw8ooOhPpQtVfJ4ZuSmP5VFiec+qoM 5Ln1n8PixG7gVRuYoByFAYG84t+5yzZJ9dAm0oUuZgFJ4+UfFXKnnNDVmNHiUq0Zrzs0 QK3ua+JPmrUXXlvpU3hGanTQSXf5yZxz88ixdCn9Nz40OtcksPIHha4jnBSIE91tJYkg V3Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="CZ/8WLp0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bz16-20020a056a02061000b0056c55eb251csi1940702pgb.123.2023.10.19.07.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:42:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="CZ/8WLp0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 2F40C80E0B45; Thu, 19 Oct 2023 07:42:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346186AbjJSOlG (ORCPT + 99 others); Thu, 19 Oct 2023 10:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346189AbjJSOk5 (ORCPT ); Thu, 19 Oct 2023 10:40:57 -0400 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 B627318C for ; Thu, 19 Oct 2023 07:40:54 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d9a4cbdad3fso10715683276.2 for ; Thu, 19 Oct 2023 07:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697726454; x=1698331254; 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=W058w3G2hIt8CMXfrmWr4+cXGEYq83hG+O1xXrw0XI4=; b=CZ/8WLp0oJeltnEKqugx4cFMo1YWwYwIAHEUDbfnpkV7elfIWdXDlF2Tja8S2o+Hjl tirvwpuXiAJyHWaGYRa99wDhNZx7+8uKapjRkXCksRyTktTh8CVeIgKA6i4YF0bLZpNT T2p03e3KHDySMeixdf0vFSlwj6U/TSxITK3T7zDEJpPJkmtBA7kNTUYEDvEsFas3Ie83 KtClGCAE1RbSHwSFJ8y6vYXTYNiKtsrNCzviC67tY/YfDTer+7dFUYUUNHPcuCxmKdp0 wtCk45ALKhx+ElvOcRPJRiKlS2F1e1gtKW9gkiKmO6hyCd+Ywdj94o2mIZ6xl4nc9nfL Gp3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697726454; x=1698331254; 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=W058w3G2hIt8CMXfrmWr4+cXGEYq83hG+O1xXrw0XI4=; b=UzHkwYTsPNak6JnYj/anmh/lOvk/qlOaHEhCo+fE3xIAoBR09LjvjRVE9z4t2QmVzX utXe9n0fgKSrNCwcCPFTj37x/SeL87m6WkXY7MbhGve8IpnTJqelHntoZlMhE4B/uA5b Ivts32mmARsY7ZIWZadtIjTmZFNOUVbTATOJ/UAZLkMJKrNJCkNwYw3WGAfHg9U5IEFA PmqxbNVu0OGGQQV7LMIViJHUP75Dyz5/lTY9+soR+QAxtFcZf+x6Bb1JWQN56tUxnUaP vHHOoA9PYQrN8MZCaPpI7bOXFU2RvRxx31KLWGHiMXxf5u4vY4TxW3VEFvN/8/eWCQk0 Pccg== X-Gm-Message-State: AOJu0Yxb1KKgoNTdEQLvtc5DxItwM/P39N1t1TT/Swv57/290pb5a00B 1JXhd03eCS7y5qE5FxBqaXko6Iq7bKBV3qV37xs= X-Received: from seb.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:31bd]) (user=sebastianene job=sendgmr) by 2002:a25:9e86:0:b0:d9a:68de:16a1 with SMTP id p6-20020a259e86000000b00d9a68de16a1mr59829ybq.0.1697726453864; Thu, 19 Oct 2023 07:40:53 -0700 (PDT) Date: Thu, 19 Oct 2023 14:40:26 +0000 In-Reply-To: <20231019144032.2943044-1-sebastianene@google.com> Mime-Version: 1.0 References: <20231019144032.2943044-1-sebastianene@google.com> X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog Message-ID: <20231019144032.2943044-6-sebastianene@google.com> Subject: [PATCH v2 04/11] KVM: arm64: Move pagetable definitions to common header From: Sebastian Ene To: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org Cc: 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:42:27 -0700 (PDT) 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 256654b89c1e..67fa122c6028 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; -- 2.42.0.655.g421f12c284-goog