From patchwork Wed Nov 4 18:36:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11881903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4CECC4742C for ; Wed, 4 Nov 2020 18:41:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57D9520739 for ; Wed, 4 Nov 2020 18:41:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HIDRAsb2"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="K5lok9pX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57D9520739 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TL/rne2oGrE5feUHRLIGs8Cal4+HQuTCJTnbQJacSek=; b=HIDRAsb2MWBbmO2+LOx2u3cRW ROROxUG4k3OCWR286xsTvStkxa++uZ3rGsjLwHLErD4OyXzKbGx+sn5J10K0CDIwysbHOP3Bdak3u x8MWDnLOg0t4l0Q81PeHdeLPgDtdYMEj7+mP2831dKUNJNKYZwBS+rRWSKNMNnD3m1tPLFo+6+dHx EHakO9XnSJFdReaVVyZzpTTWGQg/VsCbgAwiGhzuexATG/TBioYye7OhxFb73hy6azTwZF25nSq/W tAtQOINpG1LuyEL1NHR+VyB0hTVPItNJm2SXcWDy8741w5gOZvqt8+6KLGBmzGXYl+kqy1IfR3clv rmMIMUVwQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaNho-0003o0-JE; Wed, 04 Nov 2020 18:40:24 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaNeu-0001ul-Bc for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2020 18:37:25 +0000 Received: by mail-wm1-x344.google.com with SMTP id s13so115764wmh.4 for ; Wed, 04 Nov 2020 10:37:24 -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=D2iY/f0Emp/4ip0BhAwKDaO2Rz6fYg/GzmDoqFEl2bY=; b=K5lok9pXB0Y/9UmYflOIZMDSkGGd3u23Q2HOsAtpB2GQgdWbczb37MrT+zOkXv17wT XLC9vOedqgdzZukxYXUCfWK/KmpoLoHZtcqTjOfbzpJCWVRhTNn0OILGLegfnc3HNByb EiNdcjUUM9WM0ul/8L3ypEWnLJH522G2M/Whv3nq2waX0fzH+tavrd5hfyBwCWZ47rIH M/e50E9Agk8EUpEMjPxiQU7m7K6l6KIaF84T3dfGn48L0baNZQrBvimX4U882V+fCi24 OWGZhINKWlBuvULKaAafjWdNi+d8GRiezt45uezGFm5E9OxwAXUa2w/uxQNhsQbs+D1U 3Czg== 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=D2iY/f0Emp/4ip0BhAwKDaO2Rz6fYg/GzmDoqFEl2bY=; b=pkvGxcAhDghXfavncSJ11YCL+yt1dxmOjdFrBbPLXAI0AmP5c9pBr16f1SfyN4d//W RH5X71cK3fQ55h0JX1+yhsuE741pQD1D29Pma5ZU7l5MjkXgvlBkzZ9Gjx6uU8ooKOYl VwHXtTMFlegOBlCLYgLgPiU/63EX5LyMmM7TPmceioHpaeDBfhAh2ZbikGJn6zPCnQO4 o+j+KXuQr24/AE3a70kFwdWhjbM/ZHyg4Dvwvj1U5nhoDrzEqw7LHjhLWX+uG+jyteLj WyPoKdjWrAzKBZcTC9HIdPE4I/9bZZ5ZiSDlWRX/F2HmmM3AAXcHBG9NCqUwTuthE77A uHTQ== X-Gm-Message-State: AOAM532TXB6RrwVLnFScduBhhORTighTRzAmI4eqZvvtNIuEukz7b9qP bzD+QgtUZwedcZTridORRV5Ndg== X-Google-Smtp-Source: ABdhPJxUC4D2whchkuH0BO+rZJkzPCz7MjPZCo5o94FSQjlFtlPHCIT/1kpZb8MvemUgYYaqMdixvg== X-Received: by 2002:a1c:b487:: with SMTP id d129mr6273792wmf.38.1604515043233; Wed, 04 Nov 2020 10:37:23 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:c8d2:30f2:53c6:bc2]) by smtp.gmail.com with ESMTPSA id d3sm1049184wrg.16.2020.11.04.10.37.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:37:22 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [RFC PATCH 21/26] kvm: arm64: Add function to enter host from KVM nVHE hyp code Date: Wed, 4 Nov 2020 18:36:25 +0000 Message-Id: <20201104183630.27513-22-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201104_133724_457625_A265E9C1 X-CRM114-Status: GOOD ( 15.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , kernel-team@android.com, Suzuki K Poulose , Marc Zyngier , Quentin Perret , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Tejun Heo , Dennis Zhou , Christoph Lameter , David Brazdil , Will Deacon , Julien Thierry , Andrew Scull Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org All nVHE hyp code is currently executed as handlers of host's HVCs. This will change as nVHE starts intercepting host's PSCI CPU_ON SMCs. The newly booted CPU will need to initialize EL2 state and then enter the host. Add __host_enter function that branches into the existing host state-restoring code after the trap handler would have returned. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/host.S | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S index ed27f06a31ba..ff04d7115eab 100644 --- a/arch/arm64/kvm/hyp/nvhe/host.S +++ b/arch/arm64/kvm/hyp/nvhe/host.S @@ -41,6 +41,7 @@ SYM_FUNC_START(__host_exit) bl handle_trap /* Restore host regs x0-x17 */ +__host_enter_restore_full: ldp x0, x1, [x29, #CPU_XREG_OFFSET(0)] ldp x2, x3, [x29, #CPU_XREG_OFFSET(2)] ldp x4, x5, [x29, #CPU_XREG_OFFSET(4)] @@ -63,6 +64,14 @@ __host_enter_without_restoring: sb SYM_FUNC_END(__host_exit) +/* + * void __noreturn __host_enter(struct kvm_cpu_context *host_ctxt); + */ +SYM_FUNC_START(__host_enter) + mov x29, x0 + b __host_enter_restore_full +SYM_FUNC_END(__host_enter) + /* * void __noreturn __hyp_do_panic(bool restore_host, u64 spsr, u64 elr, u64 par); */