Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751438AbdI1TvS (ORCPT ); Thu, 28 Sep 2017 15:51:18 -0400 Received: from mail-co1nam03on0043.outbound.protection.outlook.com ([104.47.40.43]:21216 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750775AbdI1TvP (ORCPT ); Thu, 28 Sep 2017 15:51:15 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Date: Thu, 28 Sep 2017 22:50:59 +0300 From: Yury Norov To: Will Deacon Cc: Marc Zyngier , Catalin Marinas , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org Subject: Re: [PATCH] arm64: fix documentation on kernel pages mappings to HYP VA Message-ID: <20170928195059.jzwglkrx2vzyzjpf@yury-thinkpad> References: <20170913180830.8608-1-ynorov@caviumnetworks.com> <20170926184542.t56zpdx2s5et77gy@yury-thinkpad> <86bmlwo842.fsf@arm.com> <20170927091332.GA19317@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170927091332.GA19317@arm.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [176.59.119.163] X-ClientProxiedBy: DB6PR1001CA0006.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::16) To CY4PR0701MB3828.namprd07.prod.outlook.com (2603:10b6:910:94::34) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c5b98e3-fe37-4505-55e3-08d506aa45c4 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:CY4PR0701MB3828; X-Microsoft-Exchange-Diagnostics: 1;CY4PR0701MB3828;3:OlV59oWStExY6SY/bmve7Di4nfW35TP6w237HzHPkQZfFZpQCE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PFh+a4y1faFyM8Rzd9m8H+ZJp3mUaxeALzuZTRwpw1nHuuD4RAE5FEimLD3qHppJ6mDYK23c+GlAsIk6L2v8nPyJdhuDQipKuEZzFIW3dkQs9fIYjIept6yrXlUbt1X2F+Eer08fzwKhS6auUBzidz8OBnBhj1HYh2bjxgBZceOq8Kt6UxN68umJbfASsXjBr08/HtEOtuc86Tw6BUDIX2TwFwlo7SoT5k+K1SLyXIiSG66GXHLSz5hVwQX0J/iJYj8HQxQHjuT6Xn9+vk6OTzROC2QUMZ3hsXw48bEVzVDA8dt7OBOijn7IBTxCEOdFg06BqSn8AXcDYTv9/WbmOj8JwFbbZsRlwL37prHxHaD0hkQ9WsQTEMpuqsiqkUwLhs2zfvrxccnMoJVNaZetzcqETA=;4:QDebYGvuPIM+DR7+5GJQHNsfkznH+CfAdbolWm9EgmYH1XzgZogSIBgbTYRVAZiy8g6/MLSMORV3SQhpL7DlcnKl9/Yr3lGqFw1Dh2sWyRZL8S8D7/bH/1GNM3TQhLNYc1OSBynOS8x2W3J0NYqNk3xk+gv5GCw0yRlTWAYHDwrfRL7/ok5Ey6MNEuIvaeT4NIQCIoW/WREr+M9XlEtdANEfe8LDInE94Aw+P0GR3OFnWk5TecSqOTwcujbu4xlcCUaRkHpjID0bYs+zl87P113vyT/O1P+kFwPyDLgjDDI= X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(100000703101)(100105400095)(93006095)(10201501046)(6041248)(20161123555025)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR0701MB3828;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR0701MB3828; X-Forefront-PRVS: 0444EB1997 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(7916004)(376002)(346002)(199003)(377454003)(189002)(24454002)(16586007)(58126008)(72206003)(81166006)(3846002)(6116002)(316002)(5660300001)(54356999)(7736002)(23726003)(478600001)(50986999)(76176999)(8676002)(16526017)(81156014)(101416001)(47776003)(33646002)(50466002)(305945005)(93886005)(66066001)(229853002)(6666003)(1076002)(8936002)(76506005)(53936002)(106356001)(105586002)(2906002)(189998001)(25786009)(33716001)(68736007)(42882006)(54906003)(6496005)(6246003)(9686003)(575784001)(6486002)(97736004)(2950100002)(4326008)(83506001)(6916009);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR0701MB3828;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR0701MB3828;23:aeEhBNncLgk5Q2tJi3t/+OTwpKx5pfITPpSz+0M?= =?us-ascii?Q?fPw5wb3yTtlKov/zrnzx7+hgVbHSCX5vAA+r6HuZrKdaL83n9crdkfeV04jt?= =?us-ascii?Q?EInNMpL4b+5gSkycjSBs1fdEN4tZGG9SjQ+IJDuUfJOiQJx0Uf1u+NaQKkAU?= =?us-ascii?Q?QVVz88XJw5C06I+5sNlHgANHlCSuE4DMyLfx0RZCmOvf0mxuhQ6t/0yPUMLE?= =?us-ascii?Q?W3QDuQnZsum3c9CWARDXgHcTishc/V9iy4xN2zR/D1dVWXbyjbWYBzhSuwI+?= =?us-ascii?Q?7MXs3HjA2CydstHhbFvMej+xRLYPadtrdZv8j8mUCRYgf4OzbvPRRsR0RoMH?= =?us-ascii?Q?bOIlZ3cZafTVngyJmFMWpPIfaUe1CmKRzg+OSmwtevf257Zw6wqxTza8ae/D?= =?us-ascii?Q?pQ3+t9idGseg+fpkQbQA/X/IrZCCiv10msgFH4qqPROkTIrOq+PoKHwXDnr6?= =?us-ascii?Q?E/8DC/t4k279c641Kc6R2jRv2Wa8KePLK8JUO55tZaROAgWX+cZXPSq6ZPG7?= =?us-ascii?Q?bhuO3GRQbS1kLJW0+gEAkusF+pyCj8AKNy8eeTulrkmN9K1GexcWa3Jb5zVT?= =?us-ascii?Q?S44WV0d29yih5nX7+Dt9wwib6Fw5OqItviX4O1pkr6CzQb6JbLOa9+bpOal2?= =?us-ascii?Q?bgSzS8+E4/IWUAoLJf3OvLkMvfbHqo09weoN33STuhXqFIXTqFhJFx/nz83k?= =?us-ascii?Q?1wfnub1dHxpftBrSPApd1fxvwwfFe5jmyouLlelsElBotIPLcrhRp8XKZilZ?= =?us-ascii?Q?iz/q7WnaKmcMNZ8jUPMjk8Jj5zT0KtIzQdXX0pnBrOAftvVPjao5X+nFaW2I?= =?us-ascii?Q?jSkRYiEilsgeQuFsAW0R5SV9DCuJYzAvTDaSZ7eh7+MS71EtTvD5jhSOWrkZ?= =?us-ascii?Q?xlUQKEVdLEaPknM+mVaa1g+uTTHWHD5psTwtP/k8TS99rqB0IMkCJ3Jg166k?= =?us-ascii?Q?Hu1hmJeyGW9v1SRa49XdSQECCo8RenwPzJIK8w5qh/lYJcjljf7tytTHHESg?= =?us-ascii?Q?jyid8Gr8bZL789+pqnAAugudYvh+G0CirJl0JgorF1kRiJISUlQHqvgasDeQ?= =?us-ascii?Q?gChu4qyH328dQT7SF9ReDp4XLRA7HpITXXl5oaRFqSYGd7RPw7yq7hOj1sOb?= =?us-ascii?Q?3KESsw4sdPGBa2N6LTC9kTOpdbVgTVnVnTp7lqxsdwN3DySYCr5ObERixjOa?= =?us-ascii?Q?jDyEgb59JjsZYwQDFiNyCko5eDwIHmZat1VgS2sMZfrDDphVdLbAh4weSHb3?= =?us-ascii?Q?jL6SNs3APpH8zLrIQHp73yg0RGEMJu7Nhj/czoGzuA+0mS5CpoEmv4xbLIOE?= =?us-ascii?Q?thYkca+Zvri9fEdULbGDhig/wyKoYHHgeG8zVy8wOfGGJ?= X-Microsoft-Exchange-Diagnostics: 1;CY4PR0701MB3828;6:f4W8IldHfb0QZFD5x8XY6Ofg1IpzZtNCJXZCIkQ7kX4hVEwWnuETfzVtBzolOlNJQtNyThw43gcY1T42Ud5NwmKaJcPkXuB0zGjm9H0rcwEome5sros7k6pBoow5CV4Wv05qmlYa4w3Qr8t2rcyTCItwUEVEYN7OR6U6/ymkaVD4uDXfkyT5E/t8bhMkDzA/RqUbjztsXMVIqJNcG+3Oo+2Uh5mwd8lc5GkeLfSGtrGM6nrL7JUNN9uVC+eMMqi6VXcNTSd20t/FoSLEquZha46Qk1Uax7A7FJKLnXs5iKMREBav5j7OMxv0IQj4OWPpfgyCMds7YSMjrxlal40ZVA==;5:Q8ZNsmFccMW5vd/qTmky67zFl2R+TsZdLVcK0pfA6rR/IogXyLMZV7z/7cJkzCwcZmDgvFDQWioUusgGiR61jpGLX70YEtac9DyOaFD6Jmoxvkdy5F3gDaqXafkQ7AN79kGQV7DZ8KyDaIWORd6quw==;24:/2pdEoF4V2cEH0OOtM0L9RO3cyp4VrwFkwZa4zfVMsostUHz2SiR/8Vn21qlqDh7JN0kI9LhV64W6hEhpvfUPnhwVkXDL/JaP16EGk05wqE=;7:Lp50gY5GTcFDaZuQImAA+odFb8uPYxkk7Vm7y9bAEU6LPft52x9n3DbNvOMXizpYFLw8Me/KouNYGKAy/Ealyg6uVVYewopoOdf9GtBNfZGiOQKltQp1qg0PqRGXeHhPrV8AP7P0+FmiiPam8LljWoETAxh/tFtLYB4uuu+u4xK0sJjBVpgJsJ83B+mKxHIDmeqBvmt8NN8oIAyAcwVgq9pVU8x+jHemG6y1qn2Iqjg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2017 19:51:12.0932 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3828 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4709 Lines: 105 On Wed, Sep 27, 2017 at 10:13:33AM +0100, Will Deacon wrote: > 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"? This is the description of ARM64_HYP_OFFSET_LOW capability in arch/arm64/kernel/cpufeature.c > > 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 Thanks. Yury > --->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 > > 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.