diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-06-24 11:27:37 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-06-24 11:27:37 +0000 |
commit | 2a60785665a571597ad245604f125a60b3d1277e (patch) | |
tree | 92e63dcff5cd0c5509a3e60e44c9cd31427ab2ed | |
parent | 220080cf98234dae4756754274ff9d34f5ea7668 (diff) | |
parent | 2ca761b0b92364bea5ec829f3ac6187c20057a0a (diff) | |
download | illumos-joyent-2a60785665a571597ad245604f125a60b3d1277e.tar.gz |
[illumos-gate merge]
commit 2ca761b0b92364bea5ec829f3ac6187c20057a0a
12880 sparc: pkglint errors
commit e386029b3dc09ced91c6806c9767572be25b584b
12879 sparc: unresolved dependencies
commit e156a47b6ebcf79f0515365c32a22c7ed38dc19b
12871 bhyve ioctls needn't the struct size
commit b58b977e8fdb738e19dfe72999e4f57a62e9d05f
12869 bhyve kernel/user split should be clearer
23 files changed, 610 insertions, 715 deletions
diff --git a/exception_lists/cstyle b/exception_lists/cstyle index 19d692b0fa..85538c8968 100644 --- a/exception_lists/cstyle +++ b/exception_lists/cstyle @@ -1431,6 +1431,7 @@ usr/src/lib/libvmmapi/common/vmmapi.[ch] usr/src/uts/i86pc/io/vmm/amd/*.[ch] usr/src/uts/i86pc/io/vmm/intel/*.[chs] usr/src/uts/i86pc/io/vmm/io/*.[ch] +usr/src/uts/i86pc/io/vmm/sys/vmm_kernel.h usr/src/uts/i86pc/io/vmm/vmm.c usr/src/uts/i86pc/io/vmm/vmm_host.[ch] usr/src/uts/i86pc/io/vmm/vmm_instruction_emul.c diff --git a/usr/src/cmd/bhyve/bhyverun.c b/usr/src/cmd/bhyve/bhyverun.c index 47a3e63e27..b8a993784a 100644 --- a/usr/src/cmd/bhyve/bhyverun.c +++ b/usr/src/cmd/bhyve/bhyverun.c @@ -440,7 +440,6 @@ pincpu_parse(const char *opt) CPU_SET(pcpu, vcpumap[vcpu]); return (0); } -#endif void vm_inject_fault(void *arg, int vcpu, int vector, int errcode_valid, @@ -456,6 +455,7 @@ vm_inject_fault(void *arg, int vcpu, int vector, int errcode_valid, restart_instruction); assert(error == 0); } +#endif /* __FreeBSD__ */ void * paddr_guest2host(struct vmctx *ctx, uintptr_t gaddr, size_t len) diff --git a/usr/src/compat/bhyve/amd64/machine/vmm.h b/usr/src/compat/bhyve/amd64/machine/vmm.h index 1c54c0830d..9489b49dac 100644 --- a/usr/src/compat/bhyve/amd64/machine/vmm.h +++ b/usr/src/compat/bhyve/amd64/machine/vmm.h @@ -17,8 +17,11 @@ #ifndef _COMPAT_FREEBSD_AMD64_MACHINE_VMM_H_ #define _COMPAT_FREEBSD_AMD64_MACHINE_VMM_H_ -#include <sys/_cpuset.h> - #include <sys/vmm.h> +#ifdef _KERNEL +#include <sys/_cpuset.h> +#include <sys/vmm_kernel.h> +#endif + #endif /* _COMPAT_FREEBSD_AMD64_MACHINE_VMM_H_ */ diff --git a/usr/src/lib/libvmmapi/common/mapfile-vers b/usr/src/lib/libvmmapi/common/mapfile-vers index f8fe636386..56eb5a7b95 100644 --- a/usr/src/lib/libvmmapi/common/mapfile-vers +++ b/usr/src/lib/libvmmapi/common/mapfile-vers @@ -12,6 +12,7 @@ # # Copyright 2013 Pluribus Networks Inc. # Copyright 2019 Joyent, Inc. +# Copyright 2020 Oxide Computer Company # # @@ -74,6 +75,7 @@ SYMBOL_VERSION ILLUMOSprivate { vm_gla2gpa; vm_gla2gpa_nofault; vm_inject_exception; + vm_inject_fault; vm_inject_nmi; vm_isa_assert_irq; vm_isa_deassert_irq; diff --git a/usr/src/lib/libvmmapi/common/vmmapi.c b/usr/src/lib/libvmmapi/common/vmmapi.c index b4c96d5455..9589d09ae1 100644 --- a/usr/src/lib/libvmmapi/common/vmmapi.c +++ b/usr/src/lib/libvmmapi/common/vmmapi.c @@ -70,9 +70,6 @@ __FBSDID("$FreeBSD$"); #include <machine/vmm.h> #include <machine/vmm_dev.h> -#ifndef __FreeBSD__ -#include <sys/vmm_impl.h> -#endif #include "vmmapi.h" @@ -819,6 +816,25 @@ vm_inject_exception(struct vmctx *ctx, int vcpu, int vector, int errcode_valid, return (ioctl(ctx->fd, VM_INJECT_EXCEPTION, &exc)); } +#ifndef __FreeBSD__ +void +vm_inject_fault(struct vmctx *ctx, int vcpu, int vector, int errcode_valid, + int errcode) +{ + int error; + struct vm_exception exc; + + exc.cpuid = vcpu; + exc.vector = vector; + exc.error_code = errcode; + exc.error_code_valid = errcode_valid; + exc.restart_instruction = 1; + error = ioctl(ctx->fd, VM_INJECT_EXCEPTION, &exc); + + assert(error == 0); +} +#endif /* __FreeBSD__ */ + int vm_apicid2vcpu(struct vmctx *ctx, int apicid) { diff --git a/usr/src/lib/libvmmapi/common/vmmapi.h b/usr/src/lib/libvmmapi/common/vmmapi.h index f7a8731c9a..997267b8cc 100644 --- a/usr/src/lib/libvmmapi/common/vmmapi.h +++ b/usr/src/lib/libvmmapi/common/vmmapi.h @@ -46,6 +46,7 @@ #include <sys/param.h> #include <sys/cpuset.h> +#include <x86/segments.h> #include <stdbool.h> @@ -170,6 +171,27 @@ int vm_reinit(struct vmctx *ctx); int vm_apicid2vcpu(struct vmctx *ctx, int apicid); int vm_inject_exception(struct vmctx *ctx, int vcpu, int vector, int errcode_valid, uint32_t errcode, int restart_instruction); +#ifndef __FreeBSD__ +void vm_inject_fault(struct vmctx *ctx, int vcpu, int vector, + int errcode_valid, int errcode); + +static __inline void +vm_inject_gp(struct vmctx *ctx, int vcpuid) +{ + vm_inject_fault(ctx, vcpuid, IDT_GP, 1, 0); +} + +static __inline void +vm_inject_ac(struct vmctx *ctx, int vcpuid, int errcode) +{ + vm_inject_fault(ctx, vcpuid, IDT_AC, 1, errcode); +} +static __inline void +vm_inject_ss(struct vmctx *ctx, int vcpuid, int errcode) +{ + vm_inject_fault(ctx, vcpuid, IDT_SS, 1, errcode); +} +#endif int vm_lapic_irq(struct vmctx *ctx, int vcpu, int vector); int vm_lapic_local_irq(struct vmctx *ctx, int vcpu, int vector); int vm_lapic_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg); diff --git a/usr/src/pkg/manifests/SUNWbcp.mf b/usr/src/pkg/manifests/SUNWbcp.mf index eb4edb9456..1f4864e93f 100644 --- a/usr/src/pkg/manifests/SUNWbcp.mf +++ b/usr/src/pkg/manifests/SUNWbcp.mf @@ -24,6 +24,5 @@ # set name=pkg.fmri value=pkg:/SUNWbcp@0.5.11,5.11-0.133 -set name=pkg.renamed value=true +set name=pkg.obsolete value=true set name=variant.arch value=sparc -depend fmri=pkg:/system/compatibility/sunos4@0.5.11,5.11-0.133 type=require diff --git a/usr/src/pkg/manifests/SUNWcti2.mf b/usr/src/pkg/manifests/SUNWcti2.mf index f3ecee21b9..743e4fd714 100644 --- a/usr/src/pkg/manifests/SUNWcti2.mf +++ b/usr/src/pkg/manifests/SUNWcti2.mf @@ -24,6 +24,5 @@ # set name=pkg.fmri value=pkg:/SUNWcti2@0.5.11,5.11-0.133 -set name=pkg.renamed value=true +set name=pkg.obsolete value=true set name=variant.arch value=sparc -depend fmri=pkg:/system/kernel/platform/netra@0.5.11,5.11-0.133 type=require diff --git a/usr/src/pkg/manifests/SUNWdrr.mf b/usr/src/pkg/manifests/SUNWdrr.mf index ba33e0a53e..3856f1635b 100644 --- a/usr/src/pkg/manifests/SUNWdrr.mf +++ b/usr/src/pkg/manifests/SUNWdrr.mf @@ -24,8 +24,5 @@ # set name=pkg.fmri value=pkg:/SUNWdrr@0.5.11,5.11-0.133 -set name=pkg.renamed value=true +set name=pkg.obsolete value=true set name=variant.arch value=sparc -depend \ - fmri=pkg:/system/kernel/dynamic-reconfiguration/ultra-enterprise-10000@0.5.11,5.11-0.133 \ - type=require diff --git a/usr/src/pkg/manifests/SUNWidn.mf b/usr/src/pkg/manifests/SUNWidn.mf index 0ba1239f8e..107a3597d9 100644 --- a/usr/src/pkg/manifests/SUNWidn.mf +++ b/usr/src/pkg/manifests/SUNWidn.mf @@ -24,8 +24,5 @@ # set name=pkg.fmri value=pkg:/SUNWidn@0.5.11,5.11-0.133 -set name=pkg.renamed value=true +set name=pkg.obsolete value=true set name=variant.arch value=sparc -depend \ - fmri=pkg:/system/kernel/inter-domain/ultra-enterprise-10000@0.5.11,5.11-0.133 \ - type=require diff --git a/usr/src/pkg/manifests/SUNWsckm.mf b/usr/src/pkg/manifests/SUNWsckm.mf index 5a31de91fc..1a0671814a 100644 --- a/usr/src/pkg/manifests/SUNWsckm.mf +++ b/usr/src/pkg/manifests/SUNWsckm.mf @@ -24,7 +24,5 @@ # set name=pkg.fmri value=pkg:/SUNWsckm@0.5.11,5.11-0.133 -set name=pkg.renamed value=true +set name=pkg.obsolete value=true set name=variant.arch value=sparc -depend fmri=pkg:/service/key-management/sun-fire-15000@0.5.11,5.11-0.133 \ - type=require diff --git a/usr/src/pkg/manifests/service-picl.mf b/usr/src/pkg/manifests/service-picl.mf index 3600b02c78..72268296f0 100644 --- a/usr/src/pkg/manifests/service-picl.mf +++ b/usr/src/pkg/manifests/service-picl.mf @@ -221,7 +221,8 @@ $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Blade-2500/lib/picl/plugins/piclfrutree.conf \ group=sys $(sparc_ONLY)file \ - path=usr/platform/SUNW,Sun-Fire-280R/lib/libpsvcpolicy_psr.so.1 group=sys + path=usr/platform/SUNW,Sun-Fire-280R/lib/libpsvcpolicy_psr.so.1 group=sys \ + pkg.depend.runpath=$PKGDEPEND_RUNPATH:usr/platform/SUNW,Sun-Fire-280R/lib/picl/plugins $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-280R/lib/picl/plugins/libpiclfrutree.so.1 \ group=sys @@ -230,7 +231,8 @@ $(sparc_ONLY)file \ group=sys $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-280R/lib/picl/plugins/libpsvcplugin_psr.so.1 \ - group=sys + group=sys \ + pkg.depend.runpath=$PKGDEPEND_RUNPATH:usr/platform/SUNW,Sun-Fire-280R/lib/picl/plugins $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-280R/lib/picl/plugins/picldevtree.conf \ group=sys mode=0444 @@ -242,13 +244,15 @@ $(sparc_ONLY)file path=usr/platform/SUNW,Sun-Fire-280R/lib/platsvcd.conf \ $(sparc_ONLY)file path=usr/platform/SUNW,Sun-Fire-280R/lib/psvcobj.conf \ group=sys mode=0444 $(sparc_ONLY)file \ - path=usr/platform/SUNW,Sun-Fire-480R/lib/libpsvcpolicy_psr.so.1 group=sys + path=usr/platform/SUNW,Sun-Fire-480R/lib/libpsvcpolicy_psr.so.1 group=sys \ + pkg.depend.runpath=$PKGDEPEND_RUNPATH:usr/platform/SUNW,Sun-Fire-480R/lib/picl/plugins:usr/platform/sun4u/lib $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-480R/lib/picl/plugins/libpiclfrutree.so.1 \ group=sys $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-480R/lib/picl/plugins/libpsvcplugin_psr.so.1 \ - group=sys + group=sys \ + pkg.depend.runpath=$PKGDEPEND_RUNPATH:usr/platform/SUNW,Sun-Fire-480R/lib/picl/plugins $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-480R/lib/picl/plugins/picldevtree.conf \ group=sys mode=0444 @@ -260,13 +264,15 @@ $(sparc_ONLY)file path=usr/platform/SUNW,Sun-Fire-480R/lib/platsvcd.conf \ $(sparc_ONLY)file path=usr/platform/SUNW,Sun-Fire-480R/lib/psvcobj.conf \ group=sys mode=0444 $(sparc_ONLY)file \ - path=usr/platform/SUNW,Sun-Fire-880/lib/libpsvcpolicy_psr.so.1 group=sys + path=usr/platform/SUNW,Sun-Fire-880/lib/libpsvcpolicy_psr.so.1 group=sys \ + pkg.depend.runpath=$PKGDEPEND_RUNPATH:usr/platform/SUNW,Sun-Fire-880/lib/picl/plugins:usr/platform/sun4u/lib $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-880/lib/picl/plugins/libpiclfrutree.so.1 \ group=sys $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-880/lib/picl/plugins/libpsvcplugin_psr.so.1 \ - group=sys + group=sys \ + pkg.depend.runpath=$PKGDEPEND_RUNPATH:usr/platform/SUNW,Sun-Fire-880/lib/picl/plugins $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Fire-880/lib/picl/plugins/picldevtree.conf \ group=sys mode=0444 @@ -592,7 +598,8 @@ $(sparc_ONLY)file path=usr/platform/SUNW,Sun-Fire-V890/lib/platsvcd.conf \ $(sparc_ONLY)file path=usr/platform/SUNW,Sun-Fire-V890/lib/psvcobj.conf \ group=sys mode=0444 $(sparc_ONLY)file path=usr/platform/sun4u/lib/libpsvcobj.so.1 group=sys -$(sparc_ONLY)file path=usr/platform/sun4u/lib/libpsvcpolicy.so.1 group=sys +$(sparc_ONLY)file path=usr/platform/sun4u/lib/libpsvcpolicy.so.1 group=sys \ + pkg.depend.runpath=$PKGDEPEND_RUNPATH:usr/platform/SUNW,Sun-Fire-V490/lib/picl/plugins:usr/platform/SUNW,Sun-Fire-280R/lib/picl/plugins:usr/platform/SUNW,Sun-Fire-V890/lib/picl/plugins:usr/platform/SUNW,Sun-Fire-880/lib/picl/plugins:usr/platform/SUNW,Sun-Fire-480R/lib/picl/plugins $(sparc_ONLY)file path=usr/platform/sun4u/lib/picl/plugins/libpiclenvmon.so.1 \ group=sys $(sparc_ONLY)file path=usr/platform/sun4v/lib/libpiclsnmp.so.1 group=sys @@ -601,7 +608,7 @@ $(sparc_ONLY)file path=usr/platform/sun4v/lib/picl/plugins/libmdescplugin.so.1 \ $(sparc_ONLY)file path=usr/platform/sun4v/lib/picl/plugins/libpiclsbl.so.1 \ group=sys $(sparc_ONLY)file path=usr/platform/sun4v/lib/picl/plugins/libpriplugin.so.1 \ - group=sys + group=sys variant.opensolaris.zone=global $(sparc_ONLY)file path=usr/platform/sun4v/lib/picl/plugins/libsnmpplugin.so.1 \ group=sys file path=usr/sbin/prtpicl mode=0755 diff --git a/usr/src/pkg/manifests/system-boot-loader.mf b/usr/src/pkg/manifests/system-boot-loader.mf index 16e886195a..97fdeac2d3 100644 --- a/usr/src/pkg/manifests/system-boot-loader.mf +++ b/usr/src/pkg/manifests/system-boot-loader.mf @@ -32,8 +32,8 @@ <include global_zone_only_component> set name=pkg.fmri \ value=pkg:/system/boot/loader@1.1,$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH) -$(i386_ONLY)set name=pkg.description value="Boot Loader" -$(i386_ONLY)set name=pkg.summary value="BootForth Boot Loader" +set name=pkg.description value="Boot Loader" +set name=pkg.summary value="BootForth Boot Loader" set name=info.classification value=org.opensolaris.category.2008:System/Core set name=variant.arch value=$(ARCH) $(i386_ONLY)dir path=boot group=sys diff --git a/usr/src/pkg/manifests/system-kernel-platform.mf b/usr/src/pkg/manifests/system-kernel-platform.mf index 29538ccd9b..5cec8a4125 100644 --- a/usr/src/pkg/manifests/system-kernel-platform.mf +++ b/usr/src/pkg/manifests/system-kernel-platform.mf @@ -528,7 +528,8 @@ $(sparc_ONLY)file path=platform/SUNW,Netra-T4/kernel/drv/$(ARCH64)/lombus \ group=sys $(sparc_ONLY)file path=platform/SUNW,Netra-T4/kernel/drv/lombus.conf group=sys $(sparc_ONLY)file path=platform/SUNW,SPARC-Enterprise/kernel/$(ARCH64)/unix \ - group=sys mode=0755 + group=sys mode=0755 pkg.depend.bypass-generate=\$CPU \ + pkg.depend.bypass-generate=dtracestubs pkg.depend.bypass-generate=genunix $(sparc_ONLY)file \ path=platform/SUNW,SPARC-Enterprise/kernel/cpu/$(ARCH64)/FJSV,SPARC64-VI \ group=sys mode=0755 @@ -537,7 +538,8 @@ $(sparc_ONLY)file path=platform/SUNW,SPARC-Enterprise/kernel/drv/$(ARCH64)/dr \ $(sparc_ONLY)file \ path=platform/SUNW,SPARC-Enterprise/kernel/drv/$(ARCH64)/mc-opl group=sys $(sparc_ONLY)file \ - path=platform/SUNW,SPARC-Enterprise/kernel/drv/$(ARCH64)/oplmsu group=sys + path=platform/SUNW,SPARC-Enterprise/kernel/drv/$(ARCH64)/oplmsu group=sys \ + pkg.depend.bypass-generate=su $(sparc_ONLY)file \ path=platform/SUNW,SPARC-Enterprise/kernel/drv/$(ARCH64)/oplpanel \ group=sys @@ -557,7 +559,7 @@ $(sparc_ONLY)file path=platform/SUNW,SPARC-Enterprise/kernel/drv/scfd.conf \ group=sys $(sparc_ONLY)file \ path=platform/SUNW,SPARC-Enterprise/kernel/misc/$(ARCH64)/drmach \ - group=sys mode=0755 + group=sys mode=0755 pkg.depend.bypass-generate=opl_cfg $(sparc_ONLY)file \ path=platform/SUNW,SPARC-Enterprise/kernel/misc/$(ARCH64)/platmod \ group=sys mode=0755 @@ -571,7 +573,8 @@ $(sparc_ONLY)file \ path=platform/SUNW,Sun-Blade-100/kernel/misc/$(ARCH64)/platmod group=sys \ mode=0755 $(sparc_ONLY)file \ - path=platform/SUNW,Sun-Blade-1000/kernel/drv/$(ARCH64)/xcalppm group=sys + path=platform/SUNW,Sun-Blade-1000/kernel/drv/$(ARCH64)/xcalppm group=sys \ + pkg.depend.bypass-generate=schppm $(sparc_ONLY)file \ path=platform/SUNW,Sun-Blade-1000/kernel/drv/$(ARCH64)/xcalwd group=sys $(sparc_ONLY)file path=platform/SUNW,Sun-Blade-1000/kernel/drv/xcalppm.conf \ @@ -592,7 +595,8 @@ $(sparc_ONLY)file \ path=platform/SUNW,Sun-Blade-2500/kernel/misc/$(ARCH64)/platmod group=sys \ mode=0755 $(sparc_ONLY)file \ - path=platform/SUNW,Sun-Fire-280R/kernel/drv/$(ARCH64)/pcf8574 group=sys + path=platform/SUNW,Sun-Fire-280R/kernel/drv/$(ARCH64)/pcf8574 group=sys \ + pkg.depend.bypass-generate=i2c_svc $(sparc_ONLY)file \ path=platform/SUNW,Sun-Fire-280R/kernel/misc/$(ARCH64)/platmod group=sys \ mode=0755 @@ -600,14 +604,15 @@ $(sparc_ONLY)file \ path=platform/SUNW,Sun-Fire-480R/kernel/misc/$(ARCH64)/platmod group=sys \ mode=0755 $(sparc_ONLY)file path=platform/SUNW,Sun-Fire-880/kernel/drv/$(ARCH64)/hpc3130 \ - group=sys + group=sys pkg.depend.bypass-generate=i2c_svc $(sparc_ONLY)file path=platform/SUNW,Sun-Fire-880/kernel/drv/hpc3130.conf \ group=sys $(sparc_ONLY)file \ path=platform/SUNW,Sun-Fire-880/kernel/misc/$(ARCH64)/platmod group=sys \ mode=0755 $(sparc_ONLY)file \ - path=platform/SUNW,Sun-Fire-T200/kernel/drv/$(ARCH64)/tsalarm group=sys + path=platform/SUNW,Sun-Fire-T200/kernel/drv/$(ARCH64)/tsalarm group=sys \ + pkg.depend.bypass-generate=rmclomv $(sparc_ONLY)file path=platform/SUNW,Sun-Fire-T200/kernel/drv/tsalarm.conf \ group=sys $(sparc_ONLY)file path=platform/SUNW,Sun-Fire-V215/kernel/drv/su.conf \ @@ -616,9 +621,11 @@ $(sparc_ONLY)file \ path=platform/SUNW,Sun-Fire-V215/kernel/misc/$(ARCH64)/platmod group=sys \ mode=0755 $(sparc_ONLY)file path=platform/SUNW,Sun-Fire-V240/kernel/drv/$(ARCH64)/ntwdt \ - group=sys + group=sys pkg.depend.bypass-generate=pmugpio \ + pkg.depend.bypass-generate=rmc_comm pkg.depend.bypass-generate=rmclomv $(sparc_ONLY)file \ - path=platform/SUNW,Sun-Fire-V240/kernel/drv/$(ARCH64)/tsalarm group=sys + path=platform/SUNW,Sun-Fire-V240/kernel/drv/$(ARCH64)/tsalarm group=sys \ + pkg.depend.bypass-generate=rmclomv $(sparc_ONLY)file path=platform/SUNW,Sun-Fire-V240/kernel/drv/ntwdt.conf \ group=sys $(sparc_ONLY)file path=platform/SUNW,Sun-Fire-V240/kernel/drv/tsalarm.conf \ @@ -636,7 +643,8 @@ $(sparc_ONLY)file \ path=platform/SUNW,Sun-Fire-V445/kernel/misc/$(ARCH64)/platmod group=sys \ mode=0755 $(sparc_ONLY)file path=platform/SUNW,Sun-Fire/kernel/$(ARCH64)/unix group=sys \ - mode=0755 + mode=0755 pkg.depend.bypass-generate=\$CPU \ + pkg.depend.bypass-generate=dtracestubs pkg.depend.bypass-generate=genunix $(sparc_ONLY)file \ path=platform/SUNW,Sun-Fire/kernel/cpu/$(ARCH64)/SUNW,UltraSPARC-III \ group=sys mode=0755 @@ -657,11 +665,11 @@ $(sparc_ONLY)file path=platform/SUNW,Sun-Fire/kernel/misc/$(ARCH64)/platmod \ $(sparc_ONLY)file path=platform/SUNW,Sun-Fire/kernel/misc/$(ARCH64)/sbdp \ group=sys mode=0755 $(sparc_ONLY)file path=platform/SUNW,Ultra-250/kernel/drv/$(ARCH64)/envctrltwo \ - group=sys + group=sys pkg.depend.bypass-generate=pcipsy $(sparc_ONLY)file path=platform/SUNW,Ultra-250/kernel/misc/$(ARCH64)/platmod \ group=sys mode=0755 $(sparc_ONLY)file path=platform/SUNW,Ultra-4/kernel/drv/$(ARCH64)/envctrl \ - group=sys + group=sys pkg.depend.bypass-generate=pcipsy $(sparc_ONLY)file path=platform/SUNW,Ultra-4/kernel/misc/$(ARCH64)/platmod \ group=sys mode=0755 $(sparc_ONLY)file path=platform/SUNW,Ultra-5_10/kernel/misc/$(ARCH64)/platmod \ @@ -784,7 +792,8 @@ $(sparc_ONLY)file path=platform/sun4u/bootlst group=sys reboot-needed=true $(sparc_ONLY)file path=platform/sun4u/kernel/$(ARCH64)/genunix group=sys \ mode=0755 $(sparc_ONLY)file path=platform/sun4u/kernel/$(ARCH64)/unix group=sys \ - mode=0755 + mode=0755 pkg.depend.bypass-generate=\$CPU \ + pkg.depend.bypass-generate=dtracestubs $(sparc_ONLY)file path=platform/sun4u/kernel/cpu/$(ARCH64)/SUNW,UltraSPARC-II \ group=sys mode=0755 $(sparc_ONLY)file path=platform/sun4u/kernel/cpu/$(ARCH64)/SUNW,UltraSPARC-III \ @@ -889,7 +898,7 @@ $(sparc_ONLY)file path=platform/sun4u/kernel/misc/$(ARCH64)/pcie group=sys \ $(sparc_ONLY)file path=platform/sun4u/kernel/misc/$(ARCH64)/platmod group=sys \ mode=0755 $(sparc_ONLY)file path=platform/sun4u/kernel/misc/$(ARCH64)/sbd group=sys \ - mode=0755 + mode=0755 pkg.depend.bypass-generate=sbdp $(sparc_ONLY)file path=platform/sun4u/kernel/misc/$(ARCH64)/vis group=sys \ mode=0755 $(sparc_ONLY)file path=platform/sun4u/kernel/tod/$(ARCH64)/todbq4802 group=sys \ @@ -909,12 +918,13 @@ $(sparc_ONLY)file path=platform/sun4u/kernel/tod/$(ARCH64)/todmostek group=sys \ $(sparc_ONLY)file path=platform/sun4u/kernel/tod/$(ARCH64)/todopl group=sys \ mode=0755 $(sparc_ONLY)file path=platform/sun4u/kernel/tod/$(ARCH64)/todsg group=sys \ - mode=0755 + mode=0755 pkg.depend.bypass-generate=sgsbbc $(sparc_ONLY)file path=platform/sun4v/bootlst group=sys reboot-needed=true $(sparc_ONLY)file path=platform/sun4v/kernel/$(ARCH64)/genunix group=sys \ mode=0755 $(sparc_ONLY)file path=platform/sun4v/kernel/$(ARCH64)/unix group=sys \ - mode=0755 + mode=0755 pkg.depend.bypass-generate=\$CPU \ + pkg.depend.bypass-generate=dtracestubs $(sparc_ONLY)file path=platform/sun4v/kernel/cpu/$(ARCH64)/generic group=sys \ mode=0755 $(sparc_ONLY)file path=platform/sun4v/kernel/crypto/$(ARCH64)/arcfour \ diff --git a/usr/src/pkg/manifests/system-storage-luxadm.mf b/usr/src/pkg/manifests/system-storage-luxadm.mf index 3e7c81439f..bfd2e18ca9 100644 --- a/usr/src/pkg/manifests/system-storage-luxadm.mf +++ b/usr/src/pkg/manifests/system-storage-luxadm.mf @@ -40,7 +40,7 @@ dir path=usr/sbin dir path=usr/share/man/man1m $(sparc_ONLY)file path=usr/lib/locale/C/LC_MESSAGES/a5k_g_fc_i18n_cat $(sparc_ONLY)file path=usr/lib/locale/C/LC_MESSAGES/ibfirmware -file path=usr/sbin/luxadm mode=0555 +file path=usr/sbin/luxadm mode=0555 variant.opensolaris.zone=global file path=usr/share/man/man1m/luxadm.1m legacy pkg=SUNWluxop \ desc="Sun Enterprise Network Array firmware and utilities" \ diff --git a/usr/src/uts/i86pc/sys/vmm_impl.h b/usr/src/uts/i86pc/io/vmm/sys/vmm_impl.h index 0e8726190d..0e8726190d 100644 --- a/usr/src/uts/i86pc/sys/vmm_impl.h +++ b/usr/src/uts/i86pc/io/vmm/sys/vmm_impl.h diff --git a/usr/src/uts/i86pc/io/vmm/sys/vmm_kernel.h b/usr/src/uts/i86pc/io/vmm/sys/vmm_kernel.h new file mode 100644 index 0000000000..2a884e6e0e --- /dev/null +++ b/usr/src/uts/i86pc/io/vmm/sys/vmm_kernel.h @@ -0,0 +1,395 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2011 NetApp, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ +/* + * 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 2015 Pluribus Networks Inc. + * Copyright 2019 Joyent, Inc. + * Copyright 2020 Oxide Computer Company + */ + +#ifndef _VMM_KERNEL_H_ +#define _VMM_KERNEL_H_ + +#include <sys/sdt.h> +#include <x86/segments.h> + +SDT_PROVIDER_DECLARE(vmm); + +struct vm; +struct vm_exception; +struct seg_desc; +struct vm_exit; +struct vm_run; +struct vhpet; +struct vioapic; +struct vlapic; +struct vmspace; +struct vm_object; +struct vm_guest_paging; +struct pmap; + +struct vm_eventinfo { + u_int *rptr; /* runblock cookie */ + int *sptr; /* suspend cookie */ + int *iptr; /* reqidle cookie */ +}; + +typedef int (*vmm_init_func_t)(int ipinum); +typedef int (*vmm_cleanup_func_t)(void); +typedef void (*vmm_resume_func_t)(void); +typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap); +typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip, + struct pmap *pmap, struct vm_eventinfo *info); +typedef void (*vmi_cleanup_func_t)(void *vmi); +typedef int (*vmi_get_register_t)(void *vmi, int vcpu, int num, + uint64_t *retval); +typedef int (*vmi_set_register_t)(void *vmi, int vcpu, int num, + uint64_t val); +typedef int (*vmi_get_desc_t)(void *vmi, int vcpu, int num, + struct seg_desc *desc); +typedef int (*vmi_set_desc_t)(void *vmi, int vcpu, int num, + struct seg_desc *desc); +typedef int (*vmi_get_cap_t)(void *vmi, int vcpu, int num, int *retval); +typedef int (*vmi_set_cap_t)(void *vmi, int vcpu, int num, int val); +typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max); +typedef void (*vmi_vmspace_free)(struct vmspace *vmspace); +typedef struct vlapic * (*vmi_vlapic_init)(void *vmi, int vcpu); +typedef void (*vmi_vlapic_cleanup)(void *vmi, struct vlapic *vlapic); +#ifndef __FreeBSD__ +typedef void (*vmi_savectx)(void *vmi, int vcpu); +typedef void (*vmi_restorectx)(void *vmi, int vcpu); +#endif + +struct vmm_ops { + vmm_init_func_t init; /* module wide initialization */ + vmm_cleanup_func_t cleanup; + vmm_resume_func_t resume; + + vmi_init_func_t vminit; /* vm-specific initialization */ + vmi_run_func_t vmrun; + vmi_cleanup_func_t vmcleanup; + vmi_get_register_t vmgetreg; + vmi_set_register_t vmsetreg; + vmi_get_desc_t vmgetdesc; + vmi_set_desc_t vmsetdesc; + vmi_get_cap_t vmgetcap; + vmi_set_cap_t vmsetcap; + vmi_vmspace_alloc vmspace_alloc; + vmi_vmspace_free vmspace_free; + vmi_vlapic_init vlapic_init; + vmi_vlapic_cleanup vlapic_cleanup; + +#ifndef __FreeBSD__ + vmi_savectx vmsavectx; + vmi_restorectx vmrestorectx; +#endif +}; + +extern struct vmm_ops vmm_ops_intel; +extern struct vmm_ops vmm_ops_amd; + +int vm_create(const char *name, struct vm **retvm); +void vm_destroy(struct vm *vm); +int vm_reinit(struct vm *vm); +const char *vm_name(struct vm *vm); +uint16_t vm_get_maxcpus(struct vm *vm); +void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores, + uint16_t *threads, uint16_t *maxcpus); +int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores, + uint16_t threads, uint16_t maxcpus); + +/* + * APIs that modify the guest memory map require all vcpus to be frozen. + */ +int vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t off, + size_t len, int prot, int flags); +int vm_alloc_memseg(struct vm *vm, int ident, size_t len, bool sysmem); +void vm_free_memseg(struct vm *vm, int ident); +int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa); +int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len); +#ifdef __FreeBSD__ +int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func); +int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func); +#else +int vm_assign_pptdev(struct vm *vm, int pptfd); +int vm_unassign_pptdev(struct vm *vm, int pptfd); +#endif /* __FreeBSD__ */ + +/* + * APIs that inspect the guest memory map require only a *single* vcpu to + * be frozen. This acts like a read lock on the guest memory map since any + * modification requires *all* vcpus to be frozen. + */ +int vm_mmap_getnext(struct vm *vm, vm_paddr_t *gpa, int *segid, + vm_ooffset_t *segoff, size_t *len, int *prot, int *flags); +int vm_get_memseg(struct vm *vm, int ident, size_t *len, bool *sysmem, + struct vm_object **objptr); +vm_paddr_t vmm_sysmem_maxaddr(struct vm *vm); +void *vm_gpa_hold(struct vm *, int vcpuid, vm_paddr_t gpa, size_t len, + int prot, void **cookie); +void vm_gpa_release(void *cookie); +bool vm_mem_allocated(struct vm *vm, int vcpuid, vm_paddr_t gpa); + +int vm_get_register(struct vm *vm, int vcpu, int reg, uint64_t *retval); +int vm_set_register(struct vm *vm, int vcpu, int reg, uint64_t val); +int vm_get_seg_desc(struct vm *vm, int vcpu, int reg, + struct seg_desc *ret_desc); +int vm_set_seg_desc(struct vm *vm, int vcpu, int reg, + struct seg_desc *desc); +int vm_run(struct vm *vm, struct vm_run *vmrun); +int vm_suspend(struct vm *vm, enum vm_suspend_how how); +int vm_inject_nmi(struct vm *vm, int vcpu); +int vm_nmi_pending(struct vm *vm, int vcpuid); +void vm_nmi_clear(struct vm *vm, int vcpuid); +int vm_inject_extint(struct vm *vm, int vcpu); +int vm_extint_pending(struct vm *vm, int vcpuid); +void vm_extint_clear(struct vm *vm, int vcpuid); +struct vlapic *vm_lapic(struct vm *vm, int cpu); +struct vioapic *vm_ioapic(struct vm *vm); +struct vhpet *vm_hpet(struct vm *vm); +int vm_get_capability(struct vm *vm, int vcpu, int type, int *val); +int vm_set_capability(struct vm *vm, int vcpu, int type, int val); +int vm_get_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state *state); +int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state); +int vm_apicid2vcpuid(struct vm *vm, int apicid); +int vm_activate_cpu(struct vm *vm, int vcpu); +int vm_suspend_cpu(struct vm *vm, int vcpu); +int vm_resume_cpu(struct vm *vm, int vcpu); +struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid); +void vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t rip); +void vm_exit_debug(struct vm *vm, int vcpuid, uint64_t rip); +void vm_exit_runblock(struct vm *vm, int vcpuid, uint64_t rip); +void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip); +void vm_exit_reqidle(struct vm *vm, int vcpuid, uint64_t rip); + +#ifdef _SYS__CPUSET_H_ +cpuset_t vm_active_cpus(struct vm *vm); +cpuset_t vm_debug_cpus(struct vm *vm); +cpuset_t vm_suspended_cpus(struct vm *vm); +#endif /* _SYS__CPUSET_H_ */ + +static __inline int +vcpu_runblocked(struct vm_eventinfo *info) +{ + + return (*info->rptr != 0); +} + +static __inline int +vcpu_suspended(struct vm_eventinfo *info) +{ + + return (*info->sptr); +} + +static __inline int +vcpu_reqidle(struct vm_eventinfo *info) +{ + + return (*info->iptr); +} + +int vcpu_debugged(struct vm *vm, int vcpuid); + +/* + * Return true if device indicated by bus/slot/func is supposed to be a + * pci passthrough device. + * + * Return false otherwise. + */ +bool vmm_is_pptdev(int bus, int slot, int func); + +void *vm_iommu_domain(struct vm *vm); + +enum vcpu_state { + VCPU_IDLE, + VCPU_FROZEN, + VCPU_RUNNING, + VCPU_SLEEPING, +}; + +int vcpu_set_state(struct vm *vm, int vcpu, enum vcpu_state state, + bool from_idle); +enum vcpu_state vcpu_get_state(struct vm *vm, int vcpu, int *hostcpu); +void vcpu_block_run(struct vm *, int); +void vcpu_unblock_run(struct vm *, int); + +#ifndef __FreeBSD__ +uint64_t vcpu_tsc_offset(struct vm *vm, int vcpuid); +#endif + +static __inline int +vcpu_is_running(struct vm *vm, int vcpu, int *hostcpu) +{ + return (vcpu_get_state(vm, vcpu, hostcpu) == VCPU_RUNNING); +} + +#ifdef _SYS_THREAD_H +static __inline int +vcpu_should_yield(struct vm *vm, int vcpu) +{ + + if (curthread->t_astflag) + return (1); + else if (CPU->cpu_runrun) + return (1); + else + return (0); +} +#endif /* _SYS_THREAD_H */ + +void *vcpu_stats(struct vm *vm, int vcpu); +void vcpu_notify_event(struct vm *vm, int vcpuid, bool lapic_intr); +struct vmspace *vm_get_vmspace(struct vm *vm); +struct vatpic *vm_atpic(struct vm *vm); +struct vatpit *vm_atpit(struct vm *vm); +struct vpmtmr *vm_pmtmr(struct vm *vm); +struct vrtc *vm_rtc(struct vm *vm); + +/* + * Inject exception 'vector' into the guest vcpu. This function returns 0 on + * success and non-zero on failure. + * + * Wrapper functions like 'vm_inject_gp()' should be preferred to calling + * this function directly because they enforce the trap-like or fault-like + * behavior of an exception. + * + * This function should only be called in the context of the thread that is + * executing this vcpu. + */ +int vm_inject_exception(struct vm *vm, int vcpuid, int vector, int err_valid, + uint32_t errcode, int restart_instruction); + +/* + * This function is called after a VM-exit that occurred during exception or + * interrupt delivery through the IDT. The format of 'intinfo' is described + * in Figure 15-1, "EXITINTINFO for All Intercepts", APM, Vol 2. + * + * If a VM-exit handler completes the event delivery successfully then it + * should call vm_exit_intinfo() to extinguish the pending event. For e.g., + * if the task switch emulation is triggered via a task gate then it should + * call this function with 'intinfo=0' to indicate that the external event + * is not pending anymore. + * + * Return value is 0 on success and non-zero on failure. + */ +int vm_exit_intinfo(struct vm *vm, int vcpuid, uint64_t intinfo); + +/* + * This function is called before every VM-entry to retrieve a pending + * event that should be injected into the guest. This function combines + * nested events into a double or triple fault. + * + * Returns 0 if there are no events that need to be injected into the guest + * and non-zero otherwise. + */ +int vm_entry_intinfo(struct vm *vm, int vcpuid, uint64_t *info); + +int vm_get_intinfo(struct vm *vm, int vcpuid, uint64_t *info1, uint64_t *info2); + +enum vm_reg_name vm_segment_name(int seg_encoding); + +struct vm_copyinfo { + uint64_t gpa; + size_t len; + void *hva; + void *cookie; +}; + +/* + * Set up 'copyinfo[]' to copy to/from guest linear address space starting + * at 'gla' and 'len' bytes long. The 'prot' should be set to PROT_READ for + * a copyin or PROT_WRITE for a copyout. + * + * retval is_fault Interpretation + * 0 0 Success + * 0 1 An exception was injected into the guest + * EFAULT N/A Unrecoverable error + * + * The 'copyinfo[]' can be passed to 'vm_copyin()' or 'vm_copyout()' only if + * the return value is 0. The 'copyinfo[]' resources should be freed by calling + * 'vm_copy_teardown()' after the copy is done. + */ +int vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging, + uint64_t gla, size_t len, int prot, struct vm_copyinfo *copyinfo, + int num_copyinfo, int *is_fault); +void vm_copy_teardown(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, + int num_copyinfo); +void vm_copyin(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, + void *kaddr, size_t len); +void vm_copyout(struct vm *vm, int vcpuid, const void *kaddr, + struct vm_copyinfo *copyinfo, size_t len); + +int vcpu_trace_exceptions(struct vm *vm, int vcpuid); + +/* APIs to inject faults into the guest */ +void vm_inject_fault(struct vm *vm, int vcpuid, int vector, int errcode_valid, + int errcode); + +void vm_inject_ud(struct vm *vm, int vcpuid); +void vm_inject_gp(struct vm *vm, int vcpuid); +void vm_inject_ac(struct vm *vm, int vcpuid, int errcode); +void vm_inject_ss(struct vm *vm, int vcpuid, int errcode); + + +#ifndef __FreeBSD__ + +void vmm_sol_glue_init(void); +void vmm_sol_glue_cleanup(void); + +int vmm_mod_load(void); +int vmm_mod_unload(void); + +void vmm_call_trap(uint64_t); + +/* + * Because of tangled headers, these are mirrored by vmm_drv.h to present the + * interface to driver consumers. + */ +typedef int (*vmm_rmem_cb_t)(void *, uintptr_t, uint_t, uint64_t *); +typedef int (*vmm_wmem_cb_t)(void *, uintptr_t, uint_t, uint64_t); + +int vm_ioport_hook(struct vm *, uint_t, vmm_rmem_cb_t, vmm_wmem_cb_t, void *, + void **); +void vm_ioport_unhook(struct vm *, void **); +int vm_ioport_handle_hook(struct vm *, int, bool, int, int, uint32_t *); + +#endif /* __FreeBSD */ + +#endif /* _VMM_KERNEL_H_ */ + diff --git a/usr/src/uts/i86pc/io/vmm/vmm.c b/usr/src/uts/i86pc/io/vmm/vmm.c index 38f9a5ad71..a215e73be3 100644 --- a/usr/src/uts/i86pc/io/vmm/vmm.c +++ b/usr/src/uts/i86pc/io/vmm/vmm.c @@ -2490,21 +2490,41 @@ vm_inject_exception(struct vm *vm, int vcpuid, int vector, int errcode_valid, } void -vm_inject_fault(void *vmarg, int vcpuid, int vector, int errcode_valid, +vm_inject_fault(struct vm *vm, int vcpuid, int vector, int errcode_valid, int errcode) { - struct vm *vm; - int error, restart_instruction; - - vm = vmarg; - restart_instruction = 1; + int error; error = vm_inject_exception(vm, vcpuid, vector, errcode_valid, - errcode, restart_instruction); + errcode, 1); KASSERT(error == 0, ("vm_inject_exception error %d", error)); } void +vm_inject_ud(struct vm *vm, int vcpuid) +{ + vm_inject_fault(vm, vcpuid, IDT_UD, 0, 0); +} + +void +vm_inject_gp(struct vm *vm, int vcpuid) +{ + vm_inject_fault(vm, vcpuid, IDT_GP, 1, 0); +} + +void +vm_inject_ac(struct vm *vm, int vcpuid, int errcode) +{ + vm_inject_fault(vm, vcpuid, IDT_AC, 1, errcode); +} + +void +vm_inject_ss(struct vm *vm, int vcpuid, int errcode) +{ + vm_inject_fault(vm, vcpuid, IDT_SS, 1, errcode); +} + +void vm_inject_pf(void *vmarg, int vcpuid, int error_code, uint64_t cr2) { struct vm *vm; diff --git a/usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c b/usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c index d622648ebd..95a146661c 100644 --- a/usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c +++ b/usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c @@ -37,6 +37,7 @@ #include <x86/apicreg.h> #include <sys/vmm.h> +#include <sys/vmm_kernel.h> #include <sys/vmm_instruction_emul.h> #include <sys/vmm_dev.h> #include <sys/vmm_impl.h> diff --git a/usr/src/uts/i86pc/io/vmm/vmm_zsd.c b/usr/src/uts/i86pc/io/vmm/vmm_zsd.c index ae7cff66b6..d396c89e58 100644 --- a/usr/src/uts/i86pc/io/vmm/vmm_zsd.c +++ b/usr/src/uts/i86pc/io/vmm/vmm_zsd.c @@ -21,6 +21,7 @@ #include <sys/list.h> #include <sys/types.h> #include <sys/vmm.h> +#include <sys/vmm_kernel.h> #include <sys/vmm_impl.h> #include <sys/zone.h> diff --git a/usr/src/uts/i86pc/sys/vmm.h b/usr/src/uts/i86pc/sys/vmm.h index f4a2fe4e3a..ad7c39271f 100644 --- a/usr/src/uts/i86pc/sys/vmm.h +++ b/usr/src/uts/i86pc/sys/vmm.h @@ -44,13 +44,6 @@ #ifndef _VMM_H_ #define _VMM_H_ -#include <sys/sdt.h> -#include <x86/segments.h> - -#ifdef _KERNEL -SDT_PROVIDER_DECLARE(vmm); -#endif - enum vm_suspend_how { VM_SUSPEND_NONE, VM_SUSPEND_RESET, @@ -139,7 +132,7 @@ enum x2apic_state { /* * The VM name has to fit into the pathname length constraints of devfs, * governed primarily by SPECNAMELEN. The length is the total number of - * characters in the full path, relative to the mount point and not + * characters in the full path, relative to the mount point and not * including any leading '/' characters. * A prefix and a suffix are added to the name specified by the user. * The prefix is usually "vmm/" or "vmm.io/", but can be a few characters @@ -161,314 +154,7 @@ enum x2apic_state { #ifdef _KERNEL CTASSERT(VM_MAX_NAMELEN >= VM_MIN_NAMELEN); - -struct vm; -struct vm_exception; -struct seg_desc; -struct vm_exit; -struct vm_run; -struct vhpet; -struct vioapic; -struct vlapic; -struct vmspace; -struct vm_object; -struct vm_guest_paging; -struct pmap; - -struct vm_eventinfo { - u_int *rptr; /* runblock cookie */ - int *sptr; /* suspend cookie */ - int *iptr; /* reqidle cookie */ -}; - -typedef int (*vmm_init_func_t)(int ipinum); -typedef int (*vmm_cleanup_func_t)(void); -typedef void (*vmm_resume_func_t)(void); -typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap); -typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip, - struct pmap *pmap, struct vm_eventinfo *info); -typedef void (*vmi_cleanup_func_t)(void *vmi); -typedef int (*vmi_get_register_t)(void *vmi, int vcpu, int num, - uint64_t *retval); -typedef int (*vmi_set_register_t)(void *vmi, int vcpu, int num, - uint64_t val); -typedef int (*vmi_get_desc_t)(void *vmi, int vcpu, int num, - struct seg_desc *desc); -typedef int (*vmi_set_desc_t)(void *vmi, int vcpu, int num, - struct seg_desc *desc); -typedef int (*vmi_get_cap_t)(void *vmi, int vcpu, int num, int *retval); -typedef int (*vmi_set_cap_t)(void *vmi, int vcpu, int num, int val); -typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max); -typedef void (*vmi_vmspace_free)(struct vmspace *vmspace); -typedef struct vlapic * (*vmi_vlapic_init)(void *vmi, int vcpu); -typedef void (*vmi_vlapic_cleanup)(void *vmi, struct vlapic *vlapic); -#ifndef __FreeBSD__ -typedef void (*vmi_savectx)(void *vmi, int vcpu); -typedef void (*vmi_restorectx)(void *vmi, int vcpu); -#endif - -struct vmm_ops { - vmm_init_func_t init; /* module wide initialization */ - vmm_cleanup_func_t cleanup; - vmm_resume_func_t resume; - - vmi_init_func_t vminit; /* vm-specific initialization */ - vmi_run_func_t vmrun; - vmi_cleanup_func_t vmcleanup; - vmi_get_register_t vmgetreg; - vmi_set_register_t vmsetreg; - vmi_get_desc_t vmgetdesc; - vmi_set_desc_t vmsetdesc; - vmi_get_cap_t vmgetcap; - vmi_set_cap_t vmsetcap; - vmi_vmspace_alloc vmspace_alloc; - vmi_vmspace_free vmspace_free; - vmi_vlapic_init vlapic_init; - vmi_vlapic_cleanup vlapic_cleanup; - -#ifndef __FreeBSD__ - vmi_savectx vmsavectx; - vmi_restorectx vmrestorectx; #endif -}; - -extern struct vmm_ops vmm_ops_intel; -extern struct vmm_ops vmm_ops_amd; - -int vm_create(const char *name, struct vm **retvm); -void vm_destroy(struct vm *vm); -int vm_reinit(struct vm *vm); -const char *vm_name(struct vm *vm); -uint16_t vm_get_maxcpus(struct vm *vm); -void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores, - uint16_t *threads, uint16_t *maxcpus); -int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores, - uint16_t threads, uint16_t maxcpus); - -/* - * APIs that modify the guest memory map require all vcpus to be frozen. - */ -int vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t off, - size_t len, int prot, int flags); -int vm_alloc_memseg(struct vm *vm, int ident, size_t len, bool sysmem); -void vm_free_memseg(struct vm *vm, int ident); -int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa); -int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len); -#ifdef __FreeBSD__ -int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func); -int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func); -#else -int vm_assign_pptdev(struct vm *vm, int pptfd); -int vm_unassign_pptdev(struct vm *vm, int pptfd); -#endif /* __FreeBSD__ */ - -/* - * APIs that inspect the guest memory map require only a *single* vcpu to - * be frozen. This acts like a read lock on the guest memory map since any - * modification requires *all* vcpus to be frozen. - */ -int vm_mmap_getnext(struct vm *vm, vm_paddr_t *gpa, int *segid, - vm_ooffset_t *segoff, size_t *len, int *prot, int *flags); -int vm_get_memseg(struct vm *vm, int ident, size_t *len, bool *sysmem, - struct vm_object **objptr); -vm_paddr_t vmm_sysmem_maxaddr(struct vm *vm); -void *vm_gpa_hold(struct vm *, int vcpuid, vm_paddr_t gpa, size_t len, - int prot, void **cookie); -void vm_gpa_release(void *cookie); -bool vm_mem_allocated(struct vm *vm, int vcpuid, vm_paddr_t gpa); - -int vm_get_register(struct vm *vm, int vcpu, int reg, uint64_t *retval); -int vm_set_register(struct vm *vm, int vcpu, int reg, uint64_t val); -int vm_get_seg_desc(struct vm *vm, int vcpu, int reg, - struct seg_desc *ret_desc); -int vm_set_seg_desc(struct vm *vm, int vcpu, int reg, - struct seg_desc *desc); -int vm_run(struct vm *vm, struct vm_run *vmrun); -int vm_suspend(struct vm *vm, enum vm_suspend_how how); -int vm_inject_nmi(struct vm *vm, int vcpu); -int vm_nmi_pending(struct vm *vm, int vcpuid); -void vm_nmi_clear(struct vm *vm, int vcpuid); -int vm_inject_extint(struct vm *vm, int vcpu); -int vm_extint_pending(struct vm *vm, int vcpuid); -void vm_extint_clear(struct vm *vm, int vcpuid); -struct vlapic *vm_lapic(struct vm *vm, int cpu); -struct vioapic *vm_ioapic(struct vm *vm); -struct vhpet *vm_hpet(struct vm *vm); -int vm_get_capability(struct vm *vm, int vcpu, int type, int *val); -int vm_set_capability(struct vm *vm, int vcpu, int type, int val); -int vm_get_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state *state); -int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state); -int vm_apicid2vcpuid(struct vm *vm, int apicid); -int vm_activate_cpu(struct vm *vm, int vcpu); -int vm_suspend_cpu(struct vm *vm, int vcpu); -int vm_resume_cpu(struct vm *vm, int vcpu); -struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid); -void vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t rip); -void vm_exit_debug(struct vm *vm, int vcpuid, uint64_t rip); -void vm_exit_runblock(struct vm *vm, int vcpuid, uint64_t rip); -void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip); -void vm_exit_reqidle(struct vm *vm, int vcpuid, uint64_t rip); - -#ifdef _SYS__CPUSET_H_ -cpuset_t vm_active_cpus(struct vm *vm); -cpuset_t vm_debug_cpus(struct vm *vm); -cpuset_t vm_suspended_cpus(struct vm *vm); -#endif /* _SYS__CPUSET_H_ */ - -static __inline int -vcpu_runblocked(struct vm_eventinfo *info) -{ - - return (*info->rptr != 0); -} - -static __inline int -vcpu_suspended(struct vm_eventinfo *info) -{ - - return (*info->sptr); -} - -static __inline int -vcpu_reqidle(struct vm_eventinfo *info) -{ - - return (*info->iptr); -} - -int vcpu_debugged(struct vm *vm, int vcpuid); - -/* - * Return true if device indicated by bus/slot/func is supposed to be a - * pci passthrough device. - * - * Return false otherwise. - */ -bool vmm_is_pptdev(int bus, int slot, int func); - -void *vm_iommu_domain(struct vm *vm); - -enum vcpu_state { - VCPU_IDLE, - VCPU_FROZEN, - VCPU_RUNNING, - VCPU_SLEEPING, -}; - -int vcpu_set_state(struct vm *vm, int vcpu, enum vcpu_state state, - bool from_idle); -enum vcpu_state vcpu_get_state(struct vm *vm, int vcpu, int *hostcpu); -void vcpu_block_run(struct vm *, int); -void vcpu_unblock_run(struct vm *, int); - -#ifndef __FreeBSD__ -uint64_t vcpu_tsc_offset(struct vm *vm, int vcpuid); -#endif - -static __inline int -vcpu_is_running(struct vm *vm, int vcpu, int *hostcpu) -{ - return (vcpu_get_state(vm, vcpu, hostcpu) == VCPU_RUNNING); -} - -#ifdef _SYS_THREAD_H -static __inline int -vcpu_should_yield(struct vm *vm, int vcpu) -{ - - if (curthread->t_astflag) - return (1); - else if (CPU->cpu_runrun) - return (1); - else - return (0); -} -#endif /* _SYS_THREAD_H */ - -void *vcpu_stats(struct vm *vm, int vcpu); -void vcpu_notify_event(struct vm *vm, int vcpuid, bool lapic_intr); -struct vmspace *vm_get_vmspace(struct vm *vm); -struct vatpic *vm_atpic(struct vm *vm); -struct vatpit *vm_atpit(struct vm *vm); -struct vpmtmr *vm_pmtmr(struct vm *vm); -struct vrtc *vm_rtc(struct vm *vm); - -/* - * Inject exception 'vector' into the guest vcpu. This function returns 0 on - * success and non-zero on failure. - * - * Wrapper functions like 'vm_inject_gp()' should be preferred to calling - * this function directly because they enforce the trap-like or fault-like - * behavior of an exception. - * - * This function should only be called in the context of the thread that is - * executing this vcpu. - */ -int vm_inject_exception(struct vm *vm, int vcpuid, int vector, int err_valid, - uint32_t errcode, int restart_instruction); - -/* - * This function is called after a VM-exit that occurred during exception or - * interrupt delivery through the IDT. The format of 'intinfo' is described - * in Figure 15-1, "EXITINTINFO for All Intercepts", APM, Vol 2. - * - * If a VM-exit handler completes the event delivery successfully then it - * should call vm_exit_intinfo() to extinguish the pending event. For e.g., - * if the task switch emulation is triggered via a task gate then it should - * call this function with 'intinfo=0' to indicate that the external event - * is not pending anymore. - * - * Return value is 0 on success and non-zero on failure. - */ -int vm_exit_intinfo(struct vm *vm, int vcpuid, uint64_t intinfo); - -/* - * This function is called before every VM-entry to retrieve a pending - * event that should be injected into the guest. This function combines - * nested events into a double or triple fault. - * - * Returns 0 if there are no events that need to be injected into the guest - * and non-zero otherwise. - */ -int vm_entry_intinfo(struct vm *vm, int vcpuid, uint64_t *info); - -int vm_get_intinfo(struct vm *vm, int vcpuid, uint64_t *info1, uint64_t *info2); - -enum vm_reg_name vm_segment_name(int seg_encoding); - -struct vm_copyinfo { - uint64_t gpa; - size_t len; - void *hva; - void *cookie; -}; - -/* - * Set up 'copyinfo[]' to copy to/from guest linear address space starting - * at 'gla' and 'len' bytes long. The 'prot' should be set to PROT_READ for - * a copyin or PROT_WRITE for a copyout. - * - * retval is_fault Interpretation - * 0 0 Success - * 0 1 An exception was injected into the guest - * EFAULT N/A Unrecoverable error - * - * The 'copyinfo[]' can be passed to 'vm_copyin()' or 'vm_copyout()' only if - * the return value is 0. The 'copyinfo[]' resources should be freed by calling - * 'vm_copy_teardown()' after the copy is done. - */ -int vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging, - uint64_t gla, size_t len, int prot, struct vm_copyinfo *copyinfo, - int num_copyinfo, int *is_fault); -void vm_copy_teardown(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, - int num_copyinfo); -void vm_copyin(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, - void *kaddr, size_t len); -void vm_copyout(struct vm *vm, int vcpuid, const void *kaddr, - struct vm_copyinfo *copyinfo, size_t len); - -int vcpu_trace_exceptions(struct vm *vm, int vcpuid); -#endif /* KERNEL */ #define VM_MAXCPU 32 /* maximum virtual cpus */ @@ -489,7 +175,7 @@ enum vm_intr_trigger { EDGE_TRIGGER, LEVEL_TRIGGER }; - + /* * The 'access' field has the format specified in Table 21-2 of the Intel * Architecture Manual vol 3b. @@ -739,62 +425,8 @@ struct vm_exit { } u; }; -/* APIs to inject faults into the guest */ -void vm_inject_fault(void *vm, int vcpuid, int vector, int errcode_valid, - int errcode); - -static __inline void -vm_inject_ud(void *vm, int vcpuid) -{ - vm_inject_fault(vm, vcpuid, IDT_UD, 0, 0); -} - -static __inline void -vm_inject_gp(void *vm, int vcpuid) -{ - vm_inject_fault(vm, vcpuid, IDT_GP, 1, 0); -} - -static __inline void -vm_inject_ac(void *vm, int vcpuid, int errcode) -{ - vm_inject_fault(vm, vcpuid, IDT_AC, 1, errcode); -} - -static __inline void -vm_inject_ss(void *vm, int vcpuid, int errcode) -{ - vm_inject_fault(vm, vcpuid, IDT_SS, 1, errcode); -} - void vm_inject_pf(void *vm, int vcpuid, int error_code, uint64_t cr2); int vm_restart_instruction(void *vm, int vcpuid); -#ifndef __FreeBSD__ -#ifdef _KERNEL - -void vmm_sol_glue_init(void); -void vmm_sol_glue_cleanup(void); - -int vmm_mod_load(void); -int vmm_mod_unload(void); - -void vmm_call_trap(uint64_t); - -/* - * Because of tangled headers, these are mirrored by vmm_drv.h to present the - * interface to driver consumers. - */ -typedef int (*vmm_rmem_cb_t)(void *, uintptr_t, uint_t, uint64_t *); -typedef int (*vmm_wmem_cb_t)(void *, uintptr_t, uint_t, uint64_t); - -int vm_ioport_hook(struct vm *, uint_t, vmm_rmem_cb_t, vmm_wmem_cb_t, void *, - void **); -void vm_ioport_unhook(struct vm *, void **); -int vm_ioport_handle_hook(struct vm *, int, bool, int, int, uint32_t *); - -#endif /* _KERNEL */ -#endif /* __FreeBSD */ - #endif /* _VMM_H_ */ diff --git a/usr/src/uts/i86pc/sys/vmm_dev.h b/usr/src/uts/i86pc/sys/vmm_dev.h index 48e2c5f306..40e0857945 100644 --- a/usr/src/uts/i86pc/sys/vmm_dev.h +++ b/usr/src/uts/i86pc/sys/vmm_dev.h @@ -64,13 +64,6 @@ struct vm_memseg { char name[SPECNAMELEN + 1]; }; -struct vm_memseg_fbsd12 { - int segid; - size_t len; - char name[64]; -}; -_Static_assert(sizeof(struct vm_memseg_fbsd12) == 80, "COMPAT_FREEBSD12 ABI"); - struct vm_register { int cpuid; int regnum; /* enum vm_reg_name */ @@ -134,51 +127,6 @@ struct vm_capability { int allcpus; }; -#ifdef __FreeBSD__ -struct vm_pptdev { - int bus; - int slot; - int func; -}; - -struct vm_pptdev_mmio { - int bus; - int slot; - int func; - vm_paddr_t gpa; - vm_paddr_t hpa; - size_t len; -}; - -struct vm_pptdev_msi { - int vcpu; - int bus; - int slot; - int func; - int numvec; /* 0 means disabled */ - uint64_t msg; - uint64_t addr; -}; - -struct vm_pptdev_msix { - int vcpu; - int bus; - int slot; - int func; - int idx; - uint64_t msg; - uint32_t vector_control; - uint64_t addr; -}; - -struct vm_pptdev_limits { - int bus; - int slot; - int func; - int msi_limit; - int msix_limit; -}; -#else /* __FreeBSD__ */ struct vm_pptdev { int pptfd; }; @@ -212,7 +160,6 @@ struct vm_pptdev_limits { int msi_limit; int msix_limit; }; -#endif /* __FreeBSD__ */ struct vm_nmi { int cpuid; @@ -296,12 +243,10 @@ struct vm_rtc_data { uint8_t value; }; -#ifndef __FreeBSD__ struct vm_devmem_offset { int segid; off_t offset; }; -#endif struct vm_cpu_topology { uint16_t sockets; @@ -319,230 +264,92 @@ struct vm_readwrite_kernemu_device { }; _Static_assert(sizeof(struct vm_readwrite_kernemu_device) == 24, "ABI"); -enum { - /* general routines */ - IOCNUM_ABIVERS = 0, - IOCNUM_RUN = 1, - IOCNUM_SET_CAPABILITY = 2, - IOCNUM_GET_CAPABILITY = 3, - IOCNUM_SUSPEND = 4, - IOCNUM_REINIT = 5, - - /* memory apis */ - IOCNUM_MAP_MEMORY = 10, /* deprecated */ - IOCNUM_GET_MEMORY_SEG = 11, /* deprecated */ - IOCNUM_GET_GPA_PMAP = 12, - IOCNUM_GLA2GPA = 13, - IOCNUM_ALLOC_MEMSEG = 14, - IOCNUM_GET_MEMSEG = 15, - IOCNUM_MMAP_MEMSEG = 16, - IOCNUM_MMAP_GETNEXT = 17, - IOCNUM_GLA2GPA_NOFAULT = 18, - - /* register/state accessors */ - IOCNUM_SET_REGISTER = 20, - IOCNUM_GET_REGISTER = 21, - IOCNUM_SET_SEGMENT_DESCRIPTOR = 22, - IOCNUM_GET_SEGMENT_DESCRIPTOR = 23, - IOCNUM_SET_REGISTER_SET = 24, - IOCNUM_GET_REGISTER_SET = 25, - IOCNUM_GET_KERNEMU_DEV = 26, - IOCNUM_SET_KERNEMU_DEV = 27, - - /* interrupt injection */ - IOCNUM_GET_INTINFO = 28, - IOCNUM_SET_INTINFO = 29, - IOCNUM_INJECT_EXCEPTION = 30, - IOCNUM_LAPIC_IRQ = 31, - IOCNUM_INJECT_NMI = 32, - IOCNUM_IOAPIC_ASSERT_IRQ = 33, - IOCNUM_IOAPIC_DEASSERT_IRQ = 34, - IOCNUM_IOAPIC_PULSE_IRQ = 35, - IOCNUM_LAPIC_MSI = 36, - IOCNUM_LAPIC_LOCAL_IRQ = 37, - IOCNUM_IOAPIC_PINCOUNT = 38, - IOCNUM_RESTART_INSTRUCTION = 39, - - /* PCI pass-thru */ - IOCNUM_BIND_PPTDEV = 40, - IOCNUM_UNBIND_PPTDEV = 41, - IOCNUM_MAP_PPTDEV_MMIO = 42, - IOCNUM_PPTDEV_MSI = 43, - IOCNUM_PPTDEV_MSIX = 44, - IOCNUM_GET_PPTDEV_LIMITS = 45, - - /* statistics */ - IOCNUM_VM_STATS = 50, - IOCNUM_VM_STAT_DESC = 51, - - /* kernel device state */ - IOCNUM_SET_X2APIC_STATE = 60, - IOCNUM_GET_X2APIC_STATE = 61, - IOCNUM_GET_HPET_CAPABILITIES = 62, - - /* CPU Topology */ - IOCNUM_SET_TOPOLOGY = 63, - IOCNUM_GET_TOPOLOGY = 64, - - /* legacy interrupt injection */ - IOCNUM_ISA_ASSERT_IRQ = 80, - IOCNUM_ISA_DEASSERT_IRQ = 81, - IOCNUM_ISA_PULSE_IRQ = 82, - IOCNUM_ISA_SET_IRQ_TRIGGER = 83, - - /* vm_cpuset */ - IOCNUM_ACTIVATE_CPU = 90, - IOCNUM_GET_CPUSET = 91, - IOCNUM_SUSPEND_CPU = 92, - IOCNUM_RESUME_CPU = 93, - - /* RTC */ - IOCNUM_RTC_READ = 100, - IOCNUM_RTC_WRITE = 101, - IOCNUM_RTC_SETTIME = 102, - IOCNUM_RTC_GETTIME = 103, - -#ifndef __FreeBSD__ - /* illumos-custom ioctls */ - IOCNUM_DEVMEM_GETOFFSET = 256, - IOCNUM_WRLOCK_CYCLE = 257, -#endif -}; - -#define VM_RUN \ - _IOWR('v', IOCNUM_RUN, struct vm_run) -#define VM_SUSPEND \ - _IOW('v', IOCNUM_SUSPEND, struct vm_suspend) -#define VM_REINIT \ - _IO('v', IOCNUM_REINIT) -#define VM_ALLOC_MEMSEG_FBSD12 \ - _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg_fbsd12) -#define VM_ALLOC_MEMSEG \ - _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg) -#define VM_GET_MEMSEG_FBSD12 \ - _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg_fbsd12) -#define VM_GET_MEMSEG \ - _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg) -#define VM_MMAP_MEMSEG \ - _IOW('v', IOCNUM_MMAP_MEMSEG, struct vm_memmap) -#define VM_MMAP_GETNEXT \ - _IOWR('v', IOCNUM_MMAP_GETNEXT, struct vm_memmap) -#define VM_SET_REGISTER \ - _IOW('v', IOCNUM_SET_REGISTER, struct vm_register) -#define VM_GET_REGISTER \ - _IOWR('v', IOCNUM_GET_REGISTER, struct vm_register) -#define VM_SET_SEGMENT_DESCRIPTOR \ - _IOW('v', IOCNUM_SET_SEGMENT_DESCRIPTOR, struct vm_seg_desc) -#define VM_GET_SEGMENT_DESCRIPTOR \ - _IOWR('v', IOCNUM_GET_SEGMENT_DESCRIPTOR, struct vm_seg_desc) -#define VM_SET_REGISTER_SET \ - _IOW('v', IOCNUM_SET_REGISTER_SET, struct vm_register_set) -#define VM_GET_REGISTER_SET \ - _IOWR('v', IOCNUM_GET_REGISTER_SET, struct vm_register_set) -#define VM_SET_KERNEMU_DEV \ - _IOW('v', IOCNUM_SET_KERNEMU_DEV, \ - struct vm_readwrite_kernemu_device) -#define VM_GET_KERNEMU_DEV \ - _IOWR('v', IOCNUM_GET_KERNEMU_DEV, \ - struct vm_readwrite_kernemu_device) -#define VM_INJECT_EXCEPTION \ - _IOW('v', IOCNUM_INJECT_EXCEPTION, struct vm_exception) -#define VM_LAPIC_IRQ \ - _IOW('v', IOCNUM_LAPIC_IRQ, struct vm_lapic_irq) -#define VM_LAPIC_LOCAL_IRQ \ - _IOW('v', IOCNUM_LAPIC_LOCAL_IRQ, struct vm_lapic_irq) -#define VM_LAPIC_MSI \ - _IOW('v', IOCNUM_LAPIC_MSI, struct vm_lapic_msi) -#define VM_IOAPIC_ASSERT_IRQ \ - _IOW('v', IOCNUM_IOAPIC_ASSERT_IRQ, struct vm_ioapic_irq) -#define VM_IOAPIC_DEASSERT_IRQ \ - _IOW('v', IOCNUM_IOAPIC_DEASSERT_IRQ, struct vm_ioapic_irq) -#define VM_IOAPIC_PULSE_IRQ \ - _IOW('v', IOCNUM_IOAPIC_PULSE_IRQ, struct vm_ioapic_irq) -#define VM_IOAPIC_PINCOUNT \ - _IOR('v', IOCNUM_IOAPIC_PINCOUNT, int) -#define VM_ISA_ASSERT_IRQ \ - _IOW('v', IOCNUM_ISA_ASSERT_IRQ, struct vm_isa_irq) -#define VM_ISA_DEASSERT_IRQ \ - _IOW('v', IOCNUM_ISA_DEASSERT_IRQ, struct vm_isa_irq) -#define VM_ISA_PULSE_IRQ \ - _IOW('v', IOCNUM_ISA_PULSE_IRQ, struct vm_isa_irq) -#define VM_ISA_SET_IRQ_TRIGGER \ - _IOW('v', IOCNUM_ISA_SET_IRQ_TRIGGER, struct vm_isa_irq_trigger) -#define VM_SET_CAPABILITY \ - _IOW('v', IOCNUM_SET_CAPABILITY, struct vm_capability) -#define VM_GET_CAPABILITY \ - _IOWR('v', IOCNUM_GET_CAPABILITY, struct vm_capability) -#define VM_BIND_PPTDEV \ - _IOW('v', IOCNUM_BIND_PPTDEV, struct vm_pptdev) -#define VM_UNBIND_PPTDEV \ - _IOW('v', IOCNUM_UNBIND_PPTDEV, struct vm_pptdev) -#define VM_MAP_PPTDEV_MMIO \ - _IOW('v', IOCNUM_MAP_PPTDEV_MMIO, struct vm_pptdev_mmio) -#define VM_PPTDEV_MSI \ - _IOW('v', IOCNUM_PPTDEV_MSI, struct vm_pptdev_msi) -#define VM_PPTDEV_MSIX \ - _IOW('v', IOCNUM_PPTDEV_MSIX, struct vm_pptdev_msix) -#define VM_GET_PPTDEV_LIMITS \ - _IOR('v', IOCNUM_GET_PPTDEV_LIMITS, struct vm_pptdev_limits) -#define VM_INJECT_NMI \ - _IOW('v', IOCNUM_INJECT_NMI, struct vm_nmi) -#define VM_STATS_IOC \ - _IOWR('v', IOCNUM_VM_STATS, struct vm_stats) -#define VM_STAT_DESC \ - _IOWR('v', IOCNUM_VM_STAT_DESC, struct vm_stat_desc) -#define VM_SET_X2APIC_STATE \ - _IOW('v', IOCNUM_SET_X2APIC_STATE, struct vm_x2apic) -#define VM_GET_X2APIC_STATE \ - _IOWR('v', IOCNUM_GET_X2APIC_STATE, struct vm_x2apic) -#define VM_GET_HPET_CAPABILITIES \ - _IOR('v', IOCNUM_GET_HPET_CAPABILITIES, struct vm_hpet_cap) -#define VM_SET_TOPOLOGY \ - _IOW('v', IOCNUM_SET_TOPOLOGY, struct vm_cpu_topology) -#define VM_GET_TOPOLOGY \ - _IOR('v', IOCNUM_GET_TOPOLOGY, struct vm_cpu_topology) -#define VM_GET_GPA_PMAP \ - _IOWR('v', IOCNUM_GET_GPA_PMAP, struct vm_gpa_pte) -#define VM_GLA2GPA \ - _IOWR('v', IOCNUM_GLA2GPA, struct vm_gla2gpa) -#define VM_GLA2GPA_NOFAULT \ - _IOWR('v', IOCNUM_GLA2GPA_NOFAULT, struct vm_gla2gpa) -#define VM_ACTIVATE_CPU \ - _IOW('v', IOCNUM_ACTIVATE_CPU, struct vm_activate_cpu) -#define VM_GET_CPUS \ - _IOW('v', IOCNUM_GET_CPUSET, struct vm_cpuset) -#define VM_SUSPEND_CPU \ - _IOW('v', IOCNUM_SUSPEND_CPU, struct vm_activate_cpu) -#define VM_RESUME_CPU \ - _IOW('v', IOCNUM_RESUME_CPU, struct vm_activate_cpu) -#define VM_SET_INTINFO \ - _IOW('v', IOCNUM_SET_INTINFO, struct vm_intinfo) -#define VM_GET_INTINFO \ - _IOWR('v', IOCNUM_GET_INTINFO, struct vm_intinfo) -#define VM_RTC_WRITE \ - _IOW('v', IOCNUM_RTC_WRITE, struct vm_rtc_data) -#define VM_RTC_READ \ - _IOWR('v', IOCNUM_RTC_READ, struct vm_rtc_data) -#define VM_RTC_SETTIME \ - _IOW('v', IOCNUM_RTC_SETTIME, struct vm_rtc_time) -#define VM_RTC_GETTIME \ - _IOR('v', IOCNUM_RTC_GETTIME, struct vm_rtc_time) -#define VM_RESTART_INSTRUCTION \ - _IOW('v', IOCNUM_RESTART_INSTRUCTION, int) - -#ifndef __FreeBSD__ -#define VM_DEVMEM_GETOFFSET \ - _IOW('v', IOCNUM_DEVMEM_GETOFFSET, struct vm_devmem_offset) -#define VM_WRLOCK_CYCLE _IO('v', IOCNUM_WRLOCK_CYCLE) - -/* ioctls used against ctl device for vm create/destroy */ -#define VMM_IOC_BASE (('V' << 16) | ('M' << 8)) -#define VMM_CREATE_VM (VMM_IOC_BASE | 0x01) -#define VMM_DESTROY_VM (VMM_IOC_BASE | 0x02) -#define VMM_VM_SUPPORTED (VMM_IOC_BASE | 0x03) +#define VMMCTL_IOC_BASE (('V' << 16) | ('M' << 8)) +#define VMM_IOC_BASE (('v' << 16) | ('m' << 8)) +#define VMM_LOCK_IOC_BASE (('v' << 16) | ('l' << 8)) +#define VMM_CPU_IOC_BASE (('v' << 16) | ('p' << 8)) + +/* Operations performed on the vmmctl device */ +#define VMM_CREATE_VM (VMMCTL_IOC_BASE | 0x01) +#define VMM_DESTROY_VM (VMMCTL_IOC_BASE | 0x02) +#define VMM_VM_SUPPORTED (VMMCTL_IOC_BASE | 0x03) + +/* Operations performed in the context of a given vCPU */ +#define VM_RUN (VMM_CPU_IOC_BASE | 0x01) +#define VM_SET_REGISTER (VMM_CPU_IOC_BASE | 0x02) +#define VM_GET_REGISTER (VMM_CPU_IOC_BASE | 0x03) +#define VM_SET_SEGMENT_DESCRIPTOR (VMM_CPU_IOC_BASE | 0x04) +#define VM_GET_SEGMENT_DESCRIPTOR (VMM_CPU_IOC_BASE | 0x05) +#define VM_SET_REGISTER_SET (VMM_CPU_IOC_BASE | 0x06) +#define VM_GET_REGISTER_SET (VMM_CPU_IOC_BASE | 0x07) +#define VM_INJECT_EXCEPTION (VMM_CPU_IOC_BASE | 0x08) +#define VM_SET_CAPABILITY (VMM_CPU_IOC_BASE | 0x09) +#define VM_GET_CAPABILITY (VMM_CPU_IOC_BASE | 0x0a) +#define VM_PPTDEV_MSI (VMM_CPU_IOC_BASE | 0x0b) +#define VM_PPTDEV_MSIX (VMM_CPU_IOC_BASE | 0x0c) +#define VM_SET_X2APIC_STATE (VMM_CPU_IOC_BASE | 0x0d) +#define VM_GLA2GPA (VMM_CPU_IOC_BASE | 0x0e) +#define VM_GLA2GPA_NOFAULT (VMM_CPU_IOC_BASE | 0x0f) +#define VM_ACTIVATE_CPU (VMM_CPU_IOC_BASE | 0x10) +#define VM_SET_INTINFO (VMM_CPU_IOC_BASE | 0x11) +#define VM_GET_INTINFO (VMM_CPU_IOC_BASE | 0x12) +#define VM_RESTART_INSTRUCTION (VMM_CPU_IOC_BASE | 0x13) +#define VM_SET_KERNEMU_DEV (VMM_CPU_IOC_BASE | 0x14) +#define VM_GET_KERNEMU_DEV (VMM_CPU_IOC_BASE | 0x15) + +/* Operations requiring write-locking the VM */ +#define VM_REINIT (VMM_LOCK_IOC_BASE | 0x01) +#define VM_BIND_PPTDEV (VMM_LOCK_IOC_BASE | 0x02) +#define VM_UNBIND_PPTDEV (VMM_LOCK_IOC_BASE | 0x03) +#define VM_MAP_PPTDEV_MMIO (VMM_LOCK_IOC_BASE | 0x04) +#define VM_ALLOC_MEMSEG (VMM_LOCK_IOC_BASE | 0x05) +#define VM_MMAP_MEMSEG (VMM_LOCK_IOC_BASE | 0x06) + +#define VM_WRLOCK_CYCLE (VMM_LOCK_IOC_BASE | 0xff) + +/* All other ioctls */ +#define VM_GET_GPA_PMAP (VMM_IOC_BASE | 0x01) +#define VM_GET_MEMSEG (VMM_IOC_BASE | 0x02) +#define VM_MMAP_GETNEXT (VMM_IOC_BASE | 0x03) + +#define VM_LAPIC_IRQ (VMM_IOC_BASE | 0x04) +#define VM_LAPIC_LOCAL_IRQ (VMM_IOC_BASE | 0x05) +#define VM_LAPIC_MSI (VMM_IOC_BASE | 0x06) + +#define VM_IOAPIC_ASSERT_IRQ (VMM_IOC_BASE | 0x07) +#define VM_IOAPIC_DEASSERT_IRQ (VMM_IOC_BASE | 0x08) +#define VM_IOAPIC_PULSE_IRQ (VMM_IOC_BASE | 0x09) + +#define VM_ISA_ASSERT_IRQ (VMM_IOC_BASE | 0x0a) +#define VM_ISA_DEASSERT_IRQ (VMM_IOC_BASE | 0x0b) +#define VM_ISA_PULSE_IRQ (VMM_IOC_BASE | 0x0c) +#define VM_ISA_SET_IRQ_TRIGGER (VMM_IOC_BASE | 0x0d) + +#define VM_RTC_WRITE (VMM_IOC_BASE | 0x0e) +#define VM_RTC_READ (VMM_IOC_BASE | 0x0f) +#define VM_RTC_SETTIME (VMM_IOC_BASE | 0x10) +#define VM_RTC_GETTIME (VMM_IOC_BASE | 0x11) + +#define VM_SUSPEND (VMM_IOC_BASE | 0x12) + +#define VM_IOAPIC_PINCOUNT (VMM_IOC_BASE | 0x13) +#define VM_GET_PPTDEV_LIMITS (VMM_IOC_BASE | 0x14) +#define VM_GET_HPET_CAPABILITIES (VMM_IOC_BASE | 0x15) + +#define VM_STATS_IOC (VMM_IOC_BASE | 0x16) +#define VM_STAT_DESC (VMM_IOC_BASE | 0x17) + +#define VM_INJECT_NMI (VMM_IOC_BASE | 0x18) +#define VM_GET_X2APIC_STATE (VMM_IOC_BASE | 0x19) +#define VM_SET_TOPOLOGY (VMM_IOC_BASE | 0x1a) +#define VM_GET_TOPOLOGY (VMM_IOC_BASE | 0x1b) +#define VM_GET_CPUS (VMM_IOC_BASE | 0x1c) +#define VM_SUSPEND_CPU (VMM_IOC_BASE | 0x1d) +#define VM_RESUME_CPU (VMM_IOC_BASE | 0x1e) + + +#define VM_DEVMEM_GETOFFSET (VMM_IOC_BASE | 0xff) #define VMM_CTL_DEV "/dev/vmmctl" #endif - -#endif diff --git a/usr/src/uts/i86pc/sys/vmm_instruction_emul.h b/usr/src/uts/i86pc/sys/vmm_instruction_emul.h index d4007c37e3..d084301aee 100644 --- a/usr/src/uts/i86pc/sys/vmm_instruction_emul.h +++ b/usr/src/uts/i86pc/sys/vmm_instruction_emul.h @@ -27,18 +27,6 @@ * * $FreeBSD$ */ -/* - * 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 2015 Pluribus Networks Inc. - */ #ifndef _VMM_INSTRUCTION_EMUL_H_ #define _VMM_INSTRUCTION_EMUL_H_ |