Skip to content

Commit

Permalink
Merge remote-tracking branch 'freebsd/master' into hardened/current/m…
Browse files Browse the repository at this point in the history
…aster
  • Loading branch information
opntr-auto committed Aug 24, 2015
2 parents 69f48bf + db61d12 commit 9eed863
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 39 deletions.
1 change: 0 additions & 1 deletion Makefile.inc1
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
PATH=${TMPPATH} \
LIBDIR=/usr/lib32 \
SHLIBDIR=/usr/lib32 \
LIBPRIVATEDIR=/usr/lib32/private \
DTRACE="${DTRACE} -32"
LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
CXX="${XCXX} ${LIB32FLAGS}" \
Expand Down
11 changes: 10 additions & 1 deletion lib/libproc/proc_bkpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#elif defined(__amd64__) || defined(__i386__)
#define BREAKPOINT_INSTR 0xcc /* int 0x3 */
#define BREAKPOINT_INSTR_SZ 1
#define BREAKPOINT_ADJUST_SZ BREAKPOINT_INSTR_SZ
#elif defined(__arm__)
#define BREAKPOINT_INSTR 0xe7ffffff /* bkpt */
#define BREAKPOINT_INSTR_SZ 4
Expand Down Expand Up @@ -195,11 +196,19 @@ proc_bkptdel(struct proc_handle *phdl, uintptr_t address,
/*
* Decrement pc so that we delete the breakpoint at the correct
* address, i.e. at the BREAKPOINT_INSTR address.
*
* This is only needed on some architectures where the pc value
* when reading registers points at the instruction after the
* breakpoint, e.g. x86.
*/
void
proc_bkptregadj(unsigned long *pc)
{
*pc = *pc - BREAKPOINT_INSTR_SZ;

(void)pc;
#ifdef BREAKPOINT_ADJUST_SZ
*pc = *pc - BREAKPOINT_ADJUST_SZ;
#endif
}

/*
Expand Down
3 changes: 0 additions & 3 deletions share/mk/bsd.own.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#
# LIBCOMPATDIR Base path for compat libraries. [/usr/lib/compat]
#
# LIBPRIVATEDIR Base path for private libraries. [/usr/lib/private]
#
# LIBDATADIR Base path for misc. utility data files. [/usr/libdata]
#
# LIBEXECDIR Base path for system daemons and utilities. [/usr/libexec]
Expand Down Expand Up @@ -171,7 +169,6 @@ DTBMODE?= 444

LIBDIR?= /usr/lib
LIBCOMPATDIR?= /usr/lib/compat
LIBPRIVATEDIR?= /usr/lib/private
LIBDATADIR?= /usr/libdata
LIBEXECDIR?= /usr/libexec
LINTLIBDIR?= /usr/libdata/lint
Expand Down
30 changes: 24 additions & 6 deletions sys/arm64/arm64/pmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,9 +1516,7 @@ free_pv_chunk(struct pv_chunk *pc)
PV_STAT(atomic_add_int(&pc_chunk_frees, 1));
/* entire chunk is free, return it */
m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc));
#if 0 /* TODO: For minidump */
dump_drop_page(m->phys_addr);
#endif
vm_page_unwire(m, PQ_INACTIVE);
vm_page_free(m);
}
Expand Down Expand Up @@ -1580,9 +1578,7 @@ get_pv_entry(pmap_t pmap, struct rwlock **lockp)
}
PV_STAT(atomic_add_int(&pc_chunk_count, 1));
PV_STAT(atomic_add_int(&pc_chunk_allocs, 1));
#if 0 /* TODO: This is for minidump */
dump_add_page(m->phys_addr);
#endif
pc = (void *)PHYS_TO_DMAP(m->phys_addr);
pc->pc_pmap = pmap;
pc->pc_map[0] = PC_FREE0 & ~1ul; /* preallocated bit 0 */
Expand Down Expand Up @@ -3054,10 +3050,32 @@ pmap_activate(struct thread *td)
}

void
pmap_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t sz)
pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_t sz)
{

panic("ARM64TODO: pmap_sync_icache");
if (va >= VM_MIN_KERNEL_ADDRESS) {
cpu_icache_sync_range(va, sz);
} else {
u_int len, offset;
vm_paddr_t pa;

/* Find the length of data in this page to flush */
offset = va & PAGE_MASK;
len = imin(PAGE_SIZE - offset, sz);

while (sz != 0) {
/* Extract the physical address & find it in the DMAP */
pa = pmap_extract(pmap, va);
if (pa != 0)
cpu_icache_sync_range(PHYS_TO_DMAP(pa), len);

/* Move to the next page */
sz -= len;
va += len;
/* Set the length for the next iteration */
len = imin(PAGE_SIZE, sz);
}
}
}

