Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp413842imm; Wed, 19 Sep 2018 00:38:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZLJV16MwqFKsCEmhaQ7VtqjppPFXkRfU3cCDstOvl+1x6dnN8a6577ZL/kwrB4MmpRKFKp X-Received: by 2002:a17:902:6b4b:: with SMTP id g11-v6mr32207807plt.19.1537342734906; Wed, 19 Sep 2018 00:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537342734; cv=none; d=google.com; s=arc-20160816; b=oOio8AtRwlV9WgGYrDwOgsIQy/4ETzXvDSJ80smdr9t26sICNnhqptjNnVGtPwBlde LsGgBTzv7M0XKoks/z+gZCwekoPS7VrTXVTrbCyln0VhslR8my2TKZoDEfCoU/xkEszX L4354zHSEl6s3tMyy5iMdnNIFdm2QykUqF4HkG3mrpR+eivHaBOVOm411qvS4PxKTSWf zPmFSwbb63DEvJlbhVThli0iJiQen/VxhIK1cQcIRpdHRihU3LeCGyUj5b/UtcLdkj9V 8M5QleAG0Q+hik7i/OKxVwJSrI4K5Q14EAzpOZ64Hx3Wmo5yXWiE30Ct3ANI5By/myJN F2JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Jlu4QU+NVY0sFu6d0hqwEz2Y+UPuY2cPK1E7i2/jRBQ=; b=crgp+BMcCJ+gyyrKTBHJG7KrbQuKPuOjH1fZoNBMp+DOVBqWmdKbes+aBYkluC7Wnq JDZ6Cjxh4jf6mTuBNJGDKlOfnemhoQegumSNbw3iFmv0Vi0TOuJRg9ktZ3Dm4SwIGRQU 0QzxKe2/W1sCY6BWddTVtzTl6L538vpotLUi4rSDY/ctwZIyx1utVT5INj8mADLb4S8g n4hPOrjGKCNvCyXEDWudUJkc5AVMi067BtyLIcpLoqmAbyO1TQGE6tQUKA+bttLJwyrO cTYhRMF4PS2zCP9zO+D3tk5FnFIQhuvDWPc7d82Wmzon3HFjQ5w+7dpYS9lxPGGpoAc5 rxYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v188-v6si20716804pgb.96.2018.09.19.00.38.39; Wed, 19 Sep 2018 00:38:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731109AbeISNN1 (ORCPT + 99 others); Wed, 19 Sep 2018 09:13:27 -0400 Received: from mga02.intel.com ([134.134.136.20]:42047 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731055AbeISNN0 (ORCPT ); Wed, 19 Sep 2018 09:13:26 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2018 00:36:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,393,1531810800"; d="scan'208";a="91368456" Received: from chenyu-desktop.sh.intel.com ([10.239.160.116]) by fmsmga001.fm.intel.com with ESMTP; 19 Sep 2018 00:36:36 -0700 From: Chen Yu To: Thomas Gleixner , "Rafael J. Wysocki" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Pavel Machek , Len Brown , Zhimin Gu , Yu Chen Subject: [PATCH 11/12][RFC v3] x86-32, hibernate: Set up temporary text mapping for 32bit system Date: Wed, 19 Sep 2018 15:43:22 +0800 Message-Id: <5d152d6237274f166c60fc7dee7c6fea883ef922.1537275915.git.yu.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhimin Gu Set up the temporary text mapping for the final jump address so that the system could jump to the right address after all the pages have been copied back to their original address. Back-port from 64bit system. Cc: "Rafael J. Wysocki" Signed-off-by: Zhimin Gu Signed-off-by: Chen Yu --- arch/x86/power/hibernate_32.c | 31 +++++++++++++++++++++++++++++++ arch/x86/power/hibernate_asm_32.S | 3 +++ 2 files changed, 34 insertions(+) diff --git a/arch/x86/power/hibernate_32.c b/arch/x86/power/hibernate_32.c index a9861095fbb8..15695e30f982 100644 --- a/arch/x86/power/hibernate_32.c +++ b/arch/x86/power/hibernate_32.c @@ -143,6 +143,32 @@ static inline void resume_init_first_level_page_table(pgd_t *pg_dir) #endif } +static int set_up_temporary_text_mapping(pgd_t *pgd_base) +{ + pgd_t *pgd; + pmd_t *pmd; + pte_t *pte; + + pgd = pgd_base + pgd_index(restore_jump_address); + + pmd = resume_one_md_table_init(pgd); + if (!pmd) + return -ENOMEM; + + if (boot_cpu_has(X86_FEATURE_PSE)) { + set_pmd(pmd + pmd_index(restore_jump_address), + __pmd((jump_address_phys & PMD_MASK) | pgprot_val(PAGE_KERNEL_LARGE_EXEC))); + } else { + pte = resume_one_page_table_init(pmd); + if (!pte) + return -ENOMEM; + set_pte(pte + pte_index(restore_jump_address), + __pte((jump_address_phys & PAGE_MASK) | pgprot_val(PAGE_KERNEL_EXEC))); + } + + return 0; +} + asmlinkage int swsusp_arch_resume(void) { int error; @@ -152,6 +178,11 @@ asmlinkage int swsusp_arch_resume(void) return -ENOMEM; resume_init_first_level_page_table(resume_pg_dir); + + error = set_up_temporary_text_mapping(resume_pg_dir); + if (error) + return error; + error = resume_physical_mapping_init(resume_pg_dir); if (error) return error; diff --git a/arch/x86/power/hibernate_asm_32.S b/arch/x86/power/hibernate_asm_32.S index e9adda6b6b02..01f653fae7bd 100644 --- a/arch/x86/power/hibernate_asm_32.S +++ b/arch/x86/power/hibernate_asm_32.S @@ -36,6 +36,8 @@ ENTRY(swsusp_arch_suspend) ENDPROC(swsusp_arch_suspend) ENTRY(restore_image) + /* prepare to jump to the image kernel */ + movl restore_jump_address, %ebx movl restore_cr3, %ebp movl mmu_cr4_features, %ecx @@ -74,6 +76,7 @@ copy_loop: .p2align 4,,7 done: + jmpl *%ebx /* code below belongs to the image kernel */ .align PAGE_SIZE -- 2.17.1