From patchwork Sun Apr 23 17:09:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695003 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 A4CE760245 for ; Sun, 23 Apr 2017 17:12:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E47020564 for ; Sun, 23 Apr 2017 17:12:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83232212BE; Sun, 23 Apr 2017 17:12:21 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00EC720564 for ; Sun, 23 Apr 2017 17:12:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162154AbdDWRMS (ORCPT ); Sun, 23 Apr 2017 13:12:18 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:36883 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162778AbdDWRK1 (ORCPT ); Sun, 23 Apr 2017 13:10:27 -0400 Received: by mail-wm0-f50.google.com with SMTP id m123so50341206wma.0 for ; Sun, 23 Apr 2017 10:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=okIXUhFFTuDaYNING7xpl8YIQud6C7XxMV/YlzD4WVM=; b=jDrAO27k6KrCebcFn+fggg67DAdqP01X1iV7NJApGvUUGNe7hk2YUPtDvPn9WyV5tb fwDDM4a0YYl0haLSMHdPLft19m0UKQy/cQ7PRQVeRQwLneOyoPNg2JyldjhLNF+qqryd KbWOBqVbiEI0M/OGwnz2nJ4JHVMObvjCASK4M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=okIXUhFFTuDaYNING7xpl8YIQud6C7XxMV/YlzD4WVM=; b=sQq3ARC04HAprbnPMyZiJt9A5hPdAefg5mCq7Ms8se1CjBnIJpzvNFvTOSss76m6Ti 20pjrhIrXaDvx1et/8fdK/hsVxTXVbAGuk2LeJyTdsLghrs9PNxSqJ8KZD6ERW3EB7RZ OyfEUqtKUTantMoL/xAZ1Cugf+EzWQv+wvbd92n61VhFFSe3Ewus7NpSZNQpZiAChsjU XAdIRhBZYVGuOD4Fzll5/oGs9fPAnz+k7UbyriZlMa8VAvBLa7DrJaTQBs1g1wcwQB4Q RvNT/9EUbm3lSZoZR9PugN13+EELYaMtqt0pj7Rsr+i+APpfaKt5eyOEfaAia4FLxTi2 SAHQ== X-Gm-Message-State: AN3rC/4/U2zfT5LJP3e9X9FYaiCno7a4f3M6ZLpyKqUqVlw77uRJqf8Y +7L3rs+URPIi6TlO X-Received: by 10.28.155.203 with SMTP id d194mr6502477wme.73.1492967426638; Sun, 23 Apr 2017 10:10:26 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.10.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:25 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall Subject: [PULL 52/79] ARM: Expose the VA/IDMAP offset Date: Sun, 23 Apr 2017 19:09:02 +0200 Message-Id: <20170423170929.27334-53-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier 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. Tested-by: Keerthy Acked-by: Russell King Acked-by: Catalin Marinas Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- 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 4e016d7..e98a2b5 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); }