1
In this file are all changes necessary to implement the 4.3BSD system
2
call mprotect, and the changes to make sigreturn pass back the address
3
where a fault occurred as the `code' arg. Note that sun passes the
4
address as a 4'th arg. This might be preferable, but would involve
7
This has been tested on an hp370 running 4.3 BSD from MT Xinu.
9
A man page entry for the call as implemented below.
11
Inserting file /usr/man/man2/mprotect.2
12
---Begin File /usr/man/man2/mprotect.2---
14
.TH MPROTECT 2 "9 December 1989"
16
mprotect \- specify protection of data section memory
24
mprotect(addr, len, prot)
29
.IX mprotect "" \fLmprotect\fP
30
.IX "memory management" mprotect "" \fLmprotect\fP
31
.IX "change protections \(em \fLmprotect\fP"
35
changes the access protections on the mappings specified
38
[\fIaddr, addr + len\fP\^)
39
to be that specified by
43
are PROT_READ and (PROT_WRITE | PROT_READ).
47
returns 0 on success, \-1 on failure.
54
is not a multiple of the page size as returned
59
Addresses in the range
60
[\fIaddr, addr + len\fP)
61
are not in the data section of a process.
66
---End File /usr/man/man2/mprotect.2---
69
You need to compile the following and add it to /lib/libc.a
71
Inserting file /usr/src/lib/libc/hp300/sys/mprotect.c
72
---Begin File /usr/src/lib/libc/hp300/sys/mprotect.c---
74
_sccsid:.asciz "@(#)mprotect.c"
81
---End File /usr/src/lib/libc/hp300/sys/mprotect.c---
85
*** hp300/machdep.c.orig Tue Aug 29 13:09:56 1989
86
--- hp300/machdep.c Mon Dec 11 17:07:18 1989
92
! if (sig == SIGILL || sig == SIGFPE) {
93
sigf.sf_code = u.u_code;
100
! if (sig == SIGILL || sig == SIGFPE || sig == SIGBUS) {
101
sigf.sf_code = u.u_code;
104
*** sys/kern_mman.c.orig Tue Aug 29 13:16:29 1989
105
--- sys/kern_mman.c Thu Dec 14 10:07:39 1989
108
u.u_pofile[fd] &= ~UF_MAPPED;
118
u.u_pofile[fd] &= ~UF_MAPPED;
127
! } *uap = (struct a *)u.u_ap;
130
! register struct pte *pte;
136
+ if ((uap->len < 0 ||
137
+ (int)uap->addr & CLOFSET)) {
138
+ u.u_error = EINVAL;
143
+ if ((uap->prot & PROT_WRITE) == 0)
146
+ /* check the pages are in data section */
147
+ if (!(isadsv(u.u_procp, btoc(uap->addr))
148
+ &&isadsv(u.u_procp ,btoc(uap->addr+uap->len) -1)))
149
+ { u.u_error = ENOMEM;
153
+ fv = btop(uap->addr);
154
+ pte = vtopte(u.u_procp, fv);
155
+ for (off = 0; off < uap->len; off += NBPG) {
157
+ *(u_int *)pte &= ~PG_PROT;
158
+ *(u_int *)pte |= tprot;
161
+ newptes(vtopte(u.u_procp, fv), fv, btoc(uap->len));
166
*** hp300/trap.c.orig Tue Aug 29 13:09:59 1989
167
--- hp300/trap.c Mon Dec 11 17:48:59 1989
172
case T_BUSERR+USER: /* bus error */
173
case T_ADDRERR+USER: /* address error */
181
printf("PTF|WPF...\n");
182
if (type == T_MMUFLT)
192
if (type == T_MMUFLT)