Deleted Added
sdiff udiff text old ( 262752 ) new ( 271192 )
full compact
1/*-
2 * Copyright (c) 2003 Peter Wemm.
3 * Copyright (c) 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *

--- 16 unchanged lines hidden (view full) ---

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/sys/amd64/amd64/cpu_switch.S 262752 2014-03-04 21:35:57Z jkim $
34 */
35
36#include <machine/asmacros.h>
37#include <machine/specialreg.h>
38
39#include "assym.s"
40#include "opt_sched.h"
41

--- 352 unchanged lines hidden (view full) ---

394 movl $MSR_CSTAR,%ecx
395 rdmsr
396 movl %eax,PCB_CSTAR(%rdi)
397 movl %edx,PCB_CSTAR+4(%rdi)
398 movl $MSR_SF_MASK,%ecx
399 rdmsr
400 movl %eax,PCB_SFMASK(%rdi)
401 movl %edx,PCB_SFMASK+4(%rdi)
402 movl xsave_mask,%eax
403 movl %eax,PCB_XSMASK(%rdi)
404 movl xsave_mask+4,%eax
405 movl %eax,PCB_XSMASK+4(%rdi)
406
407 sgdt PCB_GDT(%rdi)
408 sidt PCB_IDT(%rdi)
409 sldt PCB_LDT(%rdi)
410 str PCB_TR(%rdi)
411
412 movl $1,%eax
413 ret

--- 48 unchanged lines hidden (view full) ---

462 movl $MSR_CSTAR,%ecx
463 movl PCB_CSTAR(%rdi),%eax
464 movl 4 + PCB_CSTAR(%rdi),%edx
465 wrmsr
466 movl $MSR_SF_MASK,%ecx
467 movl PCB_SFMASK(%rdi),%eax
468 wrmsr
469
470 /* Restore CR0 except for FPU mode. */
471 movq PCB_CR0(%rdi),%rax
472 andq $~(CR0_EM | CR0_TS),%rax
473 movq %rax,%cr0
474
475 /* Restore CR2, CR4 and CR3. */
476 movq PCB_CR2(%rdi),%rax
477 movq %rax,%cr2
478 movq PCB_CR4(%rdi),%rax
479 movq %rax,%cr4
480 movq PCB_CR3(%rdi),%rax
481 movq %rax,%cr3
482
483 /* Restore descriptor tables. */

--- 21 unchanged lines hidden (view full) ---

505 movq %rax,%dr2
506 movq PCB_DR3(%rdi),%rax
507 movq %rax,%dr3
508 movq PCB_DR6(%rdi),%rax
509 movq %rax,%dr6
510 movq PCB_DR7(%rdi),%rax
511 movq %rax,%dr7
512
513 /* Restore FPU state. */
514 fninit
515 movq PCB_FPUSUSPEND(%rdi),%rbx
516 movq PCB_XSMASK(%rdi),%rax
517 testq %rax,%rax
518 jz 1f
519 movq %rax,%rdx
520 shrq $32,%rdx
521 movl $XCR0,%ecx
522 xsetbv
523 xrstor (%rbx)
524 jmp 2f
5251:
526 fxrstor (%rbx)
5272:
528
529 /* Reload CR0. */
530 movq PCB_CR0(%rdi),%rax
531 movq %rax,%cr0
532
533 /* Restore other callee saved registers. */
534 movq PCB_R15(%rdi),%r15
535 movq PCB_R14(%rdi),%r14
536 movq PCB_R13(%rdi),%r13
537 movq PCB_R12(%rdi),%r12
538 movq PCB_RBP(%rdi),%rbp
539 movq PCB_RSP(%rdi),%rsp
540 movq PCB_RBX(%rdi),%rbx
541
542 /* Restore return address. */
543 movq PCB_RIP(%rdi),%rax
544 movq %rax,(%rsp)
545
546 xorl %eax,%eax
547 ret
548END(resumectx)