From patchwork Wed Feb 10 18:46:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tirumalesh Chalamarla X-Patchwork-Id: 8274021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2F4DF9F6DA for ; Wed, 10 Feb 2016 18:48:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 318A02039E for ; Wed, 10 Feb 2016 18:48:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43F4820394 for ; Wed, 10 Feb 2016 18:48:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTZnW-0000cM-Hr; Wed, 10 Feb 2016 18:47:30 +0000 Received: from mail-bl2on0086.outbound.protection.outlook.com ([65.55.169.86] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTZnT-0000Vt-3K for linux-arm-kernel@lists.infradead.org; Wed, 10 Feb 2016 18:47:27 +0000 Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from tiru-pc.caveonetworks.com (64.2.3.194) by BLUPR0701MB1780.namprd07.prod.outlook.com (10.162.87.150) with Microsoft SMTP Server (TLS) id 15.1.403.16; Wed, 10 Feb 2016 18:47:04 +0000 From: To: , Subject: [PATCH] arm64: KVM: Configure TCR_EL2.PS at runtime Date: Wed, 10 Feb 2016 10:46:53 -0800 Message-ID: <1455130013-28644-1-git-send-email-tchalamarla@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: BY2PR12CA0035.namprd12.prod.outlook.com (25.160.121.45) To BLUPR0701MB1780.namprd07.prod.outlook.com (25.162.87.150) X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1780; 2:SLu2H9WCMbBTo8++q3Sn/qx8QmpDYlxLBz0gY2JeQDe5wZ9lIWwn5NKsojhgAP+LswIlJecE2Um3xVc0j+ErP1QXq9zee8hLCA8vGWsfddHXsHEIRLDVp2S7dGK4vq5fK6qJ9gp7SWqLgFwa9s0u8Q==; 3:HbxR76GmvmG7gjKi1Ba9E41FvePkhvoBXVXHQdaegekzTzOahrFPjfwWVOElbICdlyoPjo7LrQ8TO4oWYi/1Ydyr2vifYJyyeJd/cjQs+bTbz00qYPM4xeDLwo6JN7wc; 25:UG5nNeKTHPv9XF/001JVbhe+yzxUjfpu1jGHqlGetx5MFK8+RZE9HKkRC7IM9o8qwLJb7PsfJQFR37UA7qfZkK1yI7UCbyaX3B8Xzxx4I9OyZLCYLwfIK8suqtIHCoOHV2gWvuYC4uqTLfK2rxNCfto2GUuJzCU6vi8g4O1ApsJEBdxqacYm52QQjJC69KVyB4m/bIW1k0St8pObUupSpBD2YptfXRh8gKlNBGQcmWzz5+S7sM434+v3o+rXIApBS88kgWD9lJyAFcmdZ5J6emLmnA/gg/s4Pbe8Dj+O/WGZLdGBCB0K0UxP7Zc6Xxli X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1780; X-MS-Office365-Filtering-Correlation-Id: 6e6668ee-06cf-43b5-cd85-08d3324a921c X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1780; 20:0viw1U0g8Wpb35uw4ddSNpy7aljVP/GpDJUY++3xE2Xdk6Ri8i/+hcqPKnIwFfiCK9mmD1qHyEtqMRUgimPw/wtkijvPDHKm9q6AFszKT4VhN5LJmsvzQUxHKGPZdLuzRMSZw37A2YILKMmuKb1G0TQtNgjDb523/b8JOzsIL/NZdvxC0bbENgOu4Ct5ZQItMrG61GyZeki5f1ebVwFuNRWRdAwTvVfrHqckgtwVH9K2dKd6lwg1Z5JxG8AKH2SUPyj+buaOpZbe3ylwDvyS/+OmTEEW8jOt7eJ6dgkx4VtIHrLAyuAAe6xEYLy6KDs/oE6tWhPuurR7uBJCOK+SKHI7G781cy0i/O0BnfwfHzhSuUFl1sKO5+pdODADjJytlfbJzMA2gDw0sQ6FzRUx1bGmdxPr3o3ZrbVMDLCPWPj/eBxZG2P91IJdeEGO+XViaCy8tzsIu+fsxoQnfGuuDFCWJOuqsh30SmwtxTmmQnwbGXUytKzqwjbXDeusxQ54c7rkvF39MCK9v20FXE5oJO7tvV2tYc7U1aEiKIGsodECsVgNfcd9BxMyvZjCWm7oIh42HJ6fz5c8vKo4nrmGcSrrKEKVTgBcKZZKS1pxkXI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:BLUPR0701MB1780; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1780; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1780; 4:DYUhpuOMXwbNPCiR3A6YW/1Xo45RitC+xJl/X+UeQLfWJEBrHX/Bo5Mfo+eoCKU4W+LItBBhc3EctFyHJmpjIOAPrYG94ZBIKB90jTNcPYqvzOuzANEbulZ8nDKAGxNgSgsfPCe1fCHrlxWRea/ATSGX8DWTqVASCLl72z8+bPDb7WoBunC8QpAmdRpIwimogQ+1TxlitWcuTvwEEklLtQbO/2TWQSViKxoN3ITxdjE9W2I1FqBxXKwKF2VULSE3WoKw38GTUbvSC4rLiWXtEQ2krGEAhw65t1laJbuONgGgJrPmecvMPJ7rCp+zceYZ6TvPJfNsQ6JB/HUco88B5Js7HI0kl6RY1JiNmd3f4iV8AzdFPNppwAgkJY7i2FIa X-Forefront-PRVS: 0848C1A6AA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(50986999)(50466002)(5004730100002)(575784001)(48376002)(5008740100001)(19580405001)(19580395003)(5003940100001)(36756003)(47776003)(77096005)(33646002)(86152002)(53416004)(40100003)(4326007)(229853001)(122386002)(50226001)(586003)(5001770100001)(107886002)(5001960100002)(3846002)(1096002)(66066001)(2906002)(4001430100002)(42186005)(2876002)(189998001)(87976001)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1780; H:tiru-pc.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1780; 23:NxBx1wtsxwJyAnTQj4P2LnsF5Nh+nzNbaeluUBb?= =?us-ascii?Q?E+HK+7N7hlXwYsxym0E0HxjgzljDIlT6rDdTKqnO+hzRjEMZUeGuyU/MUvm2?= =?us-ascii?Q?+zLGy9PxiDtk5oo5VOy3Pt4hydcqIjTMNzqYFVB1WUeOzxseuJDm7WW3GsMA?= =?us-ascii?Q?NuDFucMmNIyvbThkQC5MaYbEAUdGogPKeUqMv1MrUc0+Kxul5Mv94mDWR4gw?= =?us-ascii?Q?hBr51ZFJpX3UiI8XI1SwyfL6Zhu1UZ2ADCUGfmptjamqilOQUH+zjIfB5yPe?= =?us-ascii?Q?S5LKB9w+niCs0TVsOHXZW3J0DXeP9v3Jb7yUhmus3X6krVUcLTjNSRzHWZRG?= =?us-ascii?Q?HDHa0BtFI8Kh/LuNR3P6uQ1d5ZEW4GbPuq6IjCRh1qKfmnN029E5vqYgHGOf?= =?us-ascii?Q?CAEw5EZn230xK2PqoOHX72YV9IN/YsWZp2T10wPxI5BzuoB766qGkkWtm9Ex?= =?us-ascii?Q?tNDPc7wr3tYvlMKJbnoWoV5ytK8+YMlkExBtJyizpf+aIScrHBA947IwkmUY?= =?us-ascii?Q?BIAhA6pXXlF/rIr90L+TU9lSaNCRJ/sYiXO3XEV5auXD9cHUe1ItAvGJNKWC?= =?us-ascii?Q?1rsywc7Z6HCgzs5aAn2MP71dPz7MnhDLEJru8u7nSgIVrJxH1si5L1DBwSeD?= =?us-ascii?Q?NZuqCMDO/MIrhwoo/WfZJa4R+KFJIRxpNUYLsn4V9sJuzl/0b0+nHoSPpZ6z?= =?us-ascii?Q?4JJkxUk9w2AU+QK22Pnsb0nQFfoI7gXs1I2XSuNkKA4t3PFD4/0tkIhgCsQD?= =?us-ascii?Q?6R6bV/v4KqSkVJo+rW37QlQgLJPwTHqXi5N5TzlBAv4OBk+qV3Qq305z3fBk?= =?us-ascii?Q?HDCH+EStURd9W1wCEBv2QQKiGxU7zPcFJnkrJqZ6EhqptsKLAsNxp9btnADo?= =?us-ascii?Q?raHH0hnTS+y6MW9Z0FySjS6LEVzBqvwLu2MIivmlheNl1HjS+F/47tFfcv95?= =?us-ascii?Q?OIhmg0MfYxNh3p0/9yTBZAj+lUuyIXbH+wfwVimTe/1+B9ZOi38obVwuJIkK?= =?us-ascii?Q?yQpo=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1780; 5:GlubXZh5BYKOSmF26utrPk7RyFShJ8QXLnxTIB5ThYXKOUeRUYRZjYkPcsmdl8dry8xKtK0tzMHzVd0cNicuQLdMdtd6z8azJEPwYK5H/sAqBxC9Gj70Xp9baBw5CcvI9KpUEnlW0mfEKTd133GyRA==; 24:pJFzYvGGMnmMUrciBi9FJmfrvaGmjN+lflojU9aWECXPIkk/bADXmZ3SGGsbQOPh+zVduEdGalfPSluiHQs4HHNIvanMhOl7bEg+83cgLO4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2016 18:47:04.3607 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1780 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160210_104727_309643_542BE721 X-CRM114-Status: UNSURE ( 6.53 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tchalamarla@caviumnetworks.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tirumalesh Chalamarla Setting TCR_EL2.PS to 40 bits is wrong on systems with PS size is less than 40 bits. and with systems where RAM is at higher address, this will break KVM. This patch sets TCR_EL2.PS at runtime similar to VTCR_EL2.PS changes form V2: - Modified subject line and commit message. - Removed TCR_EL2_FLAGS. changes from V1: - Moved to dynamic configuration. Signed-off-by: Tirumalesh Chalamarla --- arch/arm64/include/asm/kvm_arm.h | 2 -- arch/arm64/kvm/hyp-init.S | 12 +++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 738a95f..3776db0 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -107,8 +107,6 @@ #define TCR_EL2_MASK (TCR_EL2_TG0 | TCR_EL2_SH0 | \ TCR_EL2_ORGN0 | TCR_EL2_IRGN0 | TCR_EL2_T0SZ) -#define TCR_EL2_FLAGS (TCR_EL2_RES1 | TCR_EL2_PS_40B) - /* VTCR_EL2 Registers bits */ #define VTCR_EL2_RES1 (1 << 31) #define VTCR_EL2_PS_MASK (7 << 16) diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index 3e568dc..b5ab1b0 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -64,7 +64,7 @@ __do_hyp_init: mrs x4, tcr_el1 ldr x5, =TCR_EL2_MASK and x4, x4, x5 - ldr x5, =TCR_EL2_FLAGS + ldr x5, =TCR_EL2_RES1 orr x4, x4, x5 #ifndef CONFIG_ARM64_VA_BITS_48 @@ -85,15 +85,17 @@ __do_hyp_init: ldr_l x5, idmap_t0sz bfi x4, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH #endif - msr tcr_el2, x4 - - ldr x4, =VTCR_EL2_FLAGS /* * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in - * VTCR_EL2. + * TCR_EL2 and VTCR_EL2. */ mrs x5, ID_AA64MMFR0_EL1 bfi x4, x5, #16, #3 + + msr tcr_el2, x4 + + ldr x4, =VTCR_EL2_FLAGS + bfi x4, x5, #16, #3 /* * Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS bit in * VTCR_EL2.