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: 9695095 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 26C2960245 for ; Sun, 23 Apr 2017 17:17:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12BFB228C9 for ; Sun, 23 Apr 2017 17:17:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0769D24B44; Sun, 23 Apr 2017 17:17:30 +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 B0A5D228C9 for ; Sun, 23 Apr 2017 17:17:29 +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=fco+G+4OqG051Cbr+1JgOIL6PWki0DaPrtsJLCjFrCI=; b=H2XB5OzfSM/mxhP/IAzyyF6r94 OL5kdA/GDje5AXQKVVZfAH62iKPY8facS2rUd6/zWjQTzurqTguO6G5kj0s4o+M8YZDwz/miX15lb KziZB/m3zr+vnp+OoHImotOjvSxiqfLI/ahNd0qNIqBSikq7m3mHtsr+CKtLD9p59utH5i8JjMWi/ WNb923LSDi0zTxI+tjayJx8ZAEH0vqFKAGahKB1jdCpdeTjpzENqxCK5Ne/lmJXL4Y15sevFzGGJ8 67QPrGQg1YA/Z63AaInOuI5oKdKsuSErSc4NwPzSKS8usB3IJV4rryf3AJwFaVR2Bxah8yzSe3wJA srOCLtGA==; 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 1d2L8a-0006MH-Lh; Sun, 23 Apr 2017 17:17:28 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2L24-0006Oa-23 for linux-arm-kernel@lists.infradead.org; Sun, 23 Apr 2017 17:10:54 +0000 Received: by mail-wm0-x22d.google.com with SMTP id m123so50341207wma.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=f/kEAVWbdtW62hSHI7YmLv+pxOF8MXK94+bltia/9KOjPQtpbnxH2d2Mfc4r8ZcFFF Pj828Q3Su5SAt4dXcdHUg4uqqn9Lpg1ktRy/keHwBTJvnStnsTj7DAujOARvNJ2g7ccC 8zLCsTLxDrVnUS91Y48igPrlevVay3LEOIAvkAWW2uDKOW5/5qC5fkJJfF5yUyvw8FgV XDbrELmo4XjdZu3UUf8S87EjaFdGYvDOMXmp+1j1d3TI06LJ7TfkiYxZQmU7vPda/aIv wxo/YhMAf/unVtuGmK+I5s632G9YLAponGeSInfz0VFET6qDxsfmXMj/hGTxusMsuKRa aBRQ== X-Gm-Message-State: AN3rC/66pZHwyntTnN9HheX2MTNWxqo7XmhIdsBiXv0hoU1tyBeFRQrl BMVyUwv/06y+onV8 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?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170423_101044_548529_F0EDA6A0 X-CRM114-Status: GOOD ( 11.28 ) 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: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 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); }