Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1090978pxu; Wed, 2 Dec 2020 10:46:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwslGrkFByQu5S/sMdHA99/s8/mOE8k1jbfhtSc3UD6xk/hDNh9FQp1v3qlZYm610fB7kNd X-Received: by 2002:a05:6402:1acc:: with SMTP id ba12mr1293549edb.9.1606934773336; Wed, 02 Dec 2020 10:46:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606934773; cv=none; d=google.com; s=arc-20160816; b=diH7VBf0cp4sl8RhTzzcB1D92sFO9QQlwjIai24xhQAG/y2UiHH2dfqpMAhLpLuZcE GNfCQxidPNPCRPGlgALTGhM2maX0VTjPbtAuSTNDoHUi0KMTODRyVGaYbGalUy3XD2IE J6VMng6bAvxGpA03wnUdiI6ElDCtBJ0K8gCT1G1r4o7QOUi8MWbY9ZOFe0ERduxyS9TV ZcJ9hl4nqfny2TA8EFGoG+AHYz7Ayd5E3ymwAOOpqssdvJpEHrsa+grBmxUypG1SQmNC yfLz3ivYfZ9Hv4dxmYMS1EHcwqI5lxe5FV5eefgJQ8RwnDyfova2Xz+kCuthO7+qlcjE WO7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C6am4hqHGk+Vo0ud1IP29/X2lpqX4cUlMBiGKiun4f8=; b=VuwlZX/i+oLV1VhyTd0e1hQ6vdDZ1c23ToScib6I/HiB53YLvHy9aaa74LamJ0MRdU iBznuBKtYp4EszhRUKf6BOKp08xvx/8t9qAruzOVOBYbrmL+B1CLQEBfGpfjGLsrEsnL LxPOwqlwM5Kp8l/BB4V6IusxLAZXHaaTaZcYeWOcBZACVobDcVEI9u73ISYzHYXvT9kj hFNjKh5hdtqvvTNI5If743Nd6626n2/q8mmCvTHAjea+0E60QuVsPIRIHVc5zyz0ik0i wPusS/eiuVyQfP8vwB4LyT8ciN60A5a+5OWlhTnCwKO0nqMRNO4PtpkNcxR1CtwhCReH A5gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hoQt5BzI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si525992ejq.721.2020.12.02.10.45.49; Wed, 02 Dec 2020 10:46:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hoQt5BzI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389570AbgLBSna (ORCPT + 99 others); Wed, 2 Dec 2020 13:43:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387950AbgLBSn2 (ORCPT ); Wed, 2 Dec 2020 13:43:28 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81B1BC0617A6 for ; Wed, 2 Dec 2020 10:42:11 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id a3so11092459wmb.5 for ; Wed, 02 Dec 2020 10:42:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C6am4hqHGk+Vo0ud1IP29/X2lpqX4cUlMBiGKiun4f8=; b=hoQt5BzIWgY7qXX3fYCd3gye89dvXes5OcxZR1oaFHiJQ0uNuctf0EfXcXsXQqJZHi lyMsVJArQ0COsJ3V461k6nveoLNzCLiKZbAL5LUSG4DkZ0mZ4TD+7GR+bvNwn6Oztk+b junmL8dzKUi31Dphr3YG92zBLKleqoCJLPlvFxbGeHyYhHq5d6poYXr1fCeGHotQtBSR HE+mkv/OIjfKLvHevZZVRrqv3+kaP8yMimI6sQpItNZb7BDN+1luqcdtgtiTsgiqIFoE bB/s2tgV4B1tzXzOp8LoYqmDeZbINdCG9fd4QhlOCkBE+gk5X9QdHlI8qQkX3t6UKEwH 0a9Q== 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:mime-version:content-transfer-encoding; bh=C6am4hqHGk+Vo0ud1IP29/X2lpqX4cUlMBiGKiun4f8=; b=Cw/ygCNOruBVd/FEdKWUP03tZuAdkMAE1k6aXRcCiA95TVsbzUgv1CgyY7cpE1m0UH ADqfhjnwSgOfk+eL3mTHxHHEHHnWq4zKR8IHUXHlLcMZH9VDk/43uYCOi5+tek/F/Jfw asw2XJJHNXQz9lycgvynzvzny1Z34nUiE8cTSXWuHhlD8SADK1Rq6icJIfneUOgT0u1K cIjkL1JvL7yL2XWWQWeadrN66SAbMn2iSnDdpL7hvmlA2GJOxGvREPjNV6dUhdor3pUY aDKflS5tST5qJ0kEM73a9jm6HAuncWCbp5PYW4yNq9JrWks5BUEr7Mw5CB1vCDwIA/P5 aHHw== X-Gm-Message-State: AOAM532uVVGJjEPlCuLWa05MBJJt2JOQfqIvaRpooqevvTSJuxBQba9n ejKYT0Hrpoio3SrAqejjoxUcSw== X-Received: by 2002:a7b:ce17:: with SMTP id m23mr4554470wmc.117.1606934530064; Wed, 02 Dec 2020 10:42:10 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:5ddd:b7c5:e3c9:e87a]) by smtp.gmail.com with ESMTPSA id y20sm3136706wma.15.2020.12.02.10.42.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2020 10:42:08 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: Jonathan Corbet , Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, David Brazdil Subject: [PATCH v4 19/26] kvm: arm64: Extract __do_hyp_init into a helper function Date: Wed, 2 Dec 2020 18:41:15 +0000 Message-Id: <20201202184122.26046-20-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201202184122.26046-1-dbrazdil@google.com> References: <20201202184122.26046-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for adding a CPU entry point in nVHE hyp code, extract most of __do_hyp_init hypervisor initialization code into a common helper function. This will be invoked by the entry point to install KVM on the newly booted CPU. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 47 ++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S index 712f57289357..b0856b006bc0 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S @@ -68,17 +68,36 @@ __do_hyp_init: mov x0, #SMCCC_RET_NOT_SUPPORTED eret -1: ldr x0, [x1, #NVHE_INIT_TPIDR_EL2] - msr tpidr_el2, x0 +1: mov x0, x1 + mov x4, lr + bl ___kvm_hyp_init + mov lr, x4 - ldr x0, [x1, #NVHE_INIT_MAIR_EL2] - msr mair_el2, x0 + /* Hello, World! */ + mov x0, #SMCCC_RET_SUCCESS + eret +SYM_CODE_END(__kvm_hyp_init) + +/* + * Initialize the hypervisor in EL2. + * + * Only uses x0..x3 so as to not clobber callee-saved SMCCC registers + * and leave x4 for the caller. + * + * x0: struct kvm_nvhe_init_params PA + */ +SYM_CODE_START_LOCAL(___kvm_hyp_init) + ldr x1, [x0, #NVHE_INIT_TPIDR_EL2] + msr tpidr_el2, x1 + + ldr x1, [x0, #NVHE_INIT_STACK_HYP_VA] + mov sp, x1 - ldr x0, [x1, #NVHE_INIT_STACK_HYP_VA] - mov sp, x0 + ldr x1, [x0, #NVHE_INIT_MAIR_EL2] + msr mair_el2, x1 - ldr x0, [x1, #NVHE_INIT_PGD_PA] - phys_to_ttbr x2, x0 + ldr x1, [x0, #NVHE_INIT_PGD_PA] + phys_to_ttbr x2, x1 alternative_if ARM64_HAS_CNP orr x2, x2, #TTBR_CNP_BIT alternative_else_nop_endif @@ -87,9 +106,9 @@ alternative_else_nop_endif /* * Set the PS bits in TCR_EL2. */ - ldr x0, [x1, #NVHE_INIT_TCR_EL2] - tcr_compute_pa_size x0, #TCR_EL2_PS_SHIFT, x1, x2 - msr tcr_el2, x0 + ldr x1, [x0, #NVHE_INIT_TCR_EL2] + tcr_compute_pa_size x1, #TCR_EL2_PS_SHIFT, x2, x3 + msr tcr_el2, x1 isb @@ -117,10 +136,8 @@ alternative_else_nop_endif kimg_hyp_va x0, x1 msr vbar_el2, x0 - /* Hello, World! */ - mov x0, #SMCCC_RET_SUCCESS - eret -SYM_CODE_END(__kvm_hyp_init) + ret +SYM_CODE_END(___kvm_hyp_init) SYM_CODE_START(__kvm_handle_stub_hvc) cmp x0, #HVC_SOFT_RESTART -- 2.29.2.454.gaff20da3a2-goog