Received: by 10.223.185.116 with SMTP id b49csp6667581wrg; Wed, 28 Feb 2018 13:21:44 -0800 (PST) X-Google-Smtp-Source: AH8x225ucGqLIZNum1DZHSgpQfp9NSZTjVRaK3gog3OKUEU5U9EECXmny/qG+DAJCKFjtFgIaFTz X-Received: by 10.101.93.134 with SMTP id f6mr15438570pgt.293.1519852904600; Wed, 28 Feb 2018 13:21:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519852904; cv=none; d=google.com; s=arc-20160816; b=OqQkSupvu74lMAUokXh6vaN0/cVUmkGPv8DXt20lg7o87VYOnT6EoND78QFGahmXTg I77txbJHsqjhh/9Gr5ujNsaGm/ZlbGlhR6TX7CazOI2WLOZVjr7vjqTPv2VlqZ5c2eNL ClyOxXKMhp97nF8ZwK4tdwcP/qTQlO/xW0+pJM0onsazPVXpoHa6+Xs6w25x6Xcu2P/x CriGSqscZyeWGMxEa4J3+ijvVz/9cF+S1FY8f7KjEL6cllW+YvkZtfZIrc6FWxLonb5s hp2TReRMGcQd10g72A6NQvd6rbxZUMM02ooCaRoW/ccEO7zgYD91WkGKPbJlnSrJlH0J moDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=L+HOPnnZMMyhElJIdMKzbH3U45pdGF2pwNCnHTNYaxI=; b=QB/sJb7SD2aS9GNUoIY1lMyq3l1xgb1qBUStT87i+5RrtK0gRDtLbVgcGIhIpdTrfu eAstUTsEySRlBjs+h65KlLu4fpLIMeVnDWELXq6nXUAuUa4IGVt71c2T5AU3p/Xn7nZ3 jwVOipLQa+dnU3hqMS3jmdm4V9J/QDYvoDyB0XaoZaitzuP8U1VwZ5HahjdQeWfSlQ2J G196GsARSMxi4qXoOuMuv3kDFx9EzTrxLAG7doatHFawSWwt8XYlrUSDcRD8fZ4H0yWa uIP9vWkSWkMV3lpluZV/vSZlTNqMjLuBHHcP/0FKdg2KSNELi0Nh20EZJxRLLFDWw/TZ JlBA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33-v6si1822413pld.653.2018.02.28.13.21.30; Wed, 28 Feb 2018 13:21:44 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934924AbeB1VUU (ORCPT + 99 others); Wed, 28 Feb 2018 16:20:20 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:49657 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933074AbeB1VUT (ORCPT ); Wed, 28 Feb 2018 16:20:19 -0500 Received: from p4fea5f09.dip0.t-ipconnect.de ([79.234.95.9] helo=[192.168.0.145]) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1er95c-0005IY-91; Wed, 28 Feb 2018 22:16:40 +0100 Date: Wed, 28 Feb 2018 22:20:16 +0100 (CET) From: Thomas Gleixner To: Woody Suwalski cc: Linux Kernel List , the arch/x86 maintainers , William Grant Subject: Re: 4.16 regression: s2ram broken on non-PAE i686 In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Woody, On Wed, 28 Feb 2018, Woody Suwalski wrote: > Certainly. I understand you want dmesg output for kernels build with and > without PAE, not just PAE=n on the cmdline :-) > Here it is... Thanks for providing the data. It did not pinpoint the issue but at least it gave me the hint to look into the right direction. Does the patch below fix the issue for you? It's untested as I'm at home and have no access to a 32bit machine right now. Thanks, tglx 8<------------------ Subject: x86/cpu_entry_area: Sync cpu_entry_area to initial_page_table From: Thomas Gleixner Date: Wed, 28 Feb 2018 21:14:26 +0100 The separation of the cpu_entry_area from the fixmap missed the fact that on 32bit non-PAE kernels the cpu_entry_area mapping might not be covered in initial_page_table by the previous synchronizations. This results in suspend/resume failures because 32bit utilizes initial page table for resume. The absence of the cpu_entry_area mapping results in a triple fault, aka. insta reboot. Synchronize the initial page table after setting up the cpu entry area. Instead of adding yet another copy of the same code, move it to a function and invoke it from the various places. It needs to be investigated if the existing calls in setup_arch() and setup_per_cpu_areas() can be replaced by the later invocation from setup_cpu_entry_areas(), but that's beyond the scope of this fix. Fixes: 92a0f81d8957 ("x86/cpu_entry_area: Move it out of the fixmap") Reported-by: Woody Suwalski Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org --- arch/x86/include/asm/pgtable_32.h | 1 + arch/x86/include/asm/pgtable_64.h | 1 + arch/x86/kernel/setup.c | 17 +++++------------ arch/x86/kernel/setup_percpu.c | 17 ++++------------- arch/x86/mm/cpu_entry_area.c | 6 ++++++ arch/x86/mm/init_32.c | 15 +++++++++++++++ 6 files changed, 32 insertions(+), 25 deletions(-) --- a/arch/x86/include/asm/pgtable_32.h +++ b/arch/x86/include/asm/pgtable_32.h @@ -32,6 +32,7 @@ extern pmd_t initial_pg_pmd[]; static inline void pgtable_cache_init(void) { } static inline void check_pgt_cache(void) { } void paging_init(void); +void sync_initial_page_table(void); /* * Define this if things work differently on an i386 and an i486: --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h @@ -28,6 +28,7 @@ extern pgd_t init_top_pgt[]; #define swapper_pg_dir init_top_pgt extern void paging_init(void); +static inline void sync_initial_page_table(void) { } #define pte_ERROR(e) \ pr_err("%s:%d: bad pte %p(%016lx)\n", \ --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1204,20 +1204,13 @@ void __init setup_arch(char **cmdline_p) kasan_init(); -#ifdef CONFIG_X86_32 - /* sync back kernel address range */ - clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY, - swapper_pg_dir + KERNEL_PGD_BOUNDARY, - KERNEL_PGD_PTRS); - /* - * sync back low identity map too. It is used for example - * in the 32-bit EFI stub. + * Sync back kernel address range. + * + * FIXME: Can the later sync in setup_cpu_entry_areas() replace + * this call? */ - clone_pgd_range(initial_page_table, - swapper_pg_dir + KERNEL_PGD_BOUNDARY, - min(KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY)); -#endif + sync_initial_page_table(); tboot_probe(); --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c @@ -287,24 +287,15 @@ void __init setup_per_cpu_areas(void) /* Setup cpu initialized, callin, callout masks */ setup_cpu_local_masks(); -#ifdef CONFIG_X86_32 /* * Sync back kernel address range again. We already did this in * setup_arch(), but percpu data also needs to be available in * the smpboot asm. We can't reliably pick up percpu mappings * using vmalloc_fault(), because exception dispatch needs * percpu data. + * + * FIXME: Can the later sync in setup_cpu_entry_areas() replace + * this call? */ - clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY, - swapper_pg_dir + KERNEL_PGD_BOUNDARY, - KERNEL_PGD_PTRS); - - /* - * sync back low identity map too. It is used for example - * in the 32-bit EFI stub. - */ - clone_pgd_range(initial_page_table, - swapper_pg_dir + KERNEL_PGD_BOUNDARY, - min(KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY)); -#endif + sync_initial_page_table(); } --- a/arch/x86/mm/cpu_entry_area.c +++ b/arch/x86/mm/cpu_entry_area.c @@ -163,4 +163,10 @@ void __init setup_cpu_entry_areas(void) for_each_possible_cpu(cpu) setup_cpu_entry_area(cpu); + + /* + * This is the last essential update to swapper_pgdir which needs + * to be synchronized to initial_page_table on 32bit. + */ + sync_initial_page_table(); } --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -453,6 +453,21 @@ static inline void permanent_kmaps_init( } #endif /* CONFIG_HIGHMEM */ +void __init sync_initial_page_table(void) +{ + clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY, + swapper_pg_dir + KERNEL_PGD_BOUNDARY, + KERNEL_PGD_PTRS); + + /* + * sync back low identity map too. It is used for example + * in the 32-bit EFI stub. + */ + clone_pgd_range(initial_page_table, + swapper_pg_dir + KERNEL_PGD_BOUNDARY, + min(KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY)); +} + void __init native_pagetable_init(void) { unsigned long pfn, va;