simplify IOPL gain/remove privs code. It's easier with md_regs

being a trapframe.
This commit is contained in:
Peter Wemm 1997-05-07 20:02:38 +00:00
parent f756433e8b
commit 36428e6100
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25552
6 changed files with 17 additions and 39 deletions

View File

@ -38,7 +38,7 @@
*
* from: Utah $Hdr: mem.c 1.13 89/10/08$
* from: @(#)mem.c 7.2 (Berkeley) 5/9/91
* $Id: mem.c,v 1.41 1997/02/22 09:32:33 peter Exp $
* $Id: mem.c,v 1.42 1997/04/14 15:54:26 bde Exp $
*/
/*
@ -145,16 +145,13 @@ mmclose(dev, flags, fmt, p)
int fmt;
struct proc *p;
{
struct trapframe *fp;
switch (minor(dev)) {
#ifdef PERFMON
case 32:
return perfmon_close(dev, flags, fmt, p);
#endif
case 14:
fp = (struct trapframe *)curproc->p_md.md_regs;
fp->tf_eflags &= ~PSL_IOPL;
curproc->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
break;
default:
break;
@ -170,7 +167,6 @@ mmopen(dev, flags, fmt, p)
struct proc *p;
{
int error;
struct trapframe *fp;
switch (minor(dev)) {
case 32:
@ -185,8 +181,7 @@ mmopen(dev, flags, fmt, p)
return (error);
if (securelevel > 0)
return (EPERM);
fp = (struct trapframe *)curproc->p_md.md_regs;
fp->tf_eflags |= PSL_IOPL;
curproc->p_md.md_regs->tf_eflags |= PSL_IOPL;
break;
default:
break;

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.213 1997/04/30 15:31:22 ache Exp $
* $Id: syscons.c,v 1.214 1997/05/07 10:42:06 yokota Exp $
*/
#include "sc.h"
@ -718,7 +718,6 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
int error;
u_int i;
struct tty *tp;
struct trapframe *fp;
scr_stat *scp;
tp = scdevtotty(dev);
@ -1138,13 +1137,11 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return error;
if (securelevel > 0)
return EPERM;
fp = (struct trapframe *)p->p_md.md_regs;
fp->tf_eflags |= PSL_IOPL;
p->p_md.md_regs->tf_eflags |= PSL_IOPL;
return 0;
case KDDISABIO: /* disallow io operations (default) */
fp = (struct trapframe *)p->p_md.md_regs;
fp->tf_eflags &= ~PSL_IOPL;
p->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
return 0;
case KDSETMODE: /* set current mode of this (virtual) console */

View File

@ -38,7 +38,7 @@
*
* from: Utah $Hdr: mem.c 1.13 89/10/08$
* from: @(#)mem.c 7.2 (Berkeley) 5/9/91
* $Id: mem.c,v 1.41 1997/02/22 09:32:33 peter Exp $
* $Id: mem.c,v 1.42 1997/04/14 15:54:26 bde Exp $
*/
/*
@ -145,16 +145,13 @@ mmclose(dev, flags, fmt, p)
int fmt;
struct proc *p;
{
struct trapframe *fp;
switch (minor(dev)) {
#ifdef PERFMON
case 32:
return perfmon_close(dev, flags, fmt, p);
#endif
case 14:
fp = (struct trapframe *)curproc->p_md.md_regs;
fp->tf_eflags &= ~PSL_IOPL;
curproc->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
break;
default:
break;
@ -170,7 +167,6 @@ mmopen(dev, flags, fmt, p)
struct proc *p;
{
int error;
struct trapframe *fp;
switch (minor(dev)) {
case 32:
@ -185,8 +181,7 @@ mmopen(dev, flags, fmt, p)
return (error);
if (securelevel > 0)
return (EPERM);
fp = (struct trapframe *)curproc->p_md.md_regs;
fp->tf_eflags |= PSL_IOPL;
curproc->p_md.md_regs->tf_eflags |= PSL_IOPL;
break;
default:
break;

View File

@ -211,7 +211,6 @@ spigot_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
int error;
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
struct trapframe *fp;
struct spigot_info *info;
if(!data) return(EINVAL);
@ -228,12 +227,10 @@ struct spigot_info *info;
if (securelevel > 0)
return EPERM;
#endif
fp=(struct trapframe *)p->p_md.md_regs;
fp->tf_eflags |= PSL_IOPL;
p->p_md.md_regs->tf_eflags |= PSL_IOPL;
break;
case SPIGOT_IOPL_OFF: /* deny access to the IO PAGE */
fp=(struct trapframe *)p->p_md.md_regs;
fp->tf_eflags &= ~PSL_IOPL;
p->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
break;
case SPIGOT_GET_INFO:
info = (struct spigot_info *)data;

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.213 1997/04/30 15:31:22 ache Exp $
* $Id: syscons.c,v 1.214 1997/05/07 10:42:06 yokota Exp $
*/
#include "sc.h"
@ -718,7 +718,6 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
int error;
u_int i;
struct tty *tp;
struct trapframe *fp;
scr_stat *scp;
tp = scdevtotty(dev);
@ -1138,13 +1137,11 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return error;
if (securelevel > 0)
return EPERM;
fp = (struct trapframe *)p->p_md.md_regs;
fp->tf_eflags |= PSL_IOPL;
p->p_md.md_regs->tf_eflags |= PSL_IOPL;
return 0;
case KDDISABIO: /* disallow io operations (default) */
fp = (struct trapframe *)p->p_md.md_regs;
fp->tf_eflags &= ~PSL_IOPL;
p->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
return 0;
case KDSETMODE: /* set current mode of this (virtual) console */

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.213 1997/04/30 15:31:22 ache Exp $
* $Id: syscons.c,v 1.214 1997/05/07 10:42:06 yokota Exp $
*/
#include "sc.h"
@ -718,7 +718,6 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
int error;
u_int i;
struct tty *tp;
struct trapframe *fp;
scr_stat *scp;
tp = scdevtotty(dev);
@ -1138,13 +1137,11 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return error;
if (securelevel > 0)
return EPERM;
fp = (struct trapframe *)p->p_md.md_regs;
fp->tf_eflags |= PSL_IOPL;
p->p_md.md_regs->tf_eflags |= PSL_IOPL;
return 0;
case KDDISABIO: /* disallow io operations (default) */
fp = (struct trapframe *)p->p_md.md_regs;
fp->tf_eflags &= ~PSL_IOPL;
p->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
return 0;
case KDSETMODE: /* set current mode of this (virtual) console */