Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2607737rdh; Wed, 27 Sep 2023 07:35:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHADDcfOmNO46pUxSlmCZb0pRczHLMcrjeNR/zQNgkZ+G4mrNs5qvhnU680Ak1+vTxGHhJK X-Received: by 2002:a17:902:d2d1:b0:1c3:2ee6:3802 with SMTP id n17-20020a170902d2d100b001c32ee63802mr1861976plc.47.1695825333992; Wed, 27 Sep 2023 07:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695825333; cv=none; d=google.com; s=arc-20160816; b=XGI7Lfp+ZGmes6XgLpCE9yaJT/9rLQ+ggdExqUuiRD7+fgwDyULrBPNq1olJM73L7Q tRq+crWf2y2VCDQVZlo+OKMfvzq++waM9q6aKaR+Y2EXCQJNZd2beK7I+y2TVX3bjx4n 61R9sQAS6105iVwldA56CeyXmU7C5kZMcgflenn+1+uMkFg1EOt12RNlO+/2q2uUkjyZ IRYfVrauyuG+9Dz9v9E2yMHvjOoUBfTv9cYfeVAYKfcrVmHDMumA0pYoIlGzM3yQqoHi sYhHlKNtIrIlWqyYCGelLkIjEZApXRRUCUAfVOl01SOn1Fj7PqgZVZoH1BqhtF6kA0SP Vv6Q== 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=pCmgpMBJwGuXO7/jIj16/rriK8J2TUjW9FV16THuDL4=; fh=yikR9HT1wx5LLj7DvfR9kbE/RatD/mnQgNUS++qRsJM=; b=rOLGGyOqiYDxcIzEgEEUy21h5eYFflkVvqAiTzLdlaD0KkON8KkCHFIfcfSc71uZw8 x3wtj7kDn5svk+al5ves2w41R9U6V00kvT9gccnEdqSOdMHkfMRNfprRSpW5acutOv/G VXLFWjrJBevwYapdW/muW9JNWsHapW8ULTqQAy3Snac1BZMS07pwp2Erio/ZRy+tC4aX 9wlUCRVDPvwRloCooLGfPWmm0yWRP1FxmSlzOx6mzwkdiqgY8F9KQZXwc/JdbN38tUbT 6rZ7k4dvN0oDkD+R6FF50xZv442oP04l9SnaeRPSjaSyr7I2Sex4olv88pvzEzebnz5l CPnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xvYwAFWg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id jh19-20020a170903329300b001bba90f8b73si14868682plb.78.2023.09.27.07.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:35:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xvYwAFWg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 261B580268AF; Wed, 27 Sep 2023 04:26:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231545AbjI0L0F (ORCPT + 99 others); Wed, 27 Sep 2023 07:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjI0LZv (ORCPT ); Wed, 27 Sep 2023 07:25:51 -0400 Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F90193 for ; Wed, 27 Sep 2023 04:25:47 -0700 (PDT) Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-31f3cfe7269so8348442f8f.2 for ; Wed, 27 Sep 2023 04:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695813945; x=1696418745; 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=pCmgpMBJwGuXO7/jIj16/rriK8J2TUjW9FV16THuDL4=; b=xvYwAFWgBOpMZn2A/TQ/TPaARJvAlsz+gsbyM13hZEcknjHq1/AVWslOBv+4i93X0m GPuXiF/PeXKaxmP4geuPMPHmMAKYfqj2u97qBZVweCtX3gesXTGVdTOUs23VM7VopKXP lAz2m8kt/n08eql+fEGXstU9fZcQtfY1p3afSfX2kJ4zJWL6j9snvD41EtbkHmr03lSZ 2SnYpQhHTG6ZgUCkbKQfAGDnbPC2YjL+6+Ut3TGpOnFOy2B/qst/pzcqe8lnnE4zzD6X D5nhr6Mt7LnIGr1lkZKvWLmOrQtHXfXPZYUe7L/eXrSudHXSa5o8O8SqU35D5e6mv3lg nHzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695813945; x=1696418745; 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=pCmgpMBJwGuXO7/jIj16/rriK8J2TUjW9FV16THuDL4=; b=MYfyDtjd1i7CT7hbmARlkV9QOSWcmPci4vZTBowdRi4/mDK926cGNsIqFCmA9IH0UV rg2cLwah0cHlRDB8U3JXe8Pb+3oEn6OsoSdjnktWZAt1mdHoCNP1Z1uwQKp4onNue/CP aXd85QFD+4EGM3qCL/8pw+yVRjw4mzqTnGsLRVky2OFiqG3Dk/ltxA+ebM2mzWHNRCLl cx08ELHKrMtDB5Fidsl79BY7BBb0DGui0qY7i7Kx8g9jw6qhM8cU7dhImjOfkZVb9z2R vnn9jJvGyUUghjktvS9Tn827mSdYNdLB7bjKCqweDXNMK/rLb5aa16ANiJbDlkxCc+3F Eh+A== X-Gm-Message-State: AOJu0YxgHRBooQKAoQ4jEMKeVtAl+w8IKga02IRQWjhlGXMJu4KobBE6 FlvrD3Nny2mySjDNoIh1CCgDaZKZJkhc4o6dWJjz0X2v99Oo6LRioEalhiOznae19YLBtBSzyai FcaxoYwZkPryimZCLXYammcd1kAx6CRwE/UraiB3rkpwjOZIu4j4wUo1h3/rDrYrnbvQ4AueG3T 0EOAlwp4YSXg== X-Received: from seb.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:31bd]) (user=sebastianene job=sendgmr) by 2002:adf:e7c7:0:b0:31f:97e2:a930 with SMTP id e7-20020adfe7c7000000b0031f97e2a930mr7475wrn.1.1695813945480; Wed, 27 Sep 2023 04:25:45 -0700 (PDT) Date: Wed, 27 Sep 2023 11:25:10 +0000 In-Reply-To: <20230927112517.2631674-1-sebastianene@google.com> Mime-Version: 1.0 References: <20230927112517.2631674-1-sebastianene@google.com> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230927112517.2631674-5-sebastianene@google.com> Subject: [PATCH 04/11] KVM: arm64: Move pagetable definitions to common header From: Sebastian Ene To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, will@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com, maz@kernel.org, vdonnefort@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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 04:26:30 -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.515.g380fc7ccd1-goog