diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-08-17 11:03:46 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-08-17 11:03:46 +0000 |
commit | 23187d70952e17a17d29f2e3bc82dd1ae3d715d6 (patch) | |
tree | 5f7239e8122fe4236cccb3cc39e4063f1f8b8e79 | |
parent | 2f317aec0059dbf3294f8c0e23c244f14d189976 (diff) | |
parent | 06260e34c28df0a3a191e42e1b51c9de745b3510 (diff) | |
download | illumos-joyent-23187d70952e17a17d29f2e3bc82dd1ae3d715d6.tar.gz |
[illumos-gate merge]
commit 06260e34c28df0a3a191e42e1b51c9de745b3510
12505 Answer KEBE question about cred in unexport()
commit 4e81fcfe0bcce62e29d80c1e391d9a241c0ee3b1
13027 sed loses count of relative line offset
13028 system/test/utiltest package is missing licence metadata
commit 4d3fdeb14779bb6b0838521971d9ac99d65b0572
13029 AMD bhyve should reload TSS ASAP
Conflicts:
usr/src/test/util-tests/tests/Makefile
-rw-r--r-- | usr/src/cmd/sed/Makefile | 2 | ||||
-rw-r--r-- | usr/src/cmd/sed/process.c | 36 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-test-utiltest.mf | 5 | ||||
-rw-r--r-- | usr/src/test/util-tests/runfiles/default.run | 4 | ||||
-rw-r--r-- | usr/src/test/util-tests/tests/Makefile | 5 | ||||
-rw-r--r-- | usr/src/test/util-tests/tests/awk/THIRDPARTYLICENSE.gawk.descrip | 1 | ||||
-rw-r--r-- | usr/src/test/util-tests/tests/sed/Makefile | 37 | ||||
-rw-r--r-- | usr/src/test/util-tests/tests/sed/sed_addr.ksh | 88 | ||||
-rw-r--r-- | usr/src/uts/common/fs/nfs/nfs4_srv_ns.c | 1 | ||||
-rw-r--r-- | usr/src/uts/common/fs/nfs/nfs_export.c | 27 | ||||
-rw-r--r-- | usr/src/uts/i86pc/io/vmm/amd/offsets.in | 16 | ||||
-rw-r--r-- | usr/src/uts/i86pc/io/vmm/amd/svm.c | 31 | ||||
-rw-r--r-- | usr/src/uts/i86pc/io/vmm/amd/svm_support.s | 13 |
13 files changed, 206 insertions, 60 deletions
diff --git a/usr/src/cmd/sed/Makefile b/usr/src/cmd/sed/Makefile index a2feb2ab24..4bdceea1c6 100644 --- a/usr/src/cmd/sed/Makefile +++ b/usr/src/cmd/sed/Makefile @@ -48,6 +48,4 @@ install: all $(DIRS) $(ROOTPROG) $(ROOTXPG4PROG) clean: $(RM) $(OBJS) $(POFILES) -lint: lint_SRCS - include ../Makefile.targ diff --git a/usr/src/cmd/sed/process.c b/usr/src/cmd/sed/process.c index f5c8cf0b25..275017ab1d 100644 --- a/usr/src/cmd/sed/process.c +++ b/usr/src/cmd/sed/process.c @@ -1,5 +1,6 @@ /* * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. * Copyright (c) 1992 Diomidis Spinellis. * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -34,6 +35,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <sys/ccompile.h> #include <ctype.h> #include <err.h> @@ -271,9 +273,22 @@ new: if (!nflag && !pd) * TRUE if the address passed matches the current program state * (lastline, linenumber, ps). */ -#define MATCH(a) \ - ((a)->type == AT_RE ? regexec_e((a)->u.r, ps, 0, 1, psl) : \ - (a)->type == AT_LINE ? linenum == (a)->u.l : lastline()) +static __GNU_INLINE int +MATCH(struct s_command *cp, struct s_addr *a) +{ + switch (a->type) { + case AT_RE: + return (regexec_e(a->u.r, ps, 0, 1, psl)); + case AT_LINE: + return (linenum == a->u.l); + case AT_RELLINE: + return (linenum - cp->startline == a->u.l); + case AT_LAST: + return (lastline()); + } + fatal(_("Unhandled match type")); + return (0); +} /* * Return TRUE if the command applies to the current line. Sets the start @@ -289,13 +304,11 @@ applies(struct s_command *cp) r = 1; else if (cp->a2) if (cp->startline > 0) { - if (MATCH(cp->a2)) { + if (MATCH(cp, cp->a2)) { cp->startline = 0; lastaddr = 1; r = 1; - } else if (linenum - cp->startline <= cp->a2->u.l) - r = 1; - else if ((cp->a2->type == AT_LINE && + } else if ((cp->a2->type == AT_LINE && linenum > cp->a2->u.l) || (cp->a2->type == AT_RELLINE && linenum - cp->startline > cp->a2->u.l)) { @@ -305,9 +318,10 @@ applies(struct s_command *cp) */ cp->startline = 0; r = 0; - } else + } else { r = 1; - } else if (MATCH(cp->a1)) { + } + } else if (MATCH(cp, cp->a1)) { /* * If the second address is a number less than or * equal to the line number first selected, only @@ -326,7 +340,7 @@ applies(struct s_command *cp) } else r = 0; else - r = MATCH(cp->a1); + r = MATCH(cp, cp->a1); return (cp->nonsel ? ! r : r); } @@ -642,7 +656,7 @@ lputs(char *s, size_t len) static int regexec_e(regex_t *preg, const char *string, int eflags, int nomatch, - size_t slen) + size_t slen) { int eval; diff --git a/usr/src/pkg/manifests/system-test-utiltest.mf b/usr/src/pkg/manifests/system-test-utiltest.mf index c4fb87d26e..1024e734ce 100644 --- a/usr/src/pkg/manifests/system-test-utiltest.mf +++ b/usr/src/pkg/manifests/system-test-utiltest.mf @@ -15,7 +15,7 @@ # Copyright 2014 Nexenta Systems, Inc. All rights reserved. # Copyright 2020 Joyent, Inc. # Copyright 2017 Jason King. -# Copyright 2019 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. # set name=pkg.fmri value=pkg:/system/test/utiltest@$(PKGVERS) @@ -1594,6 +1594,7 @@ file path=opt/util-tests/tests/mdb/typedef/tst.union.mdb.out mode=0444 file path=opt/util-tests/tests/mergeq/mqt mode=0555 file path=opt/util-tests/tests/mergeq/wqt mode=0555 file path=opt/util-tests/tests/printf_test mode=0555 +file path=opt/util-tests/tests/sed_addr mode=0555 file path=opt/util-tests/tests/set-linkprop mode=0555 file path=opt/util-tests/tests/show-overlay-exit mode=0555 file path=opt/util-tests/tests/sleep/sleep.awk mode=0444 @@ -1605,6 +1606,8 @@ file path=opt/util-tests/tests/xargs_test mode=0555 license lic_CDDL license=lic_CDDL license usr/src/lib/libdemangle/THIRDPARTYLICENSE \ license=usr/src/lib/libdemangle/THIRDPARTYLICENSE +license usr/src/test/util-tests/tests/awk/THIRDPARTYLICENSE.gawk \ + license=usr/src/test/util-tests/tests/awk/THIRDPARTYLICENSE.gawk license usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust \ license=usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust depend fmri=locale/de type=require diff --git a/usr/src/test/util-tests/runfiles/default.run b/usr/src/test/util-tests/runfiles/default.run index a2d463761c..36afa0c334 100644 --- a/usr/src/test/util-tests/runfiles/default.run +++ b/usr/src/test/util-tests/runfiles/default.run @@ -14,7 +14,7 @@ # Copyright 2014 Garrett D'Amore <garrett@damore.org> # Copyright 2014 Nexenta Systems, Inc. All rights reserved. # Copyright 2020 Joyent, Inc. -# Copyright 2019 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. # [DEFAULT] @@ -82,3 +82,5 @@ tests = ['custr_remove', 'custr_trunc'] [/opt/util-tests/tests/find/findtest] [/opt/util-tests/tests/mdb/mdbtest] + +[/opt/util-tests/tests/sed_addr] diff --git a/usr/src/test/util-tests/tests/Makefile b/usr/src/test/util-tests/tests/Makefile index 3362ac2941..53cd236ca2 100644 --- a/usr/src/test/util-tests/tests/Makefile +++ b/usr/src/test/util-tests/tests/Makefile @@ -15,11 +15,12 @@ # Copyright 2014 Nexenta Systems, Inc. All rights reserved. # Copyright 2017 Jason King # Copyright 2020 Joyent, Inc. -# Copyright 2019 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. # SUBDIRS = date dis dladm iconv libnvpair_json libsff printf xargs grep_xpg4 SUBDIRS += demangle mergeq workq chown ctf smbios libjedec awk make sleep -SUBDIRS += bunyan libcustr find mdb +SUBDIRS += bunyan libcustr find mdb sed +SUBDIRS += libcustr find mdb sed include $(SRC)/test/Makefile.com diff --git a/usr/src/test/util-tests/tests/awk/THIRDPARTYLICENSE.gawk.descrip b/usr/src/test/util-tests/tests/awk/THIRDPARTYLICENSE.gawk.descrip new file mode 100644 index 0000000000..7617e1c232 --- /dev/null +++ b/usr/src/test/util-tests/tests/awk/THIRDPARTYLICENSE.gawk.descrip @@ -0,0 +1 @@ +GNU awk test cases diff --git a/usr/src/test/util-tests/tests/sed/Makefile b/usr/src/test/util-tests/tests/sed/Makefile new file mode 100644 index 0000000000..5b0f006cfe --- /dev/null +++ b/usr/src/test/util-tests/tests/sed/Makefile @@ -0,0 +1,37 @@ +# +# 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 2020 OmniOS Community Edition (OmniOSce) Association. +# + +include $(SRC)/cmd/Makefile.cmd +include $(SRC)/test/Makefile.com + +PROG = sed_addr + +ROOTOPTPKG = $(ROOT)/opt/util-tests +TESTDIR = $(ROOTOPTPKG)/tests + +CMDS = $(PROG:%=$(TESTDIR)/%) +$(CMDS) := FILEMODE = 0555 + +all clean clobber: + +install: all $(CMDS) + +$(CMDS): $(TESTDIR) $(PROG).ksh + +$(TESTDIR): + $(INS.dir) + +$(TESTDIR)/%: %.ksh + $(INS.rename) diff --git a/usr/src/test/util-tests/tests/sed/sed_addr.ksh b/usr/src/test/util-tests/tests/sed/sed_addr.ksh new file mode 100644 index 0000000000..a0b8b64dee --- /dev/null +++ b/usr/src/test/util-tests/tests/sed/sed_addr.ksh @@ -0,0 +1,88 @@ +#!/bin/ksh -p +# +# 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 2020 OmniOS Community Edition (OmniOSce) Association. + +function fatal { + echo "[FATAL] $*" > /dev/stderr + exit 1 +} + +function runtest { + typeset script="$1" + typeset expect="$2" + + typeset ef=`mktemp` + [[ -n "$expect" ]] && printf "%s\n" $expect > $ef + + sed -n "$script" < $input > $output + if [[ $? -eq 0 ]] && cmp -s $output $ef; then + echo "[PASS] sed $script" + else + echo "[FAIL] sed $script" + diff -u $ef $output + err=1 + fi + rm -f $ef +} + +input=`mktemp` +output=`mktemp` +[[ -n "$input" && -f "$input" ]] || fatal "Could not create temp input" +[[ -n "$output" && -f "$output" ]] || fatal "Could not create temp output" + +typeset err=0 +printf "%s\n" a b c d e f g h a j > $input +[[ $? -eq 0 && -s "$input" ]] || fatal "Could not populate input file" + +# Simple +runtest "3p" "c" +runtest "\$p" "j" +runtest "7,\$p" "g h a j" +runtest "/d/p" "d" +runtest "/a/p" "a a" + +# Ranges +runtest "5,7p" "e f g" +runtest "5,4p" "e" +runtest "/a/,4p" "a b c d a" +runtest "0,/b/p" "" +runtest "4,/a/p" "d e f g h a" +runtest "/d/,/g/p" "d e f g" + +# Relative ranges +runtest "3,+0p" "c" +runtest "3,+1p" "c d" +runtest "5,+3p" "e f g h" +runtest "6,+3p" "f g h a" +runtest "7,+3p" "g h a j" +runtest "8,+3p" "h a j" +runtest "/a/,+1p" "a b a j" +runtest "/a/,+8p" "a b c d e f g h a" +runtest "/a/,+9p" "a b c d e f g h a j" + +# Negative +runtest "4,7!p" "a b c h a j" +runtest "6,+3!p" "a b c d e j" +runtest "7,+3!p" "a b c d e f" +runtest "8,+3!p" "a b c d e f g" + +# Branch +runtest "4,7 { /e/b + p + }" "d f g" +runtest "4,+3 { /e/b + p + }" "d f g" + +rm -f $input $output + +exit $err diff --git a/usr/src/uts/common/fs/nfs/nfs4_srv_ns.c b/usr/src/uts/common/fs/nfs/nfs4_srv_ns.c index 920ebeca53..b719b0e2ca 100644 --- a/usr/src/uts/common/fs/nfs/nfs4_srv_ns.c +++ b/usr/src/uts/common/fs/nfs/nfs4_srv_ns.c @@ -660,7 +660,6 @@ treeclimb_export(struct exportinfo *exip) if (error) break; - /* XXX KEBE ASKS DO WE NEED THIS?!? */ ASSERT3U(exip->exi_zoneid, ==, curzone->zone_id); /* * The root of the file system, or the zone's root for diff --git a/usr/src/uts/common/fs/nfs/nfs_export.c b/usr/src/uts/common/fs/nfs/nfs_export.c index 080dfe1adf..b18912d154 100644 --- a/usr/src/uts/common/fs/nfs/nfs_export.c +++ b/usr/src/uts/common/fs/nfs/nfs_export.c @@ -85,7 +85,7 @@ static bool_t exi_id_overflow; avl_tree_t exi_id_tree; kmutex_t nfs_exi_id_lock; -static int unexport(nfs_export_t *, exportinfo_t *); +static int unexport(nfs_export_t *, exportinfo_t *, cred_t *); static void exportfree(exportinfo_t *); static int loadindex(exportdata_t *); @@ -975,7 +975,15 @@ nfs_export_zone_shutdown(nfs_globals_t *ng) nfs_export_t *ne = ng->nfs_export; struct exportinfo *exi, *nexi; int i, errors; + zoneid_t zoneid = ng->nfs_zoneid; + cred_t *cr; + /* + * Use the zone's credential. Since this is a zone shutdown method, + * the zone_t should still be around for a zone_get_kcred() call. + */ + cr = zone_get_kcred(zoneid); + VERIFY(cr != NULL); rw_enter(&ne->exported_lock, RW_READER); errors = 0; @@ -986,7 +994,7 @@ nfs_export_zone_shutdown(nfs_globals_t *ng) exi_hold(exi); while (exi != NULL) { - + ASSERT3U(zoneid, ==, exi->exi_zoneid); /* * Get and hold next export before * dropping the rwlock and unexport @@ -1002,7 +1010,7 @@ nfs_export_zone_shutdown(nfs_globals_t *ng) * create/destroy handling. */ if (exi != ne->exi_root && - unexport(ne, exi) != 0) + unexport(ne, exi, cr) != 0) errors++; exi_rele(exi); @@ -1016,6 +1024,7 @@ nfs_export_zone_shutdown(nfs_globals_t *ng) } rw_exit(&ne->exported_lock); + crfree(cr); } void @@ -1286,7 +1295,7 @@ exportfs(struct exportfs_args *args, model_t model, cred_t *cr) pn_free(&lookpn); if (ex1 == NULL) return (EINVAL); - error = unexport(ne, ex1); + error = unexport(ne, ex1, cr); exi_rele(ex1); return (error); } @@ -1886,7 +1895,7 @@ export_unlink(nfs_export_t *ne, struct exportinfo *exi) * Unexport an exported filesystem */ static int -unexport(nfs_export_t *ne, struct exportinfo *exi) +unexport(nfs_export_t *ne, struct exportinfo *exi, cred_t *cr) { struct secinfo cursec[MAX_FLAVORS]; int curcnt; @@ -1954,18 +1963,14 @@ unexport(nfs_export_t *ne, struct exportinfo *exi) * the public filehandle to the root. */ - /* - * XXX KEBE ASKS --> Should CRED() instead be - * exi->exi_zone->zone_kcred? - */ if (exi == ne->exi_public) { ne->exi_public = ne->exi_root; - nfslog_share_record(ne->exi_public, CRED()); + nfslog_share_record(ne->exi_public, cr); } if (exi->exi_export.ex_flags & EX_LOG) - nfslog_unshare_record(exi, CRED()); + nfslog_unshare_record(exi, cr); exi_rele(exi); return (0); diff --git a/usr/src/uts/i86pc/io/vmm/amd/offsets.in b/usr/src/uts/i86pc/io/vmm/amd/offsets.in index 886d013607..ad4ee7155a 100644 --- a/usr/src/uts/i86pc/io/vmm/amd/offsets.in +++ b/usr/src/uts/i86pc/io/vmm/amd/offsets.in @@ -12,8 +12,10 @@ /* * Copyright 2017 Joyent, Inc. + * Copyright 2020 Oxide Computer Company */ #include <sys/types.h> +#include <sys/cpuvar.h> #include "amd/svm.h" @@ -33,5 +35,19 @@ svm_regctx sctx_r14 SCTX_R14 sctx_r15 SCTX_R15 +/* Need access to GDT to restore TSS */ +cpu + cpu_m.mcpu_gdt CPU_GDT + +user_desc USER_DESC_SZ + +system_desc + ssd_type SSD_TYPE + +\#define GDT_KTSS_OFF _MUL(USER_DESC_SZ, GDT_KTSS) + +/* Necessary for TSS-related data */ +\#include <sys/segments.h> + /* Pull in definition for MSR_GSBASE */ \#include <machine/specialreg.h> diff --git a/usr/src/uts/i86pc/io/vmm/amd/svm.c b/usr/src/uts/i86pc/io/vmm/amd/svm.c index f717962c4e..615d3cd029 100644 --- a/usr/src/uts/i86pc/io/vmm/amd/svm.c +++ b/usr/src/uts/i86pc/io/vmm/amd/svm.c @@ -1802,30 +1802,6 @@ done: } } -static __inline void -restore_host_tss(void) -{ -#ifdef __FreeBSD__ - struct system_segment_descriptor *tss_sd; - - /* - * The TSS descriptor was in use prior to launching the guest so it - * has been marked busy. - * - * 'ltr' requires the descriptor to be marked available so change the - * type to "64-bit available TSS". - */ - tss_sd = PCPU_GET(tss); - tss_sd->sd_type = SDT_SYSTSS; - ltr(GSEL(GPROC0_SEL, SEL_KPL)); -#else - system_desc_t *tss = (system_desc_t *)&CPU->cpu_gdt[GDT_KTSS]; - - tss->ssd_type = SDT_SYSTSS; - wr_tsr(KTSS_SEL); -#endif -} - #ifdef __FreeBSD__ static void check_asid(struct svm_softc *sc, int vcpuid, pmap_t pmap, u_int thiscpu) @@ -2174,13 +2150,6 @@ svm_vmrun(void *arg, int vcpu, register_t rip, pmap_t pmap, CPU_CLR_ATOMIC(curcpu, &pmap->pm_active); - /* - * The host GDTR and IDTR is saved by VMRUN and restored - * automatically on #VMEXIT. However, the host TSS needs - * to be restored explicitly. - */ - restore_host_tss(); - /* Restore host LDTR. */ lldt(ldt_sel); diff --git a/usr/src/uts/i86pc/io/vmm/amd/svm_support.s b/usr/src/uts/i86pc/io/vmm/amd/svm_support.s index 27ef1a04af..c1537b1544 100644 --- a/usr/src/uts/i86pc/io/vmm/amd/svm_support.s +++ b/usr/src/uts/i86pc/io/vmm/amd/svm_support.s @@ -28,6 +28,7 @@ /* * Copyright 2019 Joyent, Inc. + * Copyright 2020 Oxide Computer Company */ #include <sys/asm_linkage.h> @@ -142,6 +143,18 @@ ENTRY_NP(svm_launch) movl $MSR_GSBASE, %ecx wrmsr + /* + * While SVM will save/restore the GDTR and IDTR, the TR does not enjoy + * such treatment. Reload the KTSS immediately, since it is used by + * dtrace and other fault/trap handlers. + */ + movq SVMSTK_RDX(%rsp), %rdi /* %rdi = CPU */ + movq CPU_GDT(%rdi), %rdi /* %rdi = cpu->cpu_gdt */ + leaq GDT_KTSS_OFF(%rdi), %rdi /* %rdi = &cpu_gdt[GDT_KTSS] */ + andb $0xfd, SSD_TYPE(%rdi) /* ssd_type.busy = 0 */ + movw $KTSS_SEL, %ax /* reload kernel TSS */ + ltr %ax + SVM_GUEST_FLUSH_SCRATCH addq $SVMSTKSIZE, %rsp |