Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1792247rdb; Tue, 20 Feb 2024 07:12:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUMdO6feprVM0NgMaeSggTnwg+nWK30uJ16OtSV47HQ4uTFzYlZJ1gAH7nYnjNiKdzJp8NhK7bdGgXJKLx6UKC60WPh0UQShFbs0sT2dA== X-Google-Smtp-Source: AGHT+IEe79EU10zM0tyOxBuUkJmXx2aCD2ZZ0RsEvKot71zUGAc74AGhZQeY6S6WgTQc64Wmh4GE X-Received: by 2002:a05:6830:88:b0:6e2:f14c:b958 with SMTP id a8-20020a056830008800b006e2f14cb958mr18303534oto.2.1708441928565; Tue, 20 Feb 2024 07:12:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708441928; cv=pass; d=google.com; s=arc-20160816; b=tLYqA9Mpv0luwPuDQXSs0kAwBIrxrK5/PmZsw1EsBcdK287GBsSJR7ZSwWFlW1GimR C+1K34RkH7Da7BUo5n4gWiyN2Ef6bX6z9G6g1UtT2lKqJS9HdO1xfP1KUlwi69r20fZM 6/e0pvHx86r2neld31KnGqGB41+4PxID3/JqJXbcZ4zKtm/z97fuaHNOYPSaVroEfV6H pGzxFpPL73DQ+fyZ1Bo7GKdLdT4U2IJs2GbCqqrCXhiANd/djDFF/6zG8Hw72vvMDI0+ R7XFjmFZ32wrWm55pKx3Ggf6FUd6XDzAbRwSjxwfCZjdT1MmQCb1hAYe+QS/y2x4Uj/E 3i2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=Cjfo7uNgJv27FUK5l6GgvtACWLoTbWUGGoRS4ldTMrk=; fh=FwPJPLIV2tQZHRJ7/7pBTGUo8J86BL0741Gogk0i5R4=; b=IJdSLUDLr4HT+vXMjjgxZS88PvUkaSkSzfTXFmGIsBdlR80bcFVgv1HD+k7CkV6eUz bTqwdOE1FGsj3S0c8o+SfcA6II0jQgCoLoiy/3qIkY3G+JmoV+5RGQSHTlJ0ycjtlt4p Z8dHnCAsSJkQRB4E+XJQt1npmcDI/VYSKOCaJdRSp/jJcvzYLyplJQibblvtPbtUAVo3 SCwcXJrB1JXw452G390cb7Wx8zg8475vT3W7DxvREegf5G+dbDjijqTEm1qgivhmYowr WAce8I4k2HUx4wVZIDe0QOU9febm0YCTGd28KozPTkps+V2Qqteqp2CTuX7OPmrY5dQk PSzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xCceIkUA; arc=pass (i=1 spf=pass spfdomain=flex--sebastianene.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73222-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g17-20020a056102159100b00470648277a6si552219vsv.752.2024.02.20.07.12.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 07:12:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xCceIkUA; arc=pass (i=1 spf=pass spfdomain=flex--sebastianene.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73222-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B18441C20B41 for ; Tue, 20 Feb 2024 15:12:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CF627604E; Tue, 20 Feb 2024 15:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xCceIkUA" Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E07F76036 for ; Tue, 20 Feb 2024 15:11:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708441898; cv=none; b=ixjJRw01Uq+P4n+r1tLOBEi59majBVlgrjxs1uzcVq/xPy00XMLXvlxEANUr4/p/LOvlApDVQ5IsYg7OMjeQdQcKp//CNB4SDzC+S5z9fpVzIUVVBaG0hnlvfSWhLvVbKYS08G/kLo07bbo4ttJYeOwEFxFOfifQRRX4CiytwK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708441898; c=relaxed/simple; bh=tK68vHtvU4jfzgwQpLeiCDjQItafC4TSz2LntPJnZug=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=S28y0VoCqvj1mBwhXENO4QTQnTOHqMC1bgdEpEVlJiknWFXJQnUOWacjkCOEcI8fBIYzDeQy9FBw5fSnv5S0bxXVeYuzQk3Qd+DHHZ0tHa9MqaCfvD85UgjNUXp3iRVj27bK45Vmrbdq65OpEU47hNx+bVweb3+M22xUx/uoUmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=xCceIkUA; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-410d0660929so27456705e9.0 for ; Tue, 20 Feb 2024 07:11:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708441895; x=1709046695; 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=Cjfo7uNgJv27FUK5l6GgvtACWLoTbWUGGoRS4ldTMrk=; b=xCceIkUA9JeqU90NpUgHNpyo4B6qCMTHusc5CGNhZi6/KQ3jaI92fsSyd0Y1E6wbIt vvlPXxlVueWeeLIyStnk8fvavnbkWmH4u2VXoj3bkyf9Sfx7Ejkjho06oOzRhyDVpLK6 nZKgdIeX6TRbLfCuiI0MxGbv8L6b3k7c/DAvTRPFXxc8R2uPlWSMc03tbTVl8ZG2UVaV 4J5GK1206br8lobMbaAL0nWi/WG3oYRhHYpIBF5jcrpNOXtSolAk7KFwQY7nsEyODZAP FSpdiq9hz7GT5eqn+EgtxZnmcnEk04vMG2IB//diGAsI5laySsnitqTKLEkDTU93oY3S 6bxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708441895; x=1709046695; 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=Cjfo7uNgJv27FUK5l6GgvtACWLoTbWUGGoRS4ldTMrk=; b=ADRhfVh1PO76vrAl1UBZuL594K19+Lb20bXMfPfc5iyePMoelQN2avfGIqCy5roBJF AdQQxVlkHCD9zOEbGMz9JBFfnUXREzEVTVluVo6ES9f5gokdgb/aZ97e4OaZ9Xdgw5pA WtC/A4AmX4V6m6YsfbmQivg0ga4KIbYLJ89DMv987jXYJDF19rIVUuZRKKFTXkeF67fK Z9IJtrInU1Sr+Le5NyCG+1xAi1lX0Ne6RpwFPmqENX2TocEbxP72t/VB46CjobYkRtGl EzqiudWXXbcwtzLlbKjVaN2F7ANzSxsTAzekzcie/NUz/13muhQ0bHPj/8cJHoPM/IQg fNhg== X-Forwarded-Encrypted: i=1; AJvYcCX9wI3V5n2uirt2J+gChrIzuK/ZL/CcRw2uxsPjJTI5vWOW3qjY9uf3GTsn2NxBIJHQFrJv58h0DfFiSE7X2nbD1nl73AlgNqrEZjH7 X-Gm-Message-State: AOJu0YzhHT0e3IbETFToyQTS3f2QQn3hgNFGCLmFQ3fM7Cx6sOTEIvOL Xbm/0zOqSYev8LjSm6Rri/g++BfhHRP5kE6uc8wifeXUf4tWtXcQw00Ou2QpS2pZHGKAEIMVFV1 iWNI6nWA88aq9VELtxnK1lO9ZVg== X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:600c:a3a1:b0:410:e4fe:1a1f with SMTP id hn33-20020a05600ca3a100b00410e4fe1a1fmr157148wmb.0.1708441894686; Tue, 20 Feb 2024 07:11:34 -0800 (PST) Date: Tue, 20 Feb 2024 15:10:30 +0000 In-Reply-To: <20240220151035.327199-1-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240220151035.327199-1-sebastianene@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240220151035.327199-2-sebastianene@google.com> Subject: [PATCH v6 1/6] KVM: arm64: Move pagetable definitions to common header From: Sebastian Ene To: catalin.marinas@arm.com, gshan@redhat.com, james.morse@arm.com, mark.rutland@arm.com, maz@kernel.org, oliver.upton@linux.dev, rananta@google.com, ricarkol@google.com, ryan.roberts@arm.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, vdonnefort@google.com, Sebastian Ene Content-Type: text/plain; charset="UTF-8" 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 cfdf40f734b1..dd759e93084a 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 ab9d05fcf98b..eb83c8464b36 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.44.0.rc0.258.g7320e95886-goog