vm_machdep.c revision 209198
1132332Smarcel/*- 2132332Smarcel * Copyright (c) 1982, 1986 The Regents of the University of California. 3132332Smarcel * Copyright (c) 1989, 1990 William Jolitz 4132332Smarcel * Copyright (c) 1994 John Dyson 5132332Smarcel * All rights reserved. 6132332Smarcel * 7132332Smarcel * This code is derived from software contributed to Berkeley by 8132332Smarcel * the Systems Programming Group of the University of Utah Computer 9132332Smarcel * Science Department, and William Jolitz. 10132332Smarcel * 11132332Smarcel * Redistribution and use in source and binary forms, with or without 12132332Smarcel * modification, are permitted provided that the following conditions 13132332Smarcel * are met: 14132332Smarcel * 1. Redistributions of source code must retain the above copyright 15132332Smarcel * notice, this list of conditions and the following disclaimer. 16132332Smarcel * 2. Redistributions in binary form must reproduce the above copyright 17132332Smarcel * notice, this list of conditions and the following disclaimer in the 18132332Smarcel * documentation and/or other materials provided with the distribution. 19132332Smarcel * 3. All advertising materials mentioning features or use of this software 20132332Smarcel * must display the following acknowledgement: 21132332Smarcel * This product includes software developed by the University of 22132332Smarcel * California, Berkeley and its contributors. 23132332Smarcel * 4. Neither the name of the University nor the names of its contributors 24132332Smarcel * may be used to endorse or promote products derived from this software 25132332Smarcel * without specific prior written permission. 26132332Smarcel * 27132332Smarcel * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28132332Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29132332Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30132332Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31132332Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32132332Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33132332Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34132332Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35132332Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36132332Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37181059Smarcel * SUCH DAMAGE. 38181059Smarcel * 39181059Smarcel * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 40181059Smarcel * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ 41181059Smarcel */ 42181059Smarcel 43132332Smarcel#include <sys/cdefs.h> 44181059Smarcel__FBSDID("$FreeBSD: head/sys/amd64/amd64/vm_machdep.c 209198 2010-06-15 09:19:33Z kib $"); 45132332Smarcel 46132332Smarcel#include "opt_isa.h" 47132332Smarcel#include "opt_cpu.h" 48132332Smarcel#include "opt_compat.h" 49132332Smarcel 50132332Smarcel#include <sys/param.h> 51132332Smarcel#include <sys/systm.h> 52132332Smarcel#include <sys/bio.h> 53132332Smarcel#include <sys/buf.h> 54132332Smarcel#include <sys/kernel.h> 55132332Smarcel#include <sys/ktr.h> 56132332Smarcel#include <sys/lock.h> 57132332Smarcel#include <sys/malloc.h> 58132332Smarcel#include <sys/mbuf.h> 59132332Smarcel#include <sys/mutex.h> 60133802Sdavidxu#include <sys/pioctl.h> 61133802Sdavidxu#include <sys/proc.h> 62133802Sdavidxu#include <sys/sf_buf.h> 63133802Sdavidxu#include <sys/smp.h> 64133802Sdavidxu#include <sys/sysctl.h> 65133802Sdavidxu#include <sys/sysent.h> 66133802Sdavidxu#include <sys/unistd.h> 67133802Sdavidxu#include <sys/vnode.h> 68133802Sdavidxu#include <sys/vmmeter.h> 69133802Sdavidxu 70133802Sdavidxu#include <machine/cpu.h> 71133802Sdavidxu#include <machine/md_var.h> 72133802Sdavidxu#include <machine/pcb.h> 73133802Sdavidxu#include <machine/specialreg.h> 74133802Sdavidxu#include <machine/tss.h> 75133802Sdavidxu 76133802Sdavidxu#include <vm/vm.h> 77158680Sdavidxu#include <vm/vm_extern.h> 78158680Sdavidxu#include <vm/vm_kern.h> 79132332Smarcel#include <vm/vm_page.h> 80132332Smarcel#include <vm/vm_map.h> 81132332Smarcel#include <vm/vm_param.h> 82132332Smarcel 83132332Smarcel#include <x86/isa/isa.h> 84132332Smarcel 85132332Smarcelstatic void cpu_reset_real(void); 86132332Smarcel#ifdef SMP 87132332Smarcelstatic void cpu_reset_proxy(void); 88146818Sdfrstatic u_int cpu_reset_proxyid; 89146818Sdfrstatic volatile u_int cpu_reset_proxy_active; 90146818Sdfr#endif 91146818Sdfr 92132332Smarcel/* 93132332Smarcel * Finish a fork operation, with process p2 nearly set up. 94132332Smarcel * Copy and update the pcb, set up the stack so that the child 95 * ready to run and return to user mode. 96 */ 97void 98cpu_fork(td1, p2, td2, flags) 99 register struct thread *td1; 100 register struct proc *p2; 101 struct thread *td2; 102 int flags; 103{ 104 register struct proc *p1; 105 struct pcb *pcb2; 106 struct mdproc *mdp1, *mdp2; 107 struct proc_ldt *pldt; 108 pmap_t pmap2; 109 110 p1 = td1->td_proc; 111 if ((flags & RFPROC) == 0) { 112 if ((flags & RFMEM) == 0) { 113 /* unshare user LDT */ 114 mdp1 = &p1->p_md; 115 mtx_lock(&dt_lock); 116 if ((pldt = mdp1->md_ldt) != NULL && 117 pldt->ldt_refcnt > 1 && 118 user_ldt_alloc(p1, 1) == NULL) 119 panic("could not copy LDT"); 120 mtx_unlock(&dt_lock); 121 } 122 return; 123 } 124 125 /* Ensure that td1's pcb is up to date. */ 126 fpuexit(td1); 127 128 /* Point the pcb to the top of the stack */ 129 pcb2 = (struct pcb *)(td2->td_kstack + 130 td2->td_kstack_pages * PAGE_SIZE) - 1; 131 td2->td_pcb = pcb2; 132 133 /* Copy td1's pcb */ 134 bcopy(td1->td_pcb, pcb2, sizeof(*pcb2)); 135 136 /* Properly initialize pcb_save */ 137 pcb2->pcb_save = &pcb2->pcb_user_save; 138 139 /* Point mdproc and then copy over td1's contents */ 140 mdp2 = &p2->p_md; 141 bcopy(&p1->p_md, mdp2, sizeof(*mdp2)); 142 143 /* 144 * Create a new fresh stack for the new process. 145 * Copy the trap frame for the return to user mode as if from a 146 * syscall. This copies most of the user mode register values. 147 */ 148 td2->td_frame = (struct trapframe *)td2->td_pcb - 1; 149 bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); 150 151 td2->td_frame->tf_rax = 0; /* Child returns zero */ 152 td2->td_frame->tf_rflags &= ~PSL_C; /* success */ 153 td2->td_frame->tf_rdx = 1; 154 155 /* 156 * If the parent process has the trap bit set (i.e. a debugger had 157 * single stepped the process to the system call), we need to clear 158 * the trap flag from the new frame unless the debugger had set PF_FORK 159 * on the parent. Otherwise, the child will receive a (likely 160 * unexpected) SIGTRAP when it executes the first instruction after 161 * returning to userland. 162 */ 163 if ((p1->p_pfsflags & PF_FORK) == 0) 164 td2->td_frame->tf_rflags &= ~PSL_T; 165 166 /* 167 * Set registers for trampoline to user mode. Leave space for the 168 * return address on stack. These are the kernel mode register values. 169 */ 170 pmap2 = vmspace_pmap(p2->p_vmspace); 171 pcb2->pcb_cr3 = DMAP_TO_PHYS((vm_offset_t)pmap2->pm_pml4); 172 pcb2->pcb_r12 = (register_t)fork_return; /* fork_trampoline argument */ 173 pcb2->pcb_rbp = 0; 174 pcb2->pcb_rsp = (register_t)td2->td_frame - sizeof(void *); 175 pcb2->pcb_rbx = (register_t)td2; /* fork_trampoline argument */ 176 pcb2->pcb_rip = (register_t)fork_trampoline; 177 /*- 178 * pcb2->pcb_dr*: cloned above. 179 * pcb2->pcb_savefpu: cloned above. 180 * pcb2->pcb_flags: cloned above. 181 * pcb2->pcb_onfault: cloned above (always NULL here?). 182 * pcb2->pcb_[fg]sbase: cloned above 183 */ 184 185 /* Setup to release spin count in fork_exit(). */ 186 td2->td_md.md_spinlock_count = 1; 187 td2->td_md.md_saved_flags = PSL_KERNEL | PSL_I; 188 189 /* As an i386, do not copy io permission bitmap. */ 190 pcb2->pcb_tssp = NULL; 191 192 /* New segment registers. */ 193 pcb2->pcb_full_iret = 1; 194 195 /* Copy the LDT, if necessary. */ 196 mdp1 = &td1->td_proc->p_md; 197 mdp2 = &p2->p_md; 198 mtx_lock(&dt_lock); 199 if (mdp1->md_ldt != NULL) { 200 if (flags & RFMEM) { 201 mdp1->md_ldt->ldt_refcnt++; 202 mdp2->md_ldt = mdp1->md_ldt; 203 bcopy(&mdp1->md_ldt_sd, &mdp2->md_ldt_sd, sizeof(struct 204 system_segment_descriptor)); 205 } else { 206 mdp2->md_ldt = NULL; 207 mdp2->md_ldt = user_ldt_alloc(p2, 0); 208 if (mdp2->md_ldt == NULL) 209 panic("could not copy LDT"); 210 amd64_set_ldt_data(td2, 0, max_ldt_segment, 211 (struct user_segment_descriptor *) 212 mdp1->md_ldt->ldt_base); 213 } 214 } else 215 mdp2->md_ldt = NULL; 216 mtx_unlock(&dt_lock); 217 218 /* 219 * Now, cpu_switch() can schedule the new process. 220 * pcb_rsp is loaded pointing to the cpu_switch() stack frame 221 * containing the return address when exiting cpu_switch. 222 * This will normally be to fork_trampoline(), which will have 223 * %ebx loaded with the new proc's pointer. fork_trampoline() 224 * will set up a stack to call fork_return(p, frame); to complete 225 * the return to user-mode. 226 */ 227} 228 229/* 230 * Intercept the return address from a freshly forked process that has NOT 231 * been scheduled yet. 232 * 233 * This is needed to make kernel threads stay in kernel mode. 234 */ 235void 236cpu_set_fork_handler(td, func, arg) 237 struct thread *td; 238 void (*func)(void *); 239 void *arg; 240{ 241 /* 242 * Note that the trap frame follows the args, so the function 243 * is really called like this: func(arg, frame); 244 */ 245 td->td_pcb->pcb_r12 = (long) func; /* function */ 246 td->td_pcb->pcb_rbx = (long) arg; /* first arg */ 247} 248 249void 250cpu_exit(struct thread *td) 251{ 252 253 /* 254 * If this process has a custom LDT, release it. 255 */ 256 mtx_lock(&dt_lock); 257 if (td->td_proc->p_md.md_ldt != 0) 258 user_ldt_free(td); 259 else 260 mtx_unlock(&dt_lock); 261} 262 263void 264cpu_thread_exit(struct thread *td) 265{ 266 struct pcb *pcb; 267 268 critical_enter(); 269 if (td == PCPU_GET(fpcurthread)) 270 fpudrop(); 271 critical_exit(); 272 273 pcb = td->td_pcb; 274 275 /* Disable any hardware breakpoints. */ 276 if (pcb->pcb_flags & PCB_DBREGS) { 277 reset_dbregs(); 278 pcb->pcb_flags &= ~PCB_DBREGS; 279 } 280} 281 282void 283cpu_thread_clean(struct thread *td) 284{ 285 struct pcb *pcb; 286 287 pcb = td->td_pcb; 288 289 /* 290 * Clean TSS/iomap 291 */ 292 if (pcb->pcb_tssp != NULL) { 293 kmem_free(kernel_map, (vm_offset_t)pcb->pcb_tssp, 294 ctob(IOPAGES + 1)); 295 pcb->pcb_tssp = NULL; 296 } 297} 298 299void 300cpu_thread_swapin(struct thread *td) 301{ 302} 303 304void 305cpu_thread_swapout(struct thread *td) 306{ 307} 308 309void 310cpu_thread_alloc(struct thread *td) 311{ 312 313 td->td_pcb = (struct pcb *)(td->td_kstack + 314 td->td_kstack_pages * PAGE_SIZE) - 1; 315 td->td_frame = (struct trapframe *)td->td_pcb - 1; 316 td->td_pcb->pcb_save = &td->td_pcb->pcb_user_save; 317} 318 319void 320cpu_thread_free(struct thread *td) 321{ 322 323 cpu_thread_clean(td); 324} 325 326void 327cpu_set_syscall_retval(struct thread *td, int error) 328{ 329 330 switch (error) { 331 case 0: 332 td->td_frame->tf_rax = td->td_retval[0]; 333 td->td_frame->tf_rdx = td->td_retval[1]; 334 td->td_frame->tf_rflags &= ~PSL_C; 335 break; 336 337 case ERESTART: 338 /* 339 * Reconstruct pc, we know that 'syscall' is 2 bytes, 340 * lcall $X,y is 7 bytes, int 0x80 is 2 bytes. 341 * We saved this in tf_err. 342 * We have to do a full context restore so that %r10 343 * (which was holding the value of %rcx) is restored 344 * for the next iteration. 345 * r10 restore is only required for freebsd/amd64 processes, 346 * but shall be innocent for any ia32 ABI. 347 */ 348 td->td_frame->tf_rip -= td->td_frame->tf_err; 349 td->td_frame->tf_r10 = td->td_frame->tf_rcx; 350 td->td_pcb->pcb_flags |= PCB_FULLCTX; 351 break; 352 353 case EJUSTRETURN: 354 break; 355 356 default: 357 if (td->td_proc->p_sysent->sv_errsize) { 358 if (error >= td->td_proc->p_sysent->sv_errsize) 359 error = -1; /* XXX */ 360 else 361 error = td->td_proc->p_sysent->sv_errtbl[error]; 362 } 363 td->td_frame->tf_rax = error; 364 td->td_frame->tf_rflags |= PSL_C; 365 break; 366 } 367} 368 369/* 370 * Initialize machine state (pcb and trap frame) for a new thread about to 371 * upcall. Put enough state in the new thread's PCB to get it to go back 372 * userret(), where we can intercept it again to set the return (upcall) 373 * Address and stack, along with those from upcals that are from other sources 374 * such as those generated in thread_userret() itself. 375 */ 376void 377cpu_set_upcall(struct thread *td, struct thread *td0) 378{ 379 struct pcb *pcb2; 380 381 /* Point the pcb to the top of the stack. */ 382 pcb2 = td->td_pcb; 383 384 /* 385 * Copy the upcall pcb. This loads kernel regs. 386 * Those not loaded individually below get their default 387 * values here. 388 */ 389 bcopy(td0->td_pcb, pcb2, sizeof(*pcb2)); 390 pcb2->pcb_flags &= ~(PCB_FPUINITDONE | PCB_USERFPUINITDONE); 391 pcb2->pcb_save = &pcb2->pcb_user_save; 392 pcb2->pcb_full_iret = 1; 393 394 /* 395 * Create a new fresh stack for the new thread. 396 */ 397 bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe)); 398 399 /* If the current thread has the trap bit set (i.e. a debugger had 400 * single stepped the process to the system call), we need to clear 401 * the trap flag from the new frame. Otherwise, the new thread will 402 * receive a (likely unexpected) SIGTRAP when it executes the first 403 * instruction after returning to userland. 404 */ 405 td->td_frame->tf_rflags &= ~PSL_T; 406 407 /* 408 * Set registers for trampoline to user mode. Leave space for the 409 * return address on stack. These are the kernel mode register values. 410 */ 411 pcb2->pcb_r12 = (register_t)fork_return; /* trampoline arg */ 412 pcb2->pcb_rbp = 0; 413 pcb2->pcb_rsp = (register_t)td->td_frame - sizeof(void *); /* trampoline arg */ 414 pcb2->pcb_rbx = (register_t)td; /* trampoline arg */ 415 pcb2->pcb_rip = (register_t)fork_trampoline; 416 /* 417 * If we didn't copy the pcb, we'd need to do the following registers: 418 * pcb2->pcb_cr3: cloned above. 419 * pcb2->pcb_dr*: cloned above. 420 * pcb2->pcb_savefpu: cloned above. 421 * pcb2->pcb_onfault: cloned above (always NULL here?). 422 * pcb2->pcb_[fg]sbase: cloned above 423 */ 424 425 /* Setup to release spin count in fork_exit(). */ 426 td->td_md.md_spinlock_count = 1; 427 td->td_md.md_saved_flags = PSL_KERNEL | PSL_I; 428} 429 430/* 431 * Set that machine state for performing an upcall that has to 432 * be done in thread_userret() so that those upcalls generated 433 * in thread_userret() itself can be done as well. 434 */ 435void 436cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, 437 stack_t *stack) 438{ 439 440 /* 441 * Do any extra cleaning that needs to be done. 442 * The thread may have optional components 443 * that are not present in a fresh thread. 444 * This may be a recycled thread so make it look 445 * as though it's newly allocated. 446 */ 447 cpu_thread_clean(td); 448 449#ifdef COMPAT_FREEBSD32 450 if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { 451 /* 452 * Set the trap frame to point at the beginning of the uts 453 * function. 454 */ 455 td->td_frame->tf_rbp = 0; 456 td->td_frame->tf_rsp = 457 (((uintptr_t)stack->ss_sp + stack->ss_size - 4) & ~0x0f) - 4; 458 td->td_frame->tf_rip = (uintptr_t)entry; 459 460 /* 461 * Pass the address of the mailbox for this kse to the uts 462 * function as a parameter on the stack. 463 */ 464 suword32((void *)(td->td_frame->tf_rsp + sizeof(int32_t)), 465 (uint32_t)(uintptr_t)arg); 466 467 return; 468 } 469#endif 470 471 /* 472 * Set the trap frame to point at the beginning of the uts 473 * function. 474 */ 475 td->td_frame->tf_rbp = 0; 476 td->td_frame->tf_rsp = 477 ((register_t)stack->ss_sp + stack->ss_size) & ~0x0f; 478 td->td_frame->tf_rsp -= 8; 479 td->td_frame->tf_rip = (register_t)entry; 480 td->td_frame->tf_ds = _udatasel; 481 td->td_frame->tf_es = _udatasel; 482 td->td_frame->tf_fs = _ufssel; 483 td->td_frame->tf_gs = _ugssel; 484 td->td_frame->tf_flags = TF_HASSEGS; 485 486 /* 487 * Pass the address of the mailbox for this kse to the uts 488 * function as a parameter on the stack. 489 */ 490 td->td_frame->tf_rdi = (register_t)arg; 491} 492 493int 494cpu_set_user_tls(struct thread *td, void *tls_base) 495{ 496 497 if ((u_int64_t)tls_base >= VM_MAXUSER_ADDRESS) 498 return (EINVAL); 499 500#ifdef COMPAT_FREEBSD32 501 if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { 502 td->td_pcb->pcb_gsbase = (register_t)tls_base; 503 return (0); 504 } 505#endif 506 td->td_pcb->pcb_fsbase = (register_t)tls_base; 507 td->td_pcb->pcb_full_iret = 1; 508 return (0); 509} 510 511#ifdef SMP 512static void 513cpu_reset_proxy() 514{ 515 516 cpu_reset_proxy_active = 1; 517 while (cpu_reset_proxy_active == 1) 518 ; /* Wait for other cpu to see that we've started */ 519 stop_cpus((1<<cpu_reset_proxyid)); 520 printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid); 521 DELAY(1000000); 522 cpu_reset_real(); 523} 524#endif 525 526void 527cpu_reset() 528{ 529#ifdef SMP 530 u_int cnt, map; 531 532 if (smp_active) { 533 map = PCPU_GET(other_cpus) & ~stopped_cpus; 534 if (map != 0) { 535 printf("cpu_reset: Stopping other CPUs\n"); 536 stop_cpus(map); 537 } 538 539 if (PCPU_GET(cpuid) != 0) { 540 cpu_reset_proxyid = PCPU_GET(cpuid); 541 cpustop_restartfunc = cpu_reset_proxy; 542 cpu_reset_proxy_active = 0; 543 printf("cpu_reset: Restarting BSP\n"); 544 545 /* Restart CPU #0. */ 546 atomic_store_rel_int(&started_cpus, 1 << 0); 547 548 cnt = 0; 549 while (cpu_reset_proxy_active == 0 && cnt < 10000000) 550 cnt++; /* Wait for BSP to announce restart */ 551 if (cpu_reset_proxy_active == 0) 552 printf("cpu_reset: Failed to restart BSP\n"); 553 enable_intr(); 554 cpu_reset_proxy_active = 2; 555 556 while (1); 557 /* NOTREACHED */ 558 } 559 560 DELAY(1000000); 561 } 562#endif 563 cpu_reset_real(); 564 /* NOTREACHED */ 565} 566 567static void 568cpu_reset_real() 569{ 570 struct region_descriptor null_idt; 571 int b; 572 573 disable_intr(); 574 575 /* 576 * Attempt to do a CPU reset via the keyboard controller, 577 * do not turn off GateA20, as any machine that fails 578 * to do the reset here would then end up in no man's land. 579 */ 580 outb(IO_KBD + 4, 0xFE); 581 DELAY(500000); /* wait 0.5 sec to see if that did it */ 582 583 /* 584 * Attempt to force a reset via the Reset Control register at 585 * I/O port 0xcf9. Bit 2 forces a system reset when it 586 * transitions from 0 to 1. Bit 1 selects the type of reset 587 * to attempt: 0 selects a "soft" reset, and 1 selects a 588 * "hard" reset. We try a "hard" reset. The first write sets 589 * bit 1 to select a "hard" reset and clears bit 2. The 590 * second write forces a 0 -> 1 transition in bit 2 to trigger 591 * a reset. 592 */ 593 outb(0xcf9, 0x2); 594 outb(0xcf9, 0x6); 595 DELAY(500000); /* wait 0.5 sec to see if that did it */ 596 597 /* 598 * Attempt to force a reset via the Fast A20 and Init register 599 * at I/O port 0x92. Bit 1 serves as an alternate A20 gate. 600 * Bit 0 asserts INIT# when set to 1. We are careful to only 601 * preserve bit 1 while setting bit 0. We also must clear bit 602 * 0 before setting it if it isn't already clear. 603 */ 604 b = inb(0x92); 605 if (b != 0xff) { 606 if ((b & 0x1) != 0) 607 outb(0x92, b & 0xfe); 608 outb(0x92, b | 0x1); 609 DELAY(500000); /* wait 0.5 sec to see if that did it */ 610 } 611 612 printf("No known reset method worked, attempting CPU shutdown\n"); 613 DELAY(1000000); /* wait 1 sec for printf to complete */ 614 615 /* Wipe the IDT. */ 616 null_idt.rd_limit = 0; 617 null_idt.rd_base = 0; 618 lidt(&null_idt); 619 620 /* "good night, sweet prince .... <THUNK!>" */ 621 breakpoint(); 622 623 /* NOTREACHED */ 624 while(1); 625} 626 627/* 628 * Allocate an sf_buf for the given vm_page. On this machine, however, there 629 * is no sf_buf object. Instead, an opaque pointer to the given vm_page is 630 * returned. 631 */ 632struct sf_buf * 633sf_buf_alloc(struct vm_page *m, int pri) 634{ 635 636 return ((struct sf_buf *)m); 637} 638 639/* 640 * Free the sf_buf. In fact, do nothing because there are no resources 641 * associated with the sf_buf. 642 */ 643void 644sf_buf_free(struct sf_buf *sf) 645{ 646} 647 648/* 649 * Software interrupt handler for queued VM system processing. 650 */ 651void 652swi_vm(void *dummy) 653{ 654 if (busdma_swi_pending != 0) 655 busdma_swi(); 656} 657 658/* 659 * Tell whether this address is in some physical memory region. 660 * Currently used by the kernel coredump code in order to avoid 661 * dumping the ``ISA memory hole'' which could cause indefinite hangs, 662 * or other unpredictable behaviour. 663 */ 664 665int 666is_physical_memory(vm_paddr_t addr) 667{ 668 669#ifdef DEV_ISA 670 /* The ISA ``memory hole''. */ 671 if (addr >= 0xa0000 && addr < 0x100000) 672 return 0; 673#endif 674 675 /* 676 * stuff other tests for known memory-mapped devices (PCI?) 677 * here 678 */ 679 680 return 1; 681} 682