From patchwork Thu Oct 19 14:40:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 155612 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp432213vqb; Thu, 19 Oct 2023 07:41:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFm3tZZRvnAhuOhKmoLw/+p+DigqZJ37KkBM7CnJrCC3UI/CqcqcKvJc8rY3qgMrPlbWyPx X-Received: by 2002:a05:6358:f1c5:b0:168:a60d:42a1 with SMTP id kr5-20020a056358f1c500b00168a60d42a1mr1351388rwb.1.1697726487218; Thu, 19 Oct 2023 07:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697726487; cv=none; d=google.com; s=arc-20160816; b=Xq1OepUz4tqgmyTUdrzJFQs9PwNRgpEt4hfYWRwQFgQlB7A+sgqb677h9CLizh6IuZ FZSqGYe3N6LSKCuygu6j/EF3Ta9b5aOCESiIgtZyg/QFi1HvRD0qiyPp1msp/BTN/YGu YCc0rbzQwByhDeAIu0KXjsYqORq+7IHHT+44ShY+2c5K/HkyEgYcboFrvQsw53ZfR+gN qtFFA14D9lbezEKor2fq4H+p/PuNvapCdqKyeRd/qWndNOsmZ54y1LhTFkpUXNC9DYAI fKsTilbw3Vw3oTzu3o1mbp6FlWAgcsmCtzOFi7OrPYW9hKsBT/xSgNw60hft01TjUQfP RlHQ== 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 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k11-20020aa7972b000000b006be04b8c3basi6087988pfg.178.2023.10.19.07.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:41:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; 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 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id CE96983B7AA0; Thu, 19 Oct 2023 07:41:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346259AbjJSOlG (ORCPT + 25 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 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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:41:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780195249335967102 X-GMAIL-MSGID: 1780195249335967102 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;