From patchwork Wed Sep 27 11:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 146662 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4141074vqu; Fri, 29 Sep 2023 09:04:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGU9RDecKxy/y40BzL4ojS4pigheJ4FTMhDtFs7EK6mvK2gBAfnRn4UsUND2yQmxzQAYmww X-Received: by 2002:a05:6358:722:b0:143:7d73:6e63 with SMTP id e34-20020a056358072200b001437d736e63mr4435992rwj.2.1696003448109; Fri, 29 Sep 2023 09:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696003448; cv=none; d=google.com; s=arc-20160816; b=JpKHfN/fawXZ74C1NsZWoSGi0hdHfW4nB4gfT5ND6Yy2t1bJZ4kQn20QP52et2eBTa gK4tJHm1TuVnyheo2rHhLoU56jBgEaY+MikaJr306LyI+NsS8KDK5iHfxHfa2RTZ8uCj xUbin7JxPh5fP4yenbR2Y2aN8oHOI9aq4t8hgdryfPT3SQSxUxsb+clxc10IYWpW+BPw 9CZEZ8+3MVJ3vyugoqeWt/g7BECzRC8JhzF4brOQn7dLilAS4/VSrI8xf/APy/TF9aLh N9dnwPD3v4I2nE38pPwn/G123RlKXgA5DH5vKW/tK3r2/nQGVWLh3Ilf4ro/W1ZfSV/6 ljaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=pCmgpMBJwGuXO7/jIj16/rriK8J2TUjW9FV16THuDL4=; fh=yikR9HT1wx5LLj7DvfR9kbE/RatD/mnQgNUS++qRsJM=; b=rOLGGyOqiYDxcIzEgEEUy21h5eYFflkVvqAiTzLdlaD0KkON8KkCHFIfcfSc71uZw8 x3wtj7kDn5svk+al5ves2w41R9U6V00kvT9gccnEdqSOdMHkfMRNfprRSpW5acutOv/G VXLFWjrJBevwYapdW/muW9JNWsHapW8ULTqQAy3Snac1BZMS07pwp2Erio/ZRy+tC4aX 9wlUCRVDPvwRloCooLGfPWmm0yWRP1FxmSlzOx6mzwkdiqgY8F9KQZXwc/JdbN38tUbT 6rZ7k4dvN0oDkD+R6FF50xZv442oP04l9SnaeRPSjaSyr7I2Sex4olv88pvzEzebnz5l CPnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xvYwAFWg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id j2-20020a63e742000000b00577646e2b6bsi21362813pgk.206.2023.09.29.09.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 09:04:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xvYwAFWg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C0B338033356; Wed, 27 Sep 2023 04:26:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231548AbjI0L0F (ORCPT + 22 others); Wed, 27 Sep 2023 07:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjI0LZv (ORCPT ); Wed, 27 Sep 2023 07:25:51 -0400 Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F90193 for ; Wed, 27 Sep 2023 04:25:47 -0700 (PDT) Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-31f3cfe7269so8348442f8f.2 for ; Wed, 27 Sep 2023 04:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695813945; x=1696418745; 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=pCmgpMBJwGuXO7/jIj16/rriK8J2TUjW9FV16THuDL4=; b=xvYwAFWgBOpMZn2A/TQ/TPaARJvAlsz+gsbyM13hZEcknjHq1/AVWslOBv+4i93X0m GPuXiF/PeXKaxmP4geuPMPHmMAKYfqj2u97qBZVweCtX3gesXTGVdTOUs23VM7VopKXP lAz2m8kt/n08eql+fEGXstU9fZcQtfY1p3afSfX2kJ4zJWL6j9snvD41EtbkHmr03lSZ 2SnYpQhHTG6ZgUCkbKQfAGDnbPC2YjL+6+Ut3TGpOnFOy2B/qst/pzcqe8lnnE4zzD6X D5nhr6Mt7LnIGr1lkZKvWLmOrQtHXfXPZYUe7L/eXrSudHXSa5o8O8SqU35D5e6mv3lg nHzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695813945; x=1696418745; 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=pCmgpMBJwGuXO7/jIj16/rriK8J2TUjW9FV16THuDL4=; b=MYfyDtjd1i7CT7hbmARlkV9QOSWcmPci4vZTBowdRi4/mDK926cGNsIqFCmA9IH0UV rg2cLwah0cHlRDB8U3JXe8Pb+3oEn6OsoSdjnktWZAt1mdHoCNP1Z1uwQKp4onNue/CP aXd85QFD+4EGM3qCL/8pw+yVRjw4mzqTnGsLRVky2OFiqG3Dk/ltxA+ebM2mzWHNRCLl cx08ELHKrMtDB5Fidsl79BY7BBb0DGui0qY7i7Kx8g9jw6qhM8cU7dhImjOfkZVb9z2R vnn9jJvGyUUghjktvS9Tn827mSdYNdLB7bjKCqweDXNMK/rLb5aa16ANiJbDlkxCc+3F Eh+A== X-Gm-Message-State: AOJu0YxgHRBooQKAoQ4jEMKeVtAl+w8IKga02IRQWjhlGXMJu4KobBE6 FlvrD3Nny2mySjDNoIh1CCgDaZKZJkhc4o6dWJjz0X2v99Oo6LRioEalhiOznae19YLBtBSzyai FcaxoYwZkPryimZCLXYammcd1kAx6CRwE/UraiB3rkpwjOZIu4j4wUo1h3/rDrYrnbvQ4AueG3T 0EOAlwp4YSXg== X-Received: from seb.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:31bd]) (user=sebastianene job=sendgmr) by 2002:adf:e7c7:0:b0:31f:97e2:a930 with SMTP id e7-20020adfe7c7000000b0031f97e2a930mr7475wrn.1.1695813945480; Wed, 27 Sep 2023 04:25:45 -0700 (PDT) Date: Wed, 27 Sep 2023 11:25:10 +0000 In-Reply-To: <20230927112517.2631674-1-sebastianene@google.com> Mime-Version: 1.0 References: <20230927112517.2631674-1-sebastianene@google.com> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230927112517.2631674-5-sebastianene@google.com> Subject: [PATCH 04/11] KVM: arm64: Move pagetable definitions to common header From: Sebastian Ene To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, will@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com, maz@kernel.org, vdonnefort@google.com, Sebastian Ene X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 04:26:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778388511331078572 X-GMAIL-MSGID: 1778388511331078572 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 be615700f8ac..913f34d75b29 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 256654b89c1e..67fa122c6028 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;