Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp114379rdh; Mon, 18 Dec 2023 06:03:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IExUT+SlTRBbyrmWGu/bpvVDyha2+8qa80iHsi6WXX5URGWLV/kGDcs3c9QIJ8tr+PRw12a X-Received: by 2002:a05:6e02:3093:b0:35f:ab80:9d9f with SMTP id bf19-20020a056e02309300b0035fab809d9fmr2426073ilb.7.1702908203370; Mon, 18 Dec 2023 06:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702908203; cv=none; d=google.com; s=arc-20160816; b=GDTuRllCvjgVMq5t/6USvqMsF7u8wwsjJxIeffsyvComBx85rjE8hgoU3uqsSRRhaJ L4unHgT2kIhNhWaJWnwYk7/bUzFDSfjLKEuNAlC4lGT0TzJALK3JVPDrIgynGYnLlcvc fUObQsDj4pi5bn326N0ZcurnTBbto3/Vd9tdvJgaEzcImsAkDONiYDM6ED4MnJcNtl0b UQV6YcB+/ulc2CW2iu3SUBWbRFN7j/c6VFLjpPVS/UlowAcEVJLwxywnw5WG3l+h3de6 wMUnjYxT/qJdkCEuhgrhhEaWenzdKf3aKB+h/nlkwBL6skAiOC9m8L3kD4BuuIf/ISOM yu3g== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3793-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x66-20020a636345000000b005cd9243c104si2357483pgb.295.2023.12.18.06.03.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 06:03:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3793-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9D9CAB2227B for ; Mon, 18 Dec 2023 14:01:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0154749882; Mon, 18 Dec 2023 14:00:05 +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 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 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; -- 2.43.0.472.g3155946c3a-goog