RE: [BUG] Kernel panic when using Hibernation on kernel 6.1.25

From: Jia-hao Bai (白家豪)
Date: Thu Jun 13 2024 - 22:33:04 EST


Hi Pavel,

Hardware: Arm Cortex A55, 1GB RAM, eMMC 8G.

Error log:
[ 1362.985700] sh: notify_die from die+0x144/0x5f0
[ 1362.985700] sh: die from die_kernel_fault+0x138/0x148
[ 1362.985700] sh: die_kernel_fault from __do_kernel_fault.part.0+0x5c/0xac
[ 1362.985700] sh: __do_kernel_fault.part.0 from do_translation_fault+0xbc/0xe0
[ 1362.985700] sh: do_translation_fault from do_DataAbort+0x44/0x1d0
[ 1362.985700] sh: do_DataAbort from __dabt_svc+0x4c/0x80
[ 1362.985700] sh: Exception stack(0xc1e8df38 to 0xc1e8df80)
[ 1362.985700] sh: df20: c3000000 00000000
[ 1362.985700] sh: df40: c3001000 ea157ffc ea158000 c17639a8 c17bd548 edceb060 c184b540 c17bd5a0
[ 1362.985700] sh: df60: 00007fd7 ed76c000 00000000 c1e8df88 c0ebe4dc c0ebe4e4 800001d3 ffffffff
[ 1362.985700] sh: __dabt_svc from safe_copy_page+0x20/0x4c
[ 1362.985700] sh: safe_copy_page from swsusp_save+0x580/0x5ac
[ 1362.985700] sh: swsusp_save from arch_save_image+0x8/0x74
[ 1362.985700] sh: arch_save_image from cpu_suspend_abort+0x0/0x18

We compared between K5.4 and K6.1.25 and found that Hibernation does not save the reserve area on K5.4 because it is blocked by pfn_valid.

Therefore, we have added the following workaround to skip some reserved memory sections.

The skip region is obtained from "cat /proc/iomem".
40000000-42fbffff : System RAM
40008000-410fffff : Kernel code
41200000-4144a25f : Kernel data
43100000-4402ffff : System RAM
45140000-593fffff : System RAM
59401000-5940ffff : System RAM
5941f000-594effff : System RAM
59501180-595fffff : System RAM
59640000-7fffffff : System RAM

static unsigned int pfn_is_reserved(unsigned long pfn){
phys_addr_t phys = __pfn_to_phy
if(phys >= 0x42fc0000 && phys< 0x43100000){
return true;
}
if(phys >= 0x44030000 && phys< 0x45140000){
return true;
}
if(phys >= 0x59400000 && phys< 0x59401000){
return true;
}
if(phys >= 0x59410000 && phys< 0x5941f000){
return true;
}
if(phys >= 0x594f0000 && phys< 0x59501180){
return true;
}
if(phys >= 0x59600000 && phys< 0x59640000){
return true;
}
return false;

}

static struct page *saveable_page(struct zone *zone, unsigned long pfn)
{
struct page *page;

if (!pfn_valid(pfn)){
return NULL;
}

if(pfn_is_reserved(pfn))
return NULL;
........


Do you know of any patches that can fix this problem?

thanks

-----Original Message-----
From: Pavel Machek <pavel@xxxxxx>
Sent: Thursday, June 13, 2024 6:52 PM
To: Jia-hao Bai (白家豪) <Jia-hao.Bai@xxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx; rafael@xxxxxxxxxx; Iverlin Wang (王苳霖) <Iverlin.Wang@xxxxxxxxxxxx>; Boy Wu (吳勃誼) <Boy.Wu@xxxxxxxxxxxx>; Seiya Wang (王迺君) <seiya.wang@xxxxxxxxxxxx>; Dengjun Su (苏邓军) <Dengjun.Su@xxxxxxxxxxxx>; Win Yeh (葉昌倫) <Win.Yeh@xxxxxxxxxxxx>; Sowell Peng (彭首偉) <Sowell.Peng@xxxxxxxxxxxx>; Richard-CC Yang (楊職銓) <Richard-CC.Yang@xxxxxxxxxxxx>
Subject: Re: [BUG] Kernel panic when using Hibernation on kernel 6.1.25

Hi!

> I encountered a kernel panic when using the Hibernation on kernel version 6.1.25. Below are the details of the issue:
>
> **Description:**
> When I enable CONFIG_HIBERNATION and assign a specific partition for hibernation resuming and perform a specific operation, the system crashes with a kernel panic.
>
> CONFIG_HIBERNATION=y
> CONFIG_PM_STD_PARTITION="/dev/mmcblk0p16"
>
> **Steps to Reproduce:**
> 1. Set printk to level 8: ` echo 8 > /proc/sys/kernel/printk`
> 2. Set up the swap partition: ` mkswap /dev/mmcblk0p16`
> 3. Enable the swap partition: ` swapon -p -3 /dev/mmcblk0p16`
> 4. Configure hibernation resuming settings: ` echo "/dev/mmcblk0p16" > /sys/power/resume`
> 5. Configure hibernation mode:` echo reboot > /sys/power/disk`
> 6. Perform the operation: ` echo disk > /sys/power/state`
> 7. Observe the kernel panic
>
>
> **Expected Behavior:**
> The operation should complete successfully without causing a kernel panic.
>
> **Actual Behavior:**
> The system crashes with a kernel panic.
>
> **Environment:**
> - Kernel version: 6.1.25
> - Distribution: Yocto 4.0 32bit/Kernel 6.1.25 32bit
> - Hardware: Arm Cortex A55, 1GB RAM

We'd need to know way more about the hardware. Also testing with latest mainline would be useful.

Best regards,
Pavel
--
People of Russia, stop Putin before his war on Ukraine escalates.