From ec527653e3c18ef7989803fe457b94c85d781ed3 Mon Sep 17 00:00:00 2001 From: mlarkin Date: Fri, 25 Apr 2014 14:37:06 +0000 Subject: [PATCH] Defer the free of the hibernate structures until later, when it is safe to do so. Freeing the hibernate structures too early leads to inadvertent calls into splx when we aren't ready for them yet. Found when trapping splx calls in the resume path. discussed with deraadt@ at m2k14 --- sys/arch/amd64/amd64/acpi_machdep.c | 9 +-------- sys/arch/i386/i386/acpi_machdep.c | 9 +-------- sys/dev/acpi/acpi.c | 10 +++++++++- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c index ec4be74cfa7..540469e52d5 100644 --- a/sys/arch/amd64/amd64/acpi_machdep.c +++ b/sys/arch/amd64/amd64/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.59 2014/03/27 10:24:40 dlg Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.60 2014/04/25 14:37:06 mlarkin Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -327,13 +327,6 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) } /* Resume path */ -#ifdef HIBERNATE - if (state == ACPI_STATE_S4) { - hibernate_free(); - uvm_pmr_dirty_everything(); - } -#endif - /* Reset the vectors */ sc->sc_facs->wakeup_vector = 0; if (sc->sc_facs->length > 32 && sc->sc_facs->version >= 1) diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c index 2af0f10c6f3..fb803618f7e 100644 --- a/sys/arch/i386/i386/acpi_machdep.c +++ b/sys/arch/i386/i386/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.52 2014/03/13 03:52:55 dlg Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.53 2014/04/25 14:37:06 mlarkin Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -350,13 +350,6 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) } /* Resume path */ -#ifdef HIBERNATE - if (state == ACPI_STATE_S4) { - hibernate_free(); - uvm_pmr_dirty_everything(); - } -#endif - /* Reset the vectors */ sc->sc_facs->wakeup_vector = 0; if (sc->sc_facs->length > 32 && sc->sc_facs->version >= 1) diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 759344b4b52..a045de8178b 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.256 2014/04/13 14:43:01 mlarkin Exp $ */ +/* $OpenBSD: acpi.c,v 1.257 2014/04/25 14:37:06 mlarkin Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -2202,6 +2202,14 @@ fail_quiesce: acpi_record_event(sc, APM_NORMAL_RESUME); acpi_indicator(sc, ACPI_SST_WORKING); + +#ifdef HIBERNATE + if (state == ACPI_STATE_S4) { + hibernate_free(); + uvm_pmr_dirty_everything(); + } +#endif /* HIBERNATE */ + fail_tts: return (error); } -- 2.20.1