sys_machdep.c (6004362e66b76f04a5b994af40067c600da40d0a) | sys_machdep.c (753d1af16593d9609a8e8872a4eb11cadb35765c) |
---|---|
1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 402 unchanged lines hidden (view full) --- 411static int 412i386_set_ldt(td, args) 413 struct thread *td; 414 char *args; 415{ 416 int error = 0, i; 417 int largest_ld; 418 struct mdproc *mdp = &td->td_proc->p_md; | 1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 402 unchanged lines hidden (view full) --- 411static int 412i386_set_ldt(td, args) 413 struct thread *td; 414 char *args; 415{ 416 int error = 0, i; 417 int largest_ld; 418 struct mdproc *mdp = &td->td_proc->p_md; |
419 struct proc_ldt *pldt = 0; | 419 struct proc_ldt *pldt = NULL; |
420 struct i386_ldt_args ua, *uap = &ua; 421 union descriptor *descs, *dp; 422 int descs_size; 423 424 if ((error = copyin(args, uap, sizeof(struct i386_ldt_args))) < 0) 425 return(error); 426 427#ifdef DEBUG 428 printf("i386_set_ldt: start=%d num=%d descs=%p\n", 429 uap->start, uap->num, (void *)uap->descs); 430#endif 431 432 if (uap->descs == NULL) { 433 /* Free descriptors */ 434 if (uap->start == 0 && uap->num == 0) { 435 /* 436 * Treat this as a special case, so userland needn't 437 * know magic number NLDT. | 420 struct i386_ldt_args ua, *uap = &ua; 421 union descriptor *descs, *dp; 422 int descs_size; 423 424 if ((error = copyin(args, uap, sizeof(struct i386_ldt_args))) < 0) 425 return(error); 426 427#ifdef DEBUG 428 printf("i386_set_ldt: start=%d num=%d descs=%p\n", 429 uap->start, uap->num, (void *)uap->descs); 430#endif 431 432 if (uap->descs == NULL) { 433 /* Free descriptors */ 434 if (uap->start == 0 && uap->num == 0) { 435 /* 436 * Treat this as a special case, so userland needn't 437 * know magic number NLDT. |
438 */ | 438 */ |
439 uap->start = NLDT; 440 uap->num = MAX_LD - NLDT; 441 } 442 if (uap->start <= LUDATA_SEL || uap->num <= 0) 443 return (EINVAL); 444 mtx_lock_spin(&sched_lock); 445 pldt = mdp->md_ldt; 446 if (pldt == NULL || uap->start >= pldt->ldt_len) { --- 103 unchanged lines hidden (view full) --- 550 return (EACCES); 551 } 552 } 553 554 if (uap->start == LDT_AUTO_ALLOC && uap->num == 1) { 555 /* Allocate a free slot */ 556 pldt = mdp->md_ldt; 557 if (pldt == NULL) { | 439 uap->start = NLDT; 440 uap->num = MAX_LD - NLDT; 441 } 442 if (uap->start <= LUDATA_SEL || uap->num <= 0) 443 return (EINVAL); 444 mtx_lock_spin(&sched_lock); 445 pldt = mdp->md_ldt; 446 if (pldt == NULL || uap->start >= pldt->ldt_len) { --- 103 unchanged lines hidden (view full) --- 550 return (EACCES); 551 } 552 } 553 554 if (uap->start == LDT_AUTO_ALLOC && uap->num == 1) { 555 /* Allocate a free slot */ 556 pldt = mdp->md_ldt; 557 if (pldt == NULL) { |
558 error = i386_ldt_grow(td, NLDT+1); | 558 error = i386_ldt_grow(td, NLDT + 1); |
559 if (error) { 560 kmem_free(kernel_map, (vm_offset_t)descs, 561 descs_size); 562 return (error); 563 } 564 pldt = mdp->md_ldt; 565 } 566again: --- 58 unchanged lines hidden (view full) --- 625{ 626 struct mdproc *mdp = &td->td_proc->p_md; 627 struct proc_ldt *pldt; 628 caddr_t old_ldt_base; 629 int old_ldt_len; 630 631 if (len > MAX_LD) 632 return (ENOMEM); | 559 if (error) { 560 kmem_free(kernel_map, (vm_offset_t)descs, 561 descs_size); 562 return (error); 563 } 564 pldt = mdp->md_ldt; 565 } 566again: --- 58 unchanged lines hidden (view full) --- 625{ 626 struct mdproc *mdp = &td->td_proc->p_md; 627 struct proc_ldt *pldt; 628 caddr_t old_ldt_base; 629 int old_ldt_len; 630 631 if (len > MAX_LD) 632 return (ENOMEM); |
633 if (len < NLDT+1) 634 len = NLDT+1; | 633 if (len < NLDT + 1) 634 len = NLDT + 1; |
635 pldt = mdp->md_ldt; 636 /* allocate user ldt */ 637 if (!pldt || len > pldt->ldt_len) { 638 struct proc_ldt *new_ldt = user_ldt_alloc(mdp, len); 639 if (new_ldt == NULL) 640 return (ENOMEM); 641 pldt = mdp->md_ldt; 642 /* sched_lock was held by user_ldt_alloc */ --- 39 unchanged lines hidden --- | 635 pldt = mdp->md_ldt; 636 /* allocate user ldt */ 637 if (!pldt || len > pldt->ldt_len) { 638 struct proc_ldt *new_ldt = user_ldt_alloc(mdp, len); 639 if (new_ldt == NULL) 640 return (ENOMEM); 641 pldt = mdp->md_ldt; 642 /* sched_lock was held by user_ldt_alloc */ --- 39 unchanged lines hidden --- |