From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.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 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 55864C4708A for ; Thu, 27 May 2021 21:25:25 +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 184D9613E3 for ; Thu, 27 May 2021 21:25:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 184D9613E3 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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EVpC+rPNq2qoeQZZE+102BoMGRoaA+3Uqa9Eu7Got7M=; b=nWMW9ny2F6TfDT R7tXLK1GS3TZQFvTb2B0aYO7Q0ZAhjgwJVzg0ibz5u5AW3UM7ttbQrx066WVTkkL08s48gIdN3vuM FlOT+dCZk8jcpdQkygKD6JEwapmSdAV1vyuZqUuNhVFlgBaUqHeVIjfmak88U+FEOnSr9TyKTUhmz yfvJVj6atXT8LXfpl3boeJRLOcoOCQyzQ7o3K3Gm1GizgPRQvaQvCK7VWel1wUHD1KgPO3pev5Sdy GAHAm+HoHqAfbljnqzwpcB+a2xZUn0KCYn/qPhwlawzsKt8u9YfqCJnxZiZUkgPCVJyd1mrhG5tMt 1q3WUou9omoFFkVxpsMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmNU6-009a8S-ST; Thu, 27 May 2021 21:24:07 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmNU3-009a5n-5I for linux-arm-kernel@lists.infradead.org; Thu, 27 May 2021 21:24:04 +0000 Received: by mail-ed1-x535.google.com with SMTP id j9so2459883edt.6 for ; Thu, 27 May 2021 14:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wtk1KfZdLajxwbhT65JW8U2wdZuCaGM9BEuhzktfObs=; b=Htjon9vyJB4klyv3eTCZtB8q9+D6GsQWRHU6+y0ymKVo1ONHh37Pf6otfRAc8jAnWx WK7qGAo0rt9uYT4g7jQ3wIKSxNEAczZ2mYTihXLVwQvezyJ2YUWBGq70j8v8B/qP1jbP gDNKxwQ2vjJyi5k087KjKfYMXCmSZSIbFHl5NrhLxS4Rt5dO7bU4inOvbPbwDw2NHu74 HroJW4xS6/qj/FItP1rUrHm6MQL4Vq4kF/GW1IwKU5tz+RhSi4cuzKH3QtcsQ1nND36V qDg9Mvf5tDQhuDLRXeorxl4mJWTXnL6gsf1el4KjzRHP0+byzPR13155T4AEydehRUQE UM0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wtk1KfZdLajxwbhT65JW8U2wdZuCaGM9BEuhzktfObs=; b=QbGb/CkgDuTeR6KOP96JJgD+gdhgTuOe/vZvvjf8Cx00uoW12DeAVS4D3LnO0m6xOo StX3ukIo9zPXbqMiVql9UR7xm+uqYiZXgcaqKGl+EwGWRTLhZQAoAYd6HVEGTMKTc/+C LcpTQ4BnNq4HoQc3exOLzX2OrrEjTlwcCkLfMF3nmJ9/SBzc030jtlzTSqQ/aolS3hu1 oRdELGZ+iR/5LmwVtg0+hM7EijtvnNMtkd0Bt/aoA4OpPOBY6IlW/qDqCMrUzZVck+QJ jQKSpJtJ/k7WpM9ZYtQXPmO+ADrsFFtBtPvU3WAp89XkdxrAMV8R+fDdxK6kJti3jqDo Q0ew== X-Gm-Message-State: AOAM531G325Q8gFNtUZqeQc6jRelX5qk+Ty9q8Tm2ztihI/3frIj96CZ xUv60h2KJEVTfb0jFYBK/er05xDJSEC8tRijPE3GCg== X-Google-Smtp-Source: ABdhPJxuISj8qI4gAyrlKW3NSBXW5qxzRfDjheJb9RE6sYqnS3A0E0DD9bryIgfvOetzNTBQblwjQvJAz2coW3/0uuQ= X-Received: by 2002:a50:c446:: with SMTP id w6mr6454782edf.62.1622150638129; Thu, 27 May 2021 14:23:58 -0700 (PDT) MIME-Version: 1.0 References: <20210527150526.271941-1-pasha.tatashin@soleen.com> <20210527150526.271941-4-pasha.tatashin@soleen.com> <87sg28rx3c.wl-maz@kernel.org> In-Reply-To: <87sg28rx3c.wl-maz@kernel.org> From: Pavel Tatashin Date: Thu, 27 May 2021 17:23:22 -0400 Message-ID: Subject: Re: [PATCH 03/18] arm64: hyp-stub: Move elx_sync into the vectors To: Marc Zyngier Cc: James Morris , Sasha Levin , "Eric W. Biederman" , kexec mailing list , LKML , Jonathan Corbet , Catalin Marinas , Will Deacon , Linux ARM , James Morse , Vladimir Murzin , Matthias Brugger , linux-mm , Mark Rutland , steve.capper@arm.com, rfontana@redhat.com, Thomas Gleixner , Selin Dag , Tyler Hicks , Pingfan Liu , Andrew Morton , madvenka@linux.microsoft.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210527_142403_400723_495730EB X-CRM114-Status: GOOD ( 29.24 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, May 27, 2021 at 11:54 AM Marc Zyngier wrote: > > On Thu, 27 May 2021 16:05:11 +0100, > Pavel Tatashin wrote: > > > > 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 > > Now that this has turned into a macro, what are the guarantees that > mutate_to_vhe will be within reach of the site where this macro is > expanded? It does work here, but what about the other expansion sites > that will show up later in the series? > > What was wrong with directly branching to the original call site? > Nothing in the commit message explains it. Hi Marc, I need to explain this better in the commit log. Later in the series we create our own vector copy that is outside of the old and new kernel so it does not get overwritten during kexec relocation. When VHE is enabled, the vector is passed so we can switch to el2 before jumping to the new kernel. arm64_relocate_new_kernel() which performs the relocation runs with MMU being enabled until relocation is done, after that disables MMU and if vectors are passed performs: mov x0, #HVC_SOFT_RESTART hvc #0 /* Jumps from el2 */ It cannot call mutate_to_vhe because #HVC_VHE_RESTART is not used here. But, if it had to it would not work as we cannot return to the old kernel text after relocation. Thanks, Pasha > > Thanks, > > M. > > -- > Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel