summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/isainfo/isainfo.c35
-rw-r--r--usr/src/cmd/ptools/pargs/pargs.c13
-rw-r--r--usr/src/cmd/sgs/Makefile6
-rw-r--r--usr/src/cmd/sgs/elfcap.chk/Makefile53
-rw-r--r--usr/src/cmd/sgs/elfcap.chk/elfcap_chk.c160
-rw-r--r--usr/src/cmd/sgs/elfdump/common/corenote.c28
-rw-r--r--usr/src/cmd/sgs/elfedit/common/elfconst.c3
-rw-r--r--usr/src/cmd/sgs/elfedit/modules/common/cap.c61
-rw-r--r--usr/src/cmd/sgs/elfedit/modules/common/cap.msg33
-rw-r--r--usr/src/cmd/sgs/include/conv.h21
-rw-r--r--usr/src/cmd/sgs/include/debug.h2
-rw-r--r--usr/src/cmd/sgs/include/elfedit.h7
-rw-r--r--usr/src/cmd/sgs/include/libld.h3
-rw-r--r--usr/src/cmd/sgs/include/rtld.h2
-rw-r--r--usr/src/cmd/sgs/include/sgs.h4
-rw-r--r--usr/src/cmd/sgs/libconv/common/cap.c49
-rw-r--r--usr/src/cmd/sgs/libconv/common/cap.msg4
-rw-r--r--usr/src/cmd/sgs/libconv/common/cap_machelf.c19
-rw-r--r--usr/src/cmd/sgs/libconv/common/corenote.c12
-rw-r--r--usr/src/cmd/sgs/libconv/common/corenote.msg3
-rw-r--r--usr/src/cmd/sgs/libconv/common/elf.c2
-rw-r--r--usr/src/cmd/sgs/libld/common/files.c30
-rw-r--r--usr/src/cmd/sgs/libld/common/globals.c6
-rw-r--r--usr/src/cmd/sgs/libld/common/libld.msg4
-rw-r--r--usr/src/cmd/sgs/libld/common/map_support.c6
-rw-r--r--usr/src/cmd/sgs/libld/common/map_v2.c25
-rw-r--r--usr/src/cmd/sgs/libld/common/sections.c20
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/cap.c11
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/files.c13
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/liblddbg.msg9
-rw-r--r--usr/src/cmd/sgs/liblddbg/common/syms.c10
-rw-r--r--usr/src/cmd/sgs/rtld/amd64/_setup.c7
-rw-r--r--usr/src/cmd/sgs/rtld/common/cap.c128
-rw-r--r--usr/src/cmd/sgs/rtld/common/elf.c4
-rw-r--r--usr/src/cmd/sgs/rtld/common/globals.c12
-rw-r--r--usr/src/cmd/sgs/rtld/common/rtld.msg5
-rw-r--r--usr/src/cmd/sgs/rtld/common/setup.c2
-rw-r--r--usr/src/cmd/sgs/rtld/i386/_setup.c7
-rw-r--r--usr/src/cmd/sgs/tools/SUNWonld-README1
-rw-r--r--usr/src/common/elfcap/elfcap.c81
-rw-r--r--usr/src/common/elfcap/elfcap.h19
-rw-r--r--usr/src/lib/libc/port/gen/getisax.c13
-rw-r--r--usr/src/pkg/manifests/system-test-elftest.p5m3
-rw-r--r--usr/src/test/elf-tests/runfiles/default.run3
-rw-r--r--usr/src/test/elf-tests/tests/Makefile1
-rw-r--r--usr/src/test/elf-tests/tests/capabilities/Makefile41
-rw-r--r--usr/src/test/elf-tests/tests/capabilities/objcap.ksh351
-rw-r--r--usr/src/test/elf-tests/tests/capabilities/symcap.ksh269
-rw-r--r--usr/src/uts/common/exec/elf/elf.c19
-rw-r--r--usr/src/uts/common/io/cpuid_drv.c3
-rw-r--r--usr/src/uts/common/os/exec.c5
-rw-r--r--usr/src/uts/common/sys/auxv.h4
-rw-r--r--usr/src/uts/common/sys/auxv_386.h16
-rw-r--r--usr/src/uts/common/sys/cpuid_drv.h5
-rw-r--r--usr/src/uts/common/sys/elf.h5
-rw-r--r--usr/src/uts/common/sys/user.h5
-rw-r--r--usr/src/uts/intel/os/archdep.c12
-rw-r--r--usr/src/uts/intel/os/cpuid.c586
-rw-r--r--usr/src/uts/intel/sys/x86_archext.h58
59 files changed, 1885 insertions, 434 deletions
diff --git a/usr/src/cmd/isainfo/isainfo.c b/usr/src/cmd/isainfo/isainfo.c
index dcc07197cd..393b854bdf 100644
--- a/usr/src/cmd/isainfo/isainfo.c
+++ b/usr/src/cmd/isainfo/isainfo.c
@@ -25,6 +25,7 @@
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#include <sys/types.h>
@@ -147,31 +148,53 @@ static void
report_hwcap(int d, const char *isa)
{
struct cpuid_get_hwcap __cgh, *cgh = &__cgh;
- char buffer[1024], cap2[1024];
+ char cap1[ELFCAP_HW1_BUFSIZE];
+ char cap2[ELFCAP_HW2_BUFSIZE];
+ char cap3[ELFCAP_HW3_BUFSIZE];
cgh->cgh_archname = (char *)isa;
if (ioctl(d, CPUID_GET_HWCAP, cgh) != 0)
return;
(void) elfcap_hw1_to_str(ELFCAP_STYLE_LC, cgh->cgh_hwcap[0],
- buffer, sizeof (buffer), ELFCAP_FMT_SNGSPACE, machtype(isa));
+ cap1, sizeof (cap1), ELFCAP_FMT_SNGSPACE, machtype(isa));
- if (cgh->cgh_hwcap[1] != 0)
+ if (cgh->cgh_hwcap[1] != 0) {
(void) elfcap_hw2_to_str(ELFCAP_STYLE_LC, cgh->cgh_hwcap[1],
cap2, sizeof (cap2), ELFCAP_FMT_SNGSPACE, machtype(isa));
- else
+ } else {
cap2[0] = '\0';
+ }
+
+ if (cgh->cgh_hwcap[2] != 0) {
+ (void) elfcap_hw3_to_str(ELFCAP_STYLE_LC, cgh->cgh_hwcap[2],
+ cap3, sizeof (cap3), ELFCAP_FMT_SNGSPACE, machtype(isa));
+ } else {
+ cap3[0] = '\0';
+ }
if (mode & EXTN_MODE) {
(void) printf(":");
+ if (cgh->cgh_hwcap[2] != 0)
+ (void) printf(" %s", cap3);
if (cgh->cgh_hwcap[1] != 0)
(void) printf(" %s", cap2);
- (void) printf(" %s", buffer);
+ (void) printf(" %s", cap1);
(void) printf("\n");
} else {
char *p;
int linecnt = 0;
+ for (p = strtok(cap3, " "); p; p = strtok(NULL, " ")) {
+ if (linecnt + strlen(p) > 68) {
+ (void) printf("\n");
+ linecnt = 0;
+ }
+ if (linecnt == 0)
+ linecnt = printf("\t");
+ linecnt += printf("%s ", p);
+ }
+
for (p = strtok(cap2, " "); p; p = strtok(NULL, " ")) {
if (linecnt + strlen(p) > 68) {
(void) printf("\n");
@@ -182,7 +205,7 @@ report_hwcap(int d, const char *isa)
linecnt += printf("%s ", p);
}
- for (p = strtok(buffer, " "); p; p = strtok(NULL, " ")) {
+ for (p = strtok(cap1, " "); p; p = strtok(NULL, " ")) {
if (linecnt + strlen(p) > 68) {
(void) printf("\n");
linecnt = 0;
diff --git a/usr/src/cmd/ptools/pargs/pargs.c b/usr/src/cmd/ptools/pargs/pargs.c
index 9f284e0731..a4a2654e30 100644
--- a/usr/src/cmd/ptools/pargs/pargs.c
+++ b/usr/src/cmd/ptools/pargs/pargs.c
@@ -24,6 +24,7 @@
*/
/*
* Copyright (c) 2018, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -754,6 +755,17 @@ at_hwcap2(long val, char *instr, size_t n, char *str)
#endif
}
+/*ARGSUSED*/
+static void
+at_hwcap3(long val, char *instr, size_t n, char *str)
+{
+#if defined(__i386) || defined(__amd64)
+ (void) elfcap_hw3_to_str(ELFCAP_STYLE_UC, val, str, n,
+ ELFCAP_FMT_PIPSPACE, EM_386);
+#else
+#error "port me"
+#endif
+}
/*ARGSUSED*/
static void
@@ -835,6 +847,7 @@ static struct aux_id aux_arr[] = {
{ AT_SUN_EXECNAME, "AT_SUN_EXECNAME", at_str },
{ AT_SUN_HWCAP, "AT_SUN_HWCAP", at_hwcap },
{ AT_SUN_HWCAP2, "AT_SUN_HWCAP2", at_hwcap2 },
+ { AT_SUN_HWCAP3, "AT_SUN_HWCAP3", at_hwcap3 },
{ AT_SUN_IFLUSH, "AT_SUN_IFLUSH", at_null },
{ AT_SUN_CPU, "AT_SUN_CPU", at_null },
{ AT_SUN_MMU, "AT_SUN_MMU", at_null },
diff --git a/usr/src/cmd/sgs/Makefile b/usr/src/cmd/sgs/Makefile
index 203246897e..3d645521a7 100644
--- a/usr/src/cmd/sgs/Makefile
+++ b/usr/src/cmd/sgs/Makefile
@@ -60,6 +60,7 @@ SUBDIRS= libconv \
crle \
ar \
dump \
+ elfcap.chk \
elfdump \
elfedit \
elfwrap \
@@ -94,6 +95,8 @@ MSGSUBDIRS= ld ldd libld liblddbg \
elfedit crle moe lari \
librtld_db elfwrap ar
+CHKSUBDIRS= elfcap.chk
+
MSGDIR= messages
all := TARGET= all
@@ -104,6 +107,7 @@ _msg := TARGET= catalog
_msg_gettext := TARGET= catalog
_msg_sgsmsg := TARGET= catalog
chkmsg := TARGET= chkmsg
+check := TARGET= check
.KEEP_STATE:
@@ -134,7 +138,7 @@ $(MSGDIR): $(MSGSUBDIRS) FRC
chkmsg: libconv $(MSGSUBDIRS) FRC
-check: chkmsg
+check: chkmsg $(CHKSUBDIRS)
# built from lib/Makefile
install_lib: FRC
diff --git a/usr/src/cmd/sgs/elfcap.chk/Makefile b/usr/src/cmd/sgs/elfcap.chk/Makefile
new file mode 100644
index 0000000000..9e446ff0e3
--- /dev/null
+++ b/usr/src/cmd/sgs/elfcap.chk/Makefile
@@ -0,0 +1,53 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2022 Oxide Computer Company
+#
+
+PROG = elfcap.chk
+OBJS = elfcap_chk.o elfcap.o
+
+include $(SRC)/Makefile.master
+include $(SRC)/Makefile.master.64
+include ../Makefile.com
+
+CSTD = $(GNU_C99)
+NATIVE_LIBS += libc.so
+CPPFLAGS = $(CPPFLAGS.native)
+CFLAGS = $(NATIVE_CFLAGS)
+CC = $(NATIVECC)
+LDCHECKS =
+
+CPPFLAGS += -I$(ELFCAP)
+
+all: $(PROG)
+
+install:
+
+check: $(PROG)
+ ./$(PROG)
+
+$(PROG): $(OBJS)
+ $(LINK.c) -o $@ $(OBJS)
+ $(POST_PROCESS)
+
+%.o: %.c
+ $(COMPILE.c) $<
+
+%.o: $(ELFCAP)/%.c
+ $(COMPILE.c) $<
+
+clean:
+ $(RM) $(OBJS)
+
+clobber: clean
+ $(RM) $(PROG)
diff --git a/usr/src/cmd/sgs/elfcap.chk/elfcap_chk.c b/usr/src/cmd/sgs/elfcap.chk/elfcap_chk.c
new file mode 100644
index 0000000000..5598e59972
--- /dev/null
+++ b/usr/src/cmd/sgs/elfcap.chk/elfcap_chk.c
@@ -0,0 +1,160 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2022 Oxide Computer Company
+ */
+
+/*
+ * This tool is used to try and figure out what the value of various static
+ * buffers should be and if the current compile time defaults are correct. In
+ * particular, this covers the various elfcap values and is used to drive how we
+ * calculate the overall size definition.
+ *
+ * To calculate this, we assume the following:
+ *
+ * o We are using the ELFCAP_FMT_PIPSPACE as that is the longest. We don't
+ * have access to the actual strings right now.
+ * o We are using the ELFCAP_STYLE_FULL variant of the name as that's the
+ * longest.
+ * o We are going to have leftover bits that we don't know (unless we have
+ * 32-bits defined). This uses the 0x%x format and therefore is 10
+ * characters.
+ * o We check all architectures set of values and take the largest.
+ *
+ * While elfcap related information is in multiple places in the build, sgs and
+ * libconv are the places that seem most intertwined. In particular, we believe
+ * it's important that this program execute as part of make check and also get
+ * rebuilt normally as part of a build. This also allows one to iterate in
+ * cmd/sgs which is the most common place that you're working in when adding new
+ * hardware capabilities. By making it a part of the cmd/sgs suite, that also
+ * ensures that normal build logic always rebuilds this program with changes to
+ * elfcap.[ch].
+ */
+
+#include <stdio.h>
+#include <elfcap.h>
+#include <sys/sysmacros.h>
+#include <stdlib.h>
+
+/*
+ * The length of 0x%x.
+ */
+#define ECS_UNKNOWN 10
+
+typedef const elfcap_desc_t *(*elfcap_getdesc_f)(void);
+
+typedef struct elfcap_getdesc {
+ uint32_t eg_nents;
+ elfcap_getdesc_f eg_func;
+} elfcap_getdesc_t;
+
+typedef struct elfcap_case {
+ const char *ec_tag;
+ size_t ec_header;
+ elfcap_getdesc_t ec_descs[2];
+} elfcap_case_t;
+
+const elfcap_case_t elfcaps[] = {
+ { "ELFCAP_SF1_BUFSIZE", ELFCAP_SF1_BUFSIZE, {
+ { ELFCAP_NUM_SF1, elfcap_getdesc_sf1 },
+ { 0, NULL }
+ } },
+ { "ELFCAP_HW1_BUFSIZE", ELFCAP_HW1_BUFSIZE, {
+ { ELFCAP_NUM_HW1_386, elfcap_getdesc_hw1_386 },
+ { ELFCAP_NUM_HW1_SPARC, elfcap_getdesc_hw1_sparc }
+ } },
+ { "ELFCAP_HW1_BUFSIZE", ELFCAP_HW2_BUFSIZE, {
+ { ELFCAP_NUM_HW2_386, elfcap_getdesc_hw2_386 },
+ { 0, NULL }
+ } },
+ { "ELFCAP_HW1_BUFSIZE", ELFCAP_HW3_BUFSIZE, {
+ { ELFCAP_NUM_HW3_386, elfcap_getdesc_hw3_386 },
+ { 0, NULL }
+ } },
+};
+
+static size_t
+elfcap_calc_len(const elfcap_desc_t *desc, uint32_t nents, size_t space)
+{
+ size_t len = 0;
+
+ for (uint32_t i = 0; i < nents; i++) {
+ len += desc[i].c_full.s_len;
+ if (i > 0) {
+ len += space;
+ }
+ }
+
+ if (nents < 32) {
+ len += space + ECS_UNKNOWN;
+ }
+
+ /*
+ * Finally, add one for a terminator and we add an 8 character buffer in
+ * case we screwed up.
+ */
+ len += 9;
+
+ return (len);
+}
+
+static size_t
+elfcap_max_len(const elfcap_case_t *ec, size_t slen)
+{
+ size_t max = 0;
+
+ for (size_t i = 0; i < ARRAY_SIZE(ec->ec_descs); i++) {
+ const elfcap_desc_t *desc;
+ size_t len;
+
+ if (ec->ec_descs[i].eg_func == NULL)
+ continue;
+
+ desc = ec->ec_descs[i].eg_func();
+ len = elfcap_calc_len(desc, ec->ec_descs[i].eg_nents, slen);
+ if (len > max)
+ max = len;
+ }
+
+ return (max);
+}
+
+int
+main(void)
+{
+ size_t slen;
+ const elfcap_str_t *strs;
+ int ret = EXIT_SUCCESS;
+
+ strs = elfcap_getdesc_formats();
+ slen = strs[ELFCAP_FMT_PIPSPACE].s_len;
+
+ for (size_t i = 0; i < ARRAY_SIZE(elfcaps); i++) {
+ size_t out = elfcap_max_len(&elfcaps[i], slen);
+
+ if (out != elfcaps[i].ec_header) {
+ (void) fprintf(stderr, "elfcap size for %s is not "
+ "expected value!\n\tCurrent value is %zu, should "
+ "be %zu\n", elfcaps[i].ec_tag, elfcaps[i].ec_header,
+ out);
+ ret = EXIT_FAILURE;
+ }
+ }
+
+ if (ret != EXIT_SUCCESS) {
+ (void) fprintf(stderr, "please update $SRC/common/elfcap/"
+ "elfcap.h and $SRC/cmd/sgs/include/conv.h with the new "
+ "values reported above\n");
+ }
+
+ return (ret);
+}
diff --git a/usr/src/cmd/sgs/elfdump/common/corenote.c b/usr/src/cmd/sgs/elfdump/common/corenote.c
index d848221648..b06b3bf2cf 100644
--- a/usr/src/cmd/sgs/elfdump/common/corenote.c
+++ b/usr/src/cmd/sgs/elfdump/common/corenote.c
@@ -26,7 +26,7 @@
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2018, Joyent, Inc.
- * Copyright 2020 Oxide Computer Company
+ * Copyright 2022 Oxide Computer Company
*/
#include <stdlib.h>
@@ -46,7 +46,7 @@
/*
* This module contains the code that displays data from the note
- * sections found in Solaris core files. The format of these
+ * sections found in illumos core files. The format of these
* note sections are described in the core(5) manpage.
*/
@@ -470,6 +470,7 @@ dump_auxv(note_state_t *state, const char *title)
union {
Conv_cap_val_hw1_buf_t hw1;
Conv_cap_val_hw2_buf_t hw2;
+ Conv_cap_val_hw3_buf_t hw3;
Conv_cnote_auxv_af_buf_t auxv_af;
Conv_ehdr_flags_buf_t ehdr_flags;
Conv_secflags_buf_t secflags;
@@ -586,8 +587,27 @@ dump_auxv(note_state_t *state, const char *title)
vstr = NULL;
num_fmt = SL_FMT_NUM_HEX;
break;
-
-
+ case AT_SUN_HWCAP3:
+ w = extract_as_word(state, &layout->a_val);
+ vstr = conv_cap_val_hw3(w, state->ns_mach,
+ 0, &conv_buf.hw3);
+ /*
+ * conv_cap_val_hw3() produces output like:
+ *
+ * 0xfff [ flg1 flg2 0xff]
+ *
+ * where the first hex value is the complete value,
+ * and the second is the leftover bits. We only
+ * want the part in brackets, and failing that,
+ * would rather fall back to formatting the full
+ * value ourselves.
+ */
+ while ((*vstr != '\0') && (*vstr != '['))
+ vstr++;
+ if (*vstr != '[')
+ vstr = NULL;
+ num_fmt = SL_FMT_NUM_HEX;
+ break;
case AT_SUN_AUXFLAGS:
w = extract_as_word(state, &layout->a_val);
diff --git a/usr/src/cmd/sgs/elfedit/common/elfconst.c b/usr/src/cmd/sgs/elfedit/common/elfconst.c
index 0ee1e7158d..b550222a9a 100644
--- a/usr/src/cmd/sgs/elfedit/common/elfconst.c
+++ b/usr/src/cmd/sgs/elfedit/common/elfconst.c
@@ -22,6 +22,8 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2022 Oxide Computer Company
*/
#include <stdlib.h>
@@ -411,6 +413,7 @@ init_libconv_strings(conv_iter_osabi_t *osabi, Half *mach)
LC_MACH(ELFEDIT_CONST_HW1_SUNW, conv_iter_cap_val_hw1);
LC(ELFEDIT_CONST_SF1_SUNW, conv_iter_cap_val_sf1);
LC_MACH(ELFEDIT_CONST_HW2_SUNW, conv_iter_cap_val_hw2);
+ LC_MACH(ELFEDIT_CONST_HW3_SUNW, conv_iter_cap_val_hw3);
#undef LC
#undef LC_OS
diff --git a/usr/src/cmd/sgs/elfedit/modules/common/cap.c b/usr/src/cmd/sgs/elfedit/modules/common/cap.c
index 7430d4d84f..0cde92f90a 100644
--- a/usr/src/cmd/sgs/elfedit/modules/common/cap.c
+++ b/usr/src/cmd/sgs/elfedit/modules/common/cap.c
@@ -23,6 +23,7 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2012 Milan Jurik. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#include <ctype.h>
@@ -60,6 +61,7 @@ typedef enum {
CAP_CMD_T_HW1 = 5, /* cap:hw1 */
CAP_CMD_T_SF1 = 6, /* cap:sf1 */
CAP_CMD_T_HW2 = 7, /* cap:hw2 */
+ CAP_CMD_T_HW3 = 8, /* cap:hw3 */
} CAP_CMD_T;
@@ -532,6 +534,14 @@ print_cap(CAP_CMD_T cmd, int autoprint, ARGSTATE *argstate,
ELFEDIT_MSG_ERR, 0));
printed = 1;
continue;
+ case CA_SUNW_HW_3:
+ elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
+ conv_cap_val_hw3(cap->c_un.c_val,
+ argstate->obj_state->os_ehdr->
+ e_machine, CONV_FMT_NOBKT,
+ &cap_val_buf.cap_val_hw3_buf));
+ printed = 1;
+ continue;
}
}
elfedit_printf(MSG_ORIG(MSG_FMT_HEXXWORDNL),
@@ -843,6 +853,13 @@ cmd_body(CAP_CMD_T cmd, elfedit_obj_state_t *obj_state,
MSG_ORIG(MSG_STR_VALUE), print_only, &print_type);
break;
+ case CAP_CMD_T_HW3:
+ print_only = (argstate.argc == 0);
+ ndx = arg_to_index(&argstate, elfedit_atoconst_value_to_str(
+ ELFEDIT_CONST_CA, CA_SUNW_HW_3, 1),
+ MSG_ORIG(MSG_STR_VALUE), print_only, &print_type);
+ break;
+
default:
/* Note expected: All commands should have been caught above */
elfedit_command_usage();
@@ -1024,6 +1041,14 @@ cmd_body(CAP_CMD_T cmd, elfedit_obj_state_t *obj_state,
CA_SUNW_HW_2, ELFEDIT_CONST_HW2_SUNW);
}
break;
+
+ case CAP_CMD_T_HW3:
+ {
+ ret = cap_set(&argstate, cap, ndx, cap_ndx, cap_name,
+ CA_SUNW_HW_3, ELFEDIT_CONST_HW3_SUNW);
+ }
+ break;
+
}
/*
@@ -1180,6 +1205,19 @@ cpl_hw2(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_HW2_SUNW);
}
+static void
+cpl_hw3(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
+ const char *argv[], int num_opt)
+{
+ /* -capid id_name */
+ if (argc <= num_opt) {
+ cpl_capid_opt(obj_state, cpldata, argc, argv, num_opt);
+ return;
+ }
+
+ /* This routine allows multiple flags to be specified */
+ elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_HW3_SUNW);
+}
/*
* Implementation functions for the commands
*/
@@ -1231,6 +1269,12 @@ cmd_hw2(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
return (cmd_body(CAP_CMD_T_HW2, obj_state, argc, argv));
}
+static elfedit_cmdret_t
+cmd_hw3(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
+{
+ return (cmd_body(CAP_CMD_T_HW3, obj_state, argc, argv));
+}
+
/*ARGSUSED*/
elfedit_module_t *
elfedit_init(elfedit_module_version_t version)
@@ -1406,6 +1450,15 @@ elfedit_init(elfedit_module_version_t version)
{ NULL }
};
+ /* cap:hw3 */
+ static const char *name_hw3[] = { MSG_ORIG(MSG_CMD_HW3), NULL };
+ static elfedit_cmd_optarg_t arg_hw3[] = {
+ { MSG_ORIG(MSG_STR_VALUE),
+ /* MSG_INTL(MSG_A1_HW3_VALUE) */
+ ELFEDIT_I18NHDL(MSG_A1_HW3_VALUE),
+ ELFEDIT_CMDOA_F_OPT | ELFEDIT_CMDOA_F_MULT },
+ { NULL }
+ };
static elfedit_cmd_t cmds[] = {
/* cap:dump */
@@ -1472,6 +1525,14 @@ elfedit_init(elfedit_module_version_t version)
ELFEDIT_I18NHDL(MSG_HELP_HW2),
opt_ostyle_capid_bitop, arg_hw2 },
+ /* cap:hw3 */
+ { cmd_hw3, cpl_hw3, name_hw3,
+ /* MSG_INTL(MSG_DESC_HW3) */
+ ELFEDIT_I18NHDL(MSG_DESC_HW3),
+ /* MSG_INTL(MSG_HELP_HW3) */
+ ELFEDIT_I18NHDL(MSG_HELP_HW3),
+ opt_ostyle_capid_bitop, arg_hw3 },
+
{ NULL }
};
diff --git a/usr/src/cmd/sgs/elfedit/modules/common/cap.msg b/usr/src/cmd/sgs/elfedit/modules/common/cap.msg
index cd311144a0..da6e062df1 100644
--- a/usr/src/cmd/sgs/elfedit/modules/common/cap.msg
+++ b/usr/src/cmd/sgs/elfedit/modules/common/cap.msg
@@ -23,6 +23,8 @@
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2022 Oxide Computer Company
+#
@ _START_
@@ -76,6 +78,7 @@
@ MSG_DESC_HW1 "Hardware capabilities (CA_SUNW_HW_1) bit values"
@ MSG_DESC_SF1 "Software capabilities (CA_SUNW_SF_1) bit values"
@ MSG_DESC_HW2 "Hardware capabilities (CA_SUNW_HW_2) bit values"
+@ MSG_DESC_HW3 "Hardware capabilities (CA_SUNW_HW_3) bit values"
# Command option description strings
@@ -160,9 +163,14 @@
/usr/include/sys/elf.h.\n"
@ MSG_A1_HW2_VALUE "\
- Hardware capability (CA_SUNW_HW_2) values. This is available for\n\
- future expansion.\n"
+ Hardware capability (CA_SUNW_HW_2) values. This can be an integer\n\
+ value, any of the AV_386_2_ symbolic constants defined in\n\
+ /usr/include/sys/auxv_386.h.\n"
+@ MSG_A1_HW3_VALUE "\
+ Hardware capability (CA_SUNW_HW_3) values. This can be an integer\n\
+ value, any of the AV_386_3_ symbolic constants defined in\n\
+ /usr/include/sys/auxv_386.h.\n"
# Help strings
@@ -266,6 +274,26 @@
\tspecified, the new value is OR'd against the existing\n\
\tvalue. If neither -and or -or are specified, the new value\n\
\treplaces the existing value.\n"
+
+@ MSG_HELP_HW3 " \
+ The cap:hw3 command is used to display or alter the\n\
+ value of the hardware capabilities element (CA_SUNW_HW_3).\n\
+ \n\
+ If cap:hw3 is called without arguments, the current\n\
+ value is shown. If one or more value arguments are present,\n\
+ the following steps are taken:\n\
+ \n \
+ o\tAll the value arguments are OR'd together.\n\
+ \n \
+ o\tIf the -cmp option has been specified, the new value\n\
+ \tis complemented.\n\
+ \n \
+ o\tThe CA_SUNW_HW_3 element of the capabilities section is\n\
+ \tupdated with the new value. If -and is specified, the new\n\
+ \tvalue is AND'd against the existing value. If -or is\n\
+ \tspecified, the new value is OR'd against the existing\n\
+ \tvalue. If neither -and or -or are specified, the new value\n\
+ \treplaces the existing value.\n"
@ _END_
@@ -306,3 +334,4 @@
@ MSG_CMD_HW1 "hw1"
@ MSG_CMD_SF1 "sf1"
@ MSG_CMD_HW2 "hw2"
+@ MSG_CMD_HW3 "hw3"
diff --git a/usr/src/cmd/sgs/include/conv.h b/usr/src/cmd/sgs/include/conv.h
index f47b58e907..cfd690098c 100644
--- a/usr/src/cmd/sgs/include/conv.h
+++ b/usr/src/cmd/sgs/include/conv.h
@@ -27,7 +27,7 @@
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2016 RackTop Systems.
- * Copyright 2021 Oxide Computer Company
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _CONV_H
@@ -166,30 +166,37 @@ typedef union {
* These sizes are based on the maximum number of capabilities that exist.
* See common/elfcap.
*/
-#define CONV_CAP_VAL_HW1_BUFSIZE 195
+#define CONV_CAP_VAL_HW1_BUFSIZE 528
typedef union {
Conv_inv_buf_t inv_buf;
char buf[CONV_CAP_VAL_HW1_BUFSIZE];
} Conv_cap_val_hw1_buf_t;
-#define CONV_CAP_VAL_HW2_BUFSIZE 350
+#define CONV_CAP_VAL_HW2_BUFSIZE 632
typedef union {
Conv_inv_buf_t inv_buf;
char buf[CONV_CAP_VAL_HW2_BUFSIZE];
} Conv_cap_val_hw2_buf_t;
-#define CONV_CAP_VAL_SF1_BUFSIZE 45
+#define CONV_CAP_VAL_SF1_BUFSIZE 73
typedef union {
Conv_inv_buf_t inv_buf;
char buf[CONV_CAP_VAL_SF1_BUFSIZE];
} Conv_cap_val_sf1_buf_t;
+#define CONV_CAP_VAL_HW3_BUFSIZE 66
+typedef union {
+ Conv_inv_buf_t inv_buf;
+ char buf[CONV_CAP_VAL_HW3_BUFSIZE];
+} Conv_cap_val_hw3_buf_t;
+
/* conv_cap_val_buf() */
typedef union {
Conv_inv_buf_t inv_buf;
Conv_cap_val_hw1_buf_t cap_val_hw1_buf;
Conv_cap_val_sf1_buf_t cap_val_sf1_buf;
Conv_cap_val_hw2_buf_t cap_val_hw2_buf;
+ Conv_cap_val_hw3_buf_t cap_val_hw3_buf;
} Conv_cap_val_buf_t;
/* conv_config_feat() */
@@ -962,6 +969,8 @@ extern conv_iter_ret_t conv_iter_cap_val_hw2(Half, Conv_fmt_flags_t,
conv_iter_cb_t, void *);
extern conv_iter_ret_t conv_iter_cap_val_sf1(Conv_fmt_flags_t, conv_iter_cb_t,
void *);
+extern conv_iter_ret_t conv_iter_cap_val_hw3(Half, Conv_fmt_flags_t,
+ conv_iter_cb_t, void *);
extern conv_iter_ret_t conv_iter_dyn_feature1(Conv_fmt_flags_t, conv_iter_cb_t,
void *);
@@ -1027,6 +1036,7 @@ extern conv_iter_ret_t conv_iter_syminfo_flags(Conv_fmt_flags_t,
#define conv_cap_val conv64_cap_val
#define conv_cap_val_hw1 conv64_cap_val_hw1
#define conv_cap_val_hw2 conv64_cap_val_hw2
+#define conv_cap_val_hw3 conv64_cap_val_hw3
#define conv_cap_val_sf1 conv64_cap_val_sf1
#define conv_dyn_feature1 conv64_dyn_feature1
#define conv_dyn_flag1 conv64_dyn_flag1
@@ -1045,6 +1055,7 @@ extern conv_iter_ret_t conv_iter_syminfo_flags(Conv_fmt_flags_t,
#define conv_cap_val conv32_cap_val
#define conv_cap_val_hw1 conv32_cap_val_hw1
#define conv_cap_val_hw2 conv32_cap_val_hw2
+#define conv_cap_val_hw3 conv32_cap_val_hw3
#define conv_cap_val_sf1 conv32_cap_val_sf1
#define conv_dyn_feature1 conv32_dyn_feature1
#define conv_dyn_flag1 conv32_dyn_flag1
@@ -1082,6 +1093,8 @@ extern const char *conv_cap_val_hw1(Xword, Half, Conv_fmt_flags_t,
Conv_cap_val_hw1_buf_t *);
extern const char *conv_cap_val_hw2(Xword, Half, Conv_fmt_flags_t,
Conv_cap_val_hw2_buf_t *);
+extern const char *conv_cap_val_hw3(Xword, Half, Conv_fmt_flags_t,
+ Conv_cap_val_hw3_buf_t *);
extern const char *conv_cap_val_sf1(Xword, Half, Conv_fmt_flags_t,
Conv_cap_val_sf1_buf_t *);
extern const char *conv_dyn_flag1(Xword, Conv_fmt_flags_t,
diff --git a/usr/src/cmd/sgs/include/debug.h b/usr/src/cmd/sgs/include/debug.h
index 4df1885e33..d1e49a94ed 100644
--- a/usr/src/cmd/sgs/include/debug.h
+++ b/usr/src/cmd/sgs/include/debug.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _DEBUG_H
@@ -152,6 +153,7 @@ extern "C" {
#define DBG_CAP_HW_2 6
#define DBG_CAP_PLAT 7
#define DBG_CAP_MACH 8
+#define DBG_CAP_HW_3 9
#define DBG_REL_START 1
#define DBG_REL_FINISH 2
diff --git a/usr/src/cmd/sgs/include/elfedit.h b/usr/src/cmd/sgs/include/elfedit.h
index 6c5a204f1a..16f3657905 100644
--- a/usr/src/cmd/sgs/include/elfedit.h
+++ b/usr/src/cmd/sgs/include/elfedit.h
@@ -22,6 +22,8 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _ELFEDIT_H
@@ -455,7 +457,7 @@ typedef struct {
elfedit_i18nhdl_t oa_help; /* Help text for option */
elfedit_cmd_oa_flag_t oa_flags; /* Additional attributes */
elfedit_cmd_oa_mask_t oa_idmask; /* Unique id, returned by */
- /* elfedit_getopt */
+ /* elfedit_getopt */
/* for use by caller */
elfedit_cmd_oa_mask_t oa_excmask; /* Mutual exclusion mask */
} elfedit_cmd_optarg_t;
@@ -739,8 +741,9 @@ typedef enum {
ELFEDIT_CONST_HW1_SUNW = 33, /* hardware capabilities */
ELFEDIT_CONST_SF1_SUNW = 34, /* software capabilities */
ELFEDIT_CONST_HW2_SUNW = 35, /* hardware capabilities */
+ ELFEDIT_CONST_HW3_SUNW = 36, /* hardware capabilities */
- ELFEDIT_CONST_NUM = 36, /* # of constant types */
+ ELFEDIT_CONST_NUM = 37, /* # of constant types */
} elfedit_const_t;
/*
diff --git a/usr/src/cmd/sgs/include/libld.h b/usr/src/cmd/sgs/include/libld.h
index bf451f8f2a..67c877c082 100644
--- a/usr/src/cmd/sgs/include/libld.h
+++ b/usr/src/cmd/sgs/include/libld.h
@@ -24,6 +24,7 @@
* All Rights Reserved
*
* Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _LIBLD_H
@@ -210,6 +211,7 @@ typedef struct {
Caplist oc_plat; /* CA_SUNW_PLAT capabilities */
Caplist oc_mach; /* CA_SUNW_MACH capabilities */
Capstr oc_id; /* CA_SUNW_ID capability */
+ Capmask oc_hw_3; /* CA_SUNW_HW_3 capabilities */
oc_flag_t oc_flags;
} Objcapset;
@@ -524,6 +526,7 @@ struct ofl_desc {
#define FLG_OF1_OVMACHCAP 0x0800000000 /* override CA_SUNW_MACH capability */
#define FLG_OF1_OVPLATCAP 0x1000000000 /* override CA_SUNW_PLAT capability */
#define FLG_OF1_OVIDCAP 0x2000000000 /* override CA_SUNW_ID capability */
+#define FLG_OF1_OVHWCAP3 0x4000000000 /* override CA_SUNW_HW_3 capabilities */
/*
* Guidance flags. The flags with the FLG_OFG_NO_ prefix are used to suppress
diff --git a/usr/src/cmd/sgs/include/rtld.h b/usr/src/cmd/sgs/include/rtld.h
index 052cb109ee..4fe123c47d 100644
--- a/usr/src/cmd/sgs/include/rtld.h
+++ b/usr/src/cmd/sgs/include/rtld.h
@@ -22,6 +22,7 @@
/*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _RTLD_H
#define _RTLD_H
@@ -1119,6 +1120,7 @@ typedef struct {
elfcap_mask_t sc_hw_1; /* CA_SUNW_HW_1 capabilities */
elfcap_mask_t sc_sf_1; /* CA_SUNW_SF_1 capabilities */
elfcap_mask_t sc_hw_2; /* CA_SUNW_HW_2 capabilities */
+ elfcap_mask_t sc_hw_3; /* CA_SUNW_HW_3 capabilities */
char *sc_plat; /* CA_SUNW_PLAT capability */
size_t sc_platsz; /* and size */
char *sc_mach; /* CA_SUNW_MACH capability */
diff --git a/usr/src/cmd/sgs/include/sgs.h b/usr/src/cmd/sgs/include/sgs.h
index 4480d78470..54d3f60722 100644
--- a/usr/src/cmd/sgs/include/sgs.h
+++ b/usr/src/cmd/sgs/include/sgs.h
@@ -25,6 +25,7 @@
*
*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*
* Global include file for all sgs.
*/
@@ -195,7 +196,8 @@ typedef struct {
#define SGS_REJ_HWCAP_2 17 /* hardware capabilities mismatch */
#define SGS_REJ_ARCHIVE 18 /* archive used in invalid context */
#define SGS_REJ_KMOD 19 /* object is a kernel module */
-#define SGS_REJ_NUM 20
+#define SGS_REJ_HWCAP_3 20 /* hardware capabilities mismatch */
+#define SGS_REJ_NUM 21
#define FLG_REJ_ALTER 0x01 /* object name is an alternative */
diff --git a/usr/src/cmd/sgs/libconv/common/cap.c b/usr/src/cmd/sgs/libconv/common/cap.c
index 750bb36c56..c3197cf57d 100644
--- a/usr/src/cmd/sgs/libconv/common/cap.c
+++ b/usr/src/cmd/sgs/libconv/common/cap.c
@@ -22,6 +22,8 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -33,23 +35,43 @@
#include "cap_msg.h"
#include "_conv.h"
+/*
+ * These are assertions that the various sizes that are dependent on elfcap.c
+ * are actually all the same.
+ */
+#if CONV_CAP_VAL_HW1_BUFSIZE != ELFCAP_HW1_BUFSIZE
+#error "libconv needs to update CONV_CAP_VAL_HW1_BUFSIZE to match elfcap.h"
+#endif
+
+#if CONV_CAP_VAL_HW2_BUFSIZE != ELFCAP_HW2_BUFSIZE
+#error "libconv needs to update CONV_CAP_VAL_HW2_BUFSIZE to match elfcap.h"
+#endif
+
+#if CONV_CAP_VAL_HW3_BUFSIZE != ELFCAP_HW3_BUFSIZE
+#error "libconv needs to update CONV_CAP_VAL_HW3_BUFSIZE to match elfcap.h"
+#endif
+
+#if CONV_CAP_VAL_SF1_BUFSIZE != ELFCAP_SF1_BUFSIZE
+#error "libconv needs to update CONV_CAP_VAL_SF1_BUFSIZE to match elfcap.h"
+#endif
+
const conv_ds_t **
conv_cap_tag_strings(Conv_fmt_flags_t fmt_flags)
{
-#if (CA_SUNW_NUM != (CA_SUNW_ID + 1))
+#if (CA_SUNW_NUM != (CA_SUNW_HW_3 + 1))
#error "CA_SUNW_NUM has grown"
#endif
static const Msg tags_cf[] = {
MSG_CA_SUNW_NULL_CF, MSG_CA_SUNW_HW_1_CF,
MSG_CA_SUNW_SF_1_CF, MSG_CA_SUNW_HW_2_CF,
MSG_CA_SUNW_PLAT_CF, MSG_CA_SUNW_MACH_CF,
- MSG_CA_SUNW_ID_CF
+ MSG_CA_SUNW_ID_CF, MSG_CA_SUNW_HW_3_CF
};
static const Msg tags_nf[] = {
MSG_CA_SUNW_NULL_NF, MSG_CA_SUNW_HW_1_NF,
MSG_CA_SUNW_SF_1_NF, MSG_CA_SUNW_HW_2_NF,
MSG_CA_SUNW_PLAT_NF, MSG_CA_SUNW_MACH_NF,
- MSG_CA_SUNW_ID_NF
+ MSG_CA_SUNW_ID_NF, MSG_CA_SUNW_HW_3_NF
};
static const conv_ds_msg_t ds_tags_cf = {
CONV_DS_MSG_INIT(ELFCLASSNONE, tags_cf) };
@@ -140,6 +162,13 @@ conv_iter_ret_t
conv_iter_cap_val_hw2(Half mach, Conv_fmt_flags_t fmt_flags,
conv_iter_cb_t func, void *uvalue)
{
+ if ((mach == EM_386) || (mach == EM_486) ||
+ (mach == EM_AMD64) || (mach == CONV_MACH_ALL))
+ if (conv_iter_elfcap(elfcap_getdesc_hw2_386(),
+ ELFCAP_NUM_HW2_386, fmt_flags, func, uvalue) ==
+ CONV_ITER_DONE)
+ return (CONV_ITER_DONE);
+
return (CONV_ITER_DONE);
}
@@ -153,3 +182,17 @@ conv_iter_cap_val_sf1(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
return (conv_iter_elfcap(elfcap_getdesc_sf1(), ELFCAP_NUM_SF1,
fmt_flags, func, uvalue));
}
+
+conv_iter_ret_t
+conv_iter_cap_val_hw3(Half mach, Conv_fmt_flags_t fmt_flags,
+ conv_iter_cb_t func, void *uvalue)
+{
+ if ((mach == EM_386) || (mach == EM_486) ||
+ (mach == EM_AMD64) || (mach == CONV_MACH_ALL))
+ if (conv_iter_elfcap(elfcap_getdesc_hw3_386(),
+ ELFCAP_NUM_HW3_386, fmt_flags, func, uvalue) ==
+ CONV_ITER_DONE)
+ return (CONV_ITER_DONE);
+
+ return (CONV_ITER_DONE);
+}
diff --git a/usr/src/cmd/sgs/libconv/common/cap.msg b/usr/src/cmd/sgs/libconv/common/cap.msg
index ce07a0e001..5e0c56782c 100644
--- a/usr/src/cmd/sgs/libconv/common/cap.msg
+++ b/usr/src/cmd/sgs/libconv/common/cap.msg
@@ -2,6 +2,8 @@
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2022 Oxide Computer Company
+#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
@@ -38,6 +40,8 @@
@ MSG_CA_SUNW_MACH_NF "mach"
@ MSG_CA_SUNW_ID_CF "CA_SUNW_ID" # 6
@ MSG_CA_SUNW_ID_NF "id"
+@ MSG_CA_SUNW_HW_3_CF "CA_SUNW_HW_3" # 7
+@ MSG_CA_SUNW_HW_3_NF "hw_3"
@ MSG_GBL_ZERO "0"
@ MSG_GBL_OSQBRKT "0x%llx [ "
diff --git a/usr/src/cmd/sgs/libconv/common/cap_machelf.c b/usr/src/cmd/sgs/libconv/common/cap_machelf.c
index d572e29409..ce8bbbde47 100644
--- a/usr/src/cmd/sgs/libconv/common/cap_machelf.c
+++ b/usr/src/cmd/sgs/libconv/common/cap_machelf.c
@@ -22,6 +22,8 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -108,6 +110,19 @@ conv_cap_val_sf1(Xword val, Half mach, Conv_fmt_flags_t fmt_flags,
}
const char *
+conv_cap_val_hw3(Xword val, Half mach, Conv_fmt_flags_t fmt_flags,
+ Conv_cap_val_hw3_buf_t *cap_val_hw3_buf)
+{
+ if (val == 0)
+ return (MSG_ORIG(MSG_GBL_ZERO));
+
+ if (conv_cap(val, cap_val_hw3_buf->buf, sizeof (cap_val_hw3_buf->buf),
+ mach, fmt_flags, elfcap_hw3_to_str) == 0)
+ return (conv_invalid_val(&cap_val_hw3_buf->inv_buf, val, 0));
+ return ((const char *)cap_val_hw3_buf->buf);
+}
+
+const char *
conv_cap_tag(Xword tag, Conv_fmt_flags_t fmt_flags, Conv_inv_buf_t *inv_buf)
{
#ifdef _ELF64
@@ -144,6 +159,10 @@ conv_cap_val(Xword tag, Xword val, Half mach, Conv_fmt_flags_t fmt_flags,
return (conv_cap_val_hw2(val, mach, fmt_flags,
&cap_val_buf->cap_val_hw2_buf));
+ case CA_SUNW_HW_3:
+ return (conv_cap_val_hw3(val, mach, fmt_flags,
+ &cap_val_buf->cap_val_hw3_buf));
+
default:
return (conv_invalid_val(&cap_val_buf->inv_buf, val, 0));
}
diff --git a/usr/src/cmd/sgs/libconv/common/corenote.c b/usr/src/cmd/sgs/libconv/common/corenote.c
index 79f976bda1..d23a1086d3 100644
--- a/usr/src/cmd/sgs/libconv/common/corenote.c
+++ b/usr/src/cmd/sgs/libconv/common/corenote.c
@@ -26,7 +26,7 @@
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2018 Joyent, Inc.
- * Copyright 2021 Oxide Computer Company
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -107,7 +107,7 @@ conv_cnote_auxv_type(Word type, Conv_fmt_flags_t fmt_flags,
static const conv_ds_msg_t ds_types_2000_2011 = {
CONV_DS_MSG_INIT(2000, types_2000_2011) };
- static const Msg types_2014_2028[] = {
+ static const Msg types_2014_2029[] = {
MSG_AUXV_AT_SUN_EXECNAME, MSG_AUXV_AT_SUN_MMU,
MSG_AUXV_AT_SUN_LDDATA, MSG_AUXV_AT_SUN_AUXFLAGS,
MSG_AUXV_AT_SUN_EMULATOR, MSG_AUXV_AT_SUN_BRANDNAME,
@@ -115,14 +115,14 @@ conv_cnote_auxv_type(Word type, Conv_fmt_flags_t fmt_flags,
MSG_AUXV_AT_SUN_BRAND_AUX3, MSG_AUXV_AT_SUN_HWCAP2,
0, 0,
MSG_AUXV_AT_SUN_COMMPAGE, MSG_AUXV_AT_SUN_FPTYPE,
- MSG_AUXV_AT_SUN_FPSIZE
+ MSG_AUXV_AT_SUN_FPSIZE, MSG_AUXV_AT_SUN_HWCAP3
};
- static const conv_ds_msg_t ds_types_2014_2028 = {
- CONV_DS_MSG_INIT(2014, types_2014_2028) };
+ static const conv_ds_msg_t ds_types_2014_2029 = {
+ CONV_DS_MSG_INIT(2014, types_2014_2029) };
static const conv_ds_t *ds[] = {
CONV_DS_ADDR(ds_types_0_22), CONV_DS_ADDR(ds_types_2000_2011),
- CONV_DS_ADDR(ds_types_2014_2028), NULL };
+ CONV_DS_ADDR(ds_types_2014_2029), NULL };
return (conv_map_ds(ELFOSABI_NONE, EM_NONE, type, ds, fmt_flags,
inv_buf));
diff --git a/usr/src/cmd/sgs/libconv/common/corenote.msg b/usr/src/cmd/sgs/libconv/common/corenote.msg
index 7387815761..1d944cc18c 100644
--- a/usr/src/cmd/sgs/libconv/common/corenote.msg
+++ b/usr/src/cmd/sgs/libconv/common/corenote.msg
@@ -25,7 +25,7 @@
#
# Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
# Copyright (c) 2018 Joyent, Inc.
-# Copyright 2021 Oxide Computer Company
+# Copyright 2022 Oxide Computer Company
#
@ MSG_NT_PRSTATUS "[ NT_PRSTATUS ]"
@@ -107,6 +107,7 @@
@ MSG_AUXV_AT_SUN_COMMPAGE "SUN_COMMPAGE"
@ MSG_AUXV_AT_SUN_FPTYPE "SUN_FPTYPE"
@ MSG_AUXV_AT_SUN_FPSIZE "SUN_FPSIZE"
+@ MSG_AUXV_AT_SUN_HWCAP3 "SUN_HWCAP3"
@ MSG_CC_CONTENT_STACK "STACK"
diff --git a/usr/src/cmd/sgs/libconv/common/elf.c b/usr/src/cmd/sgs/libconv/common/elf.c
index 2ef1f55963..a61cc5450e 100644
--- a/usr/src/cmd/sgs/libconv/common/elf.c
+++ b/usr/src/cmd/sgs/libconv/common/elf.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -1217,6 +1218,7 @@ conv_reject_desc(Rej_desc * rej, Conv_reject_desc_buf_t *reject_desc_buf,
case SGS_REJ_HWCAP_1:
case SGS_REJ_SFCAP_1:
case SGS_REJ_HWCAP_2:
+ case SGS_REJ_HWCAP_3:
case SGS_REJ_MACHCAP:
case SGS_REJ_PLATCAP:
if (rej->rej_str)
diff --git a/usr/src/cmd/sgs/libld/common/files.c b/usr/src/cmd/sgs/libld/common/files.c
index a3277b4bf1..4ae59398b1 100644
--- a/usr/src/cmd/sgs/libld/common/files.c
+++ b/usr/src/cmd/sgs/libld/common/files.c
@@ -25,6 +25,7 @@
*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -389,12 +390,21 @@ hw_cap(Ofl_desc *ofl, Xword tag, Xword val)
elfcap_mask_t *hwcap;
ofl_flag_t flags1;
- if (tag == CA_SUNW_HW_1) {
+ switch (tag) {
+ case CA_SUNW_HW_1:
hwcap = &ofl->ofl_ocapset.oc_hw_1.cm_val;
flags1 = FLG_OF1_OVHWCAP1;
- } else {
+ break;
+ case CA_SUNW_HW_2:
hwcap = &ofl->ofl_ocapset.oc_hw_2.cm_val;
flags1 = FLG_OF1_OVHWCAP2;
+ break;
+ case CA_SUNW_HW_3:
+ hwcap = &ofl->ofl_ocapset.oc_hw_3.cm_val;
+ flags1 = FLG_OF1_OVHWCAP3;
+ break;
+ default:
+ assert(0);
}
/*
@@ -547,6 +557,9 @@ ld_cap_move_symtoobj(Ofl_desc *ofl)
CA_SUNW_MACH, &ofl->ofl_ocapset.oc_mach);
}
}
+ if (scapset->oc_hw_3.cm_val)
+ hw_cap(ofl, CA_SUNW_HW_3, scapset->oc_hw_3.cm_val);
+
if (scapset->oc_hw_2.cm_val)
hw_cap(ofl, CA_SUNW_HW_2, scapset->oc_hw_2.cm_val);
@@ -599,6 +612,8 @@ get_cap_group(Objcapset *ocapset, Word cnum, Ofl_desc *ofl, Is_desc *isp)
continue;
if (cgp->cg_set.oc_hw_2.cm_val != ocapset->oc_hw_2.cm_val)
continue;
+ if (cgp->cg_set.oc_hw_3.cm_val != ocapset->oc_hw_3.cm_val)
+ continue;
calp = cgp->cg_set.oc_plat.cl_val;
oalp = ocapset->oc_plat.cl_val;
@@ -898,6 +913,7 @@ process_cap(Ofl_desc *ofl, Ifl_desc *ifl, Is_desc *cisp)
case CA_SUNW_HW_1:
case CA_SUNW_SF_1:
case CA_SUNW_HW_2:
+ case CA_SUNW_HW_3:
/*
* If this is the start of a new group, save it.
*/
@@ -1099,7 +1115,8 @@ process_cap(Ofl_desc *ofl, Ifl_desc *ifl, Is_desc *cisp)
*/
ocapset.oc_hw_1.cm_val =
ocapset.oc_sf_1.cm_val =
- ocapset.oc_hw_2.cm_val = 0;
+ ocapset.oc_hw_2.cm_val =
+ ocapset.oc_hw_3.cm_val = 0;
if (ocapset.oc_plat.cl_val) {
free((void *)ocapset.oc_plat.cl_val);
ocapset.oc_plat.cl_val = NULL;
@@ -1157,6 +1174,13 @@ process_cap(Ofl_desc *ofl, Ifl_desc *ifl, Is_desc *cisp)
DBG_STATE_ORIGINAL, CA_SUNW_ID,
ocapset.oc_id.cs_str));
break;
+
+ case CA_SUNW_HW_3:
+ ocapset.oc_hw_3.cm_val = data->c_un.c_val;
+ DBG_CALL(Dbg_cap_val_entry(ofl->ofl_lml,
+ DBG_STATE_ORIGINAL, CA_SUNW_HW_3,
+ ocapset.oc_hw_3.cm_val, ld_targ.t_m.m_mach));
+ break;
}
/*
diff --git a/usr/src/cmd/sgs/libld/common/globals.c b/usr/src/cmd/sgs/libld/common/globals.c
index 71dda65bf2..c57dafc426 100644
--- a/usr/src/cmd/sgs/libld/common/globals.c
+++ b/usr/src/cmd/sgs/libld/common/globals.c
@@ -24,6 +24,7 @@
* All Rights Reserved
*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -77,9 +78,10 @@ reject[SGS_REJ_NUM] = {
MSG_REJ_PLATCAP, /* MSG_INTL(MSG_REJ_PLATCAP) */
MSG_REJ_HWCAP_2, /* MSG_INTL(MSG_REJ_HWCAP_2) */
MSG_REJ_ARCHIVE, /* MSG_INTL(MSG_REJ_ARCHIVE) */
- MSG_REJ_KMOD /* MSG_INTL(MSG_REJ_KMOD) */
+ MSG_REJ_KMOD, /* MSG_INTL(MSG_REJ_KMOD) */
+ MSG_REJ_HWCAP_3 /* MSG_INTL(MSG_REJ_HWCAP_3) */
};
-#if SGS_REJ_NUM != (SGS_REJ_KMOD + 1)
+#if SGS_REJ_NUM != (SGS_REJ_HWCAP_3 + 1)
#error SGS_REJ_NUM has changed
#endif
diff --git a/usr/src/cmd/sgs/libld/common/libld.msg b/usr/src/cmd/sgs/libld/common/libld.msg
index 659c40bf73..e575a263f0 100644
--- a/usr/src/cmd/sgs/libld/common/libld.msg
+++ b/usr/src/cmd/sgs/libld/common/libld.msg
@@ -23,6 +23,7 @@
# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, Joyent, Inc. All rights reserved.
# Copyright 2017 RackTop Systems.
+# Copyright 2022 Oxide Computer Company
#
@ _START_
@@ -693,6 +694,8 @@
unsupported: %s"
@ MSG_REJ_ARCHIVE "file %s: invalid archive use"
@ MSG_REJ_KMOD "file %s: kernel modules can't be link-edit input"
+@ MSG_REJ_HWCAP_3 "file %s: hardware capability (CA_SUNW_HW_3) \
+ unsupported: %s"
# Guidance messages
@ MSG_GUIDE_UNKNOWN "unrecognized -z guidance item: %s"
@@ -1617,6 +1620,7 @@
@ MSG_MAPKW_HW "HW"
@ MSG_MAPKW_HW_1 "HW_1"
@ MSG_MAPKW_HW_2 "HW_2"
+@ MSG_MAPKW_HW_3 "HW_3"
@ MSG_MAPKW_INTERPOSE "INTERPOSE"
@ MSG_MAPKW_IS_NAME "IS_NAME"
@ MSG_MAPKW_IS_ORDER "IS_ORDER"
diff --git a/usr/src/cmd/sgs/libld/common/map_support.c b/usr/src/cmd/sgs/libld/common/map_support.c
index 61d64b7fd9..ea11c8aefb 100644
--- a/usr/src/cmd/sgs/libld/common/map_support.c
+++ b/usr/src/cmd/sgs/libld/common/map_support.c
@@ -29,6 +29,7 @@
/*
* Copyright 2019 Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -203,9 +204,10 @@ ld_map_cap_set_ovflag(Mapfile *mf, Word type)
FLG_OF1_OVHWCAP2, /* CA_SUNW_HW_2 */
FLG_OF1_OVPLATCAP, /* CA_SUNW_PLAT */
FLG_OF1_OVMACHCAP, /* CA_SUNW_MACH */
- FLG_OF1_OVIDCAP /* CA_SUNW_ID */
+ FLG_OF1_OVIDCAP, /* CA_SUNW_ID */
+ FLG_OF1_OVHWCAP3 /* CA_SUNW_HW_3 */
};
-#if CA_SUNW_NUM != (CA_SUNW_ID + 1)
+#if CA_SUNW_NUM != (CA_SUNW_HW_3 + 1)
#error "CA_SUNW_NUM has grown"
#endif
mf->mf_ofl->ofl_flags1 |= override_flag[type];
diff --git a/usr/src/cmd/sgs/libld/common/map_v2.c b/usr/src/cmd/sgs/libld/common/map_v2.c
index 791ad34971..c3e8ef77eb 100644
--- a/usr/src/cmd/sgs/libld/common/map_v2.c
+++ b/usr/src/cmd/sgs/libld/common/map_v2.c
@@ -26,6 +26,7 @@
/*
* Copyright 2019 Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -1063,7 +1064,7 @@ at_cap_hw(Mapfile *mf, Token eq_tok, void *uvalue)
Token tok;
ld_map_tkval_t tkv;
Conv_inv_buf_t inv_buf;
- Word hw1 = 0, hw2 = 0;
+ Word hw1 = 0, hw2 = 0, hw3 = 0;
uint64_t v;
for (done = 0; done == 0; ) {
@@ -1082,6 +1083,12 @@ at_cap_hw(Mapfile *mf, Token eq_tok, void *uvalue)
hw2 |= v;
break;
}
+
+ if ((v = elfcap_hw3_from_str(ELFCAP_STYLE,
+ tkv.tkv_str, ld_targ.t_m.m_mach)) != 0) {
+ hw3 |= v;
+ break;
+ }
goto bad_flag;
case TK_SEMICOLON:
@@ -1103,6 +1110,9 @@ at_cap_hw(Mapfile *mf, Token eq_tok, void *uvalue)
if (!set_capmask(mf, &mf->mf_ofl->ofl_ocapset.oc_hw_2, eq_tok,
CA_SUNW_HW_2, hw2, FALSE))
return (TK_ERROR);
+ if (!set_capmask(mf, &mf->mf_ofl->ofl_ocapset.oc_hw_3, eq_tok,
+ CA_SUNW_HW_3, hw3, FALSE))
+ return (TK_ERROR);
return (tok);
}
@@ -1209,6 +1219,17 @@ at_cap_plat(Mapfile *mf, Token eq_tok, void *uvalue)
}
/*
+ * CAPABILITY [capid] { HW_3 = value ;
+ * ---------------------------^
+ */
+static Token
+at_cap_hw_3(Mapfile *mf, Token eq_tok, void *uvalue)
+{
+ return (parse_cap_mask(mf, eq_tok, &mf->mf_ofl->ofl_ocapset.oc_hw_3,
+ CA_SUNW_HW_3, elfcap_hw3_from_str));
+}
+
+/*
* Top Level Directive:
*
* CAPABILITY [capid] { ...
@@ -1222,6 +1243,7 @@ dir_capability(Mapfile *mf)
{ MSG_ORIG(MSG_MAPKW_HW), at_cap_hw, ATTR_FMT_EQ_ALL },
{ MSG_ORIG(MSG_MAPKW_HW_1), at_cap_hw_1, ATTR_FMT_EQ_ALL },
{ MSG_ORIG(MSG_MAPKW_HW_2), at_cap_hw_2, ATTR_FMT_EQ_ALL },
+ { MSG_ORIG(MSG_MAPKW_HW_3), at_cap_hw_3, ATTR_FMT_EQ_ALL },
{ MSG_ORIG(MSG_MAPKW_MACHINE), at_cap_mach, ATTR_FMT_EQ_ALL },
{ MSG_ORIG(MSG_MAPKW_PLATFORM), at_cap_plat, ATTR_FMT_EQ_ALL },
@@ -1241,6 +1263,7 @@ dir_capability(Mapfile *mf)
KW_NAME_SIZE(MSG_MAPKW_HW) +
KW_NAME_SIZE(MSG_MAPKW_HW_1) +
KW_NAME_SIZE(MSG_MAPKW_HW_2) +
+ KW_NAME_SIZE(MSG_MAPKW_HW_3) +
KW_NAME_SIZE(MSG_MAPKW_MACHINE) +
KW_NAME_SIZE(MSG_MAPKW_PLATFORM) +
KW_NAME_SIZE(MSG_MAPKW_SF) +
diff --git a/usr/src/cmd/sgs/libld/common/sections.c b/usr/src/cmd/sgs/libld/common/sections.c
index 984c3c9b8e..5ff110e346 100644
--- a/usr/src/cmd/sgs/libld/common/sections.c
+++ b/usr/src/cmd/sgs/libld/common/sections.c
@@ -24,6 +24,7 @@
* All Rights Reserved
*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -1494,6 +1495,14 @@ is_cap_redundant(Objcapset *ocapset, Objcapset *scapset)
* could be considered to be less important than lower ones. However,
* this is the only reasonable non-subjective definition.
*/
+ omsk = ocapset->oc_hw_3.cm_val;
+ smsk = scapset->oc_hw_3.cm_val;
+ if ((omsk > smsk) || (omsk && (omsk == smsk)))
+ return (1);
+ if (omsk < smsk)
+ return (0);
+
+
omsk = ocapset->oc_hw_2.cm_val;
smsk = scapset->oc_hw_2.cm_val;
if ((omsk > smsk) || (omsk && (omsk == smsk)))
@@ -1650,6 +1659,7 @@ make_cap(Ofl_desc *ofl, Word shtype, const char *shname, int ident)
*/
capstr_value(ofl->ofl_lml, CA_SUNW_PLAT, &ocapset->oc_plat, &title);
capstr_value(ofl->ofl_lml, CA_SUNW_MACH, &ocapset->oc_mach, &title);
+ capmask_value(ofl->ofl_lml, CA_SUNW_HW_3, &ocapset->oc_hw_3, &title);
capmask_value(ofl->ofl_lml, CA_SUNW_HW_2, &ocapset->oc_hw_2, &title);
capmask_value(ofl->ofl_lml, CA_SUNW_HW_1, &ocapset->oc_hw_1, &title);
capmask_value(ofl->ofl_lml, CA_SUNW_SF_1, &ocapset->oc_sf_1, &title);
@@ -1659,6 +1669,8 @@ make_cap(Ofl_desc *ofl, Word shtype, const char *shname, int ident)
*/
size += alist_nitems(ocapset->oc_plat.cl_val);
size += alist_nitems(ocapset->oc_mach.cl_val);
+ if (ocapset->oc_hw_3.cm_val)
+ size++;
if (ocapset->oc_hw_2.cm_val)
size++;
if (ocapset->oc_hw_1.cm_val)
@@ -1750,6 +1762,10 @@ make_cap(Ofl_desc *ofl, Word shtype, const char *shname, int ident)
CAP_UPDATE(cap, capndx, CA_SUNW_MACH, 0);
}
}
+ if (ocapset->oc_hw_3.cm_val) {
+ ofl->ofl_flags |= FLG_OF_PTCAP;
+ CAP_UPDATE(cap, capndx, CA_SUNW_HW_3, ocapset->oc_hw_3.cm_val);
+ }
if (ocapset->oc_hw_2.cm_val) {
ofl->ofl_flags |= FLG_OF_PTCAP;
CAP_UPDATE(cap, capndx, CA_SUNW_HW_2, ocapset->oc_hw_2.cm_val);
@@ -1830,6 +1846,10 @@ make_cap(Ofl_desc *ofl, Word shtype, const char *shname, int ident)
CA_SUNW_MACH, 0);
}
}
+ if (scapset->oc_hw_3.cm_val) {
+ CAP_UPDATE(cap, capndx, CA_SUNW_HW_3,
+ scapset->oc_hw_3.cm_val);
+ }
if (scapset->oc_hw_2.cm_val) {
CAP_UPDATE(cap, capndx, CA_SUNW_HW_2,
scapset->oc_hw_2.cm_val);
diff --git a/usr/src/cmd/sgs/liblddbg/common/cap.c b/usr/src/cmd/sgs/liblddbg/common/cap.c
index d1429920c7..0e5f12ad16 100644
--- a/usr/src/cmd/sgs/liblddbg/common/cap.c
+++ b/usr/src/cmd/sgs/liblddbg/common/cap.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#include <stdio.h>
@@ -82,6 +83,11 @@ Dbg_cap_val(Lm_list *lml, Syscapset *sys, Syscapset *alt, Half mach)
if (sys->sc_mach) {
dbg_print(lml, MSG_INTL(MSG_CAP_SYS_MACH), sys->sc_mach);
}
+ if (sys->sc_hw_3) {
+ dbg_print(lml, MSG_INTL(MSG_CAP_SYS_HW_3),
+ conv_cap_val_hw3(sys->sc_hw_3, mach, 0,
+ &cap_val_buf.cap_val_hw3_buf));
+ }
if (sys->sc_hw_2) {
dbg_print(lml, MSG_INTL(MSG_CAP_SYS_HW_2),
conv_cap_val_hw2(sys->sc_hw_2, mach, 0,
@@ -108,6 +114,11 @@ Dbg_cap_val(Lm_list *lml, Syscapset *sys, Syscapset *alt, Half mach)
dbg_print(lml, MSG_INTL(MSG_CAP_ALT_MACH),
alt->sc_mach);
}
+ if (alt->sc_hw_3 != sys->sc_hw_3) {
+ dbg_print(lml, MSG_INTL(MSG_CAP_ALT_HW_3),
+ conv_cap_val_hw3(alt->sc_hw_3, mach, 0,
+ &cap_val_buf.cap_val_hw3_buf));
+ }
if (alt->sc_hw_2 != sys->sc_hw_2) {
dbg_print(lml, MSG_INTL(MSG_CAP_ALT_HW_2),
conv_cap_val_hw2(alt->sc_hw_2, mach, 0,
diff --git a/usr/src/cmd/sgs/liblddbg/common/files.c b/usr/src/cmd/sgs/liblddbg/common/files.c
index b44aabd116..5e167103a0 100644
--- a/usr/src/cmd/sgs/liblddbg/common/files.c
+++ b/usr/src/cmd/sgs/liblddbg/common/files.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#include <sys/auxv.h>
@@ -652,8 +653,11 @@ Dbg_file_generic(Lm_list *lml, Ifl_desc *ifl)
ifl->ifl_ehdr->e_type, 0, &inv_buf));
}
-static const Msg
-reject[] = {
+#if SGS_REJ_NUM != (SGS_REJ_HWCAP_3 + 1)
+#error SGS_REJ_NUM has changed
+#endif
+
+static const Msg reject[SGS_REJ_NUM] = {
MSG_STR_EMPTY,
MSG_REJ_MACH, /* MSG_INTL(MSG_REJ_MACH) */
MSG_REJ_CLASS, /* MSG_INTL(MSG_REJ_CLASS) */
@@ -671,7 +675,10 @@ reject[] = {
MSG_REJ_SFCAP_1, /* MSG_INTL(MSG_REJ_SFCAP_1) */
MSG_REJ_MACHCAP, /* MSG_INTL(MSG_REJ_MACHCAP) */
MSG_REJ_PLATCAP, /* MSG_INTL(MSG_REJ_PLATCAP) */
- MSG_REJ_HWCAP_2 /* MSG_INTL(MSG_REJ_HWCAP_2) */
+ MSG_REJ_HWCAP_2, /* MSG_INTL(MSG_REJ_HWCAP_2) */
+ MSG_REJ_ARCHIVE, /* MSG_INTL(MSG_REJ_ARCHIVE) */
+ MSG_REJ_KMOD, /* MSG_INTL(MSG_REJ_KMOD) */
+ MSG_REJ_HWCAP_3 /* MSG_INTL(MSG_REJ_HWCAP_3) */
};
void
diff --git a/usr/src/cmd/sgs/liblddbg/common/liblddbg.msg b/usr/src/cmd/sgs/liblddbg/common/liblddbg.msg
index 74619ae699..56c4f0ada6 100644
--- a/usr/src/cmd/sgs/liblddbg/common/liblddbg.msg
+++ b/usr/src/cmd/sgs/liblddbg/common/liblddbg.msg
@@ -21,6 +21,7 @@
#
# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2022 Oxide Computer Company
#
@ _START_
@@ -751,6 +752,10 @@
unsupported: %s"
@ MSG_REJ_HWCAP_2 "obj=%s; rejected: hardware capability (CA_SUNW_HW_2) \
unsupported: %s"
+@ MSG_REJ_ARCHIVE "obj=%s; rejected: archive unsed incorrectly"
+@ MSG_REJ_KMOD "obj=%s; rejected: kernel module"
+@ MSG_REJ_HWCAP_3 "obj=%s; rejected: hardware capability (CA_SUNW_HW_3) \
+ unsupported: %s"
# Libs messages
@@ -996,6 +1001,8 @@
(CA_SUNW_PLAT): [ %s ]"
@ MSG_CAP_SYM_HW_2 " symbol=%s[%u]: capability specific \
(CA_SUNW_HW_2): [ %s ]"
+@ MSG_CAP_SYM_HW_3 " symbol=%s[%u]: capability specific \
+ (CA_SUNW_HW_3): [ %s ]"
@ MSG_SYM_LAZY_RESCAN "rescanning for lazy dependencies for symbol: %s"
@@ -1181,12 +1188,14 @@
@ MSG_CAP_SYS_MACH "machine capability (CA_SUNW_MACH) - %s"
@ MSG_CAP_SYS_PLAT "platform capability (CA_SUNW_PLAT) - %s"
@ MSG_CAP_SYS_HW_2 "hardware capabilities (CA_SUNW_HW_2) - %s"
+@ MSG_CAP_SYS_HW_3 "hardware capabilities (CA_SUNW_HW_3) - %s"
@ MSG_CAP_ALT_HW_1 "alternative hardware capabilities (CA_SUNW_HW_1) - %s"
@ MSG_CAP_ALT_SF_1 "alternative software capabilities (CA_SUNW_SF_1) - %s"
@ MSG_CAP_ALT_MACH "alternative machine capability (CA_SUNW_MACH) - %s"
@ MSG_CAP_ALT_PLAT "alternative platform capability (CA_SUNW_PLAT) - %s"
@ MSG_CAP_ALT_HW_2 "alternative hardware capabilities (CA_SUNW_HW_2) - %s"
+@ MSG_CAP_ALT_HW_3 "alternative hardware capabilities (CA_SUNW_HW_3) - %s"
@ MSG_CAP_SEC_TITLE "capabilities; input file=%s"
@ MSG_CAP_SEC_ENTRY "%12.12s %-15.15s %s"
diff --git a/usr/src/cmd/sgs/liblddbg/common/syms.c b/usr/src/cmd/sgs/liblddbg/common/syms.c
index be3315243a..446499b6e5 100644
--- a/usr/src/cmd/sgs/liblddbg/common/syms.c
+++ b/usr/src/cmd/sgs/liblddbg/common/syms.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#include <stdio.h>
@@ -40,7 +41,7 @@ Dbg_syms_lookup(Rt_map *lmp, const char *name, const char *type)
NAME(lmp), type);
}
-static const Msg captype[DBG_CAP_MACH + 1] = {
+static const Msg captype[DBG_CAP_HW_3 + 1] = {
MSG_CAP_SYM_DEFAULT, /* MSG_INTL(MSG_CAP_SYM_DEFAULT) */
MSG_CAP_SYM_USED, /* MSG_INTL(MSG_CAP_SYM_USED) */
MSG_CAP_SYM_CANDIDATE, /* MSG_INTL(MSG_CAP_SYM_CANDIDATE) */
@@ -49,7 +50,8 @@ static const Msg captype[DBG_CAP_MACH + 1] = {
MSG_CAP_SYM_SF_1, /* MSG_INTL(MSG_CAP_SYM_SF_1) */
MSG_CAP_SYM_HW_2, /* MSG_INTL(MSG_CAP_SYM_HW_2) */
MSG_CAP_SYM_PLAT, /* MSG_INTL(MSG_CAP_SYM_PLAT) */
- MSG_CAP_SYM_MACH /* MSG_INTL(MSG_CAP_SYM_MACH) */
+ MSG_CAP_SYM_MACH, /* MSG_INTL(MSG_CAP_SYM_MACH) */
+ MSG_CAP_SYM_HW_3 /* MSG_INTL(MSG_CAP_SYM_HW_3) */
};
void
@@ -82,6 +84,10 @@ Dbg_syms_cap_lookup(Rt_map *lmp, uint_t type, const char *name, uint_t ndx,
case DBG_CAP_PLAT:
str = scapset->sc_plat;
break;
+ case DBG_CAP_HW_3:
+ str = conv_cap_val_hw3(scapset->sc_hw_3, mach, 0,
+ &cap_val_buf.cap_val_hw3_buf);
+ break;
}
dbg_print(lml, MSG_INTL(captype[type]), Dbg_demangle_name(name),
diff --git a/usr/src/cmd/sgs/rtld/amd64/_setup.c b/usr/src/cmd/sgs/rtld/amd64/_setup.c
index e48db1cc11..1d45699da2 100644
--- a/usr/src/cmd/sgs/rtld/amd64/_setup.c
+++ b/usr/src/cmd/sgs/rtld/amd64/_setup.c
@@ -25,6 +25,7 @@
*/
/*
* Copyright (c) 2018, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -121,7 +122,7 @@ _setup(Boot *ebp, Dyn *ld_dyn)
char *_rt_name, **_envp, **_argv;
int _syspagsz = 0, fd = -1;
uint_t _flags = 0;
- uint_t hwcap[2] = { 0, 0 };
+ uint_t hwcap[3] = { 0, 0, 0 };
Dyn *dyn_ptr;
Phdr *phdr = NULL;
Rt_map *lmp;
@@ -217,6 +218,10 @@ _setup(Boot *ebp, Dyn *ld_dyn)
/* hardware capabilities */
hwcap[1] = (uint_t)auxv->a_un.a_val;
break;
+ case AT_SUN_HWCAP3:
+ /* hardware capabilities */
+ hwcap[2] = (uint_t)auxv->a_un.a_val;
+ break;
case AT_SUN_EMULATOR:
/* name of emulation library, if any */
_emulator = auxv->a_un.a_ptr;
diff --git a/usr/src/cmd/sgs/rtld/common/cap.c b/usr/src/cmd/sgs/rtld/common/cap.c
index 47abbc78bc..0c4109c97a 100644
--- a/usr/src/cmd/sgs/rtld/common/cap.c
+++ b/usr/src/cmd/sgs/rtld/common/cap.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#include <sys/types.h>
@@ -69,9 +70,19 @@ compare(const void *vp_a, const void *vp_b)
return (-1);
if (strcap_b && (strcap_a == NULL))
return (1);
+ /*
+ * Third, investigate any CA_SUNW_HW_3 hardware capabilities.
+ */
+ hwcap_a = fdp_a->fd_scapset.sc_hw_3;
+ hwcap_b = fdp_b->fd_scapset.sc_hw_3;
+
+ if (hwcap_a > hwcap_b)
+ return (-1);
+ if (hwcap_a < hwcap_b)
+ return (1);
/*
- * Third, investigate any CA_SUNW_HW_2 hardware capabilities.
+ * Fourth, investigate any CA_SUNW_HW_2 hardware capabilities.
*/
hwcap_a = fdp_a->fd_scapset.sc_hw_2;
hwcap_b = fdp_b->fd_scapset.sc_hw_2;
@@ -160,6 +171,30 @@ hwcap2_check(Syscapset *scapset, Xword val, Rej_desc *rej)
}
/*
+ * Determine whether HWCAP3 capabilities value is supported.
+ */
+int
+hwcap3_check(Syscapset *scapset, Xword val, Rej_desc *rej)
+{
+ Xword mval;
+
+ /*
+ * Ensure that the kernel can cope with the required capabilities.
+ */
+ if ((mval = (val & ~scapset->sc_hw_3)) != 0) {
+ if (rej) {
+ static Conv_cap_val_hw3_buf_t cap_buf;
+
+ rej->rej_type = SGS_REJ_HWCAP_3;
+ rej->rej_str = conv_cap_val_hw3(mval,
+ M_MACH, 0, &cap_buf);
+ }
+ return (0);
+ }
+ return (1);
+}
+
+/*
* Process any software capabilities.
*/
/* ARGSUSED0 */
@@ -343,6 +378,12 @@ cap_check(Cap *cptr, char *strs, int alt, Fdesc *fdp, Rej_desc *rej)
* the system. They are ignored.
*/
break;
+ case CA_SUNW_HW_3:
+ if (hwcap3_check(scapset, val, rej) == 0)
+ return (0);
+ if (fdp)
+ fdp->fd_scapset.sc_hw_3 = val;
+ break;
default:
rej->rej_type = SGS_REJ_UNKCAP;
rej->rej_info = cptr->c_tag;
@@ -837,15 +878,28 @@ typedef enum {
CAP_DISABLE = 2 /* disable capabilities */
} cap_mode;
+/*
+ * The override indexes originally followed the values of CA_SUNW_HW_1, SF_1,
+ * etc.
+ */
+typedef enum {
+ CAP_OVR_HW_1 = 0,
+ CAP_OVR_SF_1,
+ CAP_OVR_HW_2,
+ CAP_OVR_HW_3,
+ CAP_OVR_MAX
+} cap_index_t;
+
static struct {
elfcap_mask_t cs_val[3]; /* value settings, and indicator for */
int cs_set[3]; /* OVERRIDE, ENABLE and DISABLE */
elfcap_mask_t *cs_aval; /* alternative variable for final */
/* update */
-} cap_settings[3] = {
+} cap_settings[CAP_OVR_MAX] = {
{ { 0, 0, 0 }, { 0, 0, 0 }, NULL }, /* CA_SUNW_HW_1 */
{ { 0, 0, 0 }, { 0, 0, 0 }, NULL }, /* CA_SUNW_SF_1 */
- { { 0, 0, 0 }, { 0, 0, 0 }, NULL } /* CA_SUNW_HW_2 */
+ { { 0, 0, 0 }, { 0, 0, 0 }, NULL }, /* CA_SUNW_HW_2 */
+ { { 0, 0, 0 }, { 0, 0, 0 }, NULL } /* CA_SUNW_HW_3 */
};
static int
@@ -853,7 +907,7 @@ cap_modify(Xword tag, const char *str)
{
char *caps, *ptr, *next;
cap_mode mode = CAP_OVERRIDE;
- Xword ndx;
+ cap_index_t ndx;
if ((caps = strdup(str)) == NULL)
return (0);
@@ -885,16 +939,22 @@ cap_modify(Xword tag, const char *str)
* a known hardware capability mask. Note, the caller
* indicates that these are hardware capabilities by
* passing in the CA_SUNW_HW_1 tag. However, the
- * tokens could be CA_SUNW_HW_1 or CA_SUNW_HW_2.
+ * tokens could be CA_SUNW_HW_1, CA_SUNW_HW_2, or
+ * CA_SUNW_HW_3.
*/
+ if ((val = (Xword)elfcap_hw3_from_str(ELFCAP_STYLE,
+ ptr, M_MACH)) != 0) {
+ ndx = CAP_OVR_HW_3;
+ break;
+ }
if ((val = (Xword)elfcap_hw2_from_str(ELFCAP_STYLE,
ptr, M_MACH)) != 0) {
- ndx = CA_SUNW_HW_2;
+ ndx = CAP_OVR_HW_2;
break;
}
if ((val = (Xword)elfcap_hw1_from_str(ELFCAP_STYLE,
ptr, M_MACH)) != 0)
- ndx = CA_SUNW_HW_1;
+ ndx = CAP_OVR_HW_1;
break;
case CA_SUNW_SF_1:
/*
@@ -906,7 +966,7 @@ cap_modify(Xword tag, const char *str)
*/
if ((val = (Xword)elfcap_sf1_from_str(ELFCAP_STYLE,
ptr, M_MACH)) != 0)
- ndx = CA_SUNW_SF_1;
+ ndx = CAP_OVR_SF_1;
break;
}
@@ -918,6 +978,7 @@ cap_modify(Xword tag, const char *str)
*
* LD_HWCAP=[1]0x40 sets CA_SUNW_HW_1 with 0x40
* LD_HWCAP=[2]0x80 sets CA_SUNW_HW_2 with 0x80
+ * LD_HWCAP=[3]0x44 sets CA_SUNW_HW_3 with 0x44
*
* Invalid indexes are ignored.
*/
@@ -926,11 +987,19 @@ cap_modify(Xword tag, const char *str)
if ((*ptr == '[') && (*(ptr + 2) == ']')) {
if (*(ptr + 1) == '1') {
- ndx = tag;
+ ndx = CAP_OVR_HW_1;
ptr += 3;
+ } else if (*(ptr + 1) == '3') {
+ if (tag == CA_SUNW_HW_1) {
+ ndx = CAP_OVR_HW_3;
+ ptr += 3;
+ } else {
+ /* invalid index */
+ continue;
+ }
} else if (*(ptr + 1) == '2') {
if (tag == CA_SUNW_HW_1) {
- ndx = CA_SUNW_HW_2;
+ ndx = CAP_OVR_HW_2;
ptr += 3;
} else {
/* invalid index */
@@ -940,8 +1009,9 @@ cap_modify(Xword tag, const char *str)
/* invalid index */
continue;
}
- } else
- ndx = tag;
+ } else {
+ ndx = tag - 1;
+ }
errno = 0;
if (((val = strtol(ptr, &end, 16)) == 0) && errno)
@@ -959,8 +1029,8 @@ cap_modify(Xword tag, const char *str)
}
}
- cap_settings[ndx - 1].cs_val[mode] |= val;
- cap_settings[ndx - 1].cs_set[mode]++;
+ cap_settings[ndx].cs_val[mode] |= val;
+ cap_settings[ndx].cs_set[mode]++;
}
@@ -968,7 +1038,7 @@ cap_modify(Xword tag, const char *str)
* If the "override" token was supplied, set the alternative
* system capabilities, then enable or disable others.
*/
- for (ndx = 0; ndx < CA_SUNW_HW_2; ndx++) {
+ for (ndx = 0; ndx < CAP_OVR_MAX; ndx++) {
if (cap_settings[ndx].cs_set[CAP_OVERRIDE])
*(cap_settings[ndx].cs_aval) =
cap_settings[ndx].cs_val[CAP_OVERRIDE];
@@ -1046,9 +1116,10 @@ cap_alternative(void)
return (0);
*alt_scapset = *org_scapset;
- cap_settings[CA_SUNW_HW_1 - 1].cs_aval = &alt_scapset->sc_hw_1;
- cap_settings[CA_SUNW_SF_1 - 1].cs_aval = &alt_scapset->sc_sf_1;
- cap_settings[CA_SUNW_HW_2 - 1].cs_aval = &alt_scapset->sc_hw_2;
+ cap_settings[CAP_OVR_HW_1].cs_aval = &alt_scapset->sc_hw_1;
+ cap_settings[CAP_OVR_SF_1].cs_aval = &alt_scapset->sc_sf_1;
+ cap_settings[CAP_OVR_HW_2].cs_aval = &alt_scapset->sc_hw_2;
+ cap_settings[CAP_OVR_HW_3].cs_aval = &alt_scapset->sc_hw_3;
/*
* Process any replaceable variables.
@@ -1203,6 +1274,15 @@ sym_cap_check(Cap *cptr, uint_t cndx, Syscapset *bestcapset, Rt_map *lmp,
ivlmach++;
}
break;
+ case CA_SUNW_HW_3:
+ bestcapset->sc_hw_3 = val;
+ DBG_CALL(Dbg_syms_cap_lookup(lmp, DBG_CAP_HW_3,
+ name, ndx, M_MACH, bestcapset));
+
+ if (hwcap3_check(scapset, val, NULL) == 0)
+ capfail++;
+ break;
+
default:
break;
}
@@ -1269,12 +1349,18 @@ is_sym_the_best(Syscapset *bestcapset, Syscapset *symcapset)
return (1);
/*
- * Check the hardware capabilities. If the best symbols CA_SUNW_HW_2
+ * Check the hardware capabilities. If the best symbols CA_SUNW_HW_3
* capabilities are greater than the new symbols capabilities, then
- * retain the best capabilities group. If the new symbols CA_SUNW_HW_2
+ * retain the best capabilities group. If the new symbols CA_SUNW_HW_3
* capabilities are greater than the best symbol, then the new symbol
- * needs to be taken.
+ * needs to be taken. Repeat the same process for CA_SUNW_HW_2.
*/
+ if (bestcapset->sc_hw_3 > symcapset->sc_hw_3)
+ return (0);
+
+ if (bestcapset->sc_hw_3 < symcapset->sc_hw_3)
+ return (1);
+
if (bestcapset->sc_hw_2 > symcapset->sc_hw_2)
return (0);
diff --git a/usr/src/cmd/sgs/rtld/common/elf.c b/usr/src/cmd/sgs/rtld/common/elf.c
index d1d5ae3c59..31e57eeedd 100644
--- a/usr/src/cmd/sgs/rtld/common/elf.c
+++ b/usr/src/cmd/sgs/rtld/common/elf.c
@@ -27,6 +27,7 @@
*/
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -2312,6 +2313,9 @@ elf_new_lmp(Lm_list *lml, Aliste lmco, Fdesc *fdp, Addr addr, size_t msize,
CAPSET(lmp).sc_mach = STRTAB(lmp) +
cap->c_un.c_ptr;
break;
+ case CA_SUNW_HW_3:
+ CAPSET(lmp).sc_hw_3 = cap->c_un.c_val;
+ break;
}
cap++;
}
diff --git a/usr/src/cmd/sgs/rtld/common/globals.c b/usr/src/cmd/sgs/rtld/common/globals.c
index bb47b12540..3bf68a17da 100644
--- a/usr/src/cmd/sgs/rtld/common/globals.c
+++ b/usr/src/cmd/sgs/rtld/common/globals.c
@@ -24,6 +24,7 @@
* All Rights Reserved
*
* Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#include <sys/types.h>
@@ -232,9 +233,10 @@ ldd_reject[SGS_REJ_NUM] = {
MSG_LDD_REJ_PLATCAP, /* MSG_INTL(MSG_LDD_REJ_PLATCAP) */
MSG_LDD_REJ_HWCAP_2, /* MSG_INTL(MSG_LDD_REJ_HWCAP_2) */
MSG_LDD_REJ_ARCHIVE, /* MSG_INTL(MSG_LDD_REJ_ARCHIVE) */
- MSG_LDD_REJ_KMOD /* MSG_INTL(MSG_LDD_REJ_KMOD) */
+ MSG_LDD_REJ_KMOD, /* MSG_INTL(MSG_LDD_REJ_KMOD) */
+ MSG_LDD_REJ_HWCAP_3 /* MSG_INTL(MSG_LDD_REJ_HWCAP_3) */
};
-#if SGS_REJ_NUM != (SGS_REJ_KMOD + 1)
+#if SGS_REJ_NUM != (SGS_REJ_HWCAP_3 + 1)
#error SGS_REJ_NUM has changed
#endif
@@ -260,8 +262,9 @@ err_reject[SGS_REJ_NUM] = {
MSG_ERR_REJ_HWCAP_2, /* MSG_INTL(MSG_ERR_REJ_HWCAP_2) */
MSG_ERR_REJ_ARCHIVE, /* MSG_INTL(MSG_ERR_REJ_ARCHIVE) */
MSG_ERR_REJ_KMOD, /* MSG_INTL(MSG_ERR_REJ_KMOD) */
+ MSG_ERR_REJ_HWCAP_3 /* MSG_INTL(MSG_ERR_REJ_HWCAP_3) */
};
-#if SGS_REJ_NUM != (SGS_REJ_KMOD + 1)
+#if SGS_REJ_NUM != (SGS_REJ_HWCAP_3 + 1)
#error SGS_REJ_NUM has changed
#endif
@@ -287,7 +290,8 @@ ldd_warn[SGS_REJ_NUM] = {
MSG_LDD_WARN_HWCAP_2, /* MSG_INTL(MSG_LDD_WARN_HWCAP_2) */
MSG_STR_EMPTY,
MSG_STR_EMPTY,
+ MSG_LDD_WARN_HWCAP_3 /* MSG_INTL(MSG_LDD_WARN_HWCAP_3) */
};
-#if SGS_REJ_NUM != (SGS_REJ_KMOD + 1)
+#if SGS_REJ_NUM != (SGS_REJ_HWCAP_3 + 1)
#error SGS_REJ_NUM has changed
#endif
diff --git a/usr/src/cmd/sgs/rtld/common/rtld.msg b/usr/src/cmd/sgs/rtld/common/rtld.msg
index 7d0f45c9e0..f511806030 100644
--- a/usr/src/cmd/sgs/rtld/common/rtld.msg
+++ b/usr/src/cmd/sgs/rtld/common/rtld.msg
@@ -21,6 +21,7 @@
#
# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2022 Oxide Computer Company
#
@ _START_
@@ -193,6 +194,7 @@
@ MSG_LDD_REJ_MACHCAP " - machine capability (CA_SUNW_MACH) unsupported: %s"
@ MSG_LDD_REJ_PLATCAP " - platform capability (CA_SUNW_PLAT) unsupported: %s"
@ MSG_LDD_REJ_HWCAP_2 " - hardware capability (CA_SUNW_HW_2) unsupported: %s"
+@ MSG_LDD_REJ_HWCAP_3 " - hardware capability (CA_SUNW_HW_3) unsupported: %s"
@ MSG_LDD_REJ_ARCHIVE " - invalid archive use"
@ MSG_LDD_REJ_KMOD " - invalid kernel module use"
@@ -207,6 +209,8 @@
unsupported: %s\n"
@ MSG_LDD_WARN_HWCAP_2 "%s: warning: hardware capability (CA_SUNW_HW_2) \
unsupported: %s\n"
+@ MSG_LDD_WARN_HWCAP_3 "%s: warning: hardware capability (CA_SUNW_HW_3) \
+ unsupported: %s\n"
# Error rejection messages.
@@ -229,6 +233,7 @@
@ MSG_ERR_REJ_HWCAP_2 "%s: hardware capability (CA_SUNW_HW_2) unsupported: %s"
@ MSG_ERR_REJ_ARCHIVE "%s: invalid archive use"
@ MSG_ERR_REJ_KMOD "%s: invalid kernel module use"
+@ MSG_ERR_REJ_HWCAP_3 "%s: hardware capability (CA_SUNW_HW_3) unsupported: %s"
# Error TLS failures
diff --git a/usr/src/cmd/sgs/rtld/common/setup.c b/usr/src/cmd/sgs/rtld/common/setup.c
index 43a72fcd1e..1cbe41aa6b 100644
--- a/usr/src/cmd/sgs/rtld/common/setup.c
+++ b/usr/src/cmd/sgs/rtld/common/setup.c
@@ -29,6 +29,7 @@
*/
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -407,6 +408,7 @@ setup(char **envp, auxv_t *auxv, Word _flags, char *_platform, int _syspagsz,
rtld_flags2 |= RT_FL2_HWCAP;
org_scapset->sc_hw_1 = (Xword)hwcap[0];
org_scapset->sc_hw_2 = (Xword)hwcap[1];
+ org_scapset->sc_hw_3 = (Xword)hwcap[2];
}
/*
diff --git a/usr/src/cmd/sgs/rtld/i386/_setup.c b/usr/src/cmd/sgs/rtld/i386/_setup.c
index da208c45cd..aaa1bca08e 100644
--- a/usr/src/cmd/sgs/rtld/i386/_setup.c
+++ b/usr/src/cmd/sgs/rtld/i386/_setup.c
@@ -30,6 +30,7 @@
*/
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
/*
@@ -64,7 +65,7 @@ _setup(Boot *ebp, Dyn *ld_dyn)
char *_rt_name, **_envp, **_argv;
int _syspagsz = 0, fd = -1;
uint_t _flags = 0;
- uint_t hwcap[2] = { 0, 0 };
+ uint_t hwcap[3] = { 0, 0, 0 };
Dyn *dyn_ptr;
Phdr *phdr = NULL;
Rt_map *lmp;
@@ -159,6 +160,10 @@ _setup(Boot *ebp, Dyn *ld_dyn)
/* hardware capabilities */
hwcap[1] = (uint_t)auxv->a_un.a_val;
break;
+ case AT_SUN_HWCAP3:
+ /* hardware capabilities */
+ hwcap[2] = (uint_t)auxv->a_un.a_val;
+ break;
case AT_SUN_EMULATOR:
/* name of emulation library, if any */
_emulator = auxv->a_un.a_ptr;
diff --git a/usr/src/cmd/sgs/tools/SUNWonld-README b/usr/src/cmd/sgs/tools/SUNWonld-README
index 288d18aafc..13f33502da 100644
--- a/usr/src/cmd/sgs/tools/SUNWonld-README
+++ b/usr/src/cmd/sgs/tools/SUNWonld-README
@@ -1691,3 +1691,4 @@ Bugid Risk Synopsis
14722 ld should keep group members in separate output sections
14770 ld(1) should be 64bit only
14901 remove remaining a.out support from sgs
+14822 Need new word of hardware capabilities
diff --git a/usr/src/common/elfcap/elfcap.c b/usr/src/common/elfcap/elfcap.c
index ef9fb8d6b4..53eeb21104 100644
--- a/usr/src/common/elfcap/elfcap.c
+++ b/usr/src/common/elfcap/elfcap.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2019, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
/* LINTLIBRARY */
@@ -70,7 +71,8 @@
/*
* Define separators for output string processing. This must be kept in
- * sync with the elfcap_fmt_t values in elfcap.h.
+ * sync with the elfcap_fmt_t values in elfcap.h. If something is added here
+ * that is longer than ELFCAP_FMT_PIPSPACE, please update elfcap_chk.c.
*/
static const elfcap_str_t format[] = {
STRDESC(" "), /* ELFCAP_FMT_SNGSPACE */
@@ -488,6 +490,29 @@ static const elfcap_desc_t hw2_386[ELFCAP_NUM_HW2_386] = {
{ /* 0x10000000 */
AV_386_2_VAES, STRDESC("AV_386_2_VAES"),
STRDESC("VAES"), STRDESC("vaes")
+ },
+ { /* 0x20000000 */
+ AV_386_2_GFNI, STRDESC("AV_386_2_GFNI"),
+ STRDESC("GFNI"), STRDESC("gfni")
+ },
+ { /* 0x40000000 */
+ AV_386_2_AVX512_VP2INT, STRDESC("AV_386_2_AVX512_VP2INT"),
+ STRDESC("AVX512_VP2INT"), STRDESC("avx512_vp2int")
+ },
+ { /* 0x80000000 */
+ AV_386_2_AVX512_BITALG, STRDESC("AV_386_2_AVX512_BITALG"),
+ STRDESC("AVX512_BITALG"), STRDESC("avx512_bitalg")
+ }
+};
+
+static const elfcap_desc_t hw3_386[ELFCAP_NUM_HW3_386] = {
+ { /* 0x00000001 */
+ AV_386_3_AVX512_VBMI2, STRDESC("AV_386_3_AVX512_VBMI2"),
+ STRDESC("AVX512_VBMI2"), STRDESC("avx512_vbmi2")
+ },
+ { /* 0x00000002 */
+ AV_386_3_AVX512_BF16, STRDESC("AV_386_3_AVX512_BF16"),
+ STRDESC("AVX512_BF16"), STRDESC("avx512_bf16")
}
};
@@ -624,6 +649,27 @@ elfcap_hw2_to_str(elfcap_style_t style, elfcap_mask_t val, char *str,
}
/*
+ * Expand a CA_SUNW_HW_3 value.
+ */
+elfcap_err_t
+elfcap_hw3_to_str(elfcap_style_t style, elfcap_mask_t val, char *str,
+ size_t len, elfcap_fmt_t fmt, ushort_t mach)
+{
+ /*
+ * Initialize the string buffer, and validate the format request.
+ */
+ *str = '\0';
+ if ((fmt < 0) || (fmt >= FORMAT_NELTS))
+ return (ELFCAP_ERR_INVFMT);
+
+ if ((mach == EM_386) || (mach == EM_IA_64) || (mach == EM_AMD64))
+ return (expand(style, val, &hw3_386[0], ELFCAP_NUM_HW3_386,
+ str, len, fmt));
+
+ return (expand(style, val, NULL, 0, str, len, fmt));
+}
+
+/*
* Expand a CA_SUNW_SF_1 value. Note, that at present these capabilities are
* common across all platforms. The use of "mach" is therefore redundant, but
* is retained for compatibility with the interface of elfcap_hw1_to_str(), and
@@ -661,6 +707,9 @@ elfcap_tag_to_str(elfcap_style_t style, uint64_t tag, elfcap_mask_t val,
case CA_SUNW_HW_2:
return (elfcap_hw2_to_str(style, val, str, len, fmt, mach));
+ case CA_SUNW_HW_3:
+ return (elfcap_hw3_to_str(style, val, str, len, fmt, mach));
+
}
return (ELFCAP_ERR_UNKTAG);
@@ -725,6 +774,15 @@ elfcap_hw2_from_str(elfcap_style_t style, const char *str, ushort_t mach)
return (0);
}
+elfcap_mask_t
+elfcap_hw3_from_str(elfcap_style_t style, const char *str, ushort_t mach)
+{
+ if ((mach == EM_386) || (mach == EM_IA_64) || (mach == EM_AMD64))
+ return (value(style, str, &hw3_386[0], ELFCAP_NUM_HW3_386));
+
+ return (0);
+}
+
/*
* Given a capability tag type and value, return the capabilities values
@@ -743,6 +801,9 @@ elfcap_tag_from_str(elfcap_style_t style, uint64_t tag, const char *str,
case CA_SUNW_HW_2:
return (elfcap_hw2_from_str(style, str, mach));
+
+ case CA_SUNW_HW_3:
+ return (elfcap_hw3_from_str(style, str, mach));
}
return (0);
@@ -752,6 +813,12 @@ elfcap_tag_from_str(elfcap_style_t style, uint64_t tag, const char *str,
* These functions allow the caller to get direct access to the
* cap descriptors.
*/
+const elfcap_str_t *
+elfcap_getdesc_formats(void)
+{
+ return (format);
+}
+
const elfcap_desc_t *
elfcap_getdesc_hw1_sparc(void)
{
@@ -769,3 +836,15 @@ elfcap_getdesc_sf1(void)
{
return (sf1);
}
+
+const elfcap_desc_t *
+elfcap_getdesc_hw2_386(void)
+{
+ return (hw2_386);
+}
+
+const elfcap_desc_t *
+elfcap_getdesc_hw3_386(void)
+{
+ return (hw3_386);
+}
diff --git a/usr/src/common/elfcap/elfcap.h b/usr/src/common/elfcap/elfcap.h
index 0d508d02cc..ee18e7bd74 100644
--- a/usr/src/common/elfcap/elfcap.h
+++ b/usr/src/common/elfcap/elfcap.h
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2019, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _ELFCAP_DOT_H
@@ -115,8 +116,19 @@ typedef enum {
#define ELFCAP_NUM_SF1 3
#define ELFCAP_NUM_HW1_SPARC 30
#define ELFCAP_NUM_HW1_386 32
-#define ELFCAP_NUM_HW2_386 29
+#define ELFCAP_NUM_HW2_386 32
+#define ELFCAP_NUM_HW3_386 2
+/*
+ * String buffer lengths that should be sufficient for elfcap values today. This
+ * is used because this is compiled into programs. Do not assume it won't change
+ * or make it part of an ABI. This uses the worst case values as calculated by
+ * the elfcap_chk program that is run in sgs and checked as part of the build.
+ */
+#define ELFCAP_SF1_BUFSIZE 73
+#define ELFCAP_HW1_BUFSIZE 528
+#define ELFCAP_HW2_BUFSIZE 632
+#define ELFCAP_HW3_BUFSIZE 66
/*
* Given a capability section tag and value, call the proper underlying
@@ -134,6 +146,7 @@ typedef elfcap_err_t elfcap_to_str_func_t(elfcap_style_t, elfcap_mask_t, char *,
extern elfcap_to_str_func_t elfcap_hw1_to_str;
extern elfcap_to_str_func_t elfcap_hw2_to_str;
+extern elfcap_to_str_func_t elfcap_hw3_to_str;
extern elfcap_to_str_func_t elfcap_sf1_to_str;
/*
@@ -153,6 +166,7 @@ extern elfcap_mask_t elfcap_tag_from_str(elfcap_style_t, uint64_t,
extern elfcap_from_str_func_t elfcap_hw1_from_str;
extern elfcap_from_str_func_t elfcap_hw2_from_str;
extern elfcap_from_str_func_t elfcap_sf1_from_str;
+extern elfcap_from_str_func_t elfcap_hw3_from_str;
/*
* These functions give access to the individual descriptor arrays.
@@ -161,8 +175,11 @@ extern elfcap_from_str_func_t elfcap_sf1_from_str;
* of making the arrays directly visible to preclude copy relocations in
* non-pic code.
*/
+extern const elfcap_str_t *elfcap_getdesc_formats(void);
extern const elfcap_desc_t *elfcap_getdesc_hw1_sparc(void);
extern const elfcap_desc_t *elfcap_getdesc_hw1_386(void);
+extern const elfcap_desc_t *elfcap_getdesc_hw2_386(void);
+extern const elfcap_desc_t *elfcap_getdesc_hw3_386(void);
extern const elfcap_desc_t *elfcap_getdesc_sf1(void);
#ifdef __cplusplus
diff --git a/usr/src/lib/libc/port/gen/getisax.c b/usr/src/lib/libc/port/gen/getisax.c
index c721528fb3..85d60eb192 100644
--- a/usr/src/lib/libc/port/gen/getisax.c
+++ b/usr/src/lib/libc/port/gen/getisax.c
@@ -25,6 +25,7 @@
*/
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#pragma weak _getisax = getisax
@@ -48,10 +49,12 @@ getisax(uint32_t *array, uint_t n)
int i;
static uint32_t auxv_hwcap;
static uint32_t auxv_hwcap_2;
+ static uint32_t auxv_hwcap_3;
if (auxv_hwcap == 0) {
auxv_hwcap = (uint32_t)___getauxval(AT_SUN_HWCAP);
auxv_hwcap_2 = (uint32_t)___getauxval(AT_SUN_HWCAP2);
+ auxv_hwcap_3 = (uint32_t)___getauxval(AT_SUN_HWCAP3);
}
if (n > 0) {
@@ -59,9 +62,15 @@ getisax(uint32_t *array, uint_t n)
array[0] = auxv_hwcap;
if (n >= 2)
array[1] = auxv_hwcap_2;
- for (i = 2; i < n; i++)
+ if (n >= 3)
+ array[2] = auxv_hwcap_3;
+ for (i = 3; i < n; i++)
array[i] = 0;
}
- return (auxv_hwcap == 0 ? 0 : n >= 2 ? 2 : 1);
+ if (auxv_hwcap == 0) {
+ return (0);
+ }
+
+ return (n >= 3 ? 3 : n);
}
diff --git a/usr/src/pkg/manifests/system-test-elftest.p5m b/usr/src/pkg/manifests/system-test-elftest.p5m
index 108876ce67..a57ba44404 100644
--- a/usr/src/pkg/manifests/system-test-elftest.p5m
+++ b/usr/src/pkg/manifests/system-test-elftest.p5m
@@ -27,6 +27,9 @@ dir path=opt/elf-tests/tests
dir path=opt/elf-tests/tests/assert-deflib
file path=opt/elf-tests/tests/assert-deflib/link.c mode=0444
file path=opt/elf-tests/tests/assert-deflib/test-deflib mode=0555
+dir path=opt/elf-tests/tests/capabilities
+file path=opt/elf-tests/tests/capabilities/objcap mode=0555
+file path=opt/elf-tests/tests/capabilities/symcap mode=0555
dir path=opt/elf-tests/tests/groups
dir path=opt/elf-tests/tests/groups/no-relobj-group-merge
file path=opt/elf-tests/tests/groups/no-relobj-group-merge/README.md mode=0444
diff --git a/usr/src/test/elf-tests/runfiles/default.run b/usr/src/test/elf-tests/runfiles/default.run
index 0005b8976b..0978c05c89 100644
--- a/usr/src/test/elf-tests/runfiles/default.run
+++ b/usr/src/test/elf-tests/runfiles/default.run
@@ -22,6 +22,9 @@ outputdir = /var/tmp/test_results
[/opt/elf-tests/tests/assert-deflib]
tests = ['test-deflib']
+[/opt/elf-tests/tests/capabilities]
+tests = ['objcap', 'symcap']
+
[/opt/elf-tests/tests/groups/no-relobj-group-merge]
tests = ['no-relobj-group-merge']
diff --git a/usr/src/test/elf-tests/tests/Makefile b/usr/src/test/elf-tests/tests/Makefile
index 74f358d77a..7e14f57497 100644
--- a/usr/src/test/elf-tests/tests/Makefile
+++ b/usr/src/test/elf-tests/tests/Makefile
@@ -16,6 +16,7 @@
SUBDIRS = \
assert-deflib \
+ capabilities \
groups \
linker-sets \
mapfiles \
diff --git a/usr/src/test/elf-tests/tests/capabilities/Makefile b/usr/src/test/elf-tests/tests/capabilities/Makefile
new file mode 100644
index 0000000000..8b344c0793
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/capabilities/Makefile
@@ -0,0 +1,41 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2022 Oxide Computer Company
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROGS = symcap objcap
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/capabilities
+
+CMDS = $(PROGS:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+all:
+
+install: all $(CMDS)
+
+clobber: clean
+ -$(RM) $(PROG)
+
+clean:
+ -$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %.ksh
+ $(INS.rename)
diff --git a/usr/src/test/elf-tests/tests/capabilities/objcap.ksh b/usr/src/test/elf-tests/tests/capabilities/objcap.ksh
new file mode 100644
index 0000000000..806f85ea52
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/capabilities/objcap.ksh
@@ -0,0 +1,351 @@
+#!/usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# souroc. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/liocnse/CDDL.
+#
+
+#
+# Copyright 2022 Oxide Computer Company
+#
+
+#
+# This test focuses around the generation of files with object capabilities and
+# verifies that tools like elfedit, elfdump, ld, and ld.so.1 can deal with them
+# all appropriately.
+#
+
+export LC_ALL=C.UTF-8
+unalias -a
+set -o pipefail
+
+oc_arg0=$(basename $0)
+oc_tmpdir=/tmp/objcap.$$
+oc_prog_nocap="$oc_tmpdir/prog.nocap"
+oc_prog_hw1="$oc_tmpdir/prog.hw1"
+oc_prog_hw3="$oc_tmpdir/prog.hw3"
+oc_prog_hw123="$oc_tmpdir/prog.hw123"
+oc_cap_hw1="0x42"
+oc_cap_hw2="0x169"
+oc_cap_hw3="0x7777"
+oc_err=0
+
+pass()
+{
+ typeset msg="$*"
+ echo "TEST PASSED: $msg"
+}
+
+warn()
+{
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="failed"
+ echo "TEST FAILED: $msg" >&2
+ oc_err=1
+}
+
+fatal()
+{
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="failed"
+ echo "$oc_arg0: $msg" >&2
+ exit 1
+}
+
+cleanup()
+{
+ rm -rf "$oc_tmpdir"
+}
+
+#
+# Set up our test environment. This generally requires us to create the
+# source file, mapfiles, and related contents that the test requires.
+#
+setup()
+{
+ typeset cfile="$oc_tmpdir/test.c"
+ typeset mapfile_hw1="$oc_tmpdir/test.mapfile.hw1"
+ typeset mapfile_hw3="$oc_tmpdir/test.mapfile.hw3"
+ typeset mapfile_hw123="$oc_tmpdir/test.mapfile.hw123"
+
+ if ! mkdir "$oc_tmpdir"; then
+ fatal "failed to make directory $oc_tmpdir"
+ fi
+
+ trap 'cleanup' EXIT
+
+ cat > $cfile <<EOF
+int
+main(void)
+{
+ return (0);
+}
+EOF
+ if (( $? != 0 )); then
+ fatal "failed to write token C file to $cfile"
+ fi
+
+ cat > $mapfile_hw1 <<EOF
+\$mapfile_version 2
+CAPABILITY {
+ HW_1 += $oc_cap_hw1;
+};
+EOF
+
+ if (( $? != 0 )); then
+ fatal "failed to write out $mapfile_hw1"
+ fi
+
+ cat > $mapfile_hw3 <<EOF
+\$mapfile_version 2
+CAPABILITY {
+ HW_3 += $oc_cap_hw3;
+};
+EOF
+
+ if (( $? != 0 )); then
+ fatal "failed to write out $mapfile_hw3"
+ fi
+
+ cat > $mapfile_hw123 <<EOF
+\$mapfile_version 2
+CAPABILITY {
+ HW_1 += $oc_cap_hw1;
+ HW_2 += $oc_cap_hw2;
+ HW_3 += $oc_cap_hw3;
+};
+EOF
+
+ if (( $? != 0 )); then
+ fatal "failed to write out $mapfile_hw3"
+ fi
+
+ if ! gcc -m64 -o $oc_prog_nocap $cfile; then
+ fatal "failed to create $oc_prog_nocap"
+ fi
+
+ if ! gcc -m64 -o $oc_prog_hw1 $cfile -Wl,-M$mapfile_hw1; then
+ fatal "failed to create $oc_prog_hw1"
+ fi
+
+ if ! gcc -m64 -o $oc_prog_hw3 $cfile -Wl,-M$mapfile_hw3; then
+ fatal "failed to create $oc_prog_hw1"
+ fi
+
+ if ! gcc -m64 -o $oc_prog_hw123 $cfile -Wl,-M$mapfile_hw123; then
+ fatal "failed to create $oc_prog_hw1"
+ fi
+}
+
+verify_caps()
+{
+ typeset file="$1"
+ typeset data="$2"
+ typeset -a vals=($3 $4 $5)
+ typeset -a caps=("CA_SUNW_HW_1" "CA_SUNW_HW_2" "CA_SUNW_HW_3")
+ typeset -a ee=("cap:hw1" "cap:hw2" "cap:hw3")
+ typeset out=
+ typeset ee_out=
+ typeset i=
+
+ out=$(elfdump -H $file 2>&1)
+ if (( $? != 0 )); then
+ warn "elfdump -H $file failed with $?"
+ return
+ fi
+
+ #
+ # If we don't expect a object capability, then we're done here.
+ #
+ if (( data == 0 )); then
+ if [[ -n "$out" ]]; then
+ fail "elfdump -H $file had unexpected output: $out"
+ else
+ pass "elfdump -H $file contained no output"
+ fi
+ return
+ fi
+
+ if [[ -z "$out" ]]; then
+ fail "elfdump -H $file had no output, but expected caps"
+ return
+ fi
+
+ #
+ # At this point, for each hw cap, if there is a value, check that we
+ # have an elfdump output line and then verify that we have the expected
+ # value via elfedit.
+ #
+ for ((i = 0; i < 3; i++)); do
+ if [[ "${vals[$i]}" == "0" ]]; then
+ continue;
+ fi
+
+ if ! echo $out | grep -q ${caps[$i]}; then
+ warn "elfdump -H $file missing ${caps[$i]}"
+ else
+ pass "elfdump -H $file has ${caps[$i]}"
+ fi
+
+ ee_out=$(elfedit -e "${ee[$i]} -o num" $file)
+ if [[ -z $ee_out ]]; then
+ warn "failed to dump ${ee[$i]} from $file via elfedit"
+ continue
+ fi
+
+ if [[ "$ee_out" != "${vals[$i]}" ]]; then
+ warn "mismatched value for ${ee[$i]} in $file: found " \
+ "$out, expected ${vals[$i]}"
+ else
+ pass "elfedit has correct value for ${ee[$i]} in $file"
+ fi
+ done
+}
+
+#
+# Attempt to execute a program with symbol capabilities. We override the
+# symbol capabilities in the system for the specified file to the ones
+# indicated in the function. We need to restrict to the program we're
+# calling so that way we don't accidentally tell ld not to load a system
+# library.
+#
+run_prog()
+{
+ typeset prog="$1"
+ typeset run=$2
+ typeset cap="$3"
+ typeset case="$4"
+ typeset ret=
+
+ LD_CAP_FILES=$prog LD_HWCAP=$3 $prog 2>/dev/null 1>/dev/null
+ ret=$?
+ if (( run != 0 && ret == 0 )); then
+ pass "exec prog $case"
+ elif (( run != 0 && ret != 0 )); then
+ warn "exec prog $case returned $ret, expected 0"
+ elif (( run == 0 && ret == 0 )); then
+ warn "exec prog $case returned $ret, expected non-zero"
+ else
+ pass "exec prog $case"
+ fi
+}
+
+#
+# Use elfedit to modify a specific hwcap and make sure we see the new value.
+#
+edit_prog()
+{
+ typeset input="$1"
+ typeset pass="$2"
+ typeset cap="$3"
+ typeset cmd="$4"
+ typeset exp="$5"
+ typeset ret=
+
+ rm -f "$input.edit"
+ elfedit -e "$cap $cmd" "$input" "$input.edit" >/dev/null 2>/dev/null
+ ret=$?
+
+ if (( pass == 0 )); then
+ if (( ret == 0 )); then
+ warn "elfedit -e $cap $cmd $input worked, expected failure"
+ else
+ pass "elfedit -e $cap $cmd $input failed correctly"
+ fi
+ return
+ fi
+
+ if (( ret != 0 )); then
+ warn "elfedit -e $cap $cmd $input failed with $ret, expected success"
+ return
+ fi
+
+ ret=$(elfedit -e "$cap -o num" "$input.edit")
+ if (( $? != 0 )); then
+ warn "failed to extract hwcap after elfedit -e $cap $cmd $input"
+ fi
+
+ if [[ "$ret" != "$exp" ]]; then
+ warn "elfedit -e $cap $cmd $input had wrong output " \
+ "expected $exp, found $val"
+ else
+ pass "elfedit -e $cap $cmd $input"
+ fi
+}
+
+setup
+verify_caps "$oc_prog_nocap" 0
+verify_caps "$oc_prog_hw1" 1 $oc_cap_hw1 0 0
+verify_caps "$oc_prog_hw3" 1 0 0 $oc_cap_hw3
+verify_caps "$oc_prog_hw123" 1 $oc_cap_hw1 $oc_cap_hw2 $oc_cap_hw3
+
+#
+# Now that we've verified the caps in these files, try to run them in a
+# given alternate symbol cap env.
+#
+run_prog "$oc_prog_nocap" 1 "[1]0,[2]0,[3]0" "no need, no caps"
+run_prog "$oc_prog_hw1" 0 "[1]0,[2]0,[3]0" "need hw1, no caps"
+run_prog "$oc_prog_hw3" 0 "[1]0,[2]0,[3]0" "need hw3, no caps"
+run_prog "$oc_prog_hw123" 0 "[1]0,[2]0,[3]0" "need hw{123}, no caps"
+
+run_prog "$oc_prog_nocap" 1 "[1]0x42,[2]0,[3]0" "no need, hw1=0x42"
+run_prog "$oc_prog_hw1" 1 "[1]0x42,[2]0,[3]0" "need hw1, hw1=0x42"
+run_prog "$oc_prog_hw3" 0 "[1]0x42,[2]0,[3]0" "need hw3, hw1=0x42"
+run_prog "$oc_prog_hw123" 0 "[1]0x42,[2]0,[3]0" "need hw{123}, hw1=0x42"
+
+run_prog "$oc_prog_nocap" 1 "[1]0,[2]0,[3]0x7777" "no need, hw3=0x7777"
+run_prog "$oc_prog_hw1" 0 "[1]0,[2]0,[3]0x7777" "need hw1, hw3=0x7777"
+run_prog "$oc_prog_hw3" 1 "[1]0,[2]0,[3]0x7777" "need hw3, hw3=0x7777"
+run_prog "$oc_prog_hw123" 0 "[1]0,[2]0,[3]0x7777" "need hw{123}, hw3=0x7777"
+
+run_prog "$oc_prog_nocap" 1 "[1]0,[2]0x1369,[3]0" "no need, hw2=0x1369"
+run_prog "$oc_prog_hw1" 0 "[1]0,[2]0x1369,[3]0" "need hw1, hw2=0x1369"
+run_prog "$oc_prog_hw3" 0 "[1]0,[2]0x1369,[3]0" "need hw3, hw2=0x1369"
+run_prog "$oc_prog_hw123" 0 "[1]0,[2]0x1369,[3]0" "need hw{123}, hw2=0x1369"
+
+run_prog "$oc_prog_nocap" 1 "[1]0x42,[2]0,[3]0x7777" \
+ "no need, hw1=0x42,hw3=0x7777"
+run_prog "$oc_prog_hw1" 1 "[1]0x42,[2]0,[3]0x7777" \
+ "need hw1, hw1=0x42,hw3=0x7777"
+run_prog "$oc_prog_hw3" 1 "[1]0x42,[2]0,[3]0x7777" \
+ "need hw3, hw1=0x42,hw3=0x7777"
+run_prog "$oc_prog_hw123" 0 "[1]0x42,[2]0,[3]0x7777" \
+ "need hw{123}, hw1=0x42,hw3=0x7777"
+
+run_prog "$oc_prog_nocap" 1 "[1]0x42,[2]0x1369,[3]0x7777" \
+ "no need, hw1=0x42,hw2=0x1369,hw3=0x7777"
+run_prog "$oc_prog_hw1" 1 "[1]0x42,[2]0x1369,[3]0x7777" \
+ "need hw1, hw1=0x42,hw2=0x1369,hw3=0x7777"
+run_prog "$oc_prog_hw3" 1 "[1]0x42,[2]0x1369,[3]0x7777" \
+ "need hw3, hw1=0x42,hw2=0x1369,hw3=0x7777"
+run_prog "$oc_prog_hw123" 1 "[1]0x42,[2]0x1369,[3]0x7777" \
+ "need hw{123}, hw1=0x42,hw2=0x1369,hw3=0x7777"
+
+edit_prog "$oc_prog_hw1" 1 "cap:hw1" "-or 0x1000" "0x1042"
+edit_prog "$oc_prog_hw1" 1 "cap:hw1" "-and 0x1000" "0"
+edit_prog "$oc_prog_hw1" 1 "cap:hw1" "-cmp 0x42" "0xffffffbd"
+edit_prog "$oc_prog_hw3" 1 "cap:hw3" "-and 0x643f" "0x6437"
+edit_prog "$oc_prog_hw123" 1 "cap:hw2" "0x12345" "0x12345"
+
+#
+# Failure cases here are meant to cover missing capaibilities and bad strings.
+#
+edit_prog "$oc_prog_hw1" 0 "cap:hw1" "-or zelda"
+edit_prog "$oc_prog_hw1" 0 "cap:hw2" "-or 0x100"
+edit_prog "$oc_prog_nocap" 0 "cap:hw1" "-or 0x1"
+edit_prog "$oc_prog_hw3" 0 "cap:hw1" "-and 0xff"
+edit_prog "$oc_prog_hw3" 0 "cap:hw2" "-and 0xff"
+edit_prog "$oc_prog_hw3" 0 "cap:hw3" "-and link"
+edit_prog "$oc_prog_hw123" 0 "cap:hw2" "ganondorf"
+
+if (( oc_err == 0 )); then
+ printf "All tests passed successfully\n"
+fi
+
+exit $oc_err
diff --git a/usr/src/test/elf-tests/tests/capabilities/symcap.ksh b/usr/src/test/elf-tests/tests/capabilities/symcap.ksh
new file mode 100644
index 0000000000..7f58191938
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/capabilities/symcap.ksh
@@ -0,0 +1,269 @@
+#!/usr/bin/ksh
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# souroc. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/liocnse/CDDL.
+#
+
+#
+# Copyright 2022 Oxide Computer Company
+#
+
+#
+# This test generates a binary with a lot of different symbol capabilities and
+# then selects different capability environments to try and ensure that the
+# rules for what we pick are honored.
+#
+
+export LC_ALL=C.UTF-8
+unalias -a
+set -o pipefail
+
+sc_arg0=$(basename $0)
+sc_err=0
+sc_tmpdir=/tmp/symcap.$$
+sc_prog="$sc_tmpdir/symcap"
+
+#
+# To build symbol caps, we need to annotate a .o file with object caps and then
+# turn that into a symbol cap with ld. The following arrays are used to create
+# this for us. sc_obj_hw1, sc_obj_hw2, and sc_obj_hw3 are the set of object
+# capabilities that we want to use and then eventually turn into symbol
+# capabilities. Each symbol capability prints out its own index when executed.
+# This means we can see which thing ld resolved to run based on the output.
+# The following summarizes our goals with each case:
+#
+# 0: none
+# 1: only hwcap 1
+# 2: only hwcap 1, but greater than (1)
+# 3: only hwcap 2
+# 4: only hwcap 2, but greater than (3)
+# 5: only hwcap 3
+# 6: only hwcap 3, but greater than (5)
+# 7: uses all 3
+# 8: differs from (7) in hwcap1
+#
+sc_obj_hw1=( "0x0" "0x5" "0x42" "0x0" "0x0" "0x0" "0x0"
+ "0x3" "0x8" )
+sc_obj_hw2=( "0x0" "0x0" "0x0" "0x23" "0xff00" "0x0" "0x0"
+ "0xff7ff6" "0xff7ff6" )
+sc_obj_hw3=( "0x0" "0x0" "0x0" "0x0" "0x0" "0x12345" "0x7000000"
+ "0x87654321" "0x87654321" )
+
+pass()
+{
+ typeset msg="$*"
+ echo "TEST PASSED: $msg"
+}
+
+warn()
+{
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="failed"
+ echo "TEST FAILED: $msg" >&2
+ sc_err=1
+}
+
+fatal()
+{
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="failed"
+ echo "$sc_arg0: $msg" >&2
+ exit 1
+}
+
+cleanup()
+{
+ rm -rf "$sc_tmpdir"
+}
+
+sanity_check()
+{
+ if (( ${#sc_obj_hw1[@]} != ${#sc_obj_hw2[@]} )); then
+ fatal "sc_obj_hw1 does not match length of sc_obj_hw2"
+ fi
+
+ if (( ${#sc_obj_hw2[@]} != ${#sc_obj_hw3[@]} )); then
+ fatal "sc_obj_hw1 does not match length of sc_obj_hw2"
+ fi
+}
+
+setup()
+{
+ typeset tolink=
+
+ if ! mkdir "$sc_tmpdir"; then
+ fatal "failed to make directory $sc_tmpdir"
+ fi
+
+ trap 'cleanup' EXIT
+
+ cat > $sc_tmpdir/main.c <<EOF
+extern void symcap_print(void);
+
+int
+main(void)
+{
+ symcap_print();
+ return (0);
+}
+EOF
+ if (( $? != 0 )); then
+ fatal "failed to write main.c"
+ fi
+
+ tolink="$sc_tmpdir/main.c"
+
+ for (( i = 0; i < ${#sc_obj_hw1[@]}; i++)); do
+ typeset in="$sc_tmpdir/$i.c"
+ typeset map="$sc_tmpdir/$i.map"
+ typeset ofile="$sc_tmpdir/$i.o"
+ typeset obj="$sc_tmpdir/$i.o.obj"
+ typeset sym="$sc_tmpdir/$i.o.sym"
+
+ cat > $in <<EOF
+#include <stdio.h>
+
+void
+symcap_print(void)
+{
+ printf("%u\n", $i);
+}
+EOF
+ if (( $? != 0 )); then
+ fatal "failed to write $in"
+ fi
+
+ cat > $map <<EOF
+\$mapfile_version 2
+CAPABILITY {
+ HW_1 += ${sc_obj_hw1[$i]};
+ HW_2 += ${sc_obj_hw2[$i]};
+ HW_3 += ${sc_obj_hw3[$i]};
+};
+EOF
+ if (( $? != 0 )); then
+ fatal "failed to write $map"
+ fi
+
+ #
+ # There are three steps to creating a symbol capability due to
+ # the world we're in. First we need to make the normal .o. Then
+ # we use a mapfile to add the object caps, while reducing
+ # visibility. Then we turn the object cap into a symbol cap.
+ #
+ if ! gcc -m64 -o $ofile -c $in; then
+ fatal "failed to create object file $ofile"
+ fi
+
+ #
+ # If the entry has a zero for all cases (e.g. our default case),
+ # then skip the rest of this processing and append the .o.
+ #
+ if (( sc_obj_hw1[i] == 0 && sc_obj_hw2[i] == 0 &&
+ sc_obj_hw3[i] == 0 )); then
+ tolink="$tolink $ofile"
+ continue
+ fi
+
+ if ! ld -r -o $obj $ofile -M$map -Breduce; then
+ fatal "failed to create object cap file $obj"
+ fi
+
+ if ! ld -r -o $sym -z symbolcap $obj; then
+ fatal "failed to create symbol cap file $sym"
+ fi
+
+ tolink="$tolink $sym"
+ done
+
+ if ! gcc -m64 -o $sc_prog $tolink; then
+ fatal "failed to create $sc_prog"
+ fi
+}
+
+#
+# Given a set of caps, indicate which index we expect to be printed out and
+# check for that.
+#
+run_one()
+{
+ typeset index="$1"
+ typeset caps="$2"
+ typeset out=
+
+ out=$(LD_CAP_FILES=$sc_prog LD_HWCAP="$caps" $sc_prog)
+ if (( $? != 0 )); then
+ warn "failed to execute $sc_prog with cap $caps"
+ return
+ fi
+
+ if [[ "$out" != "$index" ]]; then
+ warn "$caps had wrong output, found $out, expected $index"
+ else
+ pass "LD_HWCAP=$caps"
+ fi
+}
+
+sanity_check
+setup
+
+#
+# First, go through and verify that if we match the caps exactly for this, we'll
+# choose this symbol.
+#
+run_one 0 "[1]0x0,[2]0x0,[3]0x0"
+run_one 1 "[1]0x5,[2]0x0,[3]0x0"
+run_one 2 "[1]0x42,[2]0x0,[3]0x0"
+run_one 3 "[1]0x0,[2]0x23,[3]0x0"
+run_one 4 "[1]0x0,[2]0xff00,[3]0x0"
+run_one 5 "[1]0x0,[2]0x0,[3]0x12345"
+run_one 6 "[1]0x0,[2]0x0,[3]0x7000000"
+run_one 7 "[1]0x3,[2]0xff7ff6,[3]0x87654321"
+run_one 8 "[1]0x8,[2]0xff7ff6,[3]0x87654321"
+
+#
+# For cases where we have multiple symbol caps at a given level, show that we
+# pick a sub one when we're between the two.
+#
+run_one 0 "[1]0x40,[2]0x0,[3]0x0"
+run_one 1 "[1]0x45,[2]0x0,[3]0x0"
+run_one 1 "[1]0x45,[2]0x10,[3]0x0"
+run_one 2 "[1]0x142,[2]0x10,[3]0x0"
+run_one 3 "[1]0x1,[2]0x137,[3]0x0"
+
+#
+# We expect the system to pick the "best" aka highest capability. So for the
+# next round we attempt to combine multiple values and see which we pick. In
+# particular here we're trying to pick between things at the same level and also
+# ensure we pick the one that is higher (e.g. hw3 > hw2 > hw1)
+#
+run_one 6 "[1]0x47,[2]0xff23,[3]0x7012345"
+run_one 5 "[1]0x47,[2]0xff23,[3]0x6012345"
+run_one 5 "[1]0x47,[2]0xff23,[3]0x1012345"
+run_one 4 "[1]0x47,[2]0xff23,[3]0x1002345"
+run_one 3 "[1]0x47,[2]0x7723,[3]0x1002345"
+run_one 3 "[1]0x47,[2]0x0f23,[3]0x1002345"
+run_one 3 "[1]0x47,[2]0x0023,[3]0x1002345"
+run_one 2 "[1]0x47,[2]0x0003,[3]0x1002345"
+run_one 2 "[1]0x46,[2]0x0003,[3]0x1002345"
+run_one 1 "[1]0x35,[2]0x0003,[3]0x1002345"
+run_one 1 "[1]0x15,[2]0x0003,[3]0x1002345"
+run_one 0 "[1]0x10,[2]0x0003,[3]0x1002345"
+
+#
+# Finally we want a few tests that verify that when things match, the lowest bit
+# of it decides.
+#
+run_one 8 "[1]0xb,[2]0xff7ff6,[3]0x87654321"
+run_one 8 "[1]0x3b,[2]0xff7ff6,[3]0x87654321"
+run_one 8 "[1]0xffffffff,[2]0xffffffff,[3]0xffffffff"
+run_one 7 "[1]0xfffffff7,[2]0xffffffff,[3]0xffffffff"
+
+exit $sc_err
diff --git a/usr/src/uts/common/exec/elf/elf.c b/usr/src/uts/common/exec/elf/elf.c
index 14c70821d6..4f888d6feb 100644
--- a/usr/src/uts/common/exec/elf/elf.c
+++ b/usr/src/uts/common/exec/elf/elf.c
@@ -27,7 +27,7 @@
/* All Rights Reserved */
/*
* Copyright (c) 2019, Joyent, Inc.
- * Copyright 2021 Oxide Computer Company
+ * Copyright 2022 Oxide Computer Company
*/
#include <sys/types.h>
@@ -415,11 +415,12 @@ elfexec(vnode_t *vp, execa_t *uap, uarg_t *args, intpdata_t *idatap,
* AT_SUN_AUXFLAGS
* AT_SUN_HWCAP
* AT_SUN_HWCAP2
+ * AT_SUN_HWCAP3
* AT_SUN_PLATFORM (added in stk_copyout)
* AT_SUN_EXECNAME (added in stk_copyout)
* AT_NULL
*
- * total == 9
+ * total == 10
*/
if (hasintp && hasu) {
/*
@@ -434,7 +435,7 @@ elfexec(vnode_t *vp, execa_t *uap, uarg_t *args, intpdata_t *idatap,
*
* total = 5
*/
- args->auxsize = (9 + 5) * sizeof (aux_entry_t);
+ args->auxsize = (10 + 5) * sizeof (aux_entry_t);
} else if (hasintp) {
/*
* Has PT_INTERP but no PT_PHDR
@@ -444,9 +445,9 @@ elfexec(vnode_t *vp, execa_t *uap, uarg_t *args, intpdata_t *idatap,
*
* total = 2
*/
- args->auxsize = (9 + 2) * sizeof (aux_entry_t);
+ args->auxsize = (10 + 2) * sizeof (aux_entry_t);
} else {
- args->auxsize = 9 * sizeof (aux_entry_t);
+ args->auxsize = 10 * sizeof (aux_entry_t);
}
} else {
args->auxsize = 0;
@@ -837,18 +838,16 @@ elfexec(vnode_t *vp, execa_t *uap, uarg_t *args, intpdata_t *idatap,
* Used for choosing faster library routines.
* (Potentially different between 32-bit and 64-bit ABIs)
*/
-#if defined(_LP64)
if (args->to_model == DATAMODEL_NATIVE) {
ADDAUX(aux, AT_SUN_HWCAP, auxv_hwcap)
ADDAUX(aux, AT_SUN_HWCAP2, auxv_hwcap_2)
+ ADDAUX(aux, AT_SUN_HWCAP3, auxv_hwcap_3)
} else {
ADDAUX(aux, AT_SUN_HWCAP, auxv_hwcap32)
ADDAUX(aux, AT_SUN_HWCAP2, auxv_hwcap32_2)
+ ADDAUX(aux, AT_SUN_HWCAP3, auxv_hwcap32_3)
}
-#else
- ADDAUX(aux, AT_SUN_HWCAP, auxv_hwcap)
- ADDAUX(aux, AT_SUN_HWCAP2, auxv_hwcap_2)
-#endif
+
if (branded) {
/*
* Reserve space for the brand-private aux vectors,
diff --git a/usr/src/uts/common/io/cpuid_drv.c b/usr/src/uts/common/io/cpuid_drv.c
index ef3a21793f..5711258f9e 100644
--- a/usr/src/uts/common/io/cpuid_drv.c
+++ b/usr/src/uts/common/io/cpuid_drv.c
@@ -169,14 +169,17 @@ cpuid_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cr, int *rval)
if (strcmp(areq, architecture) == 0) {
STRUCT_FSET(h, cgh_hwcap[0], auxv_hwcap);
STRUCT_FSET(h, cgh_hwcap[1], auxv_hwcap_2);
+ STRUCT_FSET(h, cgh_hwcap[2], auxv_hwcap_3);
#if defined(_SYSCALL32_IMPL)
} else if (strcmp(areq, architecture_32) == 0) {
STRUCT_FSET(h, cgh_hwcap[0], auxv_hwcap32);
STRUCT_FSET(h, cgh_hwcap[1], auxv_hwcap32_2);
+ STRUCT_FSET(h, cgh_hwcap[2], auxv_hwcap32_3);
#endif
} else {
STRUCT_FSET(h, cgh_hwcap[0], 0);
STRUCT_FSET(h, cgh_hwcap[1], 0);
+ STRUCT_FSET(h, cgh_hwcap[2], 0);
}
if (ddi_copyout(STRUCT_BUF(h),
(void *)arg, STRUCT_SIZE(h), mode))
diff --git a/usr/src/uts/common/os/exec.c b/usr/src/uts/common/os/exec.c
index f51e2c5ca1..37ca15be86 100644
--- a/usr/src/uts/common/os/exec.c
+++ b/usr/src/uts/common/os/exec.c
@@ -24,9 +24,10 @@
*/
/* Copyright (c) 1988 AT&T */
-/* All Rights Reserved */
+/* All Rights Reserved */
/*
* Copyright 2017 Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
#include <sys/types.h>
@@ -93,9 +94,11 @@ static int hold_execsw(struct execsw *);
uint_t auxv_hwcap = 0; /* auxv AT_SUN_HWCAP value; determined on the fly */
uint_t auxv_hwcap_2 = 0; /* AT_SUN_HWCAP2 */
+uint_t auxv_hwcap_3 = 0; /* AT_SUN_HWCAP3 */
#if defined(_SYSCALL32_IMPL)
uint_t auxv_hwcap32 = 0; /* 32-bit version of auxv_hwcap */
uint_t auxv_hwcap32_2 = 0; /* 32-bit version of auxv_hwcap2 */
+uint_t auxv_hwcap32_3 = 0; /* 32-bit version of auxv_hwcap3 */
#endif
#define PSUIDFLAGS (SNOCD|SUGID)
diff --git a/usr/src/uts/common/sys/auxv.h b/usr/src/uts/common/sys/auxv.h
index 1fb5011970..e591320025 100644
--- a/usr/src/uts/common/sys/auxv.h
+++ b/usr/src/uts/common/sys/auxv.h
@@ -30,6 +30,7 @@
*/
/*
* Copyright (c) 2018, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _SYS_AUXV_H
@@ -141,6 +142,7 @@ typedef struct {
*/
#define AT_SUN_HWCAP 2009
#define AT_SUN_HWCAP2 2023
+#define AT_SUN_HWCAP3 2029
#if defined(_KERNEL)
/*
@@ -149,9 +151,11 @@ typedef struct {
*/
extern uint_t auxv_hwcap;
extern uint_t auxv_hwcap_2;
+extern uint_t auxv_hwcap_3;
#if defined(_SYSCALL32)
extern uint_t auxv_hwcap32;
extern uint_t auxv_hwcap32_2;
+extern uint_t auxv_hwcap32_3;
#endif /* _SYSCALL32 */
#else
extern uint_t getisax(uint32_t *, uint_t);
diff --git a/usr/src/uts/common/sys/auxv_386.h b/usr/src/uts/common/sys/auxv_386.h
index 3654474787..d8e6938be0 100644
--- a/usr/src/uts/common/sys/auxv_386.h
+++ b/usr/src/uts/common/sys/auxv_386.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2019, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _SYS_AUXV_386_H
@@ -115,9 +116,13 @@ extern "C" {
#define AV_386_2_AVX512_VNNI 0x04000000 /* AVX512_VNNI */
#define AV_386_2_VPCLMULQDQ 0x08000000 /* VPCLMULQDQ */
#define AV_386_2_VAES 0x10000000 /* VAES */
+#define AV_386_2_GFNI 0x20000000 /* GFNI */
+#define AV_386_2_AVX512_VP2INT 0x40000000 /* AVX512 VP2INTERESECT */
+#define AV_386_2_AVX512_BITALG 0x80000000 /* AVX512 BITALG */
#define FMT_AV_386_2 \
- "\035vaes\034vpclmulqdq\033avx512_vnni" \
+ "\040avx512_vbmi2\037avx512_vp2intersect" \
+ "\036gfni\035vaes\034vpclmulqdq\033avx512_vnni" \
"\032clzero\031monitorx\030clwb\027clflushopt\026fsgsbase" \
"\025sha\024avx512_4fmaps\023avx512_4nniw\022avx512vpopcntdq" \
"\021avx512vbmi\020avx512vl\017avx512bw\016avx512cd" \
@@ -125,6 +130,15 @@ extern "C" {
"\010rdseed\07adx\06avx2\05fma\04bmi2\03bmi1\02rdrand\01f16c"
/*
+ * Flags used in AT_SUN_HWCAP3 elements
+ */
+#define AV_386_3_AVX512_VBMI2 0x00000001 /* AVX512_VBMI2 */
+#define AV_386_3_AVX512_BF16 0x00000002 /* AVX512_BF16 */
+
+#define FMT_AV_386_3 \
+ "\02avx512_bf16\01avx512_vbmi2"
+
+/*
* Flags used in AT_SUN_FPTYPE on x86.
*
* We don't currently support xsavec in illumos. However, when we do, then we
diff --git a/usr/src/uts/common/sys/cpuid_drv.h b/usr/src/uts/common/sys/cpuid_drv.h
index c26bc7e422..2321f2446f 100644
--- a/usr/src/uts/common/sys/cpuid_drv.h
+++ b/usr/src/uts/common/sys/cpuid_drv.h
@@ -25,6 +25,7 @@
*/
/*
* Copyright 2019 Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _SYS_CPUID_DRV_H
@@ -68,7 +69,7 @@ extern "C" {
struct cpuid_get_hwcap {
char *cgh_archname;
- uint_t cgh_hwcap[2];
+ uint_t cgh_hwcap[3];
};
struct cpuid_rdmsr {
@@ -82,7 +83,7 @@ struct cpuid_rdmsr {
struct cpuid_get_hwcap32 {
caddr32_t cgh_archname;
- uint32_t cgh_hwcap[2];
+ uint32_t cgh_hwcap[3];
};
#endif /* _SYSCALL32_IMPL */
diff --git a/usr/src/uts/common/sys/elf.h b/usr/src/uts/common/sys/elf.h
index 3d053de531..1f290c282c 100644
--- a/usr/src/uts/common/sys/elf.h
+++ b/usr/src/uts/common/sys/elf.h
@@ -21,7 +21,7 @@
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2018, Joyent, Inc.
- * Copyright 2020 Oxide Computer Company
+ * Copyright 2022 Oxide Computer Company
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
@@ -956,7 +956,8 @@ typedef Elf64_Word Elf64_Capchain;
#define CA_SUNW_PLAT 4 /* platform capability entry */
#define CA_SUNW_MACH 5 /* machine capability entry */
#define CA_SUNW_ID 6 /* capability identifier */
-#define CA_SUNW_NUM 7
+#define CA_SUNW_HW_3 7 /* third hardware capabilities entry */
+#define CA_SUNW_NUM 8
/*
* Define software capabilities (CA_SUNW_SF_1 values). Note, hardware
diff --git a/usr/src/uts/common/sys/user.h b/usr/src/uts/common/sys/user.h
index e8013be325..7f54dcf3ab 100644
--- a/usr/src/uts/common/sys/user.h
+++ b/usr/src/uts/common/sys/user.h
@@ -27,6 +27,7 @@
/* All Rights Reserved */
/*
* Copyright (c) 2018, Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
@@ -111,7 +112,7 @@ typedef struct uf_entry {
short uf_busy; /* file is allocated [grow, fork] */
kcondvar_t uf_wanted_cv; /* waiting for setf() [never copied] */
kcondvar_t uf_closing_cv; /* waiting for close() [never copied] */
- struct portfd *uf_portfd; /* associated with port [grow] */
+ struct portfd *uf_portfd; /* associated with port [grow] */
uf_entry_gen_t uf_gen; /* assigned fd generation [grow,fork] */
/* Avoid false sharing - pad to coherency granularity (64 bytes) */
char uf_pad[64 - sizeof (kmutex_t) - 2 * sizeof (void*) -
@@ -204,7 +205,7 @@ typedef struct { /* kernel syscall set type */
#if defined(__sparc)
#define __KERN_NAUXV_IMPL 20
#elif defined(__i386) || defined(__amd64)
-#define __KERN_NAUXV_IMPL 25
+#define __KERN_NAUXV_IMPL 26
#endif
struct execsw;
diff --git a/usr/src/uts/intel/os/archdep.c b/usr/src/uts/intel/os/archdep.c
index b28cd6c67a..08a593bffd 100644
--- a/usr/src/uts/intel/os/archdep.c
+++ b/usr/src/uts/intel/os/archdep.c
@@ -27,6 +27,7 @@
/*
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2022 Oxide Computer Company
*/
#include <sys/param.h>
@@ -854,18 +855,20 @@ uint_t auxv_hwcap32_exclude_2 = 0; /* ditto for 32-bit apps */
*
* We use this seemingly complicated mechanism so that we can ensure
* that /etc/system can be used to override what the system can or
- * cannot discover for itself.
+ * cannot discover for itself. Due to a lack of use, this has not
+ * been extended to the 3rd word.
*/
void
bind_hwcap(void)
{
- uint_t cpu_hwcap_flags[2];
+ uint_t cpu_hwcap_flags[3];
cpuid_execpass(NULL, CPUID_PASS_RESOLVE, cpu_hwcap_flags);
auxv_hwcap = (auxv_hwcap_include | cpu_hwcap_flags[0]) &
~auxv_hwcap_exclude;
auxv_hwcap_2 = (auxv_hwcap_include_2 | cpu_hwcap_flags[1]) &
~auxv_hwcap_exclude_2;
+ auxv_hwcap_3 = cpu_hwcap_flags[2];
/*
* On AMD processors, sysenter just doesn't work at all
@@ -898,6 +901,8 @@ bind_hwcap(void)
cmn_err(CE_CONT, fmt, auxv_hwcap, FMT_AV_386);
fmt = "?user ABI extensions (word 2): %b\n";
cmn_err(CE_CONT, fmt, auxv_hwcap_2, FMT_AV_386_2);
+ fmt = "?user ABI extensions (word 2): %b\n";
+ cmn_err(CE_CONT, fmt, auxv_hwcap_3, FMT_AV_386_3);
}
#if defined(_SYSCALL32_IMPL)
@@ -905,6 +910,7 @@ bind_hwcap(void)
~auxv_hwcap32_exclude;
auxv_hwcap32_2 = (auxv_hwcap32_include_2 | cpu_hwcap_flags[1]) &
~auxv_hwcap32_exclude_2;
+ auxv_hwcap32_3 = auxv_hwcap_3;
/*
* If this is an amd64 architecture machine from Intel, then
@@ -934,6 +940,8 @@ bind_hwcap(void)
cmn_err(CE_CONT, fmt, auxv_hwcap32, FMT_AV_386);
fmt = "?32-bit user ABI extensions (word 2): %b\n";
cmn_err(CE_CONT, fmt, auxv_hwcap32_2, FMT_AV_386_2);
+ fmt = "?32-bit user ABI extensions (word 3): %b\n";
+ cmn_err(CE_CONT, fmt, auxv_hwcap32_3, FMT_AV_386_3);
}
#endif
}
diff --git a/usr/src/uts/intel/os/cpuid.c b/usr/src/uts/intel/os/cpuid.c
index 3b984867cf..5e564b7acf 100644
--- a/usr/src/uts/intel/os/cpuid.c
+++ b/usr/src/uts/intel/os/cpuid.c
@@ -1634,7 +1634,12 @@ static char *x86_feature_names[NUM_X86_FEATURES] = {
"ppin",
"vaes",
"vpclmulqdq",
- "lfence_serializing"
+ "lfence_serializing",
+ "gfni",
+ "avx512_vp2intersect",
+ "avx512_bitalg",
+ "avx512_vbmi2",
+ "avx512_bf16"
};
boolean_t
@@ -1786,6 +1791,7 @@ struct cpuid_info {
/* Intel fn: 4, AMD fn: 8000001d */
struct cpuid_regs **cpi_cache_leaves; /* Acual leaves from above */
struct cpuid_regs cpi_std[NMAX_CPI_STD]; /* 0 .. 7 */
+ struct cpuid_regs cpi_sub7[1]; /* Leaf 7, sub-leaf 1 */
/*
* extended function information
*/
@@ -1857,6 +1863,7 @@ static struct cpuid_info cpuid_info0;
#define CPI_FEATURES_7_0_EBX(cpi) ((cpi)->cpi_std[7].cp_ebx)
#define CPI_FEATURES_7_0_ECX(cpi) ((cpi)->cpi_std[7].cp_ecx)
#define CPI_FEATURES_7_0_EDX(cpi) ((cpi)->cpi_std[7].cp_edx)
+#define CPI_FEATURES_7_1_EAX(cpi) ((cpi)->cpi_sub7[0].cp_eax)
#define CPI_BRANDID(cpi) BITX((cpi)->cpi_std[1].cp_ebx, 7, 0)
#define CPI_CHUNKS(cpi) BITX((cpi)->cpi_std[1].cp_ebx, 15, 7)
@@ -3386,6 +3393,109 @@ cpuid_basic_thermal(cpu_t *cpu, uchar_t *featureset)
}
/*
+ * This is used when we discover that we have AVX support in cpuid. This
+ * proceeds to scan for the rest of the AVX derived features.
+ */
+static void
+cpuid_basic_avx(cpu_t *cpu, uchar_t *featureset)
+{
+ struct cpuid_info *cpi = cpu->cpu_m.mcpu_cpi;
+
+ /*
+ * If we don't have AVX, don't bother with most of this.
+ */
+ if ((cpi->cpi_std[1].cp_ecx & CPUID_INTC_ECX_AVX) == 0)
+ return;
+
+ add_x86_feature(featureset, X86FSET_AVX);
+
+ /*
+ * Intel says we can't check these without also
+ * checking AVX.
+ */
+ if (cpi->cpi_std[1].cp_ecx & CPUID_INTC_ECX_F16C)
+ add_x86_feature(featureset, X86FSET_F16C);
+
+ if (cpi->cpi_std[1].cp_ecx & CPUID_INTC_ECX_FMA)
+ add_x86_feature(featureset, X86FSET_FMA);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_BMI1)
+ add_x86_feature(featureset, X86FSET_BMI1);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_BMI2)
+ add_x86_feature(featureset, X86FSET_BMI2);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX2)
+ add_x86_feature(featureset, X86FSET_AVX2);
+
+ if (cpi->cpi_std[7].cp_ecx & CPUID_INTC_ECX_7_0_VAES)
+ add_x86_feature(featureset, X86FSET_VAES);
+
+ if (cpi->cpi_std[7].cp_ecx & CPUID_INTC_ECX_7_0_VPCLMULQDQ)
+ add_x86_feature(featureset, X86FSET_VPCLMULQDQ);
+
+ /*
+ * The rest of the AVX features require AVX512. Do not check them unless
+ * it is present.
+ */
+ if ((cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX512F) == 0)
+ return;
+ add_x86_feature(featureset, X86FSET_AVX512F);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX512DQ)
+ add_x86_feature(featureset, X86FSET_AVX512DQ);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX512IFMA)
+ add_x86_feature(featureset, X86FSET_AVX512FMA);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX512PF)
+ add_x86_feature(featureset, X86FSET_AVX512PF);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX512ER)
+ add_x86_feature(featureset, X86FSET_AVX512ER);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX512CD)
+ add_x86_feature(featureset, X86FSET_AVX512CD);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX512BW)
+ add_x86_feature(featureset, X86FSET_AVX512BW);
+
+ if (cpi->cpi_std[7].cp_ebx & CPUID_INTC_EBX_7_0_AVX512VL)
+ add_x86_feature(featureset, X86FSET_AVX512VL);
+
+ if (cpi->cpi_std[7].cp_ecx & CPUID_INTC_ECX_7_0_AVX512VBMI)
+ add_x86_feature(featureset, X86FSET_AVX512VBMI);
+
+ if (cpi->cpi_std[7].cp_ecx & CPUID_INTC_ECX_7_0_AVX512VBMI2)
+ add_x86_feature(featureset, X86FSET_AVX512_VBMI2);
+
+ if (cpi->cpi_std[7].cp_ecx & CPUID_INTC_ECX_7_0_AVX512VNNI)
+ add_x86_feature(featureset, X86FSET_AVX512VNNI);
+
+ if (cpi->cpi_std[7].cp_ecx & CPUID_INTC_ECX_7_0_AVX512BITALG)
+ add_x86_feature(featureset, X86FSET_AVX512_BITALG);
+
+ if (cpi->cpi_std[7].cp_ecx & CPUID_INTC_ECX_7_0_AVX512VPOPCDQ)
+ add_x86_feature(featureset, X86FSET_AVX512VPOPCDQ);
+
+ if (cpi->cpi_std[7].cp_edx & CPUID_INTC_EDX_7_0_AVX5124NNIW)
+ add_x86_feature(featureset, X86FSET_AVX512NNIW);
+
+ if (cpi->cpi_std[7].cp_edx & CPUID_INTC_EDX_7_0_AVX5124FMAPS)
+ add_x86_feature(featureset, X86FSET_AVX512FMAPS);
+
+ /*
+ * More features here are in Leaf 7, subleaf 1. Don't bother checking if
+ * we don't need to.
+ */
+ if (cpi->cpi_std[7].cp_eax < 1)
+ return;
+
+ if (cpi->cpi_sub7[0].cp_eax & CPUID_INTC_EAX_7_1_AVX512_BF16)
+ add_x86_feature(featureset, X86FSET_AVX512_BF16);
+}
+
+/*
* PPIN is the protected processor inventory number. On AMD this is an actual
* feature bit. However, on Intel systems we need to read the platform
* information MSR if we're on a specific model.
@@ -3781,7 +3891,8 @@ cpuid_pass_basic(cpu_t *cpu, void *arg)
/*
* In addition to ecx and edx, Intel and AMD are storing a bunch of
- * instruction set extensions in leaf 7's ebx, ecx, and edx.
+ * instruction set extensions in leaf 7's ebx, ecx, and edx. Note, leaf
+ * 7 has sub-leaves determined by ecx.
*/
if (cpi->cpi_maxeax >= 7) {
struct cpuid_regs *ecp;
@@ -3792,7 +3903,10 @@ cpuid_pass_basic(cpu_t *cpu, void *arg)
/*
* If XSAVE has been disabled, just ignore all of the
- * extended-save-area dependent flags here.
+ * extended-save-area dependent flags here. By removing most of
+ * the leaf 7, sub-leaf 0 flags, that will ensure tha we don't
+ * end up looking at additional xsave dependent leaves right
+ * now.
*/
if (xsave_force_disable) {
ecp->cp_ebx &= ~CPUID_INTC_EBX_7_0_BMI1;
@@ -3804,6 +3918,7 @@ cpuid_pass_basic(cpu_t *cpu, void *arg)
ecp->cp_edx &= ~CPUID_INTC_EDX_7_0_ALL_AVX512;
ecp->cp_ecx &= ~CPUID_INTC_ECX_7_0_VAES;
ecp->cp_ecx &= ~CPUID_INTC_ECX_7_0_VPCLMULQDQ;
+ ecp->cp_ecx &= ~CPUID_INTC_ECX_7_0_GFNI;
}
if (ecp->cp_ebx & CPUID_INTC_EBX_7_0_SMEP)
@@ -3840,13 +3955,27 @@ cpuid_pass_basic(cpu_t *cpu, void *arg)
add_x86_feature(featureset, X86FSET_PKU);
if (ecp->cp_ecx & CPUID_INTC_ECX_7_0_OSPKE)
add_x86_feature(featureset, X86FSET_OSPKE);
+ if (ecp->cp_ecx & CPUID_INTC_ECX_7_0_GFNI)
+ add_x86_feature(featureset, X86FSET_GFNI);
+
+ if (ecp->cp_ebx & CPUID_INTC_EBX_7_0_CLWB)
+ add_x86_feature(featureset, X86FSET_CLWB);
if (cpi->cpi_vendor == X86_VENDOR_Intel) {
if (ecp->cp_ebx & CPUID_INTC_EBX_7_0_MPX)
add_x86_feature(featureset, X86FSET_MPX);
+ }
- if (ecp->cp_ebx & CPUID_INTC_EBX_7_0_CLWB)
- add_x86_feature(featureset, X86FSET_CLWB);
+ /*
+ * If we have subleaf 1 available, grab and store that. This is
+ * used for more AVX and related features.
+ */
+ if (ecp->cp_eax >= 1) {
+ struct cpuid_regs *c71;
+ c71 = &cpi->cpi_sub7[0];
+ c71->cp_eax = 7;
+ c71->cp_ecx = 1;
+ (void) __cpuid_insn(c71);
}
}
@@ -3937,105 +4066,7 @@ cpuid_pass_basic(cpu_t *cpu, void *arg)
add_x86_feature(featureset, X86FSET_XSAVE);
/* We only test AVX & AVX512 when there is XSAVE */
-
- if (cp->cp_ecx & CPUID_INTC_ECX_AVX) {
- add_x86_feature(featureset,
- X86FSET_AVX);
-
- /*
- * Intel says we can't check these without also
- * checking AVX.
- */
- if (cp->cp_ecx & CPUID_INTC_ECX_F16C)
- add_x86_feature(featureset,
- X86FSET_F16C);
-
- if (cp->cp_ecx & CPUID_INTC_ECX_FMA)
- add_x86_feature(featureset,
- X86FSET_FMA);
-
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_BMI1)
- add_x86_feature(featureset,
- X86FSET_BMI1);
-
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_BMI2)
- add_x86_feature(featureset,
- X86FSET_BMI2);
-
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX2)
- add_x86_feature(featureset,
- X86FSET_AVX2);
-
- if (cpi->cpi_std[7].cp_ecx &
- CPUID_INTC_ECX_7_0_VAES)
- add_x86_feature(featureset,
- X86FSET_VAES);
-
- if (cpi->cpi_std[7].cp_ecx &
- CPUID_INTC_ECX_7_0_VPCLMULQDQ)
- add_x86_feature(featureset,
- X86FSET_VPCLMULQDQ);
- }
-
- if (cpi->cpi_vendor == X86_VENDOR_Intel &&
- (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX512F) != 0) {
- add_x86_feature(featureset, X86FSET_AVX512F);
-
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX512DQ)
- add_x86_feature(featureset,
- X86FSET_AVX512DQ);
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX512IFMA)
- add_x86_feature(featureset,
- X86FSET_AVX512FMA);
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX512PF)
- add_x86_feature(featureset,
- X86FSET_AVX512PF);
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX512ER)
- add_x86_feature(featureset,
- X86FSET_AVX512ER);
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX512CD)
- add_x86_feature(featureset,
- X86FSET_AVX512CD);
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX512BW)
- add_x86_feature(featureset,
- X86FSET_AVX512BW);
- if (cpi->cpi_std[7].cp_ebx &
- CPUID_INTC_EBX_7_0_AVX512VL)
- add_x86_feature(featureset,
- X86FSET_AVX512VL);
-
- if (cpi->cpi_std[7].cp_ecx &
- CPUID_INTC_ECX_7_0_AVX512VBMI)
- add_x86_feature(featureset,
- X86FSET_AVX512VBMI);
- if (cpi->cpi_std[7].cp_ecx &
- CPUID_INTC_ECX_7_0_AVX512VNNI)
- add_x86_feature(featureset,
- X86FSET_AVX512VNNI);
- if (cpi->cpi_std[7].cp_ecx &
- CPUID_INTC_ECX_7_0_AVX512VPOPCDQ)
- add_x86_feature(featureset,
- X86FSET_AVX512VPOPCDQ);
-
- if (cpi->cpi_std[7].cp_edx &
- CPUID_INTC_EDX_7_0_AVX5124NNIW)
- add_x86_feature(featureset,
- X86FSET_AVX512NNIW);
- if (cpi->cpi_std[7].cp_edx &
- CPUID_INTC_EDX_7_0_AVX5124FMAPS)
- add_x86_feature(featureset,
- X86FSET_AVX512FMAPS);
- }
+ cpuid_basic_avx(cpu, featureset);
}
}
@@ -4761,36 +4792,16 @@ cpuid_pass_extended(cpu_t *cpu, void *_arg __unused)
X86FSET_VAES);
remove_x86_feature(x86_featureset,
X86FSET_VPCLMULQDQ);
-
- CPI_FEATURES_ECX(cpi) &=
- ~CPUID_INTC_ECX_XSAVE;
- CPI_FEATURES_ECX(cpi) &=
- ~CPUID_INTC_ECX_AVX;
- CPI_FEATURES_ECX(cpi) &=
- ~CPUID_INTC_ECX_F16C;
- CPI_FEATURES_ECX(cpi) &=
- ~CPUID_INTC_ECX_FMA;
- CPI_FEATURES_7_0_EBX(cpi) &=
- ~CPUID_INTC_EBX_7_0_BMI1;
- CPI_FEATURES_7_0_EBX(cpi) &=
- ~CPUID_INTC_EBX_7_0_BMI2;
- CPI_FEATURES_7_0_EBX(cpi) &=
- ~CPUID_INTC_EBX_7_0_AVX2;
- CPI_FEATURES_7_0_EBX(cpi) &=
- ~CPUID_INTC_EBX_7_0_MPX;
- CPI_FEATURES_7_0_EBX(cpi) &=
- ~CPUID_INTC_EBX_7_0_ALL_AVX512;
-
- CPI_FEATURES_7_0_ECX(cpi) &=
- ~CPUID_INTC_ECX_7_0_ALL_AVX512;
-
- CPI_FEATURES_7_0_ECX(cpi) &=
- ~CPUID_INTC_ECX_7_0_VAES;
- CPI_FEATURES_7_0_ECX(cpi) &=
- ~CPUID_INTC_ECX_7_0_VPCLMULQDQ;
-
- CPI_FEATURES_7_0_EDX(cpi) &=
- ~CPUID_INTC_EDX_7_0_ALL_AVX512;
+ remove_x86_feature(x86_featureset,
+ X86FSET_GFNI);
+ remove_x86_feature(x86_featureset,
+ X86FSET_AVX512_VP2INT);
+ remove_x86_feature(x86_featureset,
+ X86FSET_AVX512_BITALG);
+ remove_x86_feature(x86_featureset,
+ X86FSET_AVX512_VBMI2);
+ remove_x86_feature(x86_featureset,
+ X86FSET_AVX512_BF16);
xsave_force_disable = B_TRUE;
} else {
@@ -5420,11 +5431,93 @@ cpuid_pass_dynamic(cpu_t *cpu, void *_arg __unused)
}
}
+typedef struct {
+ uint32_t avm_av;
+ uint32_t avm_feat;
+} av_feat_map_t;
+
+/*
+ * These arrays are used to map features that we should add based on x86
+ * features that are present. As a large number depend on kernel features,
+ * rather than rechecking and clearing CPUID everywhere, we simply map these.
+ * There is an array of these for each hwcap word. Some features aren't tracked
+ * in the kernel x86 featureset and that's ok. They will not show up in here.
+ */
+static const av_feat_map_t x86fset_to_av1[] = {
+ { AV_386_CX8, X86FSET_CX8 },
+ { AV_386_SEP, X86FSET_SEP },
+ { AV_386_AMD_SYSC, X86FSET_ASYSC },
+ { AV_386_CMOV, X86FSET_CMOV },
+ { AV_386_FXSR, X86FSET_SSE },
+ { AV_386_SSE, X86FSET_SSE },
+ { AV_386_SSE2, X86FSET_SSE2 },
+ { AV_386_SSE3, X86FSET_SSE3 },
+ { AV_386_CX16, X86FSET_CX16 },
+ { AV_386_TSCP, X86FSET_TSCP },
+ { AV_386_AMD_SSE4A, X86FSET_SSE4A },
+ { AV_386_SSSE3, X86FSET_SSSE3 },
+ { AV_386_SSE4_1, X86FSET_SSE4_1 },
+ { AV_386_SSE4_2, X86FSET_SSE4_2 },
+ { AV_386_AES, X86FSET_AES },
+ { AV_386_PCLMULQDQ, X86FSET_PCLMULQDQ },
+ { AV_386_XSAVE, X86FSET_XSAVE },
+ { AV_386_AVX, X86FSET_AVX },
+ { AV_386_VMX, X86FSET_VMX },
+ { AV_386_AMD_SVM, X86FSET_SVM }
+};
+
+static const av_feat_map_t x86fset_to_av2[] = {
+ { AV_386_2_F16C, X86FSET_F16C },
+ { AV_386_2_RDRAND, X86FSET_RDRAND },
+ { AV_386_2_BMI1, X86FSET_BMI1 },
+ { AV_386_2_BMI2, X86FSET_BMI2 },
+ { AV_386_2_FMA, X86FSET_FMA },
+ { AV_386_2_AVX2, X86FSET_AVX2 },
+ { AV_386_2_ADX, X86FSET_ADX },
+ { AV_386_2_RDSEED, X86FSET_RDSEED },
+ { AV_386_2_AVX512F, X86FSET_AVX512F },
+ { AV_386_2_AVX512DQ, X86FSET_AVX512DQ },
+ { AV_386_2_AVX512IFMA, X86FSET_AVX512FMA },
+ { AV_386_2_AVX512PF, X86FSET_AVX512PF },
+ { AV_386_2_AVX512ER, X86FSET_AVX512ER },
+ { AV_386_2_AVX512CD, X86FSET_AVX512CD },
+ { AV_386_2_AVX512BW, X86FSET_AVX512BW },
+ { AV_386_2_AVX512VL, X86FSET_AVX512VL },
+ { AV_386_2_AVX512VBMI, X86FSET_AVX512VBMI },
+ { AV_386_2_AVX512VPOPCDQ, X86FSET_AVX512VPOPCDQ },
+ { AV_386_2_SHA, X86FSET_SHA },
+ { AV_386_2_FSGSBASE, X86FSET_FSGSBASE },
+ { AV_386_2_CLFLUSHOPT, X86FSET_CLFLUSHOPT },
+ { AV_386_2_CLWB, X86FSET_CLWB },
+ { AV_386_2_MONITORX, X86FSET_MONITORX },
+ { AV_386_2_CLZERO, X86FSET_CLZERO },
+ { AV_386_2_AVX512_VNNI, X86FSET_AVX512VNNI },
+ { AV_386_2_VPCLMULQDQ, X86FSET_VPCLMULQDQ },
+ { AV_386_2_VAES, X86FSET_VAES },
+ { AV_386_2_GFNI, X86FSET_GFNI },
+ { AV_386_2_AVX512_VP2INT, X86FSET_AVX512_VP2INT },
+ { AV_386_2_AVX512_BITALG, X86FSET_AVX512_BITALG }
+};
+
+static const av_feat_map_t x86fset_to_av3[] = {
+ { AV_386_3_AVX512_VBMI2, X86FSET_AVX512_VBMI2 },
+ { AV_386_3_AVX512_BF16, X86FSET_AVX512_BF16 }
+};
+
/*
* This routine is called out of bind_hwcap() much later in the life
* of the kernel (post_startup()). The job of this routine is to resolve
* the hardware feature support and kernel support for those features into
* what we're actually going to tell applications via the aux vector.
+ *
+ * Most of the aux vector is derived from the x86_featureset array vector where
+ * a given feature indicates that an aux vector should be plumbed through. This
+ * allows the kernel to use one tracking mechanism for these based on whether or
+ * not it has the required hardware support (most often xsave). Most newer
+ * features are added there in case we need them in the kernel. Otherwise,
+ * features are evaluated based on looking at the cpuid features that remain. If
+ * you find yourself wanting to clear out cpuid features for some reason, they
+ * should instead be driven by the feature set so we have a consistent view.
*/
static void
@@ -5432,65 +5525,42 @@ cpuid_pass_resolve(cpu_t *cpu, void *arg)
{
uint_t *hwcap_out = (uint_t *)arg;
struct cpuid_info *cpi;
- uint_t hwcap_flags = 0, hwcap_flags_2 = 0;
+ uint_t hwcap_flags = 0, hwcap_flags_2 = 0, hwcap_flags_3 = 0;
cpi = cpu->cpu_m.mcpu_cpi;
+ for (uint_t i = 0; i < ARRAY_SIZE(x86fset_to_av1); i++) {
+ if (is_x86_feature(x86_featureset,
+ x86fset_to_av1[i].avm_feat)) {
+ hwcap_flags |= x86fset_to_av1[i].avm_av;
+ }
+ }
+
+ for (uint_t i = 0; i < ARRAY_SIZE(x86fset_to_av2); i++) {
+ if (is_x86_feature(x86_featureset,
+ x86fset_to_av2[i].avm_feat)) {
+ hwcap_flags_2 |= x86fset_to_av2[i].avm_av;
+ }
+ }
+
+ for (uint_t i = 0; i < ARRAY_SIZE(x86fset_to_av3); i++) {
+ if (is_x86_feature(x86_featureset,
+ x86fset_to_av3[i].avm_feat)) {
+ hwcap_flags_3 |= x86fset_to_av3[i].avm_av;
+ }
+ }
+
+ /*
+ * From here on out we're working through features that don't have
+ * corresponding kernel feature flags for various reasons that are
+ * mostly just due to the historical implementation.
+ */
if (cpi->cpi_maxeax >= 1) {
uint32_t *edx = &cpi->cpi_support[STD_EDX_FEATURES];
uint32_t *ecx = &cpi->cpi_support[STD_ECX_FEATURES];
- uint32_t *ebx = &cpi->cpi_support[STD_EBX_FEATURES];
*edx = CPI_FEATURES_EDX(cpi);
*ecx = CPI_FEATURES_ECX(cpi);
- *ebx = CPI_FEATURES_7_0_EBX(cpi);
-
- /*
- * [these require explicit kernel support]
- */
- if (!is_x86_feature(x86_featureset, X86FSET_SEP))
- *edx &= ~CPUID_INTC_EDX_SEP;
-
- if (!is_x86_feature(x86_featureset, X86FSET_SSE))
- *edx &= ~(CPUID_INTC_EDX_FXSR|CPUID_INTC_EDX_SSE);
- if (!is_x86_feature(x86_featureset, X86FSET_SSE2))
- *edx &= ~CPUID_INTC_EDX_SSE2;
-
- if (!is_x86_feature(x86_featureset, X86FSET_HTT))
- *edx &= ~CPUID_INTC_EDX_HTT;
-
- if (!is_x86_feature(x86_featureset, X86FSET_SSE3))
- *ecx &= ~CPUID_INTC_ECX_SSE3;
-
- if (!is_x86_feature(x86_featureset, X86FSET_SSSE3))
- *ecx &= ~CPUID_INTC_ECX_SSSE3;
- if (!is_x86_feature(x86_featureset, X86FSET_SSE4_1))
- *ecx &= ~CPUID_INTC_ECX_SSE4_1;
- if (!is_x86_feature(x86_featureset, X86FSET_SSE4_2))
- *ecx &= ~CPUID_INTC_ECX_SSE4_2;
- if (!is_x86_feature(x86_featureset, X86FSET_AES))
- *ecx &= ~CPUID_INTC_ECX_AES;
- if (!is_x86_feature(x86_featureset, X86FSET_PCLMULQDQ))
- *ecx &= ~CPUID_INTC_ECX_PCLMULQDQ;
- if (!is_x86_feature(x86_featureset, X86FSET_XSAVE))
- *ecx &= ~(CPUID_INTC_ECX_XSAVE |
- CPUID_INTC_ECX_OSXSAVE);
- if (!is_x86_feature(x86_featureset, X86FSET_AVX))
- *ecx &= ~CPUID_INTC_ECX_AVX;
- if (!is_x86_feature(x86_featureset, X86FSET_F16C))
- *ecx &= ~CPUID_INTC_ECX_F16C;
- if (!is_x86_feature(x86_featureset, X86FSET_FMA))
- *ecx &= ~CPUID_INTC_ECX_FMA;
- if (!is_x86_feature(x86_featureset, X86FSET_BMI1))
- *ebx &= ~CPUID_INTC_EBX_7_0_BMI1;
- if (!is_x86_feature(x86_featureset, X86FSET_BMI2))
- *ebx &= ~CPUID_INTC_EBX_7_0_BMI2;
- if (!is_x86_feature(x86_featureset, X86FSET_AVX2))
- *ebx &= ~CPUID_INTC_EBX_7_0_AVX2;
- if (!is_x86_feature(x86_featureset, X86FSET_RDSEED))
- *ebx &= ~CPUID_INTC_EBX_7_0_RDSEED;
- if (!is_x86_feature(x86_featureset, X86FSET_ADX))
- *ebx &= ~CPUID_INTC_EBX_7_0_ADX;
/*
* [no explicit support required beyond x87 fp context]
@@ -5502,125 +5572,26 @@ cpuid_pass_resolve(cpu_t *cpu, void *arg)
* Now map the supported feature vector to things that we
* think userland will care about.
*/
- if (*edx & CPUID_INTC_EDX_SEP)
- hwcap_flags |= AV_386_SEP;
- if (*edx & CPUID_INTC_EDX_SSE)
- hwcap_flags |= AV_386_FXSR | AV_386_SSE;
- if (*edx & CPUID_INTC_EDX_SSE2)
- hwcap_flags |= AV_386_SSE2;
- if (*ecx & CPUID_INTC_ECX_SSE3)
- hwcap_flags |= AV_386_SSE3;
- if (*ecx & CPUID_INTC_ECX_SSSE3)
- hwcap_flags |= AV_386_SSSE3;
- if (*ecx & CPUID_INTC_ECX_SSE4_1)
- hwcap_flags |= AV_386_SSE4_1;
- if (*ecx & CPUID_INTC_ECX_SSE4_2)
- hwcap_flags |= AV_386_SSE4_2;
if (*ecx & CPUID_INTC_ECX_MOVBE)
hwcap_flags |= AV_386_MOVBE;
- if (*ecx & CPUID_INTC_ECX_AES)
- hwcap_flags |= AV_386_AES;
- if (*ecx & CPUID_INTC_ECX_PCLMULQDQ)
- hwcap_flags |= AV_386_PCLMULQDQ;
- if ((*ecx & CPUID_INTC_ECX_XSAVE) &&
- (*ecx & CPUID_INTC_ECX_OSXSAVE)) {
- hwcap_flags |= AV_386_XSAVE;
-
- if (*ecx & CPUID_INTC_ECX_AVX) {
- uint32_t *ecx_7 = &CPI_FEATURES_7_0_ECX(cpi);
- uint32_t *edx_7 = &CPI_FEATURES_7_0_EDX(cpi);
-
- hwcap_flags |= AV_386_AVX;
- if (*ecx & CPUID_INTC_ECX_F16C)
- hwcap_flags_2 |= AV_386_2_F16C;
- if (*ecx & CPUID_INTC_ECX_FMA)
- hwcap_flags_2 |= AV_386_2_FMA;
-
- if (*ebx & CPUID_INTC_EBX_7_0_BMI1)
- hwcap_flags_2 |= AV_386_2_BMI1;
- if (*ebx & CPUID_INTC_EBX_7_0_BMI2)
- hwcap_flags_2 |= AV_386_2_BMI2;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX2)
- hwcap_flags_2 |= AV_386_2_AVX2;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX512F)
- hwcap_flags_2 |= AV_386_2_AVX512F;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX512DQ)
- hwcap_flags_2 |= AV_386_2_AVX512DQ;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX512IFMA)
- hwcap_flags_2 |= AV_386_2_AVX512IFMA;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX512PF)
- hwcap_flags_2 |= AV_386_2_AVX512PF;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX512ER)
- hwcap_flags_2 |= AV_386_2_AVX512ER;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX512CD)
- hwcap_flags_2 |= AV_386_2_AVX512CD;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX512BW)
- hwcap_flags_2 |= AV_386_2_AVX512BW;
- if (*ebx & CPUID_INTC_EBX_7_0_AVX512VL)
- hwcap_flags_2 |= AV_386_2_AVX512VL;
-
- if (*ecx_7 & CPUID_INTC_ECX_7_0_AVX512VBMI)
- hwcap_flags_2 |= AV_386_2_AVX512VBMI;
- if (*ecx_7 & CPUID_INTC_ECX_7_0_AVX512VNNI)
- hwcap_flags_2 |= AV_386_2_AVX512_VNNI;
- if (*ecx_7 & CPUID_INTC_ECX_7_0_AVX512VPOPCDQ)
- hwcap_flags_2 |= AV_386_2_AVX512VPOPCDQ;
- if (*ecx_7 & CPUID_INTC_ECX_7_0_VAES)
- hwcap_flags_2 |= AV_386_2_VAES;
- if (*ecx_7 & CPUID_INTC_ECX_7_0_VPCLMULQDQ)
- hwcap_flags_2 |= AV_386_2_VPCLMULQDQ;
-
- if (*edx_7 & CPUID_INTC_EDX_7_0_AVX5124NNIW)
- hwcap_flags_2 |= AV_386_2_AVX512_4NNIW;
- if (*edx_7 & CPUID_INTC_EDX_7_0_AVX5124FMAPS)
- hwcap_flags_2 |= AV_386_2_AVX512_4FMAPS;
- }
- }
- if (*ecx & CPUID_INTC_ECX_VMX)
- hwcap_flags |= AV_386_VMX;
+
if (*ecx & CPUID_INTC_ECX_POPCNT)
hwcap_flags |= AV_386_POPCNT;
if (*edx & CPUID_INTC_EDX_FPU)
hwcap_flags |= AV_386_FPU;
if (*edx & CPUID_INTC_EDX_MMX)
hwcap_flags |= AV_386_MMX;
-
if (*edx & CPUID_INTC_EDX_TSC)
hwcap_flags |= AV_386_TSC;
- if (*edx & CPUID_INTC_EDX_CX8)
- hwcap_flags |= AV_386_CX8;
- if (*edx & CPUID_INTC_EDX_CMOV)
- hwcap_flags |= AV_386_CMOV;
- if (*ecx & CPUID_INTC_ECX_CX16)
- hwcap_flags |= AV_386_CX16;
-
- if (*ecx & CPUID_INTC_ECX_RDRAND)
- hwcap_flags_2 |= AV_386_2_RDRAND;
- if (*ebx & CPUID_INTC_EBX_7_0_ADX)
- hwcap_flags_2 |= AV_386_2_ADX;
- if (*ebx & CPUID_INTC_EBX_7_0_RDSEED)
- hwcap_flags_2 |= AV_386_2_RDSEED;
- if (*ebx & CPUID_INTC_EBX_7_0_SHA)
- hwcap_flags_2 |= AV_386_2_SHA;
- if (*ebx & CPUID_INTC_EBX_7_0_FSGSBASE)
- hwcap_flags_2 |= AV_386_2_FSGSBASE;
- if (*ebx & CPUID_INTC_EBX_7_0_CLWB)
- hwcap_flags_2 |= AV_386_2_CLWB;
- if (*ebx & CPUID_INTC_EBX_7_0_CLFLUSHOPT)
- hwcap_flags_2 |= AV_386_2_CLFLUSHOPT;
-
}
+
/*
- * Check a few miscilaneous features.
+ * Check a few miscellaneous features.
*/
- if (is_x86_feature(x86_featureset, X86FSET_CLZERO))
- hwcap_flags_2 |= AV_386_2_CLZERO;
-
if (cpi->cpi_xmaxeax < 0x80000001)
goto resolve_done;
switch (cpi->cpi_vendor) {
- struct cpuid_regs cp;
uint32_t *edx, *ecx;
case X86_VENDOR_Intel:
@@ -5641,27 +5612,6 @@ cpuid_pass_resolve(cpu_t *cpu, void *arg)
*ecx = CPI_FEATURES_XTD_ECX(cpi);
/*
- * [these features require explicit kernel support]
- */
- switch (cpi->cpi_vendor) {
- case X86_VENDOR_Intel:
- if (!is_x86_feature(x86_featureset, X86FSET_TSCP))
- *edx &= ~CPUID_AMD_EDX_TSCP;
- break;
-
- case X86_VENDOR_AMD:
- case X86_VENDOR_HYGON:
- if (!is_x86_feature(x86_featureset, X86FSET_TSCP))
- *edx &= ~CPUID_AMD_EDX_TSCP;
- if (!is_x86_feature(x86_featureset, X86FSET_SSE4A))
- *ecx &= ~CPUID_AMD_ECX_SSE4A;
- break;
-
- default:
- break;
- }
-
- /*
* [no explicit support required beyond
* x87 fp context and exception handlers]
*/
@@ -5669,41 +5619,27 @@ cpuid_pass_resolve(cpu_t *cpu, void *arg)
*edx &= ~(CPUID_AMD_EDX_MMXamd |
CPUID_AMD_EDX_3DNow | CPUID_AMD_EDX_3DNowx);
- if (!is_x86_feature(x86_featureset, X86FSET_NX))
- *edx &= ~CPUID_AMD_EDX_NX;
/*
* Now map the supported feature vector to
* things that we think userland will care about.
*/
- if (*edx & CPUID_AMD_EDX_SYSC)
- hwcap_flags |= AV_386_AMD_SYSC;
if (*edx & CPUID_AMD_EDX_MMXamd)
hwcap_flags |= AV_386_AMD_MMX;
if (*edx & CPUID_AMD_EDX_3DNow)
hwcap_flags |= AV_386_AMD_3DNow;
if (*edx & CPUID_AMD_EDX_3DNowx)
hwcap_flags |= AV_386_AMD_3DNowx;
- if (*ecx & CPUID_AMD_ECX_SVM)
- hwcap_flags |= AV_386_AMD_SVM;
switch (cpi->cpi_vendor) {
case X86_VENDOR_AMD:
case X86_VENDOR_HYGON:
- if (*edx & CPUID_AMD_EDX_TSCP)
- hwcap_flags |= AV_386_TSCP;
if (*ecx & CPUID_AMD_ECX_AHF64)
hwcap_flags |= AV_386_AHF;
- if (*ecx & CPUID_AMD_ECX_SSE4A)
- hwcap_flags |= AV_386_AMD_SSE4A;
if (*ecx & CPUID_AMD_ECX_LZCNT)
hwcap_flags |= AV_386_AMD_LZCNT;
- if (*ecx & CPUID_AMD_ECX_MONITORX)
- hwcap_flags_2 |= AV_386_2_MONITORX;
break;
case X86_VENDOR_Intel:
- if (*edx & CPUID_AMD_EDX_TSCP)
- hwcap_flags |= AV_386_TSCP;
if (*ecx & CPUID_AMD_ECX_LZCNT)
hwcap_flags |= AV_386_AMD_LZCNT;
/*
@@ -5713,18 +5649,11 @@ cpuid_pass_resolve(cpu_t *cpu, void *arg)
if (*ecx & CPUID_INTC_ECX_AHF64)
hwcap_flags |= AV_386_AHF;
break;
-
default:
break;
}
break;
- case X86_VENDOR_TM:
- cp.cp_eax = 0x80860001;
- (void) __cpuid_insn(&cp);
- cpi->cpi_support[TM_EDX_FEATURES] = cp.cp_edx;
- break;
-
default:
break;
}
@@ -5733,6 +5662,7 @@ resolve_done:
if (hwcap_out != NULL) {
hwcap_out[0] = hwcap_flags;
hwcap_out[1] = hwcap_flags_2;
+ hwcap_out[2] = hwcap_flags_3;
}
}
diff --git a/usr/src/uts/intel/sys/x86_archext.h b/usr/src/uts/intel/sys/x86_archext.h
index 8202ab3fd0..d1155bc84e 100644
--- a/usr/src/uts/intel/sys/x86_archext.h
+++ b/usr/src/uts/intel/sys/x86_archext.h
@@ -282,7 +282,7 @@ extern "C" {
#define CPUID_INTC_EBX_7_0_BMI1 0x00000008 /* BMI1 instrs */
#define CPUID_INTC_EBX_7_0_HLE 0x00000010 /* HLE */
#define CPUID_INTC_EBX_7_0_AVX2 0x00000020 /* AVX2 supported */
-/* Bit 6 is reserved */
+#define CPUID_INTC_EBX_7_0_FDP_EXCPN 0x00000040 /* FDP on exception */
#define CPUID_INTC_EBX_7_0_SMEP 0x00000080 /* SMEP in CR4 */
#define CPUID_INTC_EBX_7_0_BMI2 0x00000100 /* BMI2 instrs */
#define CPUID_INTC_EBX_7_0_ENH_REP_MOV 0x00000200 /* Enhanced REP MOVSB */
@@ -322,25 +322,27 @@ extern "C" {
#define CPUID_INTC_ECX_7_0_OSPKE 0x00000010 /* OSPKE */
#define CPUID_INTC_ECX_7_0_WAITPKG 0x00000020 /* WAITPKG */
#define CPUID_INTC_ECX_7_0_AVX512VBMI2 0x00000040 /* AVX512 VBMI2 */
-/* bit 7 is reserved */
+#define CPUID_INTC_ECX_7_0_CET_SS 0x00000080 /* CET Shadow Stack */
#define CPUID_INTC_ECX_7_0_GFNI 0x00000100 /* GFNI */
#define CPUID_INTC_ECX_7_0_VAES 0x00000200 /* VAES */
#define CPUID_INTC_ECX_7_0_VPCLMULQDQ 0x00000400 /* VPCLMULQDQ */
#define CPUID_INTC_ECX_7_0_AVX512VNNI 0x00000800 /* AVX512 VNNI */
#define CPUID_INTC_ECX_7_0_AVX512BITALG 0x00001000 /* AVX512 BITALG */
-/* bit 13 is reserved */
+#define CPUID_INTC_ECX_7_0_TME_EN 0x00002000 /* Total Memory Encr. */
#define CPUID_INTC_ECX_7_0_AVX512VPOPCDQ 0x00004000 /* AVX512 VPOPCNTDQ */
-/* bits 15-16 are reserved */
+/* bit 15 is reserved */
+#define CPUID_INTC_ECX_7_0_LA57 0x00010000 /* 57-bit paging */
/* bits 17-21 are the value of MAWAU */
#define CPUID_INTC_ECX_7_0_RDPID 0x00400000 /* RPID, IA32_TSC_AUX */
-/* bits 23-24 are reserved */
+#define CPUID_INTC_ECX_7_0_KLSUP 0x00800000 /* Key Locker */
+/* bit 24 is reserved */
#define CPUID_INTC_ECX_7_0_CLDEMOTE 0x02000000 /* Cache line demote */
/* bit 26 is resrved */
#define CPUID_INTC_ECX_7_0_MOVDIRI 0x08000000 /* MOVDIRI insn */
#define CPUID_INTC_ECX_7_0_MOVDIR64B 0x10000000 /* MOVDIR64B insn */
-/* bit 29 is reserved */
+#define CPUID_INTC_ECX_7_0_ENQCMD 0x20000000 /* Enqueue Stores */
#define CPUID_INTC_ECX_7_0_SGXLC 0x40000000 /* SGX Launch config */
-/* bit 31 is reserved */
+#define CPUID_INTC_ECX_7_0_PKS 0x80000000 /* protection keys */
/*
* While CPUID_INTC_ECX_7_0_GFNI, CPUID_INTC_ECX_7_0_VAES, and
@@ -356,11 +358,24 @@ extern "C" {
#define CPUID_INTC_EDX_7_0_AVX5124NNIW 0x00000004 /* AVX512 4NNIW */
#define CPUID_INTC_EDX_7_0_AVX5124FMAPS 0x00000008 /* AVX512 4FMAPS */
#define CPUID_INTC_EDX_7_0_FSREPMOV 0x00000010 /* fast short rep mov */
-/* bits 5-9 are reserved */
+#define CPUID_INTC_EDX_7_0_UINTR 0x00000020 /* user interrupts */
+/* bits 6-7 are reserved */
+#define CPUID_INTC_EDX_7_0_AVX512VP2INT 0x00000100 /* VP2INTERSECT */
+/* bit 9 is reserved */
#define CPUID_INTC_EDX_7_0_MD_CLEAR 0x00000400 /* MB VERW */
-/* bits 11-17 are reserved */
+/* bits 11-13 are reserved */
+#define CPUID_INTC_EDX_7_0_SERIALIZE 0x00004000 /* Serialize instr */
+#define CPUID_INTC_EDX_7_0_HYBRID 0x00008000 /* Hybrid CPU */
+#define CPUID_INTC_EDX_7_0_TSXLDTRK 0x00010000 /* TSX load track */
+/* bit 17 is reserved */
#define CPUID_INTC_EDX_7_0_PCONFIG 0x00040000 /* PCONFIG */
-/* bits 19-26 are reserved */
+/* bit 19 is reserved */
+#define CPUID_INTC_EDX_7_0_CET_IBT 0x00100000 /* CET ind. branch */
+/* bit 21 is reserved */
+#define CPUID_INTC_EDX_7_0_AMX_BF16 0x00400000 /* Tile F16 */
+#define CPUID_INTC_EDX_7_0_AVX512FP16 0x00800000 /* AVX512 FP16 */
+#define CPUID_INTC_EDX_7_0_AMX_TILE 0x01000000 /* Tile arch */
+#define CPUID_INTC_EDX_7_0_AMX_INT8 0x02000000 /* Tile INT8 */
#define CPUID_INTC_EDX_7_0_SPEC_CTRL 0x04000000 /* Spec, IBPB, IBRS */
#define CPUID_INTC_EDX_7_0_STIBP 0x08000000 /* STIBP */
#define CPUID_INTC_EDX_7_0_FLUSH_CMD 0x10000000 /* IA32_FLUSH_CMD */
@@ -368,7 +383,21 @@ extern "C" {
#define CPUID_INTC_EDX_7_0_SSBD 0x80000000 /* SSBD */
#define CPUID_INTC_EDX_7_0_ALL_AVX512 \
- (CPUID_INTC_EDX_7_0_AVX5124NNIW | CPUID_INTC_EDX_7_0_AVX5124FMAPS)
+ (CPUID_INTC_EDX_7_0_AVX5124NNIW | CPUID_INTC_EDX_7_0_AVX5124FMAPS | \
+ CPUID_INTC_EDX_7_0_AVX512VP2INT | CPUID_INTC_EDX_7_0_AVX512FP16)
+
+/* bits 0-3 are reserved */
+#define CPUID_INTC_EAX_7_1_AVXVNNI 0x00000010 /* VEX VNNI */
+#define CPUID_INTC_EAX_7_1_AVX512_BF16 0x00000020 /* AVX512 BF16 */
+/* bits 6-9 are reserved */
+#define CPUID_INTC_EAX_7_1_ZL_MOVSB 0x00000400 /* zero-length MOVSB */
+#define CPUID_INTC_EAX_7_1_FS_STOSB 0x00000800 /* fast short STOSB */
+#define CPUID_INTC_EAX_7_1_FS_CMPSB 0x00001000 /* fast CMPSB, SCASB */
+/* bits 13-21 are reserved */
+#define CPUID_INTC_EAX_7_1_HRESET 0x00400000 /* History Reset leaf */
+/* bits 23-25 are reserved */
+#define CPUID_INTC_EAX_7_1_LAM 0x02000000 /* Linear addr mask */
+/* bits 27-31 are reserved */
/*
* Intel also uses cpuid leaf 0xd to report additional instructions and features
@@ -762,6 +791,11 @@ extern "C" {
#define X86FSET_VAES 100
#define X86FSET_VPCLMULQDQ 101
#define X86FSET_LFENCE_SER 102
+#define X86FSET_GFNI 103
+#define X86FSET_AVX512_VP2INT 104
+#define X86FSET_AVX512_BITALG 105
+#define X86FSET_AVX512_VBMI2 106
+#define X86FSET_AVX512_BF16 107
/*
* Intel Deep C-State invariant TSC in leaf 0x80000007.
@@ -1349,7 +1383,7 @@ typedef enum x86_uarchrev {
#if defined(_KERNEL) || defined(_KMEMUSER)
-#define NUM_X86_FEATURES 103
+#define NUM_X86_FEATURES 108
extern uchar_t x86_featureset[];
extern void free_x86_featureset(void *featureset);