PERFORCE change 77413 for review

Peter Wemm peter at FreeBSD.org
Tue May 24 21:17:13 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=77413

Change 77413 by peter at peter_melody on 2005/05/24 21:16:11

	flesh out set_regs32().  This might be complete.

Affected files ...

.. //depot/projects/hammer/sys/amd64/ia32/ia32_reg.c#3 edit

Differences ...

==== //depot/projects/hammer/sys/amd64/ia32/ia32_reg.c#3 (text+ko) ====

@@ -44,6 +44,9 @@
 #include <machine/pcb.h>
 #include <machine/cpufunc.h>
 
+#define	CS_SECURE(cs)		(ISPL(cs) == SEL_UPL)
+#define EFL_SECURE(ef, oef)	((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
+
 int
 fill_regs32(struct thread *td, struct reg32 *regs)
 {
@@ -74,8 +77,34 @@
 int
 set_regs32(struct thread *td, struct reg32 *regs)
 {
+	struct pcb *pcb;
+	struct trapframe *tp;
 
-	return (ENOSYS);
+	tp = td->td_frame;
+	if (!EFL_SECURE(regs->r_eflags, tp->tf_rflags) || !CS_SECURE(regs->r_cs))
+		return (EINVAL);
+	pcb = td->td_pcb;
+	load_fs(regs->r_fs);
+	pcb->pcb_fs = regs->r_fs;
+	load_es(regs->r_es);
+	pcb->pcb_es = regs->r_es;
+	load_ds(regs->r_ds);
+	pcb->pcb_ds = regs->r_ds;
+	tp->tf_rdi = regs->r_edi;
+	tp->tf_rsi = regs->r_esi;
+	tp->tf_rbp = regs->r_ebp;
+	tp->tf_rbx = regs->r_ebx;
+	tp->tf_rdx = regs->r_edx;
+	tp->tf_rcx = regs->r_ecx;
+	tp->tf_rax = regs->r_eax;
+	tp->tf_rip = regs->r_eip;
+	tp->tf_cs = regs->r_cs;
+	tp->tf_rflags = regs->r_eflags;
+	tp->tf_rsp = regs->r_esp;
+	tp->tf_ss = regs->r_ss;
+	load_gs(regs->r_gs);
+	pcb->pcb_gs = regs->r_gs;
+	return (0);
 }
 
 int


More information about the p4-projects mailing list