From patchwork Thu May 27 15:05:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12284635 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 A56E8C47089 for ; Thu, 27 May 2021 15:49:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 61FE1610FC for ; Thu, 27 May 2021 15:49:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61FE1610FC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type: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:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7AdRbP7ibsHHO/Ub97KB24NEkgxIzRWysFabSQmnGpk=; b=Dz4EM95Pdwtt9V CYHtMT65Yu+bp5qdkbZBEDxVoRPpNsmLIihMhdThaLbsNjyhCFN5sV+gTExg8oMKNJi3f2CJn0Rkw 1kxcw/LNNUaO6sQGx8wpewjqHMPS/aZJa1J1g89jKdBPQDhDMkWwPe8cxnPiJ/nPHlImCyqUXaKth F3CWWnD6AdnBIQwX2lMm6CwsHd9E4QTR/PsYh1ZxXsIrSafUJgO82Oepf1fdgVb51WF7OR9rPLz7G sij+0ST8XWLim/raY+tL7gDGDEZg65Gsgn8jJJ5IcWpcy7h/biOZj1/3LGxlRVA5VoOPPRi/QfARq kF0Mupwt4oUwsllUhK8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmIDx-007L0r-6k; Thu, 27 May 2021 15:47:05 +0000 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmHZn-0071gI-64 for linux-arm-kernel@lists.infradead.org; Thu, 27 May 2021 15:05:38 +0000 Received: by mail-qt1-x830.google.com with SMTP id c10so407751qtx.10 for ; Thu, 27 May 2021 08:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Dd4OYNLmvVEa/N4zByXvuOh+6Xq8z1RHPtKQnceMU+s=; b=PAy8oUO7YX8LhrT2i2a4coviv4EjGLjt9zdp4yLK7smhcEYSnOPuWxth8pQ2sJKm+p 2jg8Z8xa3QAfUFb6YPB7i6dNFCgjUSpCNNTF4y2TBPfNZI+7cCG57PyzHQ9Of9f20W6B R7bkFVD0/i3hf1SwqNdYQsnQuKcFwRo7leOcm3+FWAqSlbSv3tKKbTWkEpxfIENLQcP7 Avke/bt4sGbmFGea4UxrsFvQiaqrhp1VhY7VKD6d9SVV7vKuSzxZ9sKf4SCTFCA3py1E o37jHAYoXineM+R2Or5/XjDQtnkuW/wiU2rUyJdY25VcLfzBGnauKIoXd+B4KclFdTl7 0iSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dd4OYNLmvVEa/N4zByXvuOh+6Xq8z1RHPtKQnceMU+s=; b=NCYCKywexjLL6sJoQDY0UsByQNGtSjDMOL3THPiivRsEj9DFKJ5gNzCTLh/u7jp6/B mIRK3+Ds8IOA6kiMufn3RqlIFrnwFb9HGL8+BDydv4EUjzBJvapknpC4+c2RHpJcgSa9 DpPOtNSnv3hKnSbV4Tl7duTAP5nCYut8eMKaSOBHfNgaketEyWeR9/gFFtGVAudnW5Ls KVgcOkcvAalWK/oIi5hdls/MgLSH3FtUcgcjs0rqAXrPlXhDXW7M49bDczdawwa5xuDZ bb3JawwNp4D919ilpKTRdKBTAb91u6gedqksRsqfApQRFIX/byIk+HJMBG7Ey2YI2y5l 7hXw== X-Gm-Message-State: AOAM533QgYBVhfOBGgm3ipUzelM66J/I/Po+SR84Xgs1zo7FHnh3qs9i mDiCuu6AedXvIlOJ1foL3C1uW1xbJP51v5Kl X-Google-Smtp-Source: ABdhPJxtuOVFOKAsCuiHh9cOyHIEi9No+IlR64k2qAMP9VTvqHYTpO1ydEtOEgxg9B4D+CYuBIBhhQ== X-Received: by 2002:ac8:74c2:: with SMTP id j2mr3522136qtr.185.1622127933716; Thu, 27 May 2021 08:05:33 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id x10sm1447468qkh.124.2021.05.27.08.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 08:05:33 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, maz@kernel.org, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de, selindag@gmail.com, tyhicks@linux.microsoft.com, kernelfans@gmail.com, akpm@linux-foundation.org, madvenka@linux.microsoft.com Subject: [PATCH 03/18] arm64: hyp-stub: Move elx_sync into the vectors Date: Thu, 27 May 2021 11:05:11 -0400 Message-Id: <20210527150526.271941-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527150526.271941-1-pasha.tatashin@soleen.com> References: <20210527150526.271941-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210527_080535_276231_D3B4DDE2 X-CRM114-Status: UNSURE ( 9.73 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The hyp-stub's elx_sync code fits in the vector. With this, all of the hyp-stubs behaviour is contained in its vectors. This lets kexec and hibernate copy the hyp-stub when they need its behaviour, instead of re-implementing it. Co-developed-by: James Morse Signed-off-by: Pavel Tatashin --- arch/arm64/kernel/hyp-stub.S | 64 +++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S index 18a97bee3779..86af6c4e52b9 100644 --- a/arch/arm64/kernel/hyp-stub.S +++ b/arch/arm64/kernel/hyp-stub.S @@ -21,6 +21,37 @@ SYM_CODE_START_LOCAL(\label) .align 7 b \label SYM_CODE_END(\label) +.endm + +.macro elx_sync_vector label +SYM_CODE_START_LOCAL(\label) + .align 7 + cmp x0, #HVC_SET_VECTORS + b.ne 1f + msr vbar_el2, x1 + b 9f + +1: cmp x0, #HVC_VHE_RESTART + b.eq mutate_to_vhe + +2: cmp x0, #HVC_SOFT_RESTART + b.ne 3f + mov x0, x2 + mov x2, x4 + mov x4, x1 + mov x1, x3 + br x4 // no return + +3: cmp x0, #HVC_RESET_VECTORS + beq 9f // Nothing to reset! + + /* Someone called kvm_call_hyp() against the hyp-stub... */ + mov_q x0, HVC_STUB_ERR + eret + +9: mov x0, xzr + eret +SYM_CODE_END(\label) .endm .text @@ -34,12 +65,12 @@ SYM_CODE_START(__hyp_stub_vectors) invalid_vector hyp_stub_el2t_fiq_invalid // FIQ EL2t invalid_vector hyp_stub_el2t_error_invalid // Error EL2t - ventry elx_sync // Synchronous EL2h + elx_sync_vector el2h_sync // Synchronous EL2h invalid_vector hyp_stub_el2h_irq_invalid // IRQ EL2h invalid_vector hyp_stub_el2h_fiq_invalid // FIQ EL2h invalid_vector hyp_stub_el2h_error_invalid // Error EL2h - ventry elx_sync // Synchronous 64-bit EL1 + elx_sync_vector el1_sync // Synchronous 64-bit EL1 invalid_vector hyp_stub_el1_irq_invalid // IRQ 64-bit EL1 invalid_vector hyp_stub_el1_fiq_invalid // FIQ 64-bit EL1 invalid_vector hyp_stub_el1_error_invalid // Error 64-bit EL1 @@ -55,35 +86,6 @@ SYM_CODE_END(__hyp_stub_vectors) # Check the __hyp_stub_vectors didn't overflow .org . - (__hyp_stub_vectors_end - __hyp_stub_vectors) + SZ_2K - -SYM_CODE_START_LOCAL(elx_sync) - cmp x0, #HVC_SET_VECTORS - b.ne 1f - msr vbar_el2, x1 - b 9f - -1: cmp x0, #HVC_VHE_RESTART - b.eq mutate_to_vhe - -2: cmp x0, #HVC_SOFT_RESTART - b.ne 3f - mov x0, x2 - mov x2, x4 - mov x4, x1 - mov x1, x3 - br x4 // no return - -3: cmp x0, #HVC_RESET_VECTORS - beq 9f // Nothing to reset! - - /* Someone called kvm_call_hyp() against the hyp-stub... */ - mov_q x0, HVC_STUB_ERR - eret - -9: mov x0, xzr - eret -SYM_CODE_END(elx_sync) - // nVHE? No way! Give me the real thing! SYM_CODE_START_LOCAL(mutate_to_vhe) // Sanity check: MMU *must* be off