From patchwork Mon Mar 6 14:24:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 9606657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A253B6046A for ; Mon, 6 Mar 2017 14:32:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9617826224 for ; Mon, 6 Mar 2017 14:32:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B0AC26907; Mon, 6 Mar 2017 14:32:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4D98526224 for ; Mon, 6 Mar 2017 14:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=oUKBqEinEEwiR9JwCBXziQefnKRj3nt0yxpys4NiUZQ=; b=MXcF7i7UqO6iKzQ+ndMe9+UTZ2 R1t+TKL/Y7qRq6/8jA3Hgf9afxRQmWA9xjb+2PlceHl4+cKISGZiPYInWBxnilDT6fKBYLBvazsDz hfsetJz1Zs5hPJ3sxSc37j3+8B0PtdEvb0KEvn2DqxbpOWrRKVNU1KLnp9wuUlha5B/A3eY7qrCk4 PQTp1U3poSpFJ2EjbAwcFzld9DYEgSkwPxAsUugWPyIC5XSva0Df0Z5UovVdmq8/zhQkEUdq1DOq/ DahPCGgnSIFHKX46FD2ktBK0F4uEELGluDFxsZJehfk7tCum1caOVbE71JTu27k4jO10K0oRc4QF9 RPdJzukQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ckth1-00053M-ID; Mon, 06 Mar 2017 14:32:55 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cktb4-0007Xg-7V for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2017 14:26:48 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 690A4174E; Mon, 6 Mar 2017 06:26:29 -0800 (PST) Received: from on-the-bus.cambridge.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6A7E63F220; Mon, 6 Mar 2017 06:26:27 -0800 (PST) From: Marc Zyngier To: Russell King , Ard Biesheuvel , Catalin Marinas , cdall@linaro.org, james.morse@arm.com Subject: [PATCH v3 12/25] ARM: Expose the VA/IDMAP offset Date: Mon, 6 Mar 2017 14:24:45 +0000 Message-Id: <20170306142458.8875-13-marc.zyngier@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170306142458.8875-1-marc.zyngier@arm.com> References: <20170306142458.8875-1-marc.zyngier@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170306_062646_425023_17A3F5ED X-CRM114-Status: GOOD ( 10.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The KVM code needs to be able to compute the address of symbols in its idmap page (the equivalent of a virt_to_idmap() call). Unfortunately, virt_to_idmap is slightly complicated, depending on the use of arch_phys_to_idmap_offset or not, and none of that is readily available at HYP. Instead, expose a single kimage_voffset variable which contains the offset between a kernel VA and its idmap address, enabling the VA->IDMAP conversion. This allows the KVM code to behave similarily to its arm64 counterpart. Signed-off-by: Marc Zyngier --- arch/arm/mm/mmu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 4e016d7f37b3..e98a2b5c4e85 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -87,6 +87,8 @@ struct cachepolicy { #define s2_policy(policy) 0 #endif +unsigned long kimage_voffset __ro_after_init; + static struct cachepolicy cache_policies[] __initdata = { { .policy = "uncached", @@ -1635,4 +1637,7 @@ void __init paging_init(const struct machine_desc *mdesc) empty_zero_page = virt_to_page(zero_page); __flush_dcache_page(NULL, empty_zero_page); + + /* Compute the virt/idmap offset, mostly for the sake of KVM */ + kimage_voffset = (unsigned long)&kimage_voffset - virt_to_idmap(&kimage_voffset); }