From patchwork Fri Aug 16 12:39:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13766067 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 8C636C52D7D for ; Fri, 16 Aug 2024 12:40:51 +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=nI6i7YX14nljpUXmJtSY/UgyOMgnkcqXo7+aUg8YmfE=; b=N6z9hNX8E653yTUHLrDaglP+Gt mKo3QLFzimnN+FDurW0+h4UFkEhH1QjpmT5m1tI65/mIhlkVWOY4jCg/c2UBUmILzbbmaaF3lSwOI NNo/oP3VxZrBHeD1B2Gq0Gj4jbDWPR+njdo3KQ3l+Cg1P4UURwZkS7628gzLEDGIwKn3p8e9Yg3vH pyFsKKd+NbmkruqsXh6MMcYdf2YNQBekQtW4WvPkAmYWDg1LY3Ws6CK38kHRSUObhMS27BCk2QZGz d3pusx2fzGos9zzgVKDccpithI3LDEi1jUR2NW86qnYolSej3SVPkZXv6xswgPRJMUtYfmB8Y5pW9 1wo+q17A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewFz-0000000CuOW-1JVJ; Fri, 16 Aug 2024 12:40:39 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewEg-0000000Cu2J-1Y8R for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:39:19 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6b052c5939cso15706867b3.1 for ; Fri, 16 Aug 2024 05:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723811956; x=1724416756; 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=nI6i7YX14nljpUXmJtSY/UgyOMgnkcqXo7+aUg8YmfE=; b=tpd7B73AYgeSNMqk5+XaNbqaQ/xhQ4tbEFz+ab5YTKuHiibZrQOsJIs7Sf5ukbz+Fu bBOr6tgR+Nv7NuRIqxs6Ql5bml4SITdKPVrwPhPwO5zlbN3ARQl9PBpd9zqMIbdZVEOf 83RI9NroO3FGxbR9xfOc8eaQqG2ljbX7TYbnMtuWsmsEmZnn+Dna0Kid0sc+5mhOjQrq 3cQJDf23u+krvuSJBpC2upl1btQ0rExy8pzXJepR1sY+vdWK0hpRZSBrK559BoYYVtGD Gre7Vob94H1cZffaIF3/qF5lJIqJ87hTzLe4p8yVMV3KwJS+qzHg7hqaFanR/UVMqwlE t5Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811956; x=1724416756; 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=nI6i7YX14nljpUXmJtSY/UgyOMgnkcqXo7+aUg8YmfE=; b=Jo6ZC6ctI/HLoEecQER4QYBluI2WaYyos4dG4Xc9niHkFZRilIPZqKVMFRoe/NlnUB YULE6TiItHhNsqIzC8T9SvsGjU0LQrbokSSBYspfCQd3XTlJWAji2mQwKFuyRQ9pOUk8 mQwYkphp23jr4utItq1MliKacvyIsisergZIuvvaL9uKs/4RGUmo95F7QxArZBcaj+ux NDnhY72jUObo4ycZjLBxTSgV3yd5WSPyfAOXokPTXXGcFUYidPsDAifRyLEXnLr4LA1F Aq9G96dVyl883ZwtMzeeWre+6ckA5T8Wtc5p6+qKHwRQcjFsiKECQ86DUPacv8BIUy8b VpGg== X-Forwarded-Encrypted: i=1; AJvYcCUyrkjfpy4cZxF83nh4rz8KyNarmZrOCw272Io3ZT+ge52ABR+ro8y0yAzxy063VjljpTD61M+BJ4iYd3zh1v7YtyYnp7knXYSwr8UFEHonkvOWbGk= X-Gm-Message-State: AOJu0Yy9qR3oyWCBl57NbQEf/2kPMW0G3wubQ3wt/2E5XqysettZfjqz irNk5nb4xrcD8D87ceBZdQYL4Ax514e6azawbZ7OeNBRobMZskh9U3L2kKvYY9pv8lTxHM+yLp5 K0vOVVE0b+Kip1KZVkFYeEV+fTg== X-Google-Smtp-Source: AGHT+IGBZXo0joGkpRiMwmJyr97s6u1s6BZU4K3nLmENh0HF/8kX9FtEm3bAcQpjCF+W1kNezc9xW+sgWbb25EB7K5s= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:690c:3405:b0:691:a38c:a61d with SMTP id 00721157ae682-6b1d7ef3527mr730297b3.3.1723811956425; Fri, 16 Aug 2024 05:39:16 -0700 (PDT) Date: Fri, 16 Aug 2024 12:39:01 +0000 In-Reply-To: <20240816123906.3683425-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240816123906.3683425-1-sebastianene@google.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog Message-ID: <20240816123906.3683425-2-sebastianene@google.com> Subject: [PATCH v8 1/6] 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-20240816_053918_432046_3797A536 X-CRM114-Status: GOOD ( 11.42 ) 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;