Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Mar 2014 21:35:57 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r262752 - in head/sys: amd64/amd64 amd64/include x86/acpica
Message-ID:  <201403042135.s24LZvoW023992@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Tue Mar  4 21:35:57 2014
New Revision: 262752
URL: http://svnweb.freebsd.org/changeset/base/262752

Log:
  Move fpusave() wrapper for suspend hander to sys/amd64/amd64/fpu.c.
  
  Inspired by:	jhb

Modified:
  head/sys/amd64/amd64/cpu_switch.S
  head/sys/amd64/amd64/fpu.c
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/amd64/include/fpu.h
  head/sys/amd64/include/md_var.h
  head/sys/x86/acpica/acpi_wakeup.c

Modified: head/sys/amd64/amd64/cpu_switch.S
==============================================================================
--- head/sys/amd64/amd64/cpu_switch.S	Tue Mar  4 20:21:43 2014	(r262751)
+++ head/sys/amd64/amd64/cpu_switch.S	Tue Mar  4 21:35:57 2014	(r262752)
@@ -546,16 +546,3 @@ ENTRY(resumectx)
 	xorl	%eax,%eax
 	ret
 END(resumectx)
-
-/*
- * Wrapper around fpusave to care about CR0_TS.
- */
-ENTRY(ctx_fpusave)
-	movq	%cr0,%rax
-	pushq	%rax
-	clts
-	call	fpusave
-	popq	%rax
-	movq	%rax,%cr0
-	ret
-END(ctx_fpusave)

Modified: head/sys/amd64/amd64/fpu.c
==============================================================================
--- head/sys/amd64/amd64/fpu.c	Tue Mar  4 20:21:43 2014	(r262751)
+++ head/sys/amd64/amd64/fpu.c	Tue Mar  4 21:35:57 2014	(r262752)
@@ -162,6 +162,17 @@ fpurestore(void *addr)
 		fxrstor((char *)addr);
 }
 
+void
+fpususpend(void *addr)
+{
+	u_long cr0;
+
+	cr0 = rcr0();
+	stop_emulating();
+	fpusave(addr);
+	load_cr0(cr0);
+}
+
 /*
  * Enable XSAVE if supported and allowed by user.
  * Calculate the xsave_mask.

Modified: head/sys/amd64/amd64/mp_machdep.c
==============================================================================
--- head/sys/amd64/amd64/mp_machdep.c	Tue Mar  4 20:21:43 2014	(r262751)
+++ head/sys/amd64/amd64/mp_machdep.c	Tue Mar  4 21:35:57 2014	(r262752)
@@ -1464,7 +1464,7 @@ cpususpend_handler(void)
 
 	cpu = PCPU_GET(cpuid);
 	if (savectx(susppcbs[cpu])) {
-		ctx_fpusave(susppcbs[cpu]->pcb_fpususpend);
+		fpususpend(susppcbs[cpu]->pcb_fpususpend);
 		wbinvd();
 		CPU_SET_ATOMIC(cpu, &suspended_cpus);
 	} else {

Modified: head/sys/amd64/include/fpu.h
==============================================================================
--- head/sys/amd64/include/fpu.h	Tue Mar  4 20:21:43 2014	(r262751)
+++ head/sys/amd64/include/fpu.h	Tue Mar  4 21:35:57 2014	(r262752)
@@ -63,6 +63,7 @@ int	fpusetregs(struct thread *td, struct
 	    char *xfpustate, size_t xfpustate_size);
 int	fpusetxstate(struct thread *td, char *xfpustate,
 	    size_t xfpustate_size);
+void	fpususpend(void *addr);
 int	fputrap_sse(void);
 int	fputrap_x87(void);
 void	fpuuserinited(struct thread *td);

Modified: head/sys/amd64/include/md_var.h
==============================================================================
--- head/sys/amd64/include/md_var.h	Tue Mar  4 20:21:43 2014	(r262751)
+++ head/sys/amd64/include/md_var.h	Tue Mar  4 21:35:57 2014	(r262752)
@@ -89,7 +89,6 @@ void	*alloc_fpusave(int flags);
 void	amd64_syscall(struct thread *td, int traced);
 void	busdma_swi(void);
 void	cpu_setregs(void);
-void	ctx_fpusave(void *);
 void	doreti_iret(void) __asm(__STRING(doreti_iret));
 void	doreti_iret_fault(void) __asm(__STRING(doreti_iret_fault));
 void	ld_ds(void) __asm(__STRING(ld_ds));

Modified: head/sys/x86/acpica/acpi_wakeup.c
==============================================================================
--- head/sys/x86/acpica/acpi_wakeup.c	Tue Mar  4 20:21:43 2014	(r262751)
+++ head/sys/x86/acpica/acpi_wakeup.c	Tue Mar  4 21:35:57 2014	(r262752)
@@ -202,7 +202,7 @@ acpi_sleep_machdep(struct acpi_softc *sc
 
 	if (savectx(susppcbs[0])) {
 #ifdef __amd64__
-		ctx_fpusave(susppcbs[0]->pcb_fpususpend);
+		fpususpend(susppcbs[0]->pcb_fpususpend);
 #endif
 #ifdef SMP
 		if (!CPU_EMPTY(&suspcpus) && suspend_cpus(suspcpus) == 0) {



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