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: 12284531 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 4A310C47089 for ; Thu, 27 May 2021 15:05:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D36006135F for ; Thu, 27 May 2021 15:05:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D36006135F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A59106B0073; Thu, 27 May 2021 11:05:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A30F88D0001; Thu, 27 May 2021 11:05:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 814D76B0075; Thu, 27 May 2021 11:05:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 4ADB36B0073 for ; Thu, 27 May 2021 11:05:35 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AE1F01E18 for ; Thu, 27 May 2021 15:05:34 +0000 (UTC) X-FDA: 78187334988.40.15B5324 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf07.hostedemail.com (Postfix) with ESMTP id ED6E5A0000FF for ; Thu, 27 May 2021 15:05:25 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id a15so466370qta.0 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=OewaDo6IaAirYAJ16Jg8AxO+J7tx2ZfuWJzorv0WjrWCD8ySekRQ6VilkT+dtzdljF eYLaAXGzsTUqx5LEUrnVVS7fXYYMcoREEd4B8kaiRrg+Q9tG2gYIao1hwnb2+grb4NoD FqpPV2t0VPBzFlGfjATyHtLIbbUB5r2+TqWsKmtn9wTzA5yIwbH3/i5ENCLyOKvYP3z+ gQiedpfzJPhZ3cPz2gCj3uhMvcENdGdHKYlKAPEFVrAxyxoIMqslbd9xx1aN6If9/XJS 5/vm4+g7+taMW4YpatEnBk0kk4I2uCA0o0Rrozj2AMnjD874394IEJb8YWjmGPjFDybZ SI5w== X-Gm-Message-State: AOAM530wSKUNSgQyqSgG17HRZe6ex7kStZHVoWfORXwQDvKPH4SYXi9/ IUoGEm//wNSfBweD70H7nGkCLg== 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-Rspamd-Queue-Id: ED6E5A0000FF Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=PAy8oUO7; spf=pass (imf07.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-Rspamd-Server: rspam04 X-Stat-Signature: 91g7yu3f3kd6nmdxjx4nea91xsen45e9 X-HE-Tag: 1622127925-833847 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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