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: 12853294 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56866C433FE for ; Wed, 18 May 2022 07:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232493AbiERHtP (ORCPT ); Wed, 18 May 2022 03:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232514AbiERHtM (ORCPT ); Wed, 18 May 2022 03:49:12 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD06A11E4AA; Wed, 18 May 2022 00:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1652860150; x=1684396150; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=IJmTyyhkjw1/0964q9JMarha0/iXW7c0hLj3X9s0kmc=; b=jWtLWKthHw9QzoAhlnMTCv/1rdU/ZIlpwaiwiBiZJiqk/lRFACHUNb/u MWxGBwhWX/lMASlmdAmZGlUMZRX5Lp213/yXt8W7IyPDGmTwyZjzT4pC2 w1KClwj7triO73WwW+y69yPJDbji8xPh74mwa/EHT9Yr5XyvoIXQ6Q7Yd g=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-01.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) Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org 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())