From patchwork Wed May 18 07:48:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Kumar X-Patchwork-Id: 12853277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5C69C433EF for ; Wed, 18 May 2022 07:49:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AF3F6B0073; Wed, 18 May 2022 03:49:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55ED86B0078; Wed, 18 May 2022 03:49:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 427C56B007B; Wed, 18 May 2022 03:49:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 34C286B0073 for ; Wed, 18 May 2022 03:49:12 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 167ED60577 for ; Wed, 18 May 2022 07:49:12 +0000 (UTC) X-FDA: 79478088144.09.140083A Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by imf16.hostedemail.com (Postfix) with ESMTP id 0DCB4180094 for ; Wed, 18 May 2022 07:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1652860151; x=1684396151; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=IJmTyyhkjw1/0964q9JMarha0/iXW7c0hLj3X9s0kmc=; b=ChJy16IcKgka4vF9KExmYKGxs/UI2LnOSiigMfVAORjjqydzq1NkD2FC jb4sxvC4zd8vE4Kf5hNmFyoMRFTnTSyH8k3C2S03oS7bvlk4YNEqKLB9R 5pRCq7wXPK6sRVUkCmIAPAvgKv45j11Vvwl+FaXQkJ0OSK3r1dV/7LAS4 s=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 18 May 2022 00:49:10 -0700 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2022 00:49:09 -0700 Received: from blr-ubuntu-185.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 18 May 2022 00:49:00 -0700 From: Vivek Kumar To: , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , Vivek Kumar , Prasanna Kumar Subject: [RFC 1/6] arm64: hibernate: Introduce new entry point to kernel Date: Wed, 18 May 2022 13:18:36 +0530 Message-ID: <1652860121-24092-2-git-send-email-quic_vivekuma@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1652860121-24092-1-git-send-email-quic_vivekuma@quicinc.com> References: <1652860121-24092-1-git-send-email-quic_vivekuma@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-Rspamd-Queue-Id: 0DCB4180094 X-Stat-Signature: i3j85t3tforoosj5fezrxshgwq3mo18p X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=ChJy16Ic; spf=pass (imf16.hostedemail.com: domain of quic_vivekuma@quicinc.com designates 199.106.114.39 as permitted sender) smtp.mailfrom=quic_vivekuma@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com X-Rspamd-Server: rspam09 X-HE-Tag: 1652860139-822943 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: Introduce a new entry point to hibernated kernel image. This is generally needed when bootloader restores the hibernated image from disc to ddr and passes control to it by turning off the mmu, also initialize this new entry point with cpu_resume which turns on the mmu and then proceeds with restore routines. Signed-off-by: Vivek Kumar Signed-off-by: Prasanna Kumar --- arch/arm64/kernel/hibernate.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index 6328308..4e294b3 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -74,6 +74,14 @@ static struct arch_hibernate_hdr { void (*reenter_kernel)(void); /* + * Another entry point if jump to kernel happens with mmu disabled, + * generally done when restoring hibernation image from bootloader + * context + */ + + phys_addr_t phys_reenter_kernel; + + /* * We need to know where the __hyp_stub_vectors are after restore to * re-configure el2. */ @@ -116,6 +124,7 @@ int arch_hibernation_header_save(void *addr, unsigned int max_size) arch_hdr_invariants(&hdr->invariants); hdr->ttbr1_el1 = __pa_symbol(swapper_pg_dir); hdr->reenter_kernel = _cpu_resume; + hdr->phys_reenter_kernel = __pa(cpu_resume); /* We can't use __hyp_get_vectors() because kvm may still be loaded */ if (el2_reset_needed())