machdep.c (79224) | machdep.c (79573) |
---|---|
1/*- 2 * Copyright (c) 1992 Terrence R. Lambert. 3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * William Jolitz. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 | 1/*- 2 * Copyright (c) 1992 Terrence R. Lambert. 3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * William Jolitz. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 |
38 * $FreeBSD: head/sys/i386/i386/machdep.c 79224 2001-07-04 16:20:28Z dillon $ | 38 * $FreeBSD: head/sys/i386/i386/machdep.c 79573 2001-07-11 03:15:25Z bsd $ |
39 */ 40 41#include "opt_atalk.h" 42#include "opt_compat.h" 43#include "opt_cpu.h" 44#include "opt_ddb.h" 45#include "opt_inet.h" 46#include "opt_ipx.h" --- 2134 unchanged lines hidden (view full) --- 2181 2182int 2183fill_dbregs(p, dbregs) 2184 struct proc *p; 2185 struct dbreg *dbregs; 2186{ 2187 struct pcb *pcb; 2188 | 39 */ 40 41#include "opt_atalk.h" 42#include "opt_compat.h" 43#include "opt_cpu.h" 44#include "opt_ddb.h" 45#include "opt_inet.h" 46#include "opt_ipx.h" --- 2134 unchanged lines hidden (view full) --- 2181 2182int 2183fill_dbregs(p, dbregs) 2184 struct proc *p; 2185 struct dbreg *dbregs; 2186{ 2187 struct pcb *pcb; 2188 |
2189 pcb = &p->p_addr->u_pcb; 2190 dbregs->dr0 = pcb->pcb_dr0; 2191 dbregs->dr1 = pcb->pcb_dr1; 2192 dbregs->dr2 = pcb->pcb_dr2; 2193 dbregs->dr3 = pcb->pcb_dr3; 2194 dbregs->dr4 = 0; 2195 dbregs->dr5 = 0; 2196 dbregs->dr6 = pcb->pcb_dr6; 2197 dbregs->dr7 = pcb->pcb_dr7; | 2189 if (p == NULL) { 2190 dbregs->dr0 = rdr0(); 2191 dbregs->dr1 = rdr1(); 2192 dbregs->dr2 = rdr2(); 2193 dbregs->dr3 = rdr3(); 2194 dbregs->dr4 = rdr4(); 2195 dbregs->dr5 = rdr5(); 2196 dbregs->dr6 = rdr6(); 2197 dbregs->dr7 = rdr7(); 2198 } 2199 else { 2200 pcb = &p->p_addr->u_pcb; 2201 dbregs->dr0 = pcb->pcb_dr0; 2202 dbregs->dr1 = pcb->pcb_dr1; 2203 dbregs->dr2 = pcb->pcb_dr2; 2204 dbregs->dr3 = pcb->pcb_dr3; 2205 dbregs->dr4 = 0; 2206 dbregs->dr5 = 0; 2207 dbregs->dr6 = pcb->pcb_dr6; 2208 dbregs->dr7 = pcb->pcb_dr7; 2209 } |
2198 return (0); 2199} 2200 2201int 2202set_dbregs(p, dbregs) 2203 struct proc *p; 2204 struct dbreg *dbregs; 2205{ 2206 struct pcb *pcb; 2207 int i; 2208 u_int32_t mask1, mask2; 2209 | 2210 return (0); 2211} 2212 2213int 2214set_dbregs(p, dbregs) 2215 struct proc *p; 2216 struct dbreg *dbregs; 2217{ 2218 struct pcb *pcb; 2219 int i; 2220 u_int32_t mask1, mask2; 2221 |
2210 /* 2211 * Don't let an illegal value for dr7 get set. Specifically, 2212 * check for undefined settings. Setting these bit patterns 2213 * result in undefined behaviour and can lead to an unexpected 2214 * TRCTRAP. 2215 */ 2216 for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8; 2217 i++, mask1 <<= 2, mask2 <<= 2) 2218 if ((dbregs->dr7 & mask1) == mask2) | 2222 if (p == NULL) { 2223 load_dr0(dbregs->dr0); 2224 load_dr1(dbregs->dr1); 2225 load_dr2(dbregs->dr2); 2226 load_dr3(dbregs->dr3); 2227 load_dr4(dbregs->dr4); 2228 load_dr5(dbregs->dr5); 2229 load_dr6(dbregs->dr6); 2230 load_dr7(dbregs->dr7); 2231 } 2232 else { 2233 /* 2234 * Don't let an illegal value for dr7 get set. Specifically, 2235 * check for undefined settings. Setting these bit patterns 2236 * result in undefined behaviour and can lead to an unexpected 2237 * TRCTRAP. 2238 */ 2239 for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8; 2240 i++, mask1 <<= 2, mask2 <<= 2) 2241 if ((dbregs->dr7 & mask1) == mask2) 2242 return (EINVAL); 2243 2244 if (dbregs->dr7 & 0x0000fc00) |
2219 return (EINVAL); 2220 | 2245 return (EINVAL); 2246 |
2221 if (dbregs->dr7 & 0x0000fc00) 2222 return (EINVAL); | 2247 pcb = &p->p_addr->u_pcb; 2248 2249 /* 2250 * Don't let a process set a breakpoint that is not within the 2251 * process's address space. If a process could do this, it 2252 * could halt the system by setting a breakpoint in the kernel 2253 * (if ddb was enabled). Thus, we need to check to make sure 2254 * that no breakpoints are being enabled for addresses outside 2255 * process's address space, unless, perhaps, we were called by 2256 * uid 0. 2257 * 2258 * XXX - what about when the watched area of the user's 2259 * address space is written into from within the kernel 2260 * ... wouldn't that still cause a breakpoint to be generated 2261 * from within kernel mode? 2262 */ |
2223 | 2263 |
2224 2225 2226 pcb = &p->p_addr->u_pcb; 2227 2228 /* 2229 * Don't let a process set a breakpoint that is not within the 2230 * process's address space. If a process could do this, it 2231 * could halt the system by setting a breakpoint in the kernel 2232 * (if ddb was enabled). Thus, we need to check to make sure 2233 * that no breakpoints are being enabled for addresses outside 2234 * process's address space, unless, perhaps, we were called by 2235 * uid 0. 2236 * 2237 * XXX - what about when the watched area of the user's 2238 * address space is written into from within the kernel 2239 * ... wouldn't that still cause a breakpoint to be generated 2240 * from within kernel mode? 2241 */ 2242 2243 if (suser(p) != 0) { 2244 if (dbregs->dr7 & 0x3) { 2245 /* dr0 is enabled */ 2246 if (dbregs->dr0 >= VM_MAXUSER_ADDRESS) 2247 return (EINVAL); | 2264 if (suser(p) != 0) { 2265 if (dbregs->dr7 & 0x3) { 2266 /* dr0 is enabled */ 2267 if (dbregs->dr0 >= VM_MAXUSER_ADDRESS) 2268 return (EINVAL); 2269 } 2270 2271 if (dbregs->dr7 & (0x3<<2)) { 2272 /* dr1 is enabled */ 2273 if (dbregs->dr1 >= VM_MAXUSER_ADDRESS) 2274 return (EINVAL); 2275 } 2276 2277 if (dbregs->dr7 & (0x3<<4)) { 2278 /* dr2 is enabled */ 2279 if (dbregs->dr2 >= VM_MAXUSER_ADDRESS) 2280 return (EINVAL); 2281 } 2282 2283 if (dbregs->dr7 & (0x3<<6)) { 2284 /* dr3 is enabled */ 2285 if (dbregs->dr3 >= VM_MAXUSER_ADDRESS) 2286 return (EINVAL); 2287 } |
2248 } 2249 | 2288 } 2289 |
2250 if (dbregs->dr7 & (0x3<<2)) { 2251 /* dr1 is enabled */ 2252 if (dbregs->dr1 >= VM_MAXUSER_ADDRESS) 2253 return (EINVAL); 2254 } | 2290 pcb->pcb_dr0 = dbregs->dr0; 2291 pcb->pcb_dr1 = dbregs->dr1; 2292 pcb->pcb_dr2 = dbregs->dr2; 2293 pcb->pcb_dr3 = dbregs->dr3; 2294 pcb->pcb_dr6 = dbregs->dr6; 2295 pcb->pcb_dr7 = dbregs->dr7; |
2255 | 2296 |
2256 if (dbregs->dr7 & (0x3<<4)) { 2257 /* dr2 is enabled */ 2258 if (dbregs->dr2 >= VM_MAXUSER_ADDRESS) 2259 return (EINVAL); 2260 } 2261 2262 if (dbregs->dr7 & (0x3<<6)) { 2263 /* dr3 is enabled */ 2264 if (dbregs->dr3 >= VM_MAXUSER_ADDRESS) 2265 return (EINVAL); 2266 } | 2297 pcb->pcb_flags |= PCB_DBREGS; |
2267 } 2268 | 2298 } 2299 |
2269 pcb->pcb_dr0 = dbregs->dr0; 2270 pcb->pcb_dr1 = dbregs->dr1; 2271 pcb->pcb_dr2 = dbregs->dr2; 2272 pcb->pcb_dr3 = dbregs->dr3; 2273 pcb->pcb_dr6 = dbregs->dr6; 2274 pcb->pcb_dr7 = dbregs->dr7; 2275 2276 pcb->pcb_flags |= PCB_DBREGS; 2277 | |
2278 return (0); 2279} 2280 2281/* 2282 * Return > 0 if a hardware breakpoint has been hit, and the 2283 * breakpoint was in user space. Return 0, otherwise. 2284 */ 2285int --- 177 unchanged lines hidden --- | 2300 return (0); 2301} 2302 2303/* 2304 * Return > 0 if a hardware breakpoint has been hit, and the 2305 * breakpoint was in user space. Return 0, otherwise. 2306 */ 2307int --- 177 unchanged lines hidden --- |