Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1524541pxb; Wed, 4 Nov 2020 11:14:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZbTHxiuWtT2Ee9o/5fOzDeplNb4Wns+2QiI/Wbjga6w6unKirh+ZgpTJYPVsY+aFtOmxi X-Received: by 2002:aa7:df81:: with SMTP id b1mr20709589edy.365.1604517297370; Wed, 04 Nov 2020 11:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604517297; cv=none; d=google.com; s=arc-20160816; b=pu80q5sfgNgWGUGqH7a6V/nriHZUIV1FzwzeAYLOjQKDW9q+Nqg6kfU4ZUs8RibHyQ E58C6U5fiRTTHHT46eYGMQ/L97yyCi1psMOr3YCNqqdtdTdP9FyTqFzBwt6whRt9blUU zMl76UrkiAsdRS1HUNiv4Wwt+UwF3mdf5JBgPA3NIoCgBWglpXp/YTTT5G0HfxsvQe2M pFid27WQk1FzwMB+LvVRc963kAkQ/7cQd4UNEC0CupFAtofrpd4VaYmcjgCWP4pDWsLr g3VUb6sKi5Hp3K4ZSsTpAUCKoqAtCo4ExUnsHmwqHLX+05AE1DS96FUkvAh2AtpgrHfx kKeQ== 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=lntpB9k/GNt3DHKTS6XU+Lzi+3feR2/TDoLFam5OEsI=; b=Avcx6X9alg2xhZVFK5gjf6/UbdjTcRZmVqvM8PL6+qn2eHF2am13dh4ZUxurGdRxTI i36PqnKKINCnCuZtoIVErm+3/y6vy8FVcsOPQhG2sedWI7NwDZPPxfyAnRrznAZTePbq 48W49q0jaf2XiRaaXBZWFnP1FKD+p3ZLaJ95P6bQJR/pHn2msz58pDiDgXMWY+udAjDq WeopXzcEZity0YKpBzNho1tJKSNtSNx7y0NYnf5UsG+fDsiiU1VzWLVz8jEbqMb3Vr9S 2RacNhqTiV6YArvhXnRY1hyEJwZB30cR2BwidFZxk0UOk1He57/npH2fajkfoqD0EP/e lbTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="C7k/+8DY"; 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 j20si1994431edt.424.2020.11.04.11.14.34; Wed, 04 Nov 2020 11:14:57 -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="C7k/+8DY"; 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 S1732624AbgKDShw (ORCPT + 99 others); Wed, 4 Nov 2020 13:37:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732556AbgKDShU (ORCPT ); Wed, 4 Nov 2020 13:37:20 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2371DC0613D3 for ; Wed, 4 Nov 2020 10:37:20 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id e6so5905355wro.1 for ; Wed, 04 Nov 2020 10:37:20 -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=lntpB9k/GNt3DHKTS6XU+Lzi+3feR2/TDoLFam5OEsI=; b=C7k/+8DYRMsN5av0hh1p2auJO+TujqPhkBo9BQOirCYTD1fGH4MKjmZ90c5bMU7Dvs 7iXLOCA5XTk7X+s6+G/FADEg1vlFiJNnSKQpNHFzsfJuI/egt0VB2R4bGqay6pSEtMzV mugN96IDPyJUl9J8nZJmCNxxPlcS7q0g1lFjISxMbqwVf9hoORqeGPgKxbvioXh+Gz1z LKEVEAz2BDBUn3fCSiGXaFJKOrRpL0Tc+GLucbHuJ/FMZdaIvRy4x7frQIOcGnejA6Lw PAlCYBfM7fvOkTtGmNbT8j+d/lf3B55XUIwrtUiNVEb55mNzk9xPRhDXqT+vgc88HxfL Zb+w== 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=lntpB9k/GNt3DHKTS6XU+Lzi+3feR2/TDoLFam5OEsI=; b=pPWdfGAbJtJg6YJawbyiFQrORF1jZVoNunXbk/wo5Lha2bdJndYwRfjF6RQpKthiSn UyXDyRB6F5ewgBrOjDJXINOrxQx27tbIMS3Sdas7WwUviuj2G7hBnORpYV1g3kempctm QGBBHUuJ353vYiXzPY2bQ/NOdv6fjgPP9xZ7Pcu8GJXSoBRgCqjIpwR2C8Egx9XZGrbp xP3GrQ2mE1XjWscJeY2fZX8H9QV+SJIz0g9jo6NttuiDGmWJR9aXlnGNgLkX7aZ0pKDz U7puUUp/tB488c2x68dmjvBPQK7HiCEGS+LCDb48bPLj1H679EnecO5WeRUuWKy1gt+P VVhA== X-Gm-Message-State: AOAM5302kPfU5WfPfjEJQyXvB5WySAoFhUijxEK1m6bkV8Lp0h/IjOmV zrug7Z5T7GkDTj1oS4bvm1xTfA== X-Received: by 2002:adf:f104:: with SMTP id r4mr33995916wro.202.1604515038644; Wed, 04 Nov 2020 10:37:18 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:c8d2:30f2:53c6:bc2]) by smtp.gmail.com with ESMTPSA id r1sm3905404wro.18.2020.11.04.10.37.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:37:17 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , kernel-team@android.com, David Brazdil Subject: [RFC PATCH 19/26] kvm: arm64: Extract __do_hyp_init into a helper function Date: Wed, 4 Nov 2020 18:36:23 +0000 Message-Id: <20201104183630.27513-20-dbrazdil@google.com> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104183630.27513-1-dbrazdil@google.com> References: <20201104183630.27513-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 | 39 +++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S index 6f3ac5d428ec..1726cc44b3ee 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S @@ -68,16 +68,35 @@ __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_STACK_PTR] - mov sp, x0 + /* Hello, World! */ + mov x0, #SMCCC_RET_SUCCESS + eret +SYM_CODE_END(__kvm_hyp_init) + +/* + * Initialize the hypervisor in EL2. + * + * Only modifies 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(___kvm_hyp_init) + ldr x1, [x0, #NVHE_INIT_TPIDR_EL2] + msr tpidr_el2, x1 + + ldr x1, [x0, #NVHE_INIT_STACK_PTR] + mov sp, x1 - ldr x0, [x1, #NVHE_INIT_VECTOR_PTR] - msr vbar_el2, x0 + ldr x1, [x0, #NVHE_INIT_VECTOR_PTR] + msr vbar_el2, x1 - ldr x1, [x1, #NVHE_INIT_PGD_PTR] + ldr x1, [x0, #NVHE_INIT_PGD_PTR] phys_to_ttbr x0, x1 alternative_if ARM64_HAS_CNP orr x0, x0, #TTBR_CNP_BIT @@ -137,10 +156,8 @@ alternative_else_nop_endif msr sctlr_el2, x0 isb - /* 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.1.341.ge80a0c044ae-goog