Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Make the execution flow canonical instead of jumping bac...
details: https://anonhg.NetBSD.org/src/rev/50812f527248
branches: trunk
changeset: 346272:50812f527248
user: maxv <maxv%NetBSD.org@localhost>
date: Mon Jul 04 07:56:07 2016 +0000
description:
Make the execution flow canonical instead of jumping back and forth, and
complete the userland check.
diffstat:
sys/arch/amd64/amd64/locore.S | 23 +++++++++++------------
sys/arch/i386/i386/locore.S | 31 +++++++++++++++----------------
sys/kern/kern_ras.c | 6 ++++--
3 files changed, 30 insertions(+), 30 deletions(-)
diffs (141 lines):
diff -r 494e3dfbd725 -r 50812f527248 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S Mon Jul 04 07:44:08 2016 +0000
+++ b/sys/arch/amd64/amd64/locore.S Mon Jul 04 07:56:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.103 2016/07/01 13:11:21 maxv Exp $ */
+/* $NetBSD: locore.S,v 1.104 2016/07/04 07:56:07 maxv Exp $ */
/*
* Copyright-o-rama!
@@ -1138,13 +1138,21 @@
/* Is this process using RAS (restartable atomic sequences)? */
movq L_PROC(%r12),%rdi
cmpq $0,P_RASLIST(%rdi)
- jne 5f
+ je no_RAS
+
+ /* Handle restartable atomic sequences (RAS). */
+ movq L_MD_REGS(%r12),%rbx
+ movq TF_RIP(%rbx),%rsi
+ call _C_LABEL(ras_lookup)
+ cmpq $-1,%rax
+ je no_RAS
+ movq %rax,TF_RIP(%rbx)
+no_RAS:
/*
* Restore cr0 including FPU state (may have CR0_TS set). Note that
* IPL_SCHED prevents from FPU interrupt altering the LWP's saved cr0.
*/
-2:
#ifndef XEN
movl $IPL_HIGH,CPUVAR(ILEVEL)
movl PCB_CR0(%r14),%ecx /* has CR0_TS clear */
@@ -1223,15 +1231,6 @@
popq %r12
popq %rbx
ret
-
- /* Check for restartable atomic sequences (RAS). */
-5: movq L_MD_REGS(%r12),%rbx
- movq TF_RIP(%rbx),%rsi
- call _C_LABEL(ras_lookup)
- cmpq $-1,%rax
- je 2b
- movq %rax,TF_RIP(%rbx)
- jmp 2b
END(cpu_switchto)
/*
diff -r 494e3dfbd725 -r 50812f527248 sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S Mon Jul 04 07:44:08 2016 +0000
+++ b/sys/arch/i386/i386/locore.S Mon Jul 04 07:56:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.132 2016/07/01 13:11:21 maxv Exp $ */
+/* $NetBSD: locore.S,v 1.133 2016/07/04 07:56:07 maxv Exp $ */
/*
* Copyright-o-rama!
@@ -128,7 +128,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.132 2016/07/01 13:11:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.133 2016/07/04 07:56:07 maxv Exp $");
#include "opt_compat_oldboot.h"
#include "opt_copy_symtab.h"
@@ -1191,14 +1191,25 @@
/* Is this process using RAS (restartable atomic sequences)? */
movl L_PROC(%edi),%eax
cmpl $0,P_RASLIST(%eax)
- jne 5f
+ je no_RAS
+
+ /* Handle restartable atomic sequences (RAS). */
+ movl L_MD_REGS(%edi),%ecx
+ pushl TF_EIP(%ecx)
+ pushl %eax
+ call _C_LABEL(ras_lookup)
+ addl $8,%esp
+ cmpl $-1,%eax
+ je no_RAS
+ movl L_MD_REGS(%edi),%ecx
+ movl %eax,TF_EIP(%ecx)
+no_RAS:
/*
* Restore cr0 (including FPU state). Raise the IPL to IPL_HIGH.
* FPU IPIs can alter the LWP's saved cr0. Dropping the priority
* is deferred until mi_switch(), when cpu_switchto() returns.
*/
-2:
#ifdef XEN
pushl %edi
call _C_LABEL(i386_tls_switch)
@@ -1231,18 +1242,6 @@
popl %ebx
ret
- /* Check for restartable atomic sequences (RAS). */
-5: movl L_MD_REGS(%edi),%ecx
- pushl TF_EIP(%ecx)
- pushl %eax
- call _C_LABEL(ras_lookup)
- addl $8,%esp
- cmpl $-1,%eax
- je 2b
- movl L_MD_REGS(%edi),%ecx
- movl %eax,TF_EIP(%ecx)
- jmp 2b
-
.Lcopy_iobitmap:
/* Copy I/O bitmap. */
incl _C_LABEL(pmap_iobmp_evcnt)+EV_COUNT
diff -r 494e3dfbd725 -r 50812f527248 sys/kern/kern_ras.c
--- a/sys/kern/kern_ras.c Mon Jul 04 07:44:08 2016 +0000
+++ b/sys/kern/kern_ras.c Mon Jul 04 07:56:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_ras.c,v 1.37 2016/07/01 12:49:22 maxv Exp $ */
+/* $NetBSD: kern_ras.c,v 1.38 2016/07/04 07:56:07 maxv Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.37 2016/07/01 12:49:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.38 2016/07/04 07:56:07 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -206,6 +206,8 @@
__WARNING_PUSH_LESS_NULL_PTR
if (addr < (void *)VM_MIN_ADDRESS || addr > (void *)VM_MAXUSER_ADDRESS)
return EINVAL;
+ if (endaddr > (void *)VM_MAXUSER_ADDRESS)
+ return EINVAL;
if (endaddr < addr)
return EINVAL;
__WARNING_POP_LESS_NULL_PTR
Home |
Main Index |
Thread Index |
Old Index