Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 May 2017 21:40:58 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>, Manuel St?hn <freebsdnewbie@freenet.de>, Jonathan Anderson <jonathan@FreeBSD.org>, freebsd-current@freebsd.org
Subject:   Re: regression suspend/resume on Lenovo T420
Message-ID:  <20170515184058.GF1622@kib.kiev.ua>
In-Reply-To: <20170515173758.GA1730@brick>
References:  <5746a37cd73e062c963512df1a6d24c6@email.freenet.de> <e1405329-412a-2c12-c599-dfe6a8870aaf@freenet.de> <20170506090341.GA12163@freebsd-t420.fritz.box> <20170514193006.GA1298@brick> <1190.1494792172@critter.freebsd.dk> <20170515095647.GA1622@kib.kiev.ua> <20170515173758.GA1730@brick>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, May 15, 2017 at 06:37:58PM +0100, Edward Tomasz Napiera??a wrote:
> Thanks!  The patch fixes resume for me, for both vt(4) and X11.

Thanks everybody for testing, patch below should be committable, modulo
bugs.  I did not tested it and ask for the same test as the previous
debugging patch.

diff --git a/sys/amd64/acpica/acpi_wakecode.S b/sys/amd64/acpica/acpi_wakecode.S
index 6b36d55e7d2..a63b5b8b769 100644
--- a/sys/amd64/acpica/acpi_wakecode.S
+++ b/sys/amd64/acpica/acpi_wakecode.S
@@ -156,11 +156,12 @@ wakeup_32:
 	/*
 	 * Enable EFER.LME so that we get long mode when all the prereqs are
 	 * in place.  In this case, it turns on when CR0_PG is finally enabled.
-	 * Pick up a few other EFER bits that we'll use need we're here.
+	 * Also it picks up a few other EFER bits that we'll use need we're
+	 * here, like SYSCALL and NX enable.
 	 */
 	movl	$MSR_EFER, %ecx
-	rdmsr
-	orl	$EFER_LME | EFER_SCE, %eax
+	movl	wakeup_efer - wakeup_start(%ebx), %eax
+	movl	wakeup_efer + 4 - wakeup_start(%ebx), %edx
 	wrmsr
 
 	/*
@@ -276,6 +277,8 @@ wakeup_pcb:
 	.quad	0
 wakeup_ret:
 	.quad	0
+wakeup_efer:
+	.quad	0
 wakeup_gdt:
 	.word	0
 	.quad	0
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
index 33437ad16e6..86198ab1a8c 100644
--- a/sys/amd64/amd64/cpu_switch.S
+++ b/sys/amd64/amd64/cpu_switch.S
@@ -396,7 +396,7 @@ ENTRY(resumectx)
 	movl	4 + PCB_KGSBASE(%rdi),%edx
 	wrmsr
 
-	/* Restore EFER. */
+	/* Restore EFER one more time. */
 	movl	$MSR_EFER,%ecx
 	movl	PCB_EFER(%rdi),%eax
 	wrmsr
diff --git a/sys/x86/acpica/acpi_wakeup.c b/sys/x86/acpica/acpi_wakeup.c
index 4a10ac7b304..74f4fedc28f 100644
--- a/sys/x86/acpica/acpi_wakeup.c
+++ b/sys/x86/acpica/acpi_wakeup.c
@@ -223,7 +223,9 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
 		WAKECODE_FIXUP(resume_beep, uint8_t, (acpi_resume_beep != 0));
 		WAKECODE_FIXUP(reset_video, uint8_t, (acpi_reset_video != 0));
 
-#ifndef __amd64__
+#ifdef __amd64__
+		WAKECODE_FIXUP(wakeup_efer, uint64_t, rdmsr(MSR_EFER));
+#else
 		WAKECODE_FIXUP(wakeup_cr4, register_t, pcb->pcb_cr4);
 #endif
 		WAKECODE_FIXUP(wakeup_pcb, struct pcb *, pcb);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170515184058.GF1622>