From patchwork Wed Sep 27 09:13:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 9973539 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 5CC0F60365 for ; Wed, 27 Sep 2017 09:14:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 566402911D for ; Wed, 27 Sep 2017 09:14:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B56B29126; Wed, 27 Sep 2017 09:14:00 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable 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 9AEDA2911F for ; Wed, 27 Sep 2017 09:13: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EsadzfuOhWRY4+G55N9NjJf1ws9c1hW8bszXknFya20=; b=cidpJtwUndTgzY 99+pSjm1HG1zjVDSHBeYI5I+qw8F/yyE+tKzhmeo4Dk6XELv9wPfA+sou5RGW85/jGLMKwZmuYvN9 3hT5OquPYlP/dA75d7Up4QX3Xx1cbDHhSIWmnJHYcWX88k/jqzlGYGBV5rYvFx0FoCFs/ShILL8+i CXbMblYnPlt9KRelaOEdzTcZph/0kui+6Ohct55juPpzT7VMZ+eXTU5E0XqyLSzzDmyKZLhxAj+4D FtjvU499xvGMyOTadXDjKcm7rkgIw32yQgKmiflQ61sahHW9fKU2YnA/hDJQA5/JX9ahr77NSYWtM wMaqmpi8skWamVXCek2g==; 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 1dx8Pg-0001vq-AQ; Wed, 27 Sep 2017 09:13:52 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dx8PT-0001MA-Re for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2017 09:13:50 +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 3CD101435; Wed, 27 Sep 2017 02:13:19 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0D3183F483; Wed, 27 Sep 2017 02:13:19 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 4B8891AE2DCF; Wed, 27 Sep 2017 10:13:33 +0100 (BST) Date: Wed, 27 Sep 2017 10:13:33 +0100 From: Will Deacon To: Marc Zyngier Subject: Re: [PATCH] arm64: fix documentation on kernel pages mappings to HYP VA Message-ID: <20170927091332.GA19317@arm.com> References: <20170913180830.8608-1-ynorov@caviumnetworks.com> <20170926184542.t56zpdx2s5et77gy@yury-thinkpad> <86bmlwo842.fsf@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <86bmlwo842.fsf@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_021340_462027_45604822 X-CRM114-Status: GOOD ( 20.71 ) 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-doc@vger.kernel.org, Catalin Marinas , linux-kernel@vger.kernel.org, Yury Norov , linux-arm-kernel@lists.infradead.org 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 On Wed, Sep 27, 2017 at 09:31:41AM +0100, Marc Zyngier wrote: > On Tue, Sep 26 2017 at 9:45:42 pm BST, Yury Norov wrote: > > On Wed, Sep 13, 2017 at 09:08:30PM +0300, Yury Norov wrote: > >> The Documentation/arm64/memory.txt says: > >> When using KVM, the hypervisor maps kernel pages in EL2, at a fixed > >> offset from the kernel VA (top 24bits of the kernel VA set to zero): > >> > >> In fact, kernel addresses are transleted to HYP with kern_hyp_va macro, > >> which has more options, and none of them assumes clearing of top 24bits > >> of the kernel VA. > >> > >> Signed-off-by: Yury Norov > >> --- > >> Documentation/arm64/memory.txt | 15 +++++++++------ > >> 1 file changed, 9 insertions(+), 6 deletions(-) > >> > >> diff --git a/Documentation/arm64/memory.txt b/Documentation/arm64/memory.txt > >> index d7273a5f6456..c39895d7e3a2 100644 > >> --- a/Documentation/arm64/memory.txt > >> +++ b/Documentation/arm64/memory.txt > >> @@ -86,9 +86,12 @@ Translation table lookup with 64KB pages: > >> +-------------------------------------------------> [63] TTBR0/1 > >> > >> > >> -When using KVM, the hypervisor maps kernel pages in EL2, at a fixed > >> -offset from the kernel VA (top 24bits of the kernel VA set to zero): > >> - > >> -Start End Size Use > >> ------------------------------------------------------------------------ > >> -0000004000000000 0000007fffffffff 256GB kernel objects mapped in HYP > >> +When using KVM without Virtualization Host Extensions, the hypervisor maps > >> +kernel pages in EL2, at a fixed offset from the kernel VA. Namely, top 16 > >> +or 25 bits of the kernel VA set to zero depending on ARM64_VA_BITS_48 or > >> +ARM64_VA_BITS_39 config option selected; or top 17 or 26 bits of the kernel > >> +VA set to zero if CPU has Reduced HYP mapping offset capability. See > >> +kern_hyp_va macro. > > What is this "Reduced HYP mapping offset capability"? > > You're missing the point that the location of the EL2 mapping is > conditioned by the location of the identity mapping that is used to > bring up / tear down KVM. You have to express the VA transformation in > terms of both VA_BITS (and there is more cases than just 39 or 48 bits) > *and* the idmap address, not to mention the case where KVM's VA_BITS is > larger than the rest of the kernel. See the extensive blurb in > kvm_mmu.h. > > >> + > >> +When using KVM with Virtualization Host Extensions, no additional mappings > >> +created as host kernel already operates in EL2. > > This bit is fine. FWIW, I was going to queue a simplified version along the lines of the patch below. Will --->8 commit dbf7393b7738a0ba0284551e7b6e014cfb100661 Author: Yury Norov Date: Wed Sep 13 21:08:30 2017 +0300 arm64: fix documentation on kernel pages mappings to HYP VA The Documentation/arm64/memory.txt says: When using KVM, the hypervisor maps kernel pages in EL2, at a fixed offset from the kernel VA (top 24bits of the kernel VA set to zero): In fact, kernel addresses are transleted to HYP with kern_hyp_va macro, which has more options, and none of them assumes clearing of top 24bits of the kernel VA. Signed-off-by: Yury Norov [will: removed gory details] Signed-off-by: Will Deacon Acked-by: Marc Zyngier diff --git a/Documentation/arm64/memory.txt b/Documentation/arm64/memory.txt index d7273a5f6456..ea9ee39784a2 100644 --- a/Documentation/arm64/memory.txt +++ b/Documentation/arm64/memory.txt @@ -86,9 +86,9 @@ Translation table lookup with 64KB pages: +-------------------------------------------------> [63] TTBR0/1 -When using KVM, the hypervisor maps kernel pages in EL2, at a fixed -offset from the kernel VA (top 24bits of the kernel VA set to zero): +When using KVM without the Virtualization Host Extensions, the hypervisor +maps kernel pages in EL2 at a fixed offset from the kernel VA. See the +kern_hyp_va macro for more details. -Start End Size Use ------------------------------------------------------------------------ -0000004000000000 0000007fffffffff 256GB kernel objects mapped in HYP +When using KVM with the Virtualization Host Extensions, no additional +mappings are created, since the host kernel runs directly in EL2.