From patchwork Mon Dec 18 13:58:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 180442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1258930dyi; Mon, 18 Dec 2023 06:02:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGklUnWEz7tAcssXTJ1i01S/9R8u3AAWJe6r1x50rdygutJ3dizsSkeyQLEH0lAOpOfJsBe X-Received: by 2002:ac8:5f94:0:b0:400:a2b8:1c97 with SMTP id j20-20020ac85f94000000b00400a2b81c97mr19961533qta.17.1702908131523; Mon, 18 Dec 2023 06:02:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702908131; cv=none; d=google.com; s=arc-20160816; b=GshXDY0OEAirSX7PVVfHEJ7/kLbhf7Ah7cpD3G+5zOftuWZG+Y3mOsiZbZEOeB3xWW sFgqUsbMmMotc4mjmRL6AngN1TBwCS5xr8/gz8BuW8aNecqqI1vp0k8XHrdAbnO82pa8 2lwrpIc50v/egBwLZYJs4z0FYJ2R/cH6THZnggX1zijs1PzHrAMkw/huBU9yvswII3fa lz0Bte8sBgkG+Sm3+fhTxByNJT/eX+vDxsewfaowNkr1/hGJye4CNb6hfr7N8t8M0KVl Qhz1JduYDknY8M4ZyAUosuWLvBVq6GdHYDjRU8LX/YXUZ02ZsdSuTHL2LejSDvkuJUoM XQuw== ARC-Message-Signature: i=1; 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=rOYwKOEiNUEli62sB45rLYKU5arboivvkJa3j/TVfbA=; fh=4RXM1FFjr/2FDx2f50K7N78eRirWaG15JMQkQwGVT00=; b=e2Lt8NA1lSR3MKjM0bVcKIwjFvIjmnHoWo03BEz1v9Ug67zNlx+erQPw5QmWAWuEY0 vAy9BAoPhUnapvMJtgM6ZK9oMMq2km5jGXdeWE++lrkpYQSRkWcC7G2ZcymfKDy2jvYG l816qv+m2IrX59YVZdmFysizhMw+6500GJirDnCFESpVj1llCgChf0rvAPn2v52WGA/X rq1DYJZUfSyUkK4GLcQoFdw86mpdCvzovUV8eG/iXNKZIRvn1sH633GsmmHfC/9Li5xK 7goeKjUHRG8CYlrjs4AqcK2iRkddHfHNT38dhjTR/pX6WwQfSP5IoRv3fOjkiCocfL73 kr/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=e+ttUet0; spf=pass (google.com: domain of linux-kernel+bounces-3793-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3793-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gd25-20020a05622a5c1900b00425826ea01bsi26450482qtb.212.2023.12.18.06.02.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 06:02:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3793-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=e+ttUet0; spf=pass (google.com: domain of linux-kernel+bounces-3793-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3793-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4F5281C24999 for ; Mon, 18 Dec 2023 14:02:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00A361D136; Mon, 18 Dec 2023 14:00:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="e+ttUet0" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.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 980C33A1CB for ; Mon, 18 Dec 2023 14:00:01 +0000 (UTC) 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-wr1-f74.google.com with SMTP id ffacd0b85a97d-332ee20a3f0so2752947f8f.0 for ; Mon, 18 Dec 2023 06:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702908000; x=1703512800; 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=rOYwKOEiNUEli62sB45rLYKU5arboivvkJa3j/TVfbA=; b=e+ttUet07GJyopmWfk4cM1KPq4yTgK+WsfN8R7cNaa2OVNZbk0SjPfPuIINK27E9Ew OzvpC2B4XUEAAWilt/mddKmbUIKwgIAYE7wZrvim7UH94wuTDS9PAde+VFWBojQYEgDV /zrR6VB5cnGDtHGr2URo/nFnTrkqz/LTs63rflIN5wIY6IV4fosXhosqe8kpGu5R8msS 4tE54LxoezVSyPyisyUQpa3adaYkHegS3G/3yahod5QvBQ5mDKUFpcklze8QXLPTD3Tl gaINEkqNABuq/NGYIiTe32C97828jrwAUKBIS2hCRYINiHqUBZrT4xpIinFnIOyCbVn6 dn1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702908000; x=1703512800; 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=rOYwKOEiNUEli62sB45rLYKU5arboivvkJa3j/TVfbA=; b=sjhmqUlpEjuLsapRfedBnmxEohWcXwV+Uhc5kUiGr20TFlUNp31SXgnYAfdwPcqzaG 9Xokvqgg96nxxW+GIm8TOgj8NjY5qFfcshegj1jN1Esyz9VsCGMoBcSKz7aycBWVzXS/ 73JfVO6nFrg1cVOZMDohBfEuon0xQuORTvaSlGFXNBp+SAqxFnOObuE7TgxjiprWsoT/ ShCINNb0vWRDDqjmI/Krys/RUDqFF42aJs58aCGBc8VtZb3nXO6Wtpx7aAP4Ha0P2PE2 +EntM7SWmBe8G+CUc09QNdHTHxBQfAFK+cmzKfDG8G8nMH04ntvDqmfkp6dpVZZ82fUB OyVA== X-Gm-Message-State: AOJu0YzlILUTS3dnaJ5KyMXxBExweQiyxgWG7r90GjhUAjarNEgIHOTZ aj8hsVgufTsFQtrKrhnZmPdDtsHIR/0CdvlL0Ho= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:6000:144d:b0:336:6ccb:c32b with SMTP id v13-20020a056000144d00b003366ccbc32bmr3131wrx.9.1702908000205; Mon, 18 Dec 2023 06:00:00 -0800 (PST) Date: Mon, 18 Dec 2023 13:58:56 +0000 In-Reply-To: <20231218135859.2513568-2-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231218135859.2513568-2-sebastianene@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231218135859.2513568-8-sebastianene@google.com> Subject: [PATCH v4 06/10] KVM: arm64: Move pagetable definitions to common header From: Sebastian Ene To: will@kernel.org, Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org Cc: kvmarm@lists.linux.dev, 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785628596967382889 X-GMAIL-MSGID: 1785628596967382889 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 f73efd8a8..37f2a8532 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 82fef9620..ccd46bf56 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;