Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4057460pxb; Mon, 4 Oct 2021 16:23:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcquwLYo/DvsY9D3ZqUTq8ogyfl/5oy6L2JmWoYYX1QCsMcH/hyrouJGA2YNsUPBDrY4pj X-Received: by 2002:a05:6402:2682:: with SMTP id w2mr21673065edd.62.1633389826642; Mon, 04 Oct 2021 16:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633389826; cv=none; d=google.com; s=arc-20160816; b=fdrK7Be6GaGM6bSbrkf+K5HXlDTqULfEqAYsEpdNVuSZfGmhp1EBkOFAZ00bJjRTnB k18C+cH36wWYDQMxJ4DjSR3bQT1Vv5L51ZGdqZLmTUaSGj4l103dGOOzGcgUVF3C55Wh GawdW0XO3pfZPpwaDV7IXA/E+BJdAkZurVxTH/PxtuXG3htB1XeVgqucFK1ThyaNaGP8 xZXBZDXWoGAKiQ48St/sXxRqXrvxzQ45+Jd6ulSd/KmLgkMmjv/M/on643Iiyaa+Qu74 SGHwECD86ahZXDBs0SNlqSXC+ln82308O/vHp19QgzV5qfQpSlh6Eb4YewJ7NK1QYExM f4zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ap7d2g/c5ol8Oe3DYfT7H1ZndfdcI4epmYLgX+JPF7k=; b=0g64dMMoRz7Y2bxQKYePSLcHqln11jKcn9qr2lzX4Lec2OXpCVVR/zxDYD5C2vergB fAkmBO2RBwaENvDP9YnNQB4piXg8SgPap6L/ZHkKg9ewhU/oSA9Loe5xrWiqBPKzpYju UQEjwqcj2d1dwl5yzSjRuHSxdg+RjSkcNKX2d5iIj0w00gOANsaGTS2PxMcILv7pLLaR 26xnntduk6PJev2pagN+TANxYGteZjgpOH0i7zmrQ8l5GzHKOWY65hcu6pHQVEaWsM9A sopjkcmXIZ2uepbovsDjFnRfLvUrQQmx27jAqKeQwE/i2JMFBYdHuRayTuV39G81nLld 5uhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si34660581ejs.199.2021.10.04.16.23.22; Mon, 04 Oct 2021 16:23:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235741AbhJDR64 (ORCPT + 99 others); Mon, 4 Oct 2021 13:58:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:36360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235763AbhJDR6x (ORCPT ); Mon, 4 Oct 2021 13:58:53 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3409461207; Mon, 4 Oct 2021 17:57:04 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mXS5I-00EhBv-M7; Mon, 04 Oct 2021 18:49:04 +0100 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: will@kernel.org, qperret@google.com, dbrazdil@google.com, Steven Price , Andrew Jones , Fuad Tabba , Srivatsa Vaddagiri , Shanker R Donthineni , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com Subject: [PATCH v2 15/16] arm64: Add a helper to retrieve the PTE of a fixmap Date: Mon, 4 Oct 2021 18:48:48 +0100 Message-Id: <20211004174849.2831548-16-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004174849.2831548-1-maz@kernel.org> References: <20211004174849.2831548-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, will@kernel.org, qperret@google.com, dbrazdil@google.com, steven.price@arm.com, drjones@redhat.com, tabba@google.com, vatsa@codeaurora.org, sdonthineni@nvidia.com, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to transfer the early mapping state into KVM's MMIO guard infrastucture, provide a small helper that will retrieve the associated PTE. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/fixmap.h | 2 ++ arch/arm64/mm/mmu.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h index 4335800201c9..1aae625b944f 100644 --- a/arch/arm64/include/asm/fixmap.h +++ b/arch/arm64/include/asm/fixmap.h @@ -105,6 +105,8 @@ void __init early_fixmap_init(void); extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); +extern pte_t *__get_fixmap_pte(enum fixed_addresses idx); + #include #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index cfd9deb347c3..e7029db5b540 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1286,6 +1286,21 @@ void __set_fixmap(enum fixed_addresses idx, } } +pte_t *__get_fixmap_pte(enum fixed_addresses idx) +{ + unsigned long addr = __fix_to_virt(idx); + pte_t *ptep; + + BUG_ON(idx <= FIX_HOLE || idx >= __end_of_fixed_addresses); + + ptep = fixmap_pte(addr); + + if (!pte_valid(*ptep)) + return NULL; + + return ptep; +} + void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot) { const u64 dt_virt_base = __fix_to_virt(FIX_FDT); -- 2.30.2