/*
Expand Down
2 changes: 2 additions & 0 deletions sys/fs/devfs/devfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ devfs_unmount(struct mount *mp, int mntflags)
fmp = VFSTODEVFS(mp);
KASSERT(fmp->dm_mount != NULL,
("devfs_unmount unmounted devfs_mount"));
if (mntflags & MNT_FORCE)
flags |= FORCECLOSE;
/* There is 1 extra root vnode reference from devfs_mount(). */
error = vflush(mp, 1, flags, curthread);
if (error)
Expand Down
2 changes: 2 additions & 0 deletions sys/kern/vfs_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,8 @@ dounmount(struct mount *mp, int flags, struct thread *td)
vput(coveredvp);
}
vfs_event_signal(NULL, VQ_UNMOUNT, 0);
if (mp == rootdevmp)
rootdevmp = NULL;
vfs_mount_destroy(mp);
return (0);
}
Expand Down
6 changes: 6 additions & 0 deletions sys/kern/vfs_mountroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ static struct mntarg *parse_mountroot_options(struct mntarg *, const char *);
*/
struct vnode *rootvnode;

/*
* Mount of the system's /dev.
*/
struct mount *rootdevmp;

char *rootdevnames[2] = {NULL, NULL};

struct mtx root_holds_mtx;
Expand Down Expand Up @@ -236,6 +241,7 @@ vfs_mountroot_devfs(struct thread *td, struct mount **mpp)
mtx_unlock(&mountlist_mtx);

*mpp = mp;
rootdevmp = mp;
set_rootvnode();

error = kern_symlinkat(td, "/", AT_FDCWD, "dev", UIO_SYSSPACE);
Expand Down
57 changes: 29 additions & 28 deletions sys/kern/vfs_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3543,49 +3543,50 @@ SYSCTL_PROC(_kern, KERN_VNODE, vnode, CTLTYPE_OPAQUE | CTLFLAG_RD |
"");
#endif

static void
unmount_or_warn(struct mount *mp)
{
int error;

error = dounmount(mp, MNT_FORCE, curthread);
if (error != 0) {
printf("unmount of %s failed (", mp->mnt_stat.f_mntonname);
if (error == EBUSY)
printf("BUSY)\n");
else
printf("%d)\n", error);
}
}

/*
* Unmount all filesystems. The list is traversed in reverse order
* of mounting to avoid dependencies.
*/
void
vfs_unmountall(void)
{
struct mount *mp;
struct thread *td;
int error;
struct mount *mp, *tmp;

CTR1(KTR_VFS, "%s: unmounting all filesystems", __func__);
td = curthread;

/*
* Since this only runs when rebooting, it is not interlocked.
*/
while(!TAILQ_EMPTY(&mountlist)) {
mp = TAILQ_LAST(&mountlist, mntlist);
TAILQ_FOREACH_REVERSE_SAFE(mp, &mountlist, mntlist, mnt_list, tmp) {
vfs_ref(mp);
error = dounmount(mp, MNT_FORCE, td);
if (error != 0) {
TAILQ_REMOVE(&mountlist, mp, mnt_list);
/*
* XXX: Due to the way in which we mount the root
* file system off of devfs, devfs will generate a
* "busy" warning when we try to unmount it before
* the root. Don't print a warning as a result in
* order to avoid false positive errors that may
* cause needless upset.
*/
if (strcmp(mp->mnt_vfc->vfc_name, "devfs") != 0) {
printf("unmount of %s failed (",
mp->mnt_stat.f_mntonname);
if (error == EBUSY)
printf("BUSY)\n");
else
printf("%d)\n", error);
}
} else {
/* The unmount has removed mp from the mountlist */
}

/*
* Forcibly unmounting "/dev" before "/" would prevent clean
* unmount of the latter.
*/
if (mp == rootdevmp)
continue;

unmount_or_warn(mp);
}

if (rootdevmp != NULL)
unmount_or_warn(rootdevmp);
}

/*
Expand Down
1 change: 1 addition & 0 deletions sys/sys/vnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ extern int vttoif_tab[];
* Global vnode data.
*/
extern struct vnode *rootvnode; /* root (i.e. "/") vnode */
extern struct mount *rootdevmp; /* "/dev" mount */
extern int async_io_version; /* 0 or POSIX version of AIO i'face */
extern int desiredvnodes; /* number of vnodes desired */
extern struct uma_zone *namei_zone;
Expand Down

0 comments on commit 9eed863

Please sign in to comment.