summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2018-12-05 12:16:48 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2018-12-05 12:16:48 +0000
commit35384f5aac82fb54e996c2526a0fc6064466cf05 (patch)
tree5d92033450dfff90e047086738668acf9438e69d
parent4e56bbd533ab2ed10d9a28707e63d3d4d7b0f25d (diff)
parent2f3d18f2c9f61603677fcb22d59f7157bae89d7e (diff)
downloadillumos-joyent-35384f5aac82fb54e996c2526a0fc6064466cf05.tar.gz
[illumos-gate merge]
commit 2f3d18f2c9f61603677fcb22d59f7157bae89d7e 10020 cmd-crypto: macro expands to multiple statements commit 4e9ec610a7fdddfb6264b1155d0cc9c1874aecc2 10016 bnxe: macro expands to multiple statements commit 52deb364035dd2982f68cdad950a92d577b4784d 10015 nfs: macro expands to multiple statements commit 314a1e32ce63a57bd7629fa3efdbe28f591b8708 10024 loader: set command_errmsg to NULL after printing it out commit 45079a052cd74844754a642c4c7cc69d2ac6ce6b 10023 loader: command_bcache is using %d with unsigned data commit 21368e40253d35b164340a2c37815fabb3e9a3d4 10027 loader: common/ufsread: variable 'indbuf' set but not used commit e3026534c008abc0cbdcccf8cff6ac302fac6b52 9988 Make loader.efi dual boot, step 1
-rw-r--r--usr/src/boot/sys/boot/common/bcache.c12
-rw-r--r--usr/src/boot/sys/boot/common/interp_forth.c12
-rw-r--r--usr/src/boot/sys/boot/common/ufsread.c4
-rw-r--r--usr/src/boot/sys/boot/efi/include/efilib.h3
-rw-r--r--usr/src/boot/sys/boot/efi/include/efizfs.h1
-rw-r--r--usr/src/boot/sys/boot/efi/libefi/efipart.c51
-rw-r--r--usr/src/boot/sys/boot/efi/libefi/efizfs.c16
-rw-r--r--usr/src/boot/sys/boot/efi/loader/main.c382
-rw-r--r--usr/src/cmd/cmd-crypto/pktool/gencert.c15
-rw-r--r--usr/src/uts/common/io/bnxe/577xx/drivers/common/lm/device/hw_debug.h5
-rw-r--r--usr/src/uts/common/nfs/nfs4.h95
-rw-r--r--usr/src/uts/common/nfs/rnode4.h11
12 files changed, 448 insertions, 159 deletions
diff --git a/usr/src/boot/sys/boot/common/bcache.c b/usr/src/boot/sys/boot/common/bcache.c
index ec401e7e1f..e5a237827d 100644
--- a/usr/src/boot/sys/boot/common/bcache.c
+++ b/usr/src/boot/sys/boot/common/bcache.c
@@ -475,12 +475,12 @@ command_bcache(int argc, char *argv[] __attribute((unused)))
return(CMD_ERROR);
}
- printf("\ncache blocks: %d\n", bcache_total_nblks);
- printf("cache blocksz: %d\n", bcache_blksize);
- printf("cache readahead: %d\n", bcache_rablks);
- printf("unit cache blocks: %d\n", bcache_unit_nblks);
- printf("cached units: %d\n", bcache_units);
- printf("%d ops %d bypasses %d hits %d misses\n", bcache_ops,
+ printf("\ncache blocks: %u\n", bcache_total_nblks);
+ printf("cache blocksz: %u\n", bcache_blksize);
+ printf("cache readahead: %u\n", bcache_rablks);
+ printf("unit cache blocks: %u\n", bcache_unit_nblks);
+ printf("cached units: %u\n", bcache_units);
+ printf("%u ops %u bypasses %u hits %u misses\n", bcache_ops,
bcache_bypasses, bcache_hits, bcache_misses);
return(CMD_OK);
}
diff --git a/usr/src/boot/sys/boot/common/interp_forth.c b/usr/src/boot/sys/boot/common/interp_forth.c
index 6eb14a5d49..b3eebaede4 100644
--- a/usr/src/boot/sys/boot/common/interp_forth.c
+++ b/usr/src/boot/sys/boot/common/interp_forth.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
@@ -81,7 +81,7 @@ bf_command(ficlVm *vm)
/* Get the name of the current word */
name = vm->runningWord->name;
-
+
/* Find our command structure */
cmd = NULL;
SET_FOREACH(cmdp, Xcommand_set) {
@@ -117,8 +117,9 @@ bf_command(ficlVm *vm)
/* Get remainder of invocation */
tail = ficlVmGetInBuf(vm);
- for (cp = tail, len = 0; cp != vm->tib.end && *cp != 0 && *cp != '\n'; cp++, len++)
- ;
+ len = 0;
+ for (cp = tail; cp != vm->tib.end && *cp != 0 && *cp != '\n'; cp++)
+ len++;
line = malloc(strlen(name) + len + 2);
strcpy(line, name);
@@ -136,12 +137,13 @@ bf_command(ficlVm *vm)
result = (cmd)(argc, argv);
free(argv);
} else {
- result=BF_PARSE;
+ result = BF_PARSE;
}
switch (result) {
case CMD_CRIT:
printf("%s\n", command_errmsg);
+ command_errmsg = NULL;
break;
case CMD_FATAL:
panic("%s\n", command_errmsg);
diff --git a/usr/src/boot/sys/boot/common/ufsread.c b/usr/src/boot/sys/boot/common/ufsread.c
index b063e663c4..3dee081a80 100644
--- a/usr/src/boot/sys/boot/common/ufsread.c
+++ b/usr/src/boot/sys/boot/common/ufsread.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2002 McAfee, Inc.
* All rights reserved.
*
@@ -179,11 +179,9 @@ static uint8_t
inode_type(ufs_ino_t inode)
{
char *blkbuf;
- void *indbuf;
size_t n;
blkbuf = dmadat->blkbuf;
- indbuf = dmadat->indbuf;
if (!inode)
return (0);
diff --git a/usr/src/boot/sys/boot/efi/include/efilib.h b/usr/src/boot/sys/boot/efi/include/efilib.h
index d477bf6f1b..db2a238515 100644
--- a/usr/src/boot/sys/boot/efi/include/efilib.h
+++ b/usr/src/boot/sys/boot/efi/include/efilib.h
@@ -57,10 +57,13 @@ typedef struct pdinfo
uint32_t pd_unit; /* unit number */
uint32_t pd_open; /* reference counter */
void *pd_bcache; /* buffer cache data */
+ struct pdinfo *pd_parent; /* Linked items (eg partitions) */
+ struct devsw *pd_devsw; /* Back pointer to devsw */
} pdinfo_t;
pdinfo_list_t *efiblk_get_pdinfo_list(struct devsw *dev);
pdinfo_t *efiblk_get_pdinfo(struct devdesc *dev);
+pdinfo_t *efiblk_get_pdinfo_by_handle(EFI_HANDLE h);
void *efi_get_table(EFI_GUID *tbl);
diff --git a/usr/src/boot/sys/boot/efi/include/efizfs.h b/usr/src/boot/sys/boot/efi/include/efizfs.h
index 636951c0d6..4fc0ff551f 100644
--- a/usr/src/boot/sys/boot/efi/include/efizfs.h
+++ b/usr/src/boot/sys/boot/efi/include/efizfs.h
@@ -44,5 +44,6 @@ extern void efi_zfs_probe(void);
extern zfsinfo_list_t *efizfs_get_zfsinfo_list(void);
extern bool efi_zfs_is_preferred(EFI_HANDLE *h);
extern EFI_HANDLE efizfs_get_handle_by_guid(uint64_t);
+extern bool efizfs_get_guid_by_handle(EFI_HANDLE, uint64_t *);
#endif
diff --git a/usr/src/boot/sys/boot/efi/libefi/efipart.c b/usr/src/boot/sys/boot/efi/libefi/efipart.c
index e272f5db6f..7a277d3c07 100644
--- a/usr/src/boot/sys/boot/efi/libefi/efipart.c
+++ b/usr/src/boot/sys/boot/efi/libefi/efipart.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2010 Marcel Moolenaar
* All rights reserved.
*
@@ -118,6 +118,7 @@ efiblk_get_pdinfo_list(struct devsw *dev)
return (NULL);
}
+/* XXX this gets called way way too often, investigate */
pdinfo_t *
efiblk_get_pdinfo(struct devdesc *dev)
{
@@ -135,6 +136,40 @@ efiblk_get_pdinfo(struct devdesc *dev)
return (pd);
}
+static bool
+same_handle(pdinfo_t *pd, EFI_HANDLE h)
+{
+
+ return (pd->pd_handle == h || pd->pd_alias == h);
+}
+
+pdinfo_t *
+efiblk_get_pdinfo_by_handle(EFI_HANDLE h)
+{
+ pdinfo_t *dp, *pp;
+
+ /*
+ * Check hard disks, then cd, then floppy
+ */
+ STAILQ_FOREACH(dp, &hdinfo, pd_link) {
+ if (same_handle(dp, h))
+ return (dp);
+ STAILQ_FOREACH(pp, &dp->pd_part, pd_link) {
+ if (same_handle(pp, h))
+ return (pp);
+ }
+ }
+ STAILQ_FOREACH(dp, &cdinfo, pd_link) {
+ if (same_handle(dp, h))
+ return (dp);
+ }
+ STAILQ_FOREACH(dp, &fdinfo, pd_link) {
+ if (same_handle(dp, h))
+ return (dp);
+ }
+ return (NULL);
+}
+
static int
efiblk_pdinfo_count(pdinfo_list_t *pdi)
{
@@ -293,6 +328,8 @@ efipart_fdinfo_add(EFI_HANDLE handle, uint32_t uid, EFI_DEVICE_PATH *devpath)
fd->pd_unit = uid;
fd->pd_handle = handle;
fd->pd_devpath = devpath;
+ fd->pd_parent = NULL;
+ fd->pd_devsw = &efipart_fddev;
STAILQ_INSERT_TAIL(&fdinfo, fd, pd_link);
return (0);
}
@@ -363,6 +400,8 @@ efipart_cdinfo_add(EFI_HANDLE handle, EFI_HANDLE alias,
cd->pd_unit = unit;
cd->pd_alias = alias;
cd->pd_devpath = devpath;
+ cd->pd_parent = NULL;
+ cd->pd_devsw = &efipart_cddev;
STAILQ_INSERT_TAIL(&cdinfo, cd, pd_link);
return (0);
}
@@ -488,6 +527,8 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle)
pd->pd_handle = part_handle;
pd->pd_unit = node->PartitionNumber;
pd->pd_devpath = part_devpath;
+ pd->pd_parent = hd;
+ pd->pd_devsw = &efipart_hddev;
STAILQ_INSERT_TAIL(&hd->pd_part, pd, pd_link);
return (0);
}
@@ -504,6 +545,8 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle)
hd->pd_handle = disk_handle;
hd->pd_unit = unit;
hd->pd_devpath = disk_devpath;
+ hd->pd_parent = NULL;
+ hd->pd_devsw = &efipart_hddev;
STAILQ_INSERT_TAIL(&hdinfo, hd, pd_link);
if (part_devpath == NULL)
@@ -520,6 +563,8 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle)
pd->pd_handle = part_handle;
pd->pd_unit = node->PartitionNumber;
pd->pd_devpath = part_devpath;
+ pd->pd_parent = hd;
+ pd->pd_devsw = &efipart_hddev;
STAILQ_INSERT_TAIL(&hd->pd_part, pd, pd_link);
return (0);
@@ -578,6 +623,8 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle)
pd->pd_handle = disk_handle;
pd->pd_unit = unit;
pd->pd_devpath = devpath;
+ pd->pd_parent = NULL;
+ pd->pd_devsw = &efipart_hddev;
STAILQ_INSERT_TAIL(&hdinfo, pd, pd_link);
free(pathname);
return (0);
@@ -608,6 +655,8 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle)
pd->pd_handle = disk_handle;
pd->pd_unit = unit;
pd->pd_devpath = devpath;
+ pd->pd_parent = last;
+ pd->pd_devsw = &efipart_hddev;
STAILQ_INSERT_TAIL(&last->pd_part, pd, pd_link);
free(pathname);
return (0);
diff --git a/usr/src/boot/sys/boot/efi/libefi/efizfs.c b/usr/src/boot/sys/boot/efi/libefi/efizfs.c
index cbe4bc1809..570a97ecfa 100644
--- a/usr/src/boot/sys/boot/efi/libefi/efizfs.c
+++ b/usr/src/boot/sys/boot/efi/libefi/efizfs.c
@@ -61,6 +61,22 @@ efizfs_get_handle_by_guid(uint64_t guid)
return (NULL);
}
+bool
+efizfs_get_guid_by_handle(EFI_HANDLE handle, uint64_t *guid)
+{
+ zfsinfo_t *zi;
+
+ if (guid == NULL)
+ return (false);
+ STAILQ_FOREACH(zi, &zfsinfo, zi_link) {
+ if (zi->zi_handle == handle) {
+ *guid = zi->zi_pool_guid;
+ return (true);
+ }
+ }
+ return (false);
+}
+
static void
insert_zfs(EFI_HANDLE handle, uint64_t guid)
{
diff --git a/usr/src/boot/sys/boot/efi/loader/main.c b/usr/src/boot/sys/boot/efi/loader/main.c
index 4f19452b50..dabde127b1 100644
--- a/usr/src/boot/sys/boot/efi/loader/main.c
+++ b/usr/src/boot/sys/boot/efi/loader/main.c
@@ -64,10 +64,77 @@ extern void efi_getsmap(void);
static EFI_LOADED_IMAGE *img;
+/*
+ * Number of seconds to wait for a keystroke before exiting with failure
+ * in the event no currdev is found. -2 means always break, -1 means
+ * never break, 0 means poll once and then reboot, > 0 means wait for
+ * that many seconds. "fail_timeout" can be set in the environment as
+ * well.
+ */
+static int fail_timeout = 5;
+
bool
efi_zfs_is_preferred(EFI_HANDLE *h)
{
- return (h == img->DeviceHandle);
+ EFI_DEVICE_PATH *devpath, *dp, *node;
+ HARDDRIVE_DEVICE_PATH *hd;
+ bool ret;
+ extern UINT64 start_sector; /* from multiboot.S */
+
+ /* This check is true for chainloader case. */
+ if (h == img->DeviceHandle)
+ return (true);
+
+ /*
+ * Make sure the image was loaded from the hard disk.
+ */
+ devpath = efi_lookup_devpath(img->DeviceHandle);
+ if (devpath == NULL)
+ return (false);
+ node = efi_devpath_last_node(devpath);
+ if (node == NULL)
+ return (false);
+ if (DevicePathType(node) != MEDIA_DEVICE_PATH &&
+ (DevicePathSubType(node) != MEDIA_FILEPATH_DP ||
+ DevicePathSubType(node) != MEDIA_HARDDRIVE_DP)) {
+ return (false);
+ }
+
+ /*
+ * XXX We ignore the MEDIA_FILEPATH_DP here for now as it is
+ * used on arm and we do not support arm.
+ */
+ ret = false;
+ dp = efi_devpath_trim(devpath);
+ devpath = NULL;
+ if (dp == NULL)
+ goto done;
+
+ devpath = efi_lookup_devpath(h);
+ if (devpath == NULL)
+ goto done;
+ hd = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(devpath);
+ if (hd == NULL) {
+ devpath = NULL;
+ goto done;
+ }
+ devpath = efi_devpath_trim(devpath);
+ if (devpath == NULL)
+ goto done;
+
+ if (!efi_devpath_match(dp, devpath))
+ goto done;
+
+ /* It is the same disk, do we have partition start? */
+ if (start_sector == 0)
+ ret = true;
+ else if (start_sector == hd->PartitionStart)
+ ret = true;
+
+done:
+ free(dp);
+ free(devpath);
+ return (ret);
}
static bool
@@ -153,110 +220,174 @@ out:
}
static void
-set_devdesc_currdev(struct devsw *dev, int unit)
+set_currdev_devdesc(struct devdesc *currdev)
{
- struct devdesc currdev;
char *devname;
- currdev.d_dev = dev;
- currdev.d_unit = unit;
- devname = efi_fmtdev(&currdev);
+ devname = efi_fmtdev(currdev);
+
+ printf("Setting currdev to %s\n", devname);
env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev,
env_nounset);
env_setenv("loaddev", EV_VOLATILE, devname, env_noset, env_nounset);
}
-static int
+static void
+set_currdev_devsw(struct devsw *dev, int unit)
+{
+ struct devdesc currdev;
+
+ currdev.d_dev = dev;
+ currdev.d_unit = unit;
+
+ set_currdev_devdesc(&currdev);
+}
+
+static void
+set_currdev_pdinfo(pdinfo_t *dp)
+{
+
+ /*
+ * Disks are special: they have partitions. if the parent
+ * pointer is non-null, we're a partition not a full disk
+ * and we need to adjust currdev appropriately.
+ */
+ if (dp->pd_devsw->dv_type == DEVT_DISK) {
+ struct disk_devdesc currdev;
+
+ currdev.dd.d_dev = dp->pd_devsw;
+ if (dp->pd_parent == NULL) {
+ currdev.dd.d_unit = dp->pd_unit;
+ currdev.d_slice = -1;
+ currdev.d_partition = -1;
+ } else {
+ currdev.dd.d_unit = dp->pd_parent->pd_unit;
+ currdev.d_slice = dp->pd_unit;
+ currdev.d_partition = 255; /* Assumes GPT */
+ }
+ set_currdev_devdesc((struct devdesc *)&currdev);
+ } else {
+ set_currdev_devsw(dp->pd_devsw, dp->pd_unit);
+ }
+}
+
+static bool
+sanity_check_currdev(void)
+{
+ struct stat st;
+
+ return (stat("/boot/defaults/loader.conf", &st) == 0);
+}
+
+static bool
+probe_zfs_currdev(uint64_t guid)
+{
+ struct zfs_devdesc currdev;
+
+ currdev.dd.d_dev = &zfs_dev;
+ currdev.dd.d_unit = 0;
+ currdev.pool_guid = guid;
+ currdev.root_guid = 0;
+ set_currdev_devdesc((struct devdesc *)&currdev);
+
+ return (sanity_check_currdev());
+}
+
+static bool
+try_as_currdev(pdinfo_t *pp)
+{
+ uint64_t guid;
+
+ /*
+ * If there's a zpool on this device, try it as a ZFS
+ * filesystem, which has somewhat different setup than all
+ * other types of fs due to imperfect loader integration.
+ * This all stems from ZFS being both a device (zpool) and
+ * a filesystem, plus the boot env feature.
+ */
+ if (efizfs_get_guid_by_handle(pp->pd_handle, &guid))
+ return (probe_zfs_currdev(guid));
+
+ /*
+ * All other filesystems just need the pdinfo
+ * initialized in the standard way.
+ */
+ set_currdev_pdinfo(pp);
+ return (sanity_check_currdev());
+}
+
+static bool
find_currdev(EFI_LOADED_IMAGE *img)
{
- pdinfo_list_t *pdi_list;
pdinfo_t *dp, *pp;
EFI_DEVICE_PATH *devpath, *copy;
EFI_HANDLE h;
- char *devname;
+ CHAR16 *text;
struct devsw *dev;
int unit;
uint64_t extra;
- /* Did efi_zfs_probe() detect the boot pool? */
+ /*
+ * Did efi_zfs_probe() detect the boot pool? If so, use the zpool
+ * it found, if it's sane. ZFS is the only thing that looks for
+ * disks and pools to boot.
+ */
if (pool_guid != 0) {
- struct zfs_devdesc currdev;
-
- currdev.dd.d_dev = &zfs_dev;
- currdev.dd.d_unit = 0;
- currdev.pool_guid = pool_guid;
- currdev.root_guid = 0;
- devname = efi_fmtdev(&currdev);
-
- env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev,
- env_nounset);
- env_setenv("loaddev", EV_VOLATILE, devname, env_noset,
- env_nounset);
- return (0);
+ printf("Trying ZFS pool\n");
+ if (probe_zfs_currdev(pool_guid))
+ return (true);
}
- /* We have device lists for hd, cd, fd, walk them all. */
- pdi_list = efiblk_get_pdinfo_list(&efipart_hddev);
- STAILQ_FOREACH(dp, pdi_list, pd_link) {
- struct disk_devdesc currdev;
-
- currdev.dd.d_dev = &efipart_hddev;
- currdev.dd.d_unit = dp->pd_unit;
- currdev.d_slice = -1;
- currdev.d_partition = -1;
-
- if (dp->pd_handle == img->DeviceHandle) {
- devname = efi_fmtdev(&currdev);
-
- env_setenv("currdev", EV_VOLATILE, devname,
- efi_setcurrdev, env_nounset);
- env_setenv("loaddev", EV_VOLATILE, devname,
- env_noset, env_nounset);
- return (0);
+ /*
+ * Try to find the block device by its handle based on the
+ * image we're booting. If we can't find a sane partition,
+ * search all the other partitions of the disk. We do not
+ * search other disks because it's a violation of the UEFI
+ * boot protocol to do so. We fail and let UEFI go on to
+ * the next candidate.
+ */
+ dp = efiblk_get_pdinfo_by_handle(img->DeviceHandle);
+ if (dp != NULL) {
+ text = efi_devpath_name(dp->pd_devpath);
+ if (text != NULL) {
+ printf("Trying ESP: %S\n", text);
+ efi_free_devpath_name(text);
}
- /* Assuming GPT partitioning. */
- STAILQ_FOREACH(pp, &dp->pd_part, pd_link) {
- if (pp->pd_handle == img->DeviceHandle) {
- currdev.d_slice = pp->pd_unit;
- currdev.d_partition = 255;
- devname = efi_fmtdev(&currdev);
-
- env_setenv("currdev", EV_VOLATILE, devname,
- efi_setcurrdev, env_nounset);
- env_setenv("loaddev", EV_VOLATILE, devname,
- env_noset, env_nounset);
- return (0);
+ set_currdev_pdinfo(dp);
+ if (sanity_check_currdev())
+ return (true);
+ if (dp->pd_parent != NULL) {
+ dp = dp->pd_parent;
+ STAILQ_FOREACH(pp, &dp->pd_part, pd_link) {
+ text = efi_devpath_name(pp->pd_devpath);
+ if (text != NULL) {
+ printf("And now the part: %S\n", text);
+ efi_free_devpath_name(text);
+ }
+ /*
+ * Roll up the ZFS special case
+ * for those partitions that have
+ * zpools on them
+ */
+ if (try_as_currdev(pp))
+ return (true);
}
}
- }
-
- pdi_list = efiblk_get_pdinfo_list(&efipart_cddev);
- STAILQ_FOREACH(dp, pdi_list, pd_link) {
- if (dp->pd_handle == img->DeviceHandle ||
- dp->pd_alias == img->DeviceHandle) {
- set_devdesc_currdev(&efipart_cddev, dp->pd_unit);
- return (0);
- }
- }
-
- pdi_list = efiblk_get_pdinfo_list(&efipart_fddev);
- STAILQ_FOREACH(dp, pdi_list, pd_link) {
- if (dp->pd_handle == img->DeviceHandle) {
- set_devdesc_currdev(&efipart_fddev, dp->pd_unit);
- return (0);
- }
+ } else {
+ printf("Can't find device by handle\n");
}
/*
* Try the device handle from our loaded image first. If that
* fails, use the device path from the loaded image and see if
* any of the nodes in that path match one of the enumerated
- * handles.
+ * handles. Currently, this handle list is only for netboot.
*/
if (efi_handle_lookup(img->DeviceHandle, &dev, &unit, &extra) == 0) {
- set_devdesc_currdev(dev, unit);
- return (0);
+ set_currdev_devsw(dev, unit);
+ if (sanity_check_currdev())
+ return (true);
}
copy = NULL;
@@ -270,8 +401,9 @@ find_currdev(EFI_LOADED_IMAGE *img)
copy = NULL;
if (efi_handle_lookup(h, &dev, &unit, &extra) == 0) {
- set_devdesc_currdev(dev, unit);
- return (0);
+ set_currdev_devsw(dev, unit);
+ if (sanity_check_currdev())
+ return (true);
}
devpath = efi_lookup_devpath(h);
@@ -282,19 +414,51 @@ find_currdev(EFI_LOADED_IMAGE *img)
}
free(copy);
- return (ENOENT);
+ return (false);
+}
+
+static bool
+interactive_interrupt(const char *msg)
+{
+ time_t now, then, last;
+
+ last = 0;
+ now = then = getsecs();
+ printf("%s\n", msg);
+ if (fail_timeout == -2) /* Always break to OK */
+ return (true);
+ if (fail_timeout == -1) /* Never break to OK */
+ return (false);
+ do {
+ if (last != now) {
+ printf("press any key to interrupt reboot in %d seconds\r",
+ fail_timeout - (int)(now - then));
+ last = now;
+ }
+
+ /* XXX no pause or timeout wait for char */
+ if (ischar())
+ return (true);
+ now = getsecs();
+ } while (now - then < fail_timeout);
+ return (false);
}
EFI_STATUS
main(int argc, CHAR16 *argv[])
{
char var[128];
- EFI_GUID *guid;
int i, j, howto;
bool vargood;
void *ptr;
- UINTN k;
bool has_kbd;
+ char *s;
+ EFI_DEVICE_PATH *imgpath;
+ CHAR16 *text;
+ EFI_STATUS status;
+ UINT16 boot_current;
+ size_t sz;
+ UINT16 boot_order[100];
archsw.arch_autoload = efi_autoload;
archsw.arch_getdev = efi_getdev;
@@ -331,12 +495,15 @@ main(int argc, CHAR16 *argv[])
/*
* Parse the args to set the console settings, etc
* boot1.efi passes these in, if it can read /boot.config or /boot/config
- * or iPXE may be setup to pass these in.
+ * or iPXE may be setup to pass these in. Or the optional argument in the
+ * boot environment was used to pass these arguments in (in which case
+ * neither /boot.config nor /boot/config are consulted).
*
* Loop through the args, and for each one that contains an '=' that is
* not the first character, add it to the environment. This allows
* loader and kernel env vars to be passed on the command line. Convert
- * args from UCS-2 to ASCII (16 to 8 bit) as they are copied.
+ * args from UCS-2 to ASCII (16 to 8 bit) as they are copied (though this
+ * method is flawed for non-ASCII characters).
*/
howto = 0;
for (i = 1; i < argc; i++) {
@@ -418,6 +585,11 @@ main(int argc, CHAR16 *argv[])
for (i = 0; howto_names[i].ev != NULL; i++)
if (howto & howto_names[i].mask)
setenv(howto_names[i].ev, "YES", 1);
+
+ /*
+ * XXX we need fallback to this stuff after looking at the ConIn,
+ * ConOut and ConErr variables.
+ */
if (howto & RB_MULTIPLE) {
if (howto & RB_SERIAL)
setenv("console", "ttya text" , 1);
@@ -425,7 +597,11 @@ main(int argc, CHAR16 *argv[])
setenv("console", "text ttya" , 1);
} else if (howto & RB_SERIAL) {
setenv("console", "ttya" , 1);
- }
+ } else
+ setenv("console", "text" , 1);
+
+ if ((s = getenv("fail_timeout")) != NULL)
+ fail_timeout = strtol(s, NULL, 10);
/*
* Scan the BLOCK IO MEDIA handles then
@@ -452,6 +628,38 @@ main(int argc, CHAR16 *argv[])
printf("\n%s", bootprog_info);
+ /* Determine the devpath of our image so we can prefer it. */
+ text = efi_devpath_name(img->FilePath);
+ if (text != NULL) {
+ printf(" Load Path: %S\n", text);
+ efi_setenv_illumos_wcs("LoaderPath", text);
+ efi_free_devpath_name(text);
+ }
+
+ status = BS->HandleProtocol(img->DeviceHandle, &devid,
+ (void **)&imgpath);
+ if (status == EFI_SUCCESS) {
+ text = efi_devpath_name(imgpath);
+ if (text != NULL) {
+ printf(" Load Device: %S\n", text);
+ efi_setenv_illumos_wcs("LoaderDev", text);
+ efi_free_devpath_name(text);
+ }
+ }
+
+ boot_current = 0;
+ sz = sizeof(boot_current);
+ efi_global_getenv("BootCurrent", &boot_current, &sz);
+ printf(" BootCurrent: %04x\n", boot_current);
+
+ sz = sizeof(boot_order);
+ efi_global_getenv("BootOrder", &boot_order, &sz);
+ printf(" BootOrder:");
+ for (i = 0; i < sz / sizeof(boot_order[0]); i++)
+ printf(" %04x%s", boot_order[i],
+ boot_order[i] == boot_current ? "[*]" : "");
+ printf("\n");
+
/*
* Disable the watchdog timer. By default the boot manager sets
* the timer to 5 minutes before invoking a boot option. If we
@@ -463,8 +671,16 @@ main(int argc, CHAR16 *argv[])
*/
BS->SetWatchdogTimer(0, 0, 0, NULL);
- if (find_currdev(img) != 0)
- return (EFI_NOT_FOUND);
+ /*
+ * Try and find a good currdev based on the image that was booted.
+ * It might be desirable here to have a short pause to allow falling
+ * through to the boot loader instead of returning instantly to follow
+ * the boot protocol and also allow an escape hatch for users wishing
+ * to try something different.
+ */
+ if (!find_currdev(img))
+ if (!interactive_interrupt("Failed to find bootable partition"))
+ return (EFI_NOT_FOUND);
efi_init_environment();
setenv("ISADIR", "amd64", 1); /* we only build 64bit */
diff --git a/usr/src/cmd/cmd-crypto/pktool/gencert.c b/usr/src/cmd/cmd-crypto/pktool/gencert.c
index 95dd206c44..6f507d2560 100644
--- a/usr/src/cmd/cmd-crypto/pktool/gencert.c
+++ b/usr/src/cmd/cmd-crypto/pktool/gencert.c
@@ -33,13 +33,14 @@
#include <kmfapi.h>
-#define SET_VALUE(f, s) \
- kmfrv = f; \
- if (kmfrv != KMF_OK) { \
- cryptoerror(LOG_STDERR, \
- gettext("Failed to set %s: 0x%02x\n"), \
- s, kmfrv); \
- goto cleanup; \
+#define SET_VALUE(f, s) { \
+ kmfrv = f; \
+ if (kmfrv != KMF_OK) { \
+ cryptoerror(LOG_STDERR, \
+ gettext("Failed to set %s: 0x%02x\n"), \
+ s, kmfrv); \
+ goto cleanup; \
+ } \
}
static int
diff --git a/usr/src/uts/common/io/bnxe/577xx/drivers/common/lm/device/hw_debug.h b/usr/src/uts/common/io/bnxe/577xx/drivers/common/lm/device/hw_debug.h
index 6efb896d2f..222936f19c 100644
--- a/usr/src/uts/common/io/bnxe/577xx/drivers/common/lm/device/hw_debug.h
+++ b/usr/src/uts/common/io/bnxe/577xx/drivers/common/lm/device/hw_debug.h
@@ -91,7 +91,7 @@ enum {
}
-#define IDLE_CHK_CHIP_MASK_CHK(chip_mask) \
+#define IDLE_CHK_CHIP_MASK_CHK(chip_mask) { \
b_test_chip=0; \
var_chip_mask = 0; \
val = REG_RD(pdev, MISC_REG_CHIP_NUM); \
@@ -110,7 +110,8 @@ enum {
} \
if (var_chip_mask & chip_mask) { \
b_test_chip = 1;\
- }
+ } \
+}
/* read one reg and check the condition */
#define IDLE_CHK_1(chip_mask, offset, condition, severity, fail_msg) \
diff --git a/usr/src/uts/common/nfs/nfs4.h b/usr/src/uts/common/nfs/nfs4.h
index e27bd42ae4..2dee6d22f4 100644
--- a/usr/src/uts/common/nfs/nfs4.h
+++ b/usr/src/uts/common/nfs/nfs4.h
@@ -191,8 +191,8 @@ typedef struct ss_pn {
*
*/
typedef struct rfs4_oldstate {
- struct rfs4_oldstate *next;
- struct rfs4_oldstate *prev;
+ struct rfs4_oldstate *next;
+ struct rfs4_oldstate *prev;
rfs4_ss_pn_t *ss_pn;
nfs_client_id4 cl_id4;
} rfs4_oldstate_t;
@@ -471,9 +471,9 @@ nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths;
* says that the use of cleanlocks() on individual files
* is not required?
* can_reclaim - indicates if client is allowed to reclaim after server
- * start-up (client had previous state at server)
+ * start-up (client had previous state at server)
* ss_remove - indicates that the rfs4_client_destroy function should
- * clean up stable storage file.
+ * clean up stable storage file.
* forced_expire - set if the sysadmin has used clear_locks for this client.
* no_referrals - set if the client is Solaris and pre-dates referrals
* deleg_revoked - how many delegations have been revoked for this client?
@@ -500,7 +500,7 @@ typedef struct rfs4_client {
unsigned rc_need_confirm:1;
unsigned rc_unlksys_completed:1;
unsigned rc_can_reclaim:1;
- unsigned rc_ss_remove:1;
+ unsigned rc_ss_remove:1;
unsigned rc_forced_expire:1;
uint_t rc_deleg_revoked;
struct rfs4_client *rc_cp_confirmed;
@@ -718,12 +718,12 @@ typedef struct rfs4_dinfo {
* file_rwlock - lock for serializing the removal of a file while
* the state structures are active within the server
*
- * The only requirement for locking file_rwlock is that the
- * caller have a reference to the containing rfs4_file. The dbe
- * lock may or may not be held for lock/unlock of file_rwlock.
- * As mentioned above, the file_rwlock is used for serialization
- * of file removal and more specifically reference to the held
- * vnode (e.g. vp).
+ * The only requirement for locking file_rwlock is that the
+ * caller have a reference to the containing rfs4_file. The dbe
+ * lock may or may not be held for lock/unlock of file_rwlock.
+ * As mentioned above, the file_rwlock is used for serialization
+ * of file removal and more specifically reference to the held
+ * vnode (e.g. vp).
*/
typedef struct rfs4_file {
rfs4_dbe_t *rf_dbe;
@@ -1009,8 +1009,8 @@ struct nfs_fh4_fmt {
#define FH4_ATTRDIR 2
#define fh4_fsid fh4_i.fhx_fsid
-#define fh4_len fh4_i.fhx_len /* fid length */
-#define fh4_data fh4_i.fhx_data /* fid bytes */
+#define fh4_len fh4_i.fhx_len /* fid length */
+#define fh4_data fh4_i.fhx_data /* fid bytes */
#define fh4_xlen fh4_i.fhx_xlen
#define fh4_xdata fh4_i.fhx_xdata
typedef struct nfs_fh4_fmt nfs_fh4_fmt_t;
@@ -1042,10 +1042,11 @@ typedef struct nfs_fh4_fmt nfs_fh4_fmt_t;
/*
* A few definitions of repeatedly used constructs for nfsv4
*/
-#define UTF8STRING_FREE(str) \
+#define UTF8STRING_FREE(str) { \
kmem_free((str).utf8string_val, (str).utf8string_len); \
(str).utf8string_val = NULL; \
- (str).utf8string_len = 0;
+ (str).utf8string_len = 0; \
+}
/*
* NFS4_VOLATILE_FH yields non-zero if the filesystem uses non-persistent
@@ -1081,27 +1082,27 @@ typedef struct nfs_fh4_fmt nfs_fh4_fmt_t;
struct compound_state {
struct exportinfo *exi;
struct exportinfo *saved_exi; /* export struct for saved_vp */
- cred_t *basecr; /* UNIX cred: only RPC request */
- caddr_t principal;
- int nfsflavor;
- cred_t *cr; /* UNIX cred: RPC request and */
+ cred_t *basecr; /* UNIX cred: only RPC request */
+ caddr_t principal;
+ int nfsflavor;
+ cred_t *cr; /* UNIX cred: RPC request and */
/* target export */
- bool_t cont;
- uint_t access; /* access perm on vp per request */
- bool_t deleg; /* TRUE if current fh has */
+ bool_t cont;
+ uint_t access; /* access perm on vp per request */
+ bool_t deleg; /* TRUE if current fh has */
/* write delegated */
- vnode_t *vp; /* modified by PUTFH, and by ops that */
+ vnode_t *vp; /* modified by PUTFH, and by ops that */
/* input to GETFH */
- bool_t mandlock; /* Is mandatory locking in effect */
+ bool_t mandlock; /* Is mandatory locking in effect */
/* for vp */
- vnode_t *saved_vp; /* modified by SAVEFH, copied to */
+ vnode_t *saved_vp; /* modified by SAVEFH, copied to */
/* vp by RESTOREFH */
- nfsstat4 *statusp;
- nfs_fh4 fh; /* ditto. valid only if vp != NULL */
- nfs_fh4 saved_fh; /* ditto. valid only if */
- /* saved_vp != NULL */
+ nfsstat4 *statusp;
+ nfs_fh4 fh; /* ditto. valid only if vp != NULL */
+ nfs_fh4 saved_fh; /* ditto. valid only if */
+ /* saved_vp != NULL */
struct svc_req *req;
- char fhbuf[NFS4_FHSIZE];
+ char fhbuf[NFS4_FHSIZE];
};
/*
@@ -1121,9 +1122,9 @@ struct nfs4_svgetit_arg {
nfs4_attr_cmd_t op; /* getit or setit */
struct compound_state *cs;
struct statvfs64 *sbp;
- uint_t flag; /* VOP_GETATTR/VOP_SETATTR flag */
- uint_t xattr; /* object is xattr */
- bool_t rdattr_error_req; /* if readdir & client wants */
+ uint_t flag; /* VOP_GETATTR/VOP_SETATTR flag */
+ uint_t xattr; /* object is xattr */
+ bool_t rdattr_error_req; /* if readdir & client wants */
/* rdattr_error */
nfsstat4 rdattr_error; /* used for per-entry status */
/* (if rdattr_err) */
@@ -1141,22 +1142,22 @@ struct nfs4_svgetit_arg {
};
struct nfs4_ntov_map {
- bitmap4 fbit; /* FATTR4_XXX_MASKY */
- uint_t vbit; /* AT_XXX */
- bool_t vfsstat;
- bool_t mandatory; /* attribute mandatory to implement? */
- uint_t nval;
+ bitmap4 fbit; /* FATTR4_XXX_MASKY */
+ uint_t vbit; /* AT_XXX */
+ bool_t vfsstat;
+ bool_t mandatory; /* attribute mandatory to implement? */
+ uint_t nval;
int xdr_size; /* Size of XDR'd attr */
- xdrproc_t xfunc;
+ xdrproc_t xfunc;
int (*sv_getit)(nfs4_attr_cmd_t, struct nfs4_svgetit_arg *,
union nfs4_attr_u *); /* subroutine for getting attr. */
- char *prtstr; /* string attr for printing */
+ char *prtstr; /* string attr for printing */
};
struct nfs4attr_to_vattr {
- vnode_t *vp;
- vattr_t *vap;
- nfs_fh4 *fhp;
+ vnode_t *vp;
+ vattr_t *vap;
+ nfs_fh4 *fhp;
nfsstat4 rdattr_error;
uint32_t flag;
fattr4_change change;
@@ -1224,13 +1225,13 @@ enum lkp4_attr_setup {
*/
typedef struct lookup4_param {
enum lkp4_attr_setup l4_getattrs; /* (in) get attrs in the lookup? */
- int header_len; /* (in) num ops before first lookup */
- int trailer_len; /* (in) num ops after last */
+ int header_len; /* (in) num ops before first lookup */
+ int trailer_len; /* (in) num ops after last */
/* Lookup/Getattr */
- bitmap4 ga_bits; /* (in) Which attributes for Getattr */
+ bitmap4 ga_bits; /* (in) Which attributes for Getattr */
COMPOUND4args_clnt *argsp; /* (in/out) args for compound struct */
COMPOUND4res_clnt *resp; /* (in/out) res for compound struct */
- int arglen; /* (out) argop buffer alloc'd length */
+ int arglen; /* (out) argop buffer alloc'd length */
struct mntinfo4 *mi;
} lookup4_param_t;
diff --git a/usr/src/uts/common/nfs/rnode4.h b/usr/src/uts/common/nfs/rnode4.h
index ca2e38c8e8..216ebd266a 100644
--- a/usr/src/uts/common/nfs/rnode4.h
+++ b/usr/src/uts/common/nfs/rnode4.h
@@ -216,7 +216,7 @@ typedef struct r4hashq {
* be held whenever any kind of access of r_size is made.
*
* Lock ordering:
- * r_rwlock > r_lkserlock > r_os_lock > r_statelock > r_statev4_lock
+ * r_rwlock > r_lkserlock > r_os_lock > r_statelock > r_statev4_lock
* vnode_t::v_lock > r_os_lock
*/
struct exportinfo; /* defined in nfs/export.h */
@@ -308,11 +308,11 @@ typedef struct rnode4 {
/* delegation has been recalled by */
/* the server during open with */
/* CLAIM_PREVIOUS */
- unsigned r_deleg_return_pending:1;
+ unsigned r_deleg_return_pending:1;
/* delegreturn is pending, don't use */
/* the delegation stateid, set in */
/* nfs4_dlistadd */
- unsigned r_deleg_return_inprog:1;
+ unsigned r_deleg_return_inprog:1;
/* delegreturn is in progress, may */
/* only be set by nfs4delegreturn. */
nfs_rwlock_t r_deleg_recall_lock;
@@ -440,11 +440,12 @@ extern void nfs4_clear_open_streams(rnode4_t *);
*
* The caller must not be holding the rnode r_statelock mutex.
*/
-#define PURGE_ATTRCACHE4_LOCKED(rp) \
+#define PURGE_ATTRCACHE4_LOCKED(rp) { \
rp->r_time_attr_inval = gethrtime(); \
rp->r_time_attr_saved = rp->r_time_attr_inval; \
rp->r_pathconf.pc4_xattr_valid = 0; \
- rp->r_pathconf.pc4_cache_valid = 0;
+ rp->r_pathconf.pc4_cache_valid = 0; \
+}
#define PURGE_ATTRCACHE4(vp) { \
rnode4_t *rp = VTOR4(vp); \