summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2019-10-24 14:07:14 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2019-10-24 14:07:14 +0000
commit72313197becf405ef4e91a54aa4691e4a55868d1 (patch)
treef268b3723d709ebdc46bf2136291cd04b27f7650
parent9812695da2de32f90ea47ba21e78e29437e4de8f (diff)
parenta2e92fdb91a6e5451ecb5488b74ee1e95a4bafd0 (diff)
downloadillumos-joyent-72313197becf405ef4e91a54aa4691e4a55868d1.tar.gz
[illumos-gate merge]
commit a2e92fdb91a6e5451ecb5488b74ee1e95a4bafd0 11691 ptree could show service FMRIs commit 3ef756924267e272e432add760e4dc8597faef89 11849 listen of IPv6 address fails with EAFNOSUPPORT commit 125965389c591835d37b560971900f263cc8f988 11844 add rdmsr utility Conflicts: usr/src/man/man1m/Makefile usr/src/man/man1/ptree.1 usr/src/cmd/ptools/ptree/ptree.c
-rw-r--r--manifest2
-rw-r--r--usr/src/cmd/Makefile2
-rw-r--r--usr/src/cmd/ptools/ptree/ptree.c57
-rw-r--r--usr/src/cmd/rdmsr/Makefile35
-rw-r--r--usr/src/cmd/rdmsr/rdmsr.c85
-rw-r--r--usr/src/cmd/truss/Makefile.com6
-rw-r--r--usr/src/cmd/truss/codes.c9
-rw-r--r--usr/src/man/man1/ptree.12
-rw-r--r--usr/src/man/man1m/Makefile3
-rw-r--r--usr/src/man/man1m/rdmsr.1m43
-rw-r--r--usr/src/pkg/manifests/SUNWcs.man1m.inc2
-rw-r--r--usr/src/pkg/manifests/SUNWcs.mf1
-rw-r--r--usr/src/uts/common/inet/tcp/tcp.c10
-rw-r--r--usr/src/uts/common/io/cpuid_drv.c32
-rw-r--r--usr/src/uts/common/sys/cpuid_drv.h8
15 files changed, 260 insertions, 37 deletions
diff --git a/manifest b/manifest
index 0be23336c1..66d5d46b6c 100644
--- a/manifest
+++ b/manifest
@@ -10888,6 +10888,7 @@ f usr/sbin/raidctl 0555 root bin
f usr/sbin/ramdiskadm 0555 root bin
f usr/sbin/rcapadm 0555 root bin
f usr/sbin/rctladm 0555 root bin
+f usr/sbin/rdmsr 0555 root bin
h usr/sbin/reboot=usr/sbin/halt
f usr/sbin/rem_drv 0555 root sys
s usr/sbin/repquota=../lib/fs/ufs/repquota
@@ -12536,6 +12537,7 @@ f usr/share/man/man1m/rcapadm.1m 0444 root bin
f usr/share/man/man1m/rcapd.1m 0444 root bin
f usr/share/man/man1m/rctladm.1m 0444 root bin
f usr/share/man/man1m/rdate.1m 0444 root bin
+f usr/share/man/man1m/rdmsr.1m 0444 root bin
s usr/share/man/man1m/rdisc.1m=in.rdisc.1m
f usr/share/man/man1m/reboot.1m 0444 root bin
f usr/share/man/man1m/rem_drv.1m 0444 root bin
diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile
index fdbb25c9a0..88b249abd2 100644
--- a/usr/src/cmd/Makefile
+++ b/usr/src/cmd/Makefile
@@ -490,6 +490,7 @@ i386_SUBDIRS= \
cxgbetool \
diskscan \
nvmeadm \
+ rdmsr \
rtc \
ucodeadm \
xhci \
@@ -755,6 +756,7 @@ sparc_MSGSUBDIRS= \
vntsd
i386_MSGSUBDIRS= \
+ rdmsr \
ucodeadm
#
diff --git a/usr/src/cmd/ptools/ptree/ptree.c b/usr/src/cmd/ptools/ptree/ptree.c
index 9890583260..685a5c76ae 100644
--- a/usr/src/cmd/ptools/ptree/ptree.c
+++ b/usr/src/cmd/ptools/ptree/ptree.c
@@ -87,7 +87,8 @@ static int cflag = 0;
static int sflag = 0;
static int zflag = 0;
static zoneid_t zoneid;
-static const char *svc_fmri;
+static char *match_svc;
+static char *match_inst;
static int columns = 80;
static bool match_proc(ps_t *);
@@ -97,7 +98,7 @@ static void insertchild(ps_t *, ps_t *);
static void prsort(ps_t *);
static void printsubtree(ps_t *, int);
static void p_get_svc_fmri(ps_t *, ct_stathdl_t);
-static char *stripsvc(const char *);
+static char *parse_svc(const char *, char **);
static zoneid_t getzone(const char *);
static ps_t *fakepid0(void);
@@ -136,7 +137,7 @@ main(int argc, char **argv)
break;
case 's':
sflag = 1;
- svc_fmri = stripsvc(optarg);
+ match_svc = parse_svc(optarg, &match_inst);
break;
case 'z': /* only processes in given zone */
zflag = 1;
@@ -570,15 +571,16 @@ printsubtree(ps_t *p, int level)
}
/*
- * For the service matching, we don't go the whole hog like svcs(1), but we will
- * strip svc:/ and a :default prefix, and allow a match of the final part of the
- * service such as "name-service-cache".
+ * Match against the service name (and just the final component), and any
+ * specified instance name.
*/
static bool
match_proc(ps_t *p)
{
+ bool matched = false;
const char *cp;
- char *psvc;
+ char *p_inst;
+ char *p_svc;
if (zflag && p->zoneid != zoneid)
return (false);
@@ -589,24 +591,22 @@ match_proc(ps_t *p)
if (p->svc_fmri == NULL)
return (false);
- if (strcmp(p->svc_fmri, svc_fmri) == 0)
- return (true);
-
- psvc = stripsvc(p->svc_fmri);
+ p_svc = parse_svc(p->svc_fmri, &p_inst);
- if (strcmp(psvc, svc_fmri) == 0) {
- free(psvc);
- return (true);
+ if (strcmp(p_svc, match_svc) != 0 &&
+ ((cp = strrchr(p_svc, '/')) == NULL ||
+ strcmp(cp + 1, match_svc) != 0)) {
+ goto out;
}
- if ((cp = strrchr(psvc, '/')) != NULL &&
- strcmp(cp + 1, svc_fmri) == 0) {
- free(psvc);
- return (true);
- }
+ if (strlen(match_inst) == 0 ||
+ strcmp(p_inst, match_inst) == 0)
+ matched = true;
- free(psvc);
- return (false);
+out:
+ free(p_svc);
+ free(p_inst);
+ return (matched);
}
static void
@@ -667,9 +667,9 @@ getzone(const char *arg)
return (zoneid);
}
-/* svc:/...:default -> ... */
+/* svc:/mysvc:default -> mysvc, default */
static char *
-stripsvc(const char *arg)
+parse_svc(const char *arg, char **instp)
{
const char *p = arg;
char *ret;
@@ -686,6 +686,17 @@ stripsvc(const char *arg)
if ((cp = strrchr(ret, ':')) != NULL &&
strcmp(cp, ":default") == 0)
*cp = '\0';
+ if ((cp = strrchr(ret, ':')) != NULL) {
+ *cp = '\0';
+ cp++;
+ } else {
+ cp = "";
+ }
+
+ if ((*instp = strdup(cp)) == NULL) {
+ perror("strdup()");
+ exit(1);
+ }
return (ret);
}
diff --git a/usr/src/cmd/rdmsr/Makefile b/usr/src/cmd/rdmsr/Makefile
new file mode 100644
index 0000000000..835a1349e4
--- /dev/null
+++ b/usr/src/cmd/rdmsr/Makefile
@@ -0,0 +1,35 @@
+#
+# 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 2019 Joyent, Inc.
+#
+
+PROG = rdmsr
+
+include ../Makefile.cmd
+include ../Makefile.cmd.64
+
+.KEEP_STATE:
+
+CPPFLAGS += -I../../uts/common
+
+all: $(PROG)
+
+install: all $(ROOTUSRSBINPROG)
+
+check: $(PROG).c
+ $(CSTYLE) -pP $(PROG).c
+
+clean:
+ $(RM) $(OBJS)
+
+include ../Makefile.targ
diff --git a/usr/src/cmd/rdmsr/rdmsr.c b/usr/src/cmd/rdmsr/rdmsr.c
new file mode 100644
index 0000000000..c2019553b8
--- /dev/null
+++ b/usr/src/cmd/rdmsr/rdmsr.c
@@ -0,0 +1,85 @@
+/*
+ * 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 2019 Joyent, Inc.
+ */
+
+#include <sys/cpuid_drv.h>
+
+#include <libintl.h>
+#include <string.h>
+#include <locale.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <err.h>
+
+static const char dev_cpu_self_cpuid[] = "/dev/" CPUID_SELF_NAME;
+
+int
+main(int argc, char *argv[])
+{
+ int ret = EXIT_SUCCESS;
+ int errflg = 0;
+ int fd;
+ int c;
+
+ (void) setlocale(LC_ALL, "");
+ (void) textdomain(TEXT_DOMAIN);
+
+ while ((c = getopt(argc, argv, "")) != EOF) {
+ switch (c) {
+ case '?':
+ default:
+ errflg++;
+ break;
+ }
+ }
+
+ if (errflg != 0 || optind == argc) {
+ fprintf(stderr, gettext("usage: rdmsr [0x<msrnr>...]\n"));
+ return (EXIT_FAILURE);
+ }
+
+ if ((fd = open(dev_cpu_self_cpuid, O_RDONLY)) == -1) {
+ err(EXIT_FAILURE, gettext("failed to open %s"),
+ dev_cpu_self_cpuid);
+ }
+
+ while (optind != argc) {
+ struct cpuid_rdmsr crm;
+ char *p;
+
+ errno = 0;
+ crm.cr_msr_nr = strtoull(argv[optind], &p, 0);
+
+ if (errno != 0 || p == argv[optind] || *p != '\0') {
+ fprintf(stderr,
+ gettext("rdmsr: invalid argument '%s'\n"),
+ argv[optind]);
+ exit(EXIT_FAILURE);
+ }
+
+ if (ioctl(fd, CPUID_RDMSR, &crm) != 0) {
+ warn(gettext("rdmsr of 0x%lx failed"), crm.cr_msr_nr);
+ ret = EXIT_FAILURE;
+ } else {
+ printf("0x%lx: 0x%lx\n", crm.cr_msr_nr, crm.cr_msr_val);
+ }
+
+ optind++;
+ }
+
+ return (ret);
+}
diff --git a/usr/src/cmd/truss/Makefile.com b/usr/src/cmd/truss/Makefile.com
index 4140101d8d..1d134f6528 100644
--- a/usr/src/cmd/truss/Makefile.com
+++ b/usr/src/cmd/truss/Makefile.com
@@ -23,7 +23,7 @@
# Copyright (c) 2016 by Delphix. All rights reserved.
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
#
PROG= truss
@@ -49,6 +49,7 @@ CSTD= $(CSTD_GNU99)
LDLIBS += -lproc -lrtld_db -lc_db -lnsl -lsocket -ltsol -lnvpair
CPPFLAGS += -D_REENTRANT -D_LARGEFILE64_SOURCE=1
CPPFLAGS += -I$(SRC)/uts/common/fs/zfs
+CPPFLAGS += -I$(SRC)/uts/common
LINTFLAGS += -erroff=E_STATIC_UNUSED
LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
@@ -69,7 +70,4 @@ $(PROG): $(OBJS)
clean:
$(RM) $(OBJS)
-lint:
- $(LINT.c) $(SRCS) $(LDLIBS)
-
include ../../Makefile.targ
diff --git a/usr/src/cmd/truss/codes.c b/usr/src/cmd/truss/codes.c
index 9e7d513178..de04009d59 100644
--- a/usr/src/cmd/truss/codes.c
+++ b/usr/src/cmd/truss/codes.c
@@ -23,7 +23,7 @@
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright 2019, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
* Copyright (c) 2014, OmniTI Computer Consulting, Inc. All rights reserved.
*/
@@ -103,6 +103,7 @@
#include <sys/usb/clients/hid/hid.h>
#include <sys/pm.h>
#include <sys/soundcard.h>
+#include <sys/cpuid_drv.h>
#include "ramdata.h"
#include "proto.h"
@@ -1670,6 +1671,12 @@ const struct ioc {
"pm_searchargs_t" },
#endif /* _SYSCALL */
+ /* cpuid ioctls */
+ { (uint_t)CPUID_GET_HWCAP, "CPUID_GET_HWCAP", NULL },
+#if defined(__i386) || defined(__amd64)
+ { (uint_t)CPUID_RDMSR, "CPUID_RDMSR", NULL },
+#endif
+
{ (uint_t)0, NULL, NULL }
};
diff --git a/usr/src/man/man1/ptree.1 b/usr/src/man/man1/ptree.1
index e001066d59..8777a8e235 100644
--- a/usr/src/man/man1/ptree.1
+++ b/usr/src/man/man1/ptree.1
@@ -46,7 +46,7 @@ This option implies the \fB-a\fR option.
.ad
.RS 11n
Print only processes with an SMF service FMRI matching the argument. The FMRI
-may be in truncated form (such as 'console-login'). This includes children
+may be in truncated form (such as 'console-login'). This includes child
processes even if they are not members of the service contract.
See \fBprocess\fR(4).
.RE
diff --git a/usr/src/man/man1m/Makefile b/usr/src/man/man1m/Makefile
index 42fcdf1e64..eae46cdb4c 100644
--- a/usr/src/man/man1m/Makefile
+++ b/usr/src/man/man1m/Makefile
@@ -11,7 +11,7 @@
#
# Copyright 2011, Richard Lowe
-# Copyright 2016 Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
# Copyright 2016 Toomas Soome <tsoome@me.com>
@@ -548,6 +548,7 @@ i386_MANFILES= \
acpixtract.1m \
nvmeadm.1m \
pptadm.1m
+ rdmsr.1m
sparc_MANFILES= dcs.1m \
drd.1m \
diff --git a/usr/src/man/man1m/rdmsr.1m b/usr/src/man/man1m/rdmsr.1m
new file mode 100644
index 0000000000..c483d803d2
--- /dev/null
+++ b/usr/src/man/man1m/rdmsr.1m
@@ -0,0 +1,43 @@
+.\"
+.\" 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 2019 Joyent, Inc.
+.\"
+.Dd October 14, 2019
+.Dt RDMSR 1M
+.Os
+.Sh NAME
+.Nm rdmsr
+.Nd Read Model-Specific Register
+.Sh SYNOPSIS
+.Nm
+.Ar [0x<msrnr>]...
+.Sh DESCRIPTION
+The
+.Nm
+command can be used to read a value out of one or more x86 MSRs, as defined by
+the Intel and AMD CPU specifications.
+The integer MSR number should be given (typically in 0x-prefixed hexadecimal).
+It is the command-line equivalent of the
+.Fn rdmsr
+instruction).
+.Pp
+The read is done on the current CPU, which may change arbitrarily
+between MSR reads: to read from a particular CPU,
+.Xr pbind 1M
+can be used to execute this utility.
+.Sh EXIT STATUS
+The
+.Nm
+utility exits 0 on success, or 1 if an error occurs, or at least one MSR
+could not be read.
+.Sh SEE ALSO
+Intel 64 and IA-32 Architectures Software Developer's Manual Volume 4:
+Model-Specific Registers
diff --git a/usr/src/pkg/manifests/SUNWcs.man1m.inc b/usr/src/pkg/manifests/SUNWcs.man1m.inc
index 8643a52bff..3c900d36bf 100644
--- a/usr/src/pkg/manifests/SUNWcs.man1m.inc
+++ b/usr/src/pkg/manifests/SUNWcs.man1m.inc
@@ -15,6 +15,7 @@
# Copyright 2016 Toomas Soome <tsoome@me.com>
# Copyright (c) 2017, Chris Fraire <cfraire@me.com>.
# Copyright (c) 2016 by Delphix. All rights reserved.
+# Copyright 2019 Joyent, Inc.
#
file path=usr/share/man/man1m/6to4relay.1m
@@ -204,6 +205,7 @@ file path=usr/share/man/man1m/quotaon.1m
file path=usr/share/man/man1m/raidctl.1m
file path=usr/share/man/man1m/ramdiskadm.1m
file path=usr/share/man/man1m/rctladm.1m
+$(i386_ONLY) file path=usr/share/man/man1m/rdmsr.1m variant.opensolaris.zone=global
file path=usr/share/man/man1m/reboot.1m
file path=usr/share/man/man1m/rem_drv.1m
file path=usr/share/man/man1m/repquota.1m
diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf
index c8ac10f524..1f9adb20cd 100644
--- a/usr/src/pkg/manifests/SUNWcs.mf
+++ b/usr/src/pkg/manifests/SUNWcs.mf
@@ -1332,6 +1332,7 @@ file path=usr/sbin/pwconv group=sys mode=0555
file path=usr/sbin/raidctl mode=0555
file path=usr/sbin/ramdiskadm mode=0555
file path=usr/sbin/rctladm mode=0555
+$(i386_ONLY)file path=usr/sbin/rdmsr mode=0555 variant.opensolaris.zone=global
file path=usr/sbin/rem_drv group=sys mode=0555
file path=usr/sbin/root_archive group=sys mode=0555
file path=usr/sbin/rpcbind mode=0555
diff --git a/usr/src/uts/common/inet/tcp/tcp.c b/usr/src/uts/common/inet/tcp/tcp.c
index 1f4025a50c..ef4c96db1c 100644
--- a/usr/src/uts/common/inet/tcp/tcp.c
+++ b/usr/src/uts/common/inet/tcp/tcp.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2017 Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
* Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013, 2017 by Delphix. All rights reserved.
* Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
@@ -4349,11 +4349,11 @@ tcp_do_listen(conn_t *connp, struct sockaddr *sa, socklen_t len,
}
return (-TOUTSTATE);
} else {
- if (sa == NULL) {
- sin6_t addr;
- sin_t *sin;
- sin6_t *sin6;
+ sin6_t addr;
+ sin_t *sin;
+ sin6_t *sin6;
+ if (sa == NULL) {
ASSERT(IPCL_IS_NONSTR(connp));
/* Do an implicit bind: Request for a generic port. */
if (connp->conn_family == AF_INET) {
diff --git a/usr/src/uts/common/io/cpuid_drv.c b/usr/src/uts/common/io/cpuid_drv.c
index 4f65c5ee09..35bc999b44 100644
--- a/usr/src/uts/common/io/cpuid_drv.c
+++ b/usr/src/uts/common/io/cpuid_drv.c
@@ -22,7 +22,7 @@
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2019 Joyent, Inc.
*/
@@ -39,6 +39,7 @@
#include <sys/modctl.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
+#include <sys/policy.h>
#include <sys/auxv.h>
#include <sys/cpuid_drv.h>
@@ -183,6 +184,35 @@ cpuid_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cr, int *rval)
return (0);
}
+#ifdef __x86
+ case CPUID_RDMSR: {
+ struct cpuid_rdmsr crm = { 0, };
+ label_t label;
+
+ if (secpolicy_sys_config(cr, B_FALSE) != 0)
+ return (EPERM);
+
+ if (ddi_copyin((void *)arg, &crm, sizeof (crm), mode))
+ return (EFAULT);
+
+ kpreempt_disable();
+
+ if (on_fault(&label)) {
+ kpreempt_enable();
+ return (ENOENT);
+ }
+
+ crm.cr_msr_val = rdmsr(crm.cr_msr_nr);
+
+ no_fault();
+ kpreempt_enable();
+
+ if (ddi_copyout(&crm, (void *)arg, sizeof (crm), mode))
+ return (EFAULT);
+ return (0);
+ }
+#endif
+
default:
return (ENOTTY);
}
diff --git a/usr/src/uts/common/sys/cpuid_drv.h b/usr/src/uts/common/sys/cpuid_drv.h
index 42cc9a7a32..c26bc7e422 100644
--- a/usr/src/uts/common/sys/cpuid_drv.h
+++ b/usr/src/uts/common/sys/cpuid_drv.h
@@ -24,7 +24,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2019 Joyent, Inc.
*/
#ifndef _SYS_CPUID_DRV_H
@@ -64,12 +64,18 @@ extern "C" {
#define CPUID_IOC (('c'<<24)|('i'<<16)|('d'<<8))
#define CPUID_GET_HWCAP (CPUID_IOC|0)
+#define CPUID_RDMSR (CPUID_IOC|1)
struct cpuid_get_hwcap {
char *cgh_archname;
uint_t cgh_hwcap[2];
};
+struct cpuid_rdmsr {
+ uint64_t cr_msr_nr;
+ uint64_t cr_msr_val;
+};
+
#if defined(_SYSCALL32_IMPL)
#include <sys/types32.h>