Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Sep 2007 06:53:06 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        arch@freebsd.org, Roman Divacky <rdivacky@freebsd.org>, i386@freebsd.org
Subject:   Re: PSL_RF inclusion in PSL_USERCHANGE for i386
Message-ID:  <20070904035306.GB53667@deviant.kiev.zoral.com.ua>
In-Reply-To: <20070903105130.L48985@delplex.bde.org>
References:  <20070902173953.GA52566@freebsd.org> <20070903105130.L48985@delplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--zx4FCpZtqtKETZ7O
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Sep 03, 2007 at 11:18:37AM +1000, Bruce Evans wrote:
>=20
> On Sun, 2 Sep 2007, Roman Divacky wrote:
>=20
> >in i386/i386/machdep.c the set_regs() function sets i386 registers (call=
ed
> >by ptrace for example). it checks what eflags are being changed and=20
> >compares
> >that with a mask of allowed flags to be changed. the mask is defined in=
=20
> >psl.h
> >like this:
> >
> >#define PSL_USERCHANGE (PSL_C | PSL_PF | PSL_AF | PSL_Z | PSL_N | PSL_T \
> >                       | PSL_D | PSL_V | PSL_NT | PSL_AC | PSL_ID)
> >
> >PSL_RF (Flag to ensure single-step only happens once per instruction.).=
=20
> >Can someone
> >tell me why this is omitted? I think its because of having in-kernel=20
> >debugger.
>=20
> I think it is just because user mode cannot set this flag directly,
> except probably in vm86 mode (vm86 support code already has special
> cases for it).  (Old) docs say that it can be set by popfl and iret,
> but popfl doesn't set it for me now and user mode cannot execute iret (?).
It can. It would result in exception when the normal privilege checks trigg=
ers,
but would execute as expected otherwise. For instance,

#include <sys/syscall.h>

	.text

	.globl	main
	.type	main, @function
main:	pushl	$12	/* _exit() code */
	pushfl
	pushl	%cs
	pushl	$2f

	iretl

1:	movl	$SYS_exit, %eax
	pushl	%eax
	int	$0x80

2:	pushl	$hello
	call	printf
	popl	%eax
	jmp	1b

	.size	main, . - main

hello:	.asciz	"Hello from iret\n"

--zx4FCpZtqtKETZ7O
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFG3NahC3+MBN1Mb4gRArvYAJ463KcW7Ryhk9Q70RpLY1hqKuUFoQCeO9Xw
v4RdylW+Gp4TNzhrLNA1Gwo=
=0i/3
-----END PGP SIGNATURE-----

--zx4FCpZtqtKETZ7O--



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