From patchwork Tue Feb 20 15:10:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 203635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp465168dyc; Tue, 20 Feb 2024 07:12:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLnzax4U7joxhLhR9QJZCRmeLM6iD2n3lYeVuMz3yvhafN+ikem62+02ryWCEkBjkOuGC6NX44CgwE6ShR4DnzBIBsqA== X-Google-Smtp-Source: AGHT+IGvg1Iu9eWAhfXczISjPKPkqJ3qI8I/ys61lTGZIPsPuKeqH3ie8C6RNSFf6K4p78KZ+dau X-Received: by 2002:a05:6871:587:b0:21e:6e02:2793 with SMTP id u7-20020a056871058700b0021e6e022793mr14008517oan.47.1708441944840; Tue, 20 Feb 2024 07:12:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708441944; cv=pass; d=google.com; s=arc-20160816; b=KolF7iCH/dWptr3UQjUw/N/+TZ7D00MJlxVOfkR2DhOr1Sns3Eillld6Gw0yWgBSdy MS08hZByA77GrsZkh+NmHcg6LE89yPZ33/v3zNQin5sdy6h9sVYP78AirSM4LLfGQEG2 JSy92P7UPaWmkVV8KO5KrehgN+jJPjz9jD2H5LbZAp1ooCWqtbttQoqsaVhRg15TN/0E /liIqmgOuJOMDcr8XlRYHjOEV8nP+gWInxs7r1N0HtrUnFqgvdexl71jFNYx/Accuewu EeEVo9j0TsQkuDZUXEuDUTHalWhDsGzc6vhydXmwJTegXODAhCArn6DL6YTBJTsKObvd 9x/Q== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73222-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x27-20020a056a00189b00b006e46560c72bsi3276081pfh.87.2024.02.20.07.12.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 07:12:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73222-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73222-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9AB3F281954 for ; Tue, 20 Feb 2024 15:12:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61737762D9; Tue, 20 Feb 2024 15:11:41 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791431220639243253 X-GMAIL-MSGID: 1791431220639243253 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;