From 7bce35db7419e9fac4915da8ac5e800285bd14f5 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Tue, 4 Jun 2024 20:31:36 +0000 Subject: Enable hibernate/resume to nvme(4) disks with 4096 byte sectors. testing by florian@ mglocker@ mlarkin@ ok deraadt@ mglocker@ mlarkin@ --- sys/arch/i386/stand/libsa/diskprobe.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sys/arch/i386') diff --git a/sys/arch/i386/stand/libsa/diskprobe.c b/sys/arch/i386/stand/libsa/diskprobe.c index d2876cb8d9a..b309a5c0ab4 100644 --- a/sys/arch/i386/stand/libsa/diskprobe.c +++ b/sys/arch/i386/stand/libsa/diskprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskprobe.c,v 1.48 2022/09/01 13:45:26 krw Exp $ */ +/* $OpenBSD: diskprobe.c,v 1.49 2024/06/04 20:31:35 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -467,9 +467,10 @@ bootdev_has_hibernate(void) void check_hibernate(struct diskinfo *dip) { + uint8_t buf[DEV_BSIZE]; daddr_t sec; int error; - union hibernate_info hib; + union hibernate_info *hib = (union hibernate_info *)&buf; /* read hibernate */ if (dip->disklabel.d_partitions[1].p_fstype != FS_SWAP || @@ -477,10 +478,10 @@ check_hibernate(struct diskinfo *dip) return; sec = DL_GETPOFFSET(&dip->disklabel.d_partitions[1]) + - DL_GETPSIZE(&dip->disklabel.d_partitions[1]) - - (sizeof(union hibernate_info) / DEV_BSIZE); + DL_GETPSIZE(&dip->disklabel.d_partitions[1]) - 1; - error = dip->strategy(dip, F_READ, sec, sizeof hib, &hib, NULL); - if (error == 0 && hib.magic == HIBERNATE_MAGIC) + error = dip->strategy(dip, F_READ, DL_SECTOBLK(&dip->disklabel, sec), + sizeof buf, &buf, NULL); + if (error == 0 && hib->magic == HIBERNATE_MAGIC) dip->bios_info.flags |= BDI_HIBVALID; /* Hibernate present */ } -- cgit v1.2.3