Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp644295pxu; Thu, 26 Nov 2020 07:59:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUWHA57pP9RMXSK8RsfRnBk3hGyXxauUq9NFe6WlYBvMAmhhtuCyMyXjNR8gU3dElKyqeU X-Received: by 2002:a50:a689:: with SMTP id e9mr3130937edc.233.1606406395907; Thu, 26 Nov 2020 07:59:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606406395; cv=none; d=google.com; s=arc-20160816; b=fxbgt4kyBj/FnBEh6ykjc7/nF/z3EBCKYPIg+W1uJ1n6n1w5QM8RJdlm64J0BRrk36 vhxQTZUuFqIbBJlGsxZ4/hmwSqjUBja4eqjdLClupFuttEVOk6hVpD8HsBUynMH+AzEK 50fmXhpaY6oRX1m9ZLlhcgBeCoyZEqo6vyo3jbG246FpVKLOc+0U7T4vDmQRSkEpvTDc WknOjMaw6PVW7Xtthvg5RdgnS8Ns2DKvC+eYf9bNxU9/RqiNkUESGqLTRRyM3E+kZHTb h8UGdkC6jonm/y+CJM9vRyqFplnZOjg++jAnMXMmxxanKrrO5yicEFtv5ZtR205M/TZU qzZw== 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=Pb+ABw8dDs4PbD0OqVCMWkPKj8CiLKPB9XpZniqrrrk=; b=z7Vc7UL9nrA+7uOh/PLoPzCOSg2cW2BUq/JtnOjUywm6qTyYMmpZXVd6ZI+muN6SM8 HZevtaTKAZ4IchkkxWp4g8oamP46FIoK0rCBm0+obndjGxIt7r7xoQdCBvHLnKC77bJB X1ZcocyFnLt+3gdtIo+2hGZoMXURPaFDWWrjuquUmOwH+kxxrOm/e3JVadvJW6Opc0HD wZ83VGApZPatLZMFjE3U4YFWSn8q0PCTL4JKWq+W/1Jm1zH+gq1A01WqxoQe+lViqDk7 BOQoKlVWOkWmfr5EMI18VBWNyyPe10+4ghei173ds9IwDHur2pfaac9LUB9Ta+MKgxLV Au7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="pbb/yCmE"; 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 k15si3201824ejp.554.2020.11.26.07.59.33; Thu, 26 Nov 2020 07:59:55 -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="pbb/yCmE"; 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 S2403809AbgKZPzF (ORCPT + 99 others); Thu, 26 Nov 2020 10:55:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403782AbgKZPzF (ORCPT ); Thu, 26 Nov 2020 10:55:05 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC986C0613D4 for ; Thu, 26 Nov 2020 07:55:04 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id k14so2663805wrn.1 for ; Thu, 26 Nov 2020 07:55:04 -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=Pb+ABw8dDs4PbD0OqVCMWkPKj8CiLKPB9XpZniqrrrk=; b=pbb/yCmE0LnjVE/ExQ/pJl7w83OT3LzqwQppQ3HqidXv2SfAJ9Nb1cPbq9a8ZZI4YA X5M/PUSmd0+3fpTDL/InmQ2mCDNpr9piPAuo7p6crV0IeKBHx/ZTIZOgH/esG4VTPy2J vlfVzxrBEn8n6D2S5rPjeXvv6YodXNpHneVC8Nwje61zvBtJxL9jKl+VgVh2Lahc+ksZ iHqtiBbtPHB1T5RFyjVg6EG7jdM6DUm23grUSANYdwjKev67RJFOYVUfOzyGvHvg8snO dasZpwdSKPiXhpsLurhfNgNIsnFGj3Bo6vrCCFJGRdAo6Tb+BYMNEOrvmCeSdXjXLlsU jk1Q== 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=Pb+ABw8dDs4PbD0OqVCMWkPKj8CiLKPB9XpZniqrrrk=; b=CzPxulnYTxqWEd/5H2LOVMBrGF/A89Rnz3qRrD9t5zljyvzRaISTY44Vyuc5ZKm+Jd 6nLTPCX1mkWJGEuXxmpaGA3qomeqS2xxHeyIw9Dt4xHDYr35G1stM+jxZ7A+qUfkXrz3 8MUcOkcJzxIlcbX7RxuKe+d4/SDbE0s2/PO7xCFqphxaff+jNT0q3leSIcK4Bw9rSd2I r27cBPO2C3hz/1wdwljrmFytjzugPB/tw9rPdkBl5IrSD712lEAzXA+Q9zA4BB86MXIM 6r6gRFp0rALREqVew6a1v1IUx9ZY3ALP4AxiDjPkAUP5vyvSBUQFLJoOeB4+Y3IwSH9q RghA== X-Gm-Message-State: AOAM533PhBGIH/XLjjBzARdVnIU7xIaOJ21dw3LWjshTgE0p8ySYIyMn LUawF1BQFR3b90aYsOhDee1x3w== X-Received: by 2002:adf:eb4d:: with SMTP id u13mr4757138wrn.146.1606406103382; Thu, 26 Nov 2020 07:55:03 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:f008:704d:8d4b:9951]) by smtp.gmail.com with ESMTPSA id g25sm8706624wmk.5.2020.11.26.07.55.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Nov 2020 07:55:02 -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 v3 17/23] kvm: arm64: Extract __do_hyp_init into a helper function Date: Thu, 26 Nov 2020 15:54:15 +0000 Message-Id: <20201126155421.14901-18-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201126155421.14901-1-dbrazdil@google.com> References: <20201126155421.14901-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 | 35 ++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S index 77c983aa90fa..98ce40e17b42 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S @@ -68,13 +68,32 @@ __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_HYP_VA] - mov sp, 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(___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 x1, [x1, #NVHE_INIT_PGD_PA] + ldr x1, [x0, #NVHE_INIT_PGD_PA] phys_to_ttbr x0, x1 alternative_if ARM64_HAS_CNP orr x0, x0, #TTBR_CNP_BIT @@ -139,10 +158,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