diff options
Diffstat (limited to 'sys')
31 files changed, 720 insertions, 425 deletions
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index f7c59847140b..473887240b9b 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -870,7 +870,7 @@ vm_assign_pptdev(struct vm *vm, int bus, int slot, int func) int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval) { - + /* Negative values represent VM control structure fields. */ if (reg >= VM_REG_LAST) return (EINVAL); @@ -882,6 +882,7 @@ vm_set_register(struct vcpu *vcpu, int reg, uint64_t val) { int error; + /* Negative values represent VM control structure fields. */ if (reg >= VM_REG_LAST) return (EINVAL); diff --git a/sys/amd64/vmm/vmm_dev_machdep.c b/sys/amd64/vmm/vmm_dev_machdep.c index dfebc9dcadbf..b84be809ea24 100644 --- a/sys/amd64/vmm/vmm_dev_machdep.c +++ b/sys/amd64/vmm/vmm_dev_machdep.c @@ -124,12 +124,16 @@ const struct vmmdev_ioctl vmmdev_machdep_ioctls[] = { VMMDEV_IOCTL(VM_SET_KERNEMU_DEV, VMMDEV_IOCTL_LOCK_ONE_VCPU), VMMDEV_IOCTL(VM_BIND_PPTDEV, - VMMDEV_IOCTL_XLOCK_MEMSEGS | VMMDEV_IOCTL_LOCK_ALL_VCPUS), + VMMDEV_IOCTL_XLOCK_MEMSEGS | VMMDEV_IOCTL_LOCK_ALL_VCPUS | + VMMDEV_IOCTL_PRIV_CHECK_DRIVER), VMMDEV_IOCTL(VM_UNBIND_PPTDEV, - VMMDEV_IOCTL_XLOCK_MEMSEGS | VMMDEV_IOCTL_LOCK_ALL_VCPUS), + VMMDEV_IOCTL_XLOCK_MEMSEGS | VMMDEV_IOCTL_LOCK_ALL_VCPUS | + VMMDEV_IOCTL_PRIV_CHECK_DRIVER), - VMMDEV_IOCTL(VM_MAP_PPTDEV_MMIO, VMMDEV_IOCTL_LOCK_ALL_VCPUS), - VMMDEV_IOCTL(VM_UNMAP_PPTDEV_MMIO, VMMDEV_IOCTL_LOCK_ALL_VCPUS), + VMMDEV_IOCTL(VM_MAP_PPTDEV_MMIO, VMMDEV_IOCTL_LOCK_ALL_VCPUS | + VMMDEV_IOCTL_PRIV_CHECK_DRIVER), + VMMDEV_IOCTL(VM_UNMAP_PPTDEV_MMIO, VMMDEV_IOCTL_LOCK_ALL_VCPUS | + VMMDEV_IOCTL_PRIV_CHECK_DRIVER), #ifdef BHYVE_SNAPSHOT #ifdef COMPAT_FREEBSD13 VMMDEV_IOCTL(VM_SNAPSHOT_REQ_13, VMMDEV_IOCTL_LOCK_ALL_VCPUS), @@ -147,9 +151,9 @@ const struct vmmdev_ioctl vmmdev_machdep_ioctls[] = { VMMDEV_IOCTL(VM_LAPIC_LOCAL_IRQ, VMMDEV_IOCTL_MAYBE_ALLOC_VCPU), - VMMDEV_IOCTL(VM_PPTDEV_MSI, 0), - VMMDEV_IOCTL(VM_PPTDEV_MSIX, 0), - VMMDEV_IOCTL(VM_PPTDEV_DISABLE_MSIX, 0), + VMMDEV_IOCTL(VM_PPTDEV_MSI, VMMDEV_IOCTL_PRIV_CHECK_DRIVER), + VMMDEV_IOCTL(VM_PPTDEV_MSIX, VMMDEV_IOCTL_PRIV_CHECK_DRIVER), + VMMDEV_IOCTL(VM_PPTDEV_DISABLE_MSIX, VMMDEV_IOCTL_PRIV_CHECK_DRIVER), VMMDEV_IOCTL(VM_LAPIC_MSI, 0), VMMDEV_IOCTL(VM_IOAPIC_ASSERT_IRQ, 0), VMMDEV_IOCTL(VM_IOAPIC_DEASSERT_IRQ, 0), @@ -172,40 +176,13 @@ int vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, int fflag, struct thread *td) { - struct vm_seg_desc *vmsegdesc; - struct vm_run *vmrun; -#ifdef COMPAT_FREEBSD13 - struct vm_run_13 *vmrun_13; -#endif - struct vm_exception *vmexc; - struct vm_lapic_irq *vmirq; - struct vm_lapic_msi *vmmsi; - struct vm_ioapic_irq *ioapic_irq; - struct vm_isa_irq *isa_irq; - struct vm_isa_irq_trigger *isa_irq_trigger; - struct vm_pptdev *pptdev; - struct vm_pptdev_mmio *pptmmio; - struct vm_pptdev_msi *pptmsi; - struct vm_pptdev_msix *pptmsix; - struct vm_x2apic *x2apic; - struct vm_gpa_pte *gpapte; - struct vm_gla2gpa *gg; - struct vm_intinfo *vmii; - struct vm_rtc_time *rtctime; - struct vm_rtc_data *rtcdata; - struct vm_readwrite_kernemu_device *kernemu; -#ifdef BHYVE_SNAPSHOT - struct vm_snapshot_meta *snapshot_meta; -#ifdef COMPAT_FREEBSD13 - struct vm_snapshot_meta_13 *snapshot_13; -#endif -#endif int error; error = 0; switch (cmd) { case VM_RUN: { struct vm_exit *vme; + struct vm_run *vmrun; vmrun = (struct vm_run *)data; vme = vm_exitinfo(vcpu); @@ -243,6 +220,7 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, case VM_RUN_13: { struct vm_exit *vme; struct vm_exit_13 *vme_13; + struct vm_run_13 *vmrun_13; vmrun_13 = (struct vm_run_13 *)data; vme_13 = &vmrun_13->vm_exit; @@ -281,85 +259,123 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, break; } #endif - case VM_PPTDEV_MSI: + case VM_PPTDEV_MSI: { + struct vm_pptdev_msi *pptmsi; + pptmsi = (struct vm_pptdev_msi *)data; - error = ppt_setup_msi(vm, - pptmsi->bus, pptmsi->slot, pptmsi->func, - pptmsi->addr, pptmsi->msg, - pptmsi->numvec); + error = ppt_setup_msi(vm, pptmsi->bus, pptmsi->slot, + pptmsi->func, pptmsi->addr, pptmsi->msg, pptmsi->numvec); break; - case VM_PPTDEV_MSIX: + } + case VM_PPTDEV_MSIX: { + struct vm_pptdev_msix *pptmsix; + pptmsix = (struct vm_pptdev_msix *)data; - error = ppt_setup_msix(vm, - pptmsix->bus, pptmsix->slot, - pptmsix->func, pptmsix->idx, - pptmsix->addr, pptmsix->msg, - pptmsix->vector_control); + error = ppt_setup_msix(vm, pptmsix->bus, pptmsix->slot, + pptmsix->func, pptmsix->idx, pptmsix->addr, pptmsix->msg, + pptmsix->vector_control); break; - case VM_PPTDEV_DISABLE_MSIX: + } + case VM_PPTDEV_DISABLE_MSIX: { + struct vm_pptdev *pptdev; + pptdev = (struct vm_pptdev *)data; error = ppt_disable_msix(vm, pptdev->bus, pptdev->slot, - pptdev->func); + pptdev->func); break; - case VM_MAP_PPTDEV_MMIO: + } + case VM_MAP_PPTDEV_MMIO: { + struct vm_pptdev_mmio *pptmmio; + pptmmio = (struct vm_pptdev_mmio *)data; error = ppt_map_mmio(vm, pptmmio->bus, pptmmio->slot, - pptmmio->func, pptmmio->gpa, pptmmio->len, - pptmmio->hpa); + pptmmio->func, pptmmio->gpa, pptmmio->len, pptmmio->hpa); break; - case VM_UNMAP_PPTDEV_MMIO: + } + case VM_UNMAP_PPTDEV_MMIO: { + struct vm_pptdev_mmio *pptmmio; + pptmmio = (struct vm_pptdev_mmio *)data; error = ppt_unmap_mmio(vm, pptmmio->bus, pptmmio->slot, - pptmmio->func, pptmmio->gpa, pptmmio->len); + pptmmio->func, pptmmio->gpa, pptmmio->len); break; - case VM_BIND_PPTDEV: + } + case VM_BIND_PPTDEV: { + struct vm_pptdev *pptdev; + pptdev = (struct vm_pptdev *)data; error = vm_assign_pptdev(vm, pptdev->bus, pptdev->slot, - pptdev->func); + pptdev->func); break; - case VM_UNBIND_PPTDEV: + } + case VM_UNBIND_PPTDEV: { + struct vm_pptdev *pptdev; + pptdev = (struct vm_pptdev *)data; error = vm_unassign_pptdev(vm, pptdev->bus, pptdev->slot, - pptdev->func); + pptdev->func); break; - case VM_INJECT_EXCEPTION: + } + case VM_INJECT_EXCEPTION: { + struct vm_exception *vmexc; + vmexc = (struct vm_exception *)data; error = vm_inject_exception(vcpu, vmexc->vector, vmexc->error_code_valid, vmexc->error_code, vmexc->restart_instruction); break; + } case VM_INJECT_NMI: error = vm_inject_nmi(vcpu); break; - case VM_LAPIC_IRQ: + case VM_LAPIC_IRQ: { + struct vm_lapic_irq *vmirq; + vmirq = (struct vm_lapic_irq *)data; error = lapic_intr_edge(vcpu, vmirq->vector); break; - case VM_LAPIC_LOCAL_IRQ: + } + case VM_LAPIC_LOCAL_IRQ: { + struct vm_lapic_irq *vmirq; + vmirq = (struct vm_lapic_irq *)data; error = lapic_set_local_intr(vm, vcpu, vmirq->vector); break; - case VM_LAPIC_MSI: + } + case VM_LAPIC_MSI: { + struct vm_lapic_msi *vmmsi; + vmmsi = (struct vm_lapic_msi *)data; error = lapic_intr_msi(vm, vmmsi->addr, vmmsi->msg); break; - case VM_IOAPIC_ASSERT_IRQ: + } + case VM_IOAPIC_ASSERT_IRQ: { + struct vm_ioapic_irq *ioapic_irq; + ioapic_irq = (struct vm_ioapic_irq *)data; error = vioapic_assert_irq(vm, ioapic_irq->irq); break; - case VM_IOAPIC_DEASSERT_IRQ: + } + case VM_IOAPIC_DEASSERT_IRQ: { + struct vm_ioapic_irq *ioapic_irq; + ioapic_irq = (struct vm_ioapic_irq *)data; error = vioapic_deassert_irq(vm, ioapic_irq->irq); break; - case VM_IOAPIC_PULSE_IRQ: + } + case VM_IOAPIC_PULSE_IRQ: { + struct vm_ioapic_irq *ioapic_irq; + ioapic_irq = (struct vm_ioapic_irq *)data; error = vioapic_pulse_irq(vm, ioapic_irq->irq); break; + } case VM_IOAPIC_PINCOUNT: *(int *)data = vioapic_pincount(vm); break; case VM_SET_KERNEMU_DEV: case VM_GET_KERNEMU_DEV: { + struct vm_readwrite_kernemu_device *kernemu; mem_region_write_t mwrite; mem_region_read_t mread; int size; @@ -396,60 +412,86 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, error = mread(vcpu, kernemu->gpa, &kernemu->value, size, &arg); break; - } - case VM_ISA_ASSERT_IRQ: + } + case VM_ISA_ASSERT_IRQ: { + struct vm_isa_irq *isa_irq; + isa_irq = (struct vm_isa_irq *)data; error = vatpic_assert_irq(vm, isa_irq->atpic_irq); if (error == 0 && isa_irq->ioapic_irq != -1) error = vioapic_assert_irq(vm, isa_irq->ioapic_irq); break; - case VM_ISA_DEASSERT_IRQ: + } + case VM_ISA_DEASSERT_IRQ: { + struct vm_isa_irq *isa_irq; + isa_irq = (struct vm_isa_irq *)data; error = vatpic_deassert_irq(vm, isa_irq->atpic_irq); if (error == 0 && isa_irq->ioapic_irq != -1) error = vioapic_deassert_irq(vm, isa_irq->ioapic_irq); break; - case VM_ISA_PULSE_IRQ: + } + case VM_ISA_PULSE_IRQ: { + struct vm_isa_irq *isa_irq; + isa_irq = (struct vm_isa_irq *)data; error = vatpic_pulse_irq(vm, isa_irq->atpic_irq); if (error == 0 && isa_irq->ioapic_irq != -1) error = vioapic_pulse_irq(vm, isa_irq->ioapic_irq); break; - case VM_ISA_SET_IRQ_TRIGGER: + } + case VM_ISA_SET_IRQ_TRIGGER: { + struct vm_isa_irq_trigger *isa_irq_trigger; + isa_irq_trigger = (struct vm_isa_irq_trigger *)data; error = vatpic_set_irq_trigger(vm, isa_irq_trigger->atpic_irq, isa_irq_trigger->trigger); break; - case VM_SET_SEGMENT_DESCRIPTOR: + } + case VM_SET_SEGMENT_DESCRIPTOR: { + struct vm_seg_desc *vmsegdesc; + vmsegdesc = (struct vm_seg_desc *)data; - error = vm_set_seg_desc(vcpu, - vmsegdesc->regnum, - &vmsegdesc->desc); + error = vm_set_seg_desc(vcpu, vmsegdesc->regnum, + &vmsegdesc->desc); break; - case VM_GET_SEGMENT_DESCRIPTOR: + } + case VM_GET_SEGMENT_DESCRIPTOR: { + struct vm_seg_desc *vmsegdesc; + vmsegdesc = (struct vm_seg_desc *)data; - error = vm_get_seg_desc(vcpu, - vmsegdesc->regnum, - &vmsegdesc->desc); + error = vm_get_seg_desc(vcpu, vmsegdesc->regnum, + &vmsegdesc->desc); break; - case VM_SET_X2APIC_STATE: + } + case VM_SET_X2APIC_STATE: { + struct vm_x2apic *x2apic; + x2apic = (struct vm_x2apic *)data; error = vm_set_x2apic_state(vcpu, x2apic->state); break; - case VM_GET_X2APIC_STATE: + } + case VM_GET_X2APIC_STATE: { + struct vm_x2apic *x2apic; + x2apic = (struct vm_x2apic *)data; error = vm_get_x2apic_state(vcpu, &x2apic->state); break; - case VM_GET_GPA_PMAP: + } + case VM_GET_GPA_PMAP: { + struct vm_gpa_pte *gpapte; + gpapte = (struct vm_gpa_pte *)data; - pmap_get_mapping(vmspace_pmap(vm_vmspace(vm)), - gpapte->gpa, gpapte->pte, &gpapte->ptenum); - error = 0; + pmap_get_mapping(vmspace_pmap(vm_vmspace(vm)), gpapte->gpa, + gpapte->pte, &gpapte->ptenum); break; + } case VM_GET_HPET_CAPABILITIES: error = vhpet_getcap((struct vm_hpet_cap *)data); break; case VM_GLA2GPA: { + struct vm_gla2gpa *gg; + CTASSERT(PROT_READ == VM_PROT_READ); CTASSERT(PROT_WRITE == VM_PROT_WRITE); CTASSERT(PROT_EXEC == VM_PROT_EXECUTE); @@ -460,50 +502,76 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, ("%s: vm_gla2gpa unknown error %d", __func__, error)); break; } - case VM_GLA2GPA_NOFAULT: + case VM_GLA2GPA_NOFAULT: { + struct vm_gla2gpa *gg; + gg = (struct vm_gla2gpa *)data; error = vm_gla2gpa_nofault(vcpu, &gg->paging, gg->gla, gg->prot, &gg->gpa, &gg->fault); KASSERT(error == 0 || error == EFAULT, ("%s: vm_gla2gpa unknown error %d", __func__, error)); break; - case VM_SET_INTINFO: + } + case VM_SET_INTINFO: { + struct vm_intinfo *vmii; + vmii = (struct vm_intinfo *)data; error = vm_exit_intinfo(vcpu, vmii->info1); break; - case VM_GET_INTINFO: + } + case VM_GET_INTINFO: { + struct vm_intinfo *vmii; + vmii = (struct vm_intinfo *)data; error = vm_get_intinfo(vcpu, &vmii->info1, &vmii->info2); break; - case VM_RTC_WRITE: + } + case VM_RTC_WRITE: { + struct vm_rtc_data *rtcdata; + rtcdata = (struct vm_rtc_data *)data; error = vrtc_nvram_write(vm, rtcdata->offset, rtcdata->value); break; - case VM_RTC_READ: + } + case VM_RTC_READ: { + struct vm_rtc_data *rtcdata; + rtcdata = (struct vm_rtc_data *)data; error = vrtc_nvram_read(vm, rtcdata->offset, &rtcdata->value); break; - case VM_RTC_SETTIME: + } + case VM_RTC_SETTIME: { + struct vm_rtc_time *rtctime; + rtctime = (struct vm_rtc_time *)data; error = vrtc_set_time(vm, rtctime->secs); break; - case VM_RTC_GETTIME: - error = 0; + } + case VM_RTC_GETTIME: { + struct vm_rtc_time *rtctime; + rtctime = (struct vm_rtc_time *)data; rtctime->secs = vrtc_get_time(vm); break; + } case VM_RESTART_INSTRUCTION: error = vm_restart_instruction(vcpu); break; #ifdef BHYVE_SNAPSHOT - case VM_SNAPSHOT_REQ: + case VM_SNAPSHOT_REQ: { + struct vm_snapshot_meta *snapshot_meta; + snapshot_meta = (struct vm_snapshot_meta *)data; error = vm_snapshot_req(vm, snapshot_meta); break; + } #ifdef COMPAT_FREEBSD13 - case VM_SNAPSHOT_REQ_13: + case VM_SNAPSHOT_REQ_13: { + struct vm_snapshot_meta *snapshot_meta; + struct vm_snapshot_meta_13 *snapshot_13; + /* * The old structure just has an additional pointer at * the start that is ignored. @@ -513,6 +581,7 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, (struct vm_snapshot_meta *)&snapshot_13->dev_data; error = vm_snapshot_req(vm, snapshot_meta); break; + } #endif case VM_RESTORE_TIME: error = vm_restore_time(vm); diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c index bf52dc0fe916..14ea26c3668c 100644 --- a/sys/arm64/vmm/vmm.c +++ b/sys/arm64/vmm/vmm.c @@ -1279,8 +1279,7 @@ vcpu_get_state(struct vcpu *vcpu, int *hostcpu) int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval) { - - if (reg >= VM_REG_LAST) + if (reg < 0 || reg >= VM_REG_LAST) return (EINVAL); return (vmmops_getreg(vcpu->cookie, reg, retval)); @@ -1291,7 +1290,7 @@ vm_set_register(struct vcpu *vcpu, int reg, uint64_t val) { int error; - if (reg >= VM_REG_LAST) + if (reg < 0 || reg >= VM_REG_LAST) return (EINVAL); error = vmmops_setreg(vcpu->cookie, reg, val); if (error || reg != VM_REG_GUEST_PC) diff --git a/sys/arm64/vmm/vmm_dev_machdep.c b/sys/arm64/vmm/vmm_dev_machdep.c index 926a74fa528b..29d14e1ba952 100644 --- a/sys/arm64/vmm/vmm_dev_machdep.c +++ b/sys/arm64/vmm/vmm_dev_machdep.c @@ -68,19 +68,13 @@ int vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, int fflag, struct thread *td) { - struct vm_run *vmrun; - struct vm_vgic_version *vgv; - struct vm_vgic_descr *vgic; - struct vm_irq *vi; - struct vm_exception *vmexc; - struct vm_gla2gpa *gg; - struct vm_msi *vmsi; int error; error = 0; switch (cmd) { case VM_RUN: { struct vm_exit *vme; + struct vm_run *vmrun; vmrun = (struct vm_run *)data; vme = vm_exitinfo(vcpu); @@ -94,41 +88,62 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, break; break; } - case VM_INJECT_EXCEPTION: + case VM_INJECT_EXCEPTION: { + struct vm_exception *vmexc; + vmexc = (struct vm_exception *)data; error = vm_inject_exception(vcpu, vmexc->esr, vmexc->far); break; - case VM_GLA2GPA_NOFAULT: + } + case VM_GLA2GPA_NOFAULT: { + struct vm_gla2gpa *gg; + gg = (struct vm_gla2gpa *)data; error = vm_gla2gpa_nofault(vcpu, &gg->paging, gg->gla, gg->prot, &gg->gpa, &gg->fault); KASSERT(error == 0 || error == EFAULT, ("%s: vm_gla2gpa unknown error %d", __func__, error)); break; - case VM_GET_VGIC_VERSION: + } + case VM_GET_VGIC_VERSION: { + struct vm_vgic_version *vgv; + vgv = (struct vm_vgic_version *)data; /* TODO: Query the vgic driver for this */ vgv->version = 3; vgv->flags = 0; error = 0; break; - case VM_ATTACH_VGIC: + } + case VM_ATTACH_VGIC: { + struct vm_vgic_descr *vgic; + vgic = (struct vm_vgic_descr *)data; error = vm_attach_vgic(vm, vgic); break; - case VM_RAISE_MSI: + } + case VM_RAISE_MSI: { + struct vm_msi *vmsi; + vmsi = (struct vm_msi *)data; error = vm_raise_msi(vm, vmsi->msg, vmsi->addr, vmsi->bus, vmsi->slot, vmsi->func); break; - case VM_ASSERT_IRQ: + } + case VM_ASSERT_IRQ: { + struct vm_irq *vi; + vi = (struct vm_irq *)data; error = vm_assert_irq(vm, vi->irq); break; - case VM_DEASSERT_IRQ: + } + case VM_DEASSERT_IRQ: { + struct vm_irq *vi; + vi = (struct vm_irq *)data; error = vm_deassert_irq(vm, vi->irq); break; + } default: error = ENOTTY; break; diff --git a/sys/compat/linuxkpi/common/include/linux/compiler.h b/sys/compat/linuxkpi/common/include/linux/compiler.h index 948396144ad6..4146c829b936 100644 --- a/sys/compat/linuxkpi/common/include/linux/compiler.h +++ b/sys/compat/linuxkpi/common/include/linux/compiler.h @@ -31,6 +31,7 @@ #define _LINUXKPI_LINUX_COMPILER_H_ #include <sys/cdefs.h> +#include <sys/endian.h> #define __user #define __kernel @@ -79,6 +80,13 @@ #else #define __counted_by(_x) #endif +#if BYTE_ORDER == LITTLE_ENDIAN +#define __counted_by_le(_x) __counted_by(_x) +#define __counted_by_be(_x) +#else +#define __counted_by_le(_x) +#define __counted_by_be(_x) __counted_by(_x) +#endif #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h index 7dd6340746d2..c291133e2e0b 100644 --- a/sys/compat/linuxkpi/common/include/linux/device.h +++ b/sys/compat/linuxkpi/common/include/linux/device.h @@ -92,6 +92,7 @@ struct device_driver { const struct dev_pm_ops *pm; void (*shutdown) (struct device *); + void (*coredump) (struct device *); }; struct device_type { diff --git a/sys/compat/linuxkpi/common/include/linux/etherdevice.h b/sys/compat/linuxkpi/common/include/linux/etherdevice.h index 1f2d6cf22d7e..b9a4951de8ac 100644 --- a/sys/compat/linuxkpi/common/include/linux/etherdevice.h +++ b/sys/compat/linuxkpi/common/include/linux/etherdevice.h @@ -27,6 +27,8 @@ #include <linux/types.h> #include <linux/device.h> +#include <linux/skbuff.h> +#include <linux/netdevice.h> #include <sys/random.h> #include <sys/libkern.h> @@ -137,4 +139,25 @@ device_get_mac_address(struct device *dev, char *dst) return (-ENOENT); } +/* Returns network byte order. */ +static inline uint16_t +eth_type_trans(struct sk_buff *skb, struct net_device *dev) +{ + pr_debug("%s: TODO\n", __func__); + return (htons(ETHERTYPE_8023)); +} + +static inline void +eth_hw_addr_set(struct net_device *dev, const u8 *addr) +{ + pr_debug("%s: TODO (if we want to)\n", __func__); +} + +static inline int +eth_platform_get_mac_address(struct device *dev __unused, u8 *addr __unused) +{ + pr_debug("%s: TODO\n", __func__); + return (-ENODEV); +} + #endif /* _LINUXKPI_LINUX_ETHERDEVICE_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/fips.h b/sys/compat/linuxkpi/common/include/linux/fips.h new file mode 100644 index 000000000000..25c0c1fc1fa0 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/fips.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2025 Bjoern A. Zeeb + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#ifndef _LINUXKPI_LINUX_FIPS_H +#define _LINUXKPI_LINUX_FIPS_H + +#define fips_enabled 0 + +#endif /* _LINUXKPI_LINUX_FIPS_H */ diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h b/sys/compat/linuxkpi/common/include/linux/ieee80211.h index 17041bb03ce8..ea8c0fc8ef5e 100644 --- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h +++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h @@ -312,6 +312,7 @@ enum ieee80211_ac_numbers { #define IEEE80211_MLD_CAP_OP_MAX_SIMUL_LINKS 0xf #define IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP 0x0060 #define IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP_SAME 1 +#define IEEE80211_MLD_CAP_OP_LINK_RECONF_SUPPORT 0x2000 struct ieee80211_mcs_info { uint8_t rx_mask[IEEE80211_HT_MCS_MASK_LEN]; @@ -365,6 +366,7 @@ enum ieee80211_chanctx_change_flags { IEEE80211_CHANCTX_CHANGE_CHANNEL = BIT(4), IEEE80211_CHANCTX_CHANGE_PUNCTURING = BIT(5), IEEE80211_CHANCTX_CHANGE_MIN_DEF = BIT(6), + IEEE80211_CHANCTX_CHANGE_AP = BIT(7), }; enum ieee80211_frame_release_type { diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h b/sys/compat/linuxkpi/common/include/linux/netdevice.h index 3b808a4a1749..cf27753bcb80 100644 --- a/sys/compat/linuxkpi/common/include/linux/netdevice.h +++ b/sys/compat/linuxkpi/common/include/linux/netdevice.h @@ -486,6 +486,21 @@ netdev_priv(const struct net_device *ndev) } /* -------------------------------------------------------------------------- */ + +static __inline void +netif_device_attach(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); +} + +static __inline void +netif_device_detach(struct net_device *ndev) +{ + pr_debug("%s: TODO\n", __func__); +} + + +/* -------------------------------------------------------------------------- */ /* This is really rtnetlink and probably belongs elsewhere. */ #define rtnl_lock() do { } while(0) diff --git a/sys/compat/linuxkpi/common/include/linux/nl80211.h b/sys/compat/linuxkpi/common/include/linux/nl80211.h index f3979d3a2abc..845ffec4bcba 100644 --- a/sys/compat/linuxkpi/common/include/linux/nl80211.h +++ b/sys/compat/linuxkpi/common/include/linux/nl80211.h @@ -50,6 +50,7 @@ enum nl80211_feature_flags { NL80211_FEATURE_WFA_TPC_IE_IN_PROBES = BIT(15), NL80211_FEATURE_AP_SCAN = BIT(16), NL80211_FEATURE_ACTIVE_MONITOR = BIT(17), + NL80211_FEATURE_SAE = BIT(18), }; enum nl80211_pmsr_ftm_failure_flags { @@ -85,6 +86,7 @@ enum nl80211_reg_rule_flags { NL80211_RRF_NO_6GHZ_AFC_CLIENT = BIT(15), NL80211_RRF_PSD = BIT(16), NL80211_RRF_ALLOW_6GHZ_VLP_AP = BIT(17), + NL80211_RRF_ALLOW_20MHZ_ACTIVITY = BIT(18), }; #define NL80211_RRF_NO_HT40 (NL80211_RRF_NO_HT40MINUS|NL80211_RRF_NO_HT40PLUS) @@ -434,6 +436,14 @@ enum nl80211_hidden_ssid { NL80211_HIDDEN_SSID_NOT_IN_USE, }; +enum nl80211_external_auth_action { + NL80211_EXTERNAL_AUTH_START, +}; + +enum nl80211_rxmgmt_flags { + NL80211_RXMGMT_FLAG_EXTERNAL_AUTH = BIT(1), +}; + #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16 #define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24 diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index ffc2be600c22..06336bf963d6 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -832,6 +832,19 @@ lkpi_pci_restore_state(struct pci_dev *pdev) #define pci_restore_state(dev) lkpi_pci_restore_state(dev) static inline int +linuxkpi_pci_enable_wake(struct pci_dev *pdev, pci_power_t state, bool ena) +{ + /* + * We do not currently support this in device.h either to + * check if the device is allowed to wake up in first place. + */ + pr_debug("%s: TODO\n", __func__); + return (0); +} +#define pci_enable_wake(dev, state, ena) \ + linuxkpi_pci_enable_wake(dev, state, ena) + +static inline int pci_reset_function(struct pci_dev *pdev) { diff --git a/sys/compat/linuxkpi/common/include/linux/platform_device.h b/sys/compat/linuxkpi/common/include/linux/platform_device.h index 6853e709cb70..dba79f5936cc 100644 --- a/sys/compat/linuxkpi/common/include/linux/platform_device.h +++ b/sys/compat/linuxkpi/common/include/linux/platform_device.h @@ -39,7 +39,7 @@ struct platform_device { }; struct platform_driver { - int (*remove)(struct platform_device *); + void (*remove)(struct platform_device *); struct device_driver driver; }; diff --git a/sys/compat/linuxkpi/common/include/linux/skbuff.h b/sys/compat/linuxkpi/common/include/linux/skbuff.h index 6e41c368a8b8..2e560a120e41 100644 --- a/sys/compat/linuxkpi/common/include/linux/skbuff.h +++ b/sys/compat/linuxkpi/common/include/linux/skbuff.h @@ -1159,6 +1159,9 @@ skb_cow_head(struct sk_buff *skb, unsigned int headroom) return (-1); } +/* Misplaced here really but sock comes from skbuff. */ +#define sk_pacing_shift_update(sock, n) + #define SKB_WITH_OVERHEAD(_s) \ (_s) - ALIGN(sizeof(struct skb_shared_info), CACHE_LINE_SIZE) diff --git a/sys/compat/linuxkpi/common/include/linux/soc/mediatek/mtk_wed.h b/sys/compat/linuxkpi/common/include/linux/soc/mediatek/mtk_wed.h index 903053e7f6e8..9f3a1ee4c139 100644 --- a/sys/compat/linuxkpi/common/include/linux/soc/mediatek/mtk_wed.h +++ b/sys/compat/linuxkpi/common/include/linux/soc/mediatek/mtk_wed.h @@ -1,54 +1,36 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2022-2023 Bjoern A. Zeeb - * - * 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. + * Copyright (c) 2022-2025 Bjoern A. Zeeb * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR 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. + * SPDX-License-Identifier: BSD-2-Clause */ #ifndef _LINUXKPI_LINUX_SOC_MEDIATEK_MTK_WED_H #define _LINUXKPI_LINUX_SOC_MEDIATEK_MTK_WED_H +#include <linux/kernel.h> /* pr_debug */ + struct mtk_wed_device { }; #define WED_WO_STA_REC 0x6 -#define mtk_wed_device_start(_dev, _mask) do { } while(0) -#define mtk_wed_device_detach(_dev) do { } while(0) +#define mtk_wed_device_start(_dev, _mask) do { pr_debug("%s: TODO\n", __func__); } while(0) +#define mtk_wed_device_detach(_dev) do { pr_debug("%s: TODO\n", __func__); } while(0) #define mtk_wed_device_irq_get(_dev, _mask) 0 -#define mtk_wed_device_irq_set_mask(_dev, _mask) do { } while(0) -#define mtk_wed_device_update_msg(_dev, _id, _msg, _len) (-ENODEV) -#define mtk_wed_device_dma_reset(_dev) do {} while (0) +#define mtk_wed_device_irq_set_mask(_dev, _mask) do { pr_debug("%s: TODO\n", __func__); } while(0) +#define mtk_wed_device_update_msg(_dev, _id, _msg, _len) ({ pr_debug("%s: TODO\n", __func__); -ENODEV; }) +#define mtk_wed_device_dma_reset(_dev) do { pr_debug("%s: TODO\n", __func__); } while (0) #define mtk_wed_device_ppe_check(_dev, _skb, _reason, _entry) \ - do {} while (0) -#define mtk_wed_device_stop(_dev) do { } while(0) -#define mtk_wed_device_start_hw_rro(_dev, _mask, _b) do { } while(0) -#define mtk_wed_device_setup_tc(_dev, _ndev, _type, _tdata) (-EOPNOTSUPP) + do { pr_debug("%s: TODO\n", __func__); } while (0) +#define mtk_wed_device_stop(_dev) do { pr_debug("%s: TODO\n", __func__); } while(0) +#define mtk_wed_device_start_hw_rro(_dev, _mask, _b) do { pr_debug("%s: TODO\n", __func__); } while(0) +#define mtk_wed_device_setup_tc(_dev, _ndev, _type, _tdata) ({ pr_debug("%s: TODO\n", __func__); -EOPNOTSUPP; }) static inline bool mtk_wed_device_active(struct mtk_wed_device *dev __unused) { + pr_debug("%s: TODO\n", __func__); return (false); } @@ -56,6 +38,7 @@ static inline bool mtk_wed_get_rx_capa(struct mtk_wed_device *dev __unused) { + pr_debug("%s: TODO\n", __func__); return (false); } diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h index 239b4a5ae7b8..f769cfdd4075 100644 --- a/sys/compat/linuxkpi/common/include/net/cfg80211.h +++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h @@ -56,7 +56,7 @@ extern int linuxkpi_debug_80211; #define D80211_IMPROVE 0x2 #endif #define TODO(fmt, ...) if (linuxkpi_debug_80211 & D80211_TODO) \ - printf("%s:%d: XXX LKPI80211 TODO " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) + printf("%s:%d: XXX LKPI80211 TODO " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) #define IMPROVE(fmt, ...) if (linuxkpi_debug_80211 & D80211_IMPROVE) \ printf("%s:%d: XXX LKPI80211 IMPROVE " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) @@ -260,6 +260,19 @@ enum ieee80211_vht_opmode { IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4, }; +struct cfg80211_bss_ies { + uint8_t *data; + size_t len; +}; + +struct cfg80211_bss { + /* XXX TODO */ + struct cfg80211_bss_ies *ies; + struct cfg80211_bss_ies *beacon_ies; + uint64_t ts_boottime; + int32_t signal; +}; + struct cfg80211_connect_resp_params { /* XXX TODO */ uint8_t *bssid; @@ -267,7 +280,13 @@ struct cfg80211_connect_resp_params { const uint8_t *resp_ie; uint32_t req_ie_len; uint32_t resp_ie_len; - int status; + int status; + struct { + const uint8_t *addr; + const uint8_t *bssid; + struct cfg80211_bss *bss; + uint16_t status; + } links[IEEE80211_MLD_MAX_NUM_LINKS]; }; struct cfg80211_inform_bss { @@ -284,19 +303,12 @@ struct cfg80211_roam_info { uint32_t req_ie_len; uint32_t resp_ie_len; struct linuxkpi_ieee80211_channel *channel; -}; - -struct cfg80211_bss_ies { - uint8_t *data; - size_t len; -}; - -struct cfg80211_bss { - /* XXX TODO */ - struct cfg80211_bss_ies *ies; - struct cfg80211_bss_ies *beacon_ies; - - int32_t signal; + struct { + const uint8_t *addr; + const uint8_t *bssid; + struct cfg80211_bss *bss; + struct linuxkpi_ieee80211_channel *channel; + } links[IEEE80211_MLD_MAX_NUM_LINKS]; }; struct cfg80211_chan_def { @@ -404,6 +416,7 @@ struct cfg80211_scan_request { bool no_cck; bool scan_6ghz; bool duration_mandatory; + bool first_part; int8_t tsf_report_link_id; uint16_t duration; uint32_t flags; @@ -463,6 +476,24 @@ struct cfg80211_beacon_data { uint32_t assocresp_ies_len; }; +struct cfg80211_ap_update { + /* XXX TODO */ + struct cfg80211_beacon_data beacon; +}; + +struct cfg80211_crypto_settings { + /* XXX TODO */ + enum nl80211_wpa_versions wpa_versions; + uint32_t cipher_group; /* WLAN_CIPHER_SUITE_* */ + uint32_t *akm_suites; + uint32_t *ciphers_pairwise; + const uint8_t *sae_pwd; + const uint8_t *psk; + int n_akm_suites; + int n_ciphers_pairwise; + int sae_pwd_len; +}; + struct cfg80211_ap_settings { /* XXX TODO */ int auth_type, beacon_interval, dtim_period, hidden_ssid, inactivity_timeout; @@ -470,6 +501,7 @@ struct cfg80211_ap_settings { size_t ssid_len; struct cfg80211_beacon_data beacon; struct cfg80211_chan_def chandef; + struct cfg80211_crypto_settings crypto; }; struct cfg80211_bss_selection { @@ -484,23 +516,12 @@ struct cfg80211_bss_selection { } param; }; -struct cfg80211_crypto { /* XXX made up name */ - /* XXX TODO */ - enum nl80211_wpa_versions wpa_versions; - uint32_t cipher_group; /* WLAN_CIPHER_SUITE_* */ - uint32_t *akm_suites; - uint32_t *ciphers_pairwise; - const uint8_t *sae_pwd; - const uint8_t *psk; - int n_akm_suites; - int n_ciphers_pairwise; - int sae_pwd_len; -}; - struct cfg80211_connect_params { /* XXX TODO */ struct linuxkpi_ieee80211_channel *channel; + struct linuxkpi_ieee80211_channel *channel_hint; uint8_t *bssid; + uint8_t *bssid_hint; const uint8_t *ie; const uint8_t *ssid; uint32_t ie_len; @@ -509,7 +530,7 @@ struct cfg80211_connect_params { uint32_t key_len; int auth_type, key_idx, privacy, want_1x; struct cfg80211_bss_selection bss_select; - struct cfg80211_crypto crypto; + struct cfg80211_crypto_settings crypto; }; enum bss_param_flags { /* Used as bitflags. XXX FIXME values? */ @@ -538,6 +559,14 @@ struct cfg80211_mgmt_tx_params { int wait; }; +struct cfg80211_external_auth_params { + uint8_t bssid[ETH_ALEN]; + uint16_t status; + enum nl80211_external_auth_action action; + unsigned int key_mgmt_suite; + struct cfg80211_ssid ssid; +}; + struct cfg80211_pmk_conf { /* XXX TODO */ const uint8_t *pmk; @@ -548,6 +577,8 @@ struct cfg80211_pmksa { /* XXX TODO */ const uint8_t *bssid; const uint8_t *pmkid; + const uint8_t *ssid; + size_t ssid_len; }; struct station_del_parameters { @@ -961,6 +992,27 @@ struct cfg80211_set_hw_timestamp { bool enable; }; +struct survey_info { /* net80211::struct ieee80211_channel_survey */ + /* TODO FIXME */ + uint32_t filled; +#define SURVEY_INFO_TIME 0x0001 +#define SURVEY_INFO_TIME_RX 0x0002 +#define SURVEY_INFO_TIME_SCAN 0x0004 +#define SURVEY_INFO_TIME_TX 0x0008 +#define SURVEY_INFO_TIME_BSS_RX 0x0010 +#define SURVEY_INFO_TIME_BUSY 0x0020 +#define SURVEY_INFO_IN_USE 0x0040 +#define SURVEY_INFO_NOISE_DBM 0x0080 + uint32_t noise; + uint64_t time; + uint64_t time_bss_rx; + uint64_t time_busy; + uint64_t time_rx; + uint64_t time_scan; + uint64_t time_tx; + struct linuxkpi_ieee80211_channel *channel; +}; + enum wiphy_vendor_cmd_need_flags { WIPHY_VENDOR_CMD_NEED_NETDEV = 0x01, WIPHY_VENDOR_CMD_NEED_RUNNING = 0x02, @@ -1118,49 +1170,53 @@ struct wireless_dev { struct cfg80211_ops { /* XXX TODO */ struct wireless_dev *(*add_virtual_intf)(struct wiphy *, const char *, unsigned char, enum nl80211_iftype, struct vif_params *); - int (*del_virtual_intf)(struct wiphy *, struct wireless_dev *); - s32 (*change_virtual_intf)(struct wiphy *, struct net_device *, enum nl80211_iftype, struct vif_params *); - s32 (*scan)(struct wiphy *, struct cfg80211_scan_request *); - s32 (*set_wiphy_params)(struct wiphy *, u32); - s32 (*join_ibss)(struct wiphy *, struct net_device *, struct cfg80211_ibss_params *); - s32 (*leave_ibss)(struct wiphy *, struct net_device *); - s32 (*get_station)(struct wiphy *, struct net_device *, const u8 *, struct station_info *); - int (*dump_station)(struct wiphy *, struct net_device *, int, u8 *, struct station_info *); - s32 (*set_tx_power)(struct wiphy *, struct wireless_dev *, enum nl80211_tx_power_setting, s32); - s32 (*get_tx_power)(struct wiphy *, struct wireless_dev *, s32 *); - s32 (*add_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *, struct key_params *); - s32 (*del_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *); - s32 (*get_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *, void *, void(*)(void *, struct key_params *)); - s32 (*set_default_key)(struct wiphy *, struct net_device *, u8, bool, bool); - s32 (*set_default_mgmt_key)(struct wiphy *, struct net_device *, u8); - s32 (*set_power_mgmt)(struct wiphy *, struct net_device *, bool, s32); - s32 (*connect)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *); - s32 (*disconnect)(struct wiphy *, struct net_device *, u16); - s32 (*suspend)(struct wiphy *, struct cfg80211_wowlan *); - s32 (*resume)(struct wiphy *); - s32 (*set_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *); - s32 (*del_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *); - s32 (*flush_pmksa)(struct wiphy *, struct net_device *); - s32 (*start_ap)(struct wiphy *, struct net_device *, struct cfg80211_ap_settings *); - int (*stop_ap)(struct wiphy *, struct net_device *); - s32 (*change_beacon)(struct wiphy *, struct net_device *, struct cfg80211_beacon_data *); - int (*del_station)(struct wiphy *, struct net_device *, struct station_del_parameters *); - int (*change_station)(struct wiphy *, struct net_device *, const u8 *, struct station_parameters *); + int (*del_virtual_intf)(struct wiphy *, struct wireless_dev *); + int (*change_virtual_intf)(struct wiphy *, struct net_device *, enum nl80211_iftype, struct vif_params *); + int (*scan)(struct wiphy *, struct cfg80211_scan_request *); + int (*set_wiphy_params)(struct wiphy *, int, uint32_t); + int (*join_ibss)(struct wiphy *, struct net_device *, struct cfg80211_ibss_params *); + int (*leave_ibss)(struct wiphy *, struct net_device *); + int (*get_station)(struct wiphy *, struct net_device *, const uint8_t *, struct station_info *); + int (*dump_station)(struct wiphy *, struct net_device *, int, uint8_t *, struct station_info *); + int (*set_tx_power)(struct wiphy *, struct wireless_dev *, int, enum nl80211_tx_power_setting, int); + int (*get_tx_power)(struct wiphy *, struct wireless_dev *, int, unsigned int, int *); + int (*add_key)(struct wiphy *, struct net_device *, int, uint8_t, bool, const uint8_t *, struct key_params *); + int (*del_key)(struct wiphy *, struct net_device *, int, uint8_t, bool, const uint8_t *); + int (*get_key)(struct wiphy *, struct net_device *, int, uint8_t, bool, const uint8_t *, void *, void(*)(void *, struct key_params *)); + int (*set_default_key)(struct wiphy *, struct net_device *, int, uint8_t, bool, bool); + int (*set_default_mgmt_key)(struct wiphy *, struct net_device *, int, uint8_t); + int (*set_power_mgmt)(struct wiphy *, struct net_device *, bool, int); + int (*connect)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *); + int (*disconnect)(struct wiphy *, struct net_device *, uint16_t); + int (*suspend)(struct wiphy *, struct cfg80211_wowlan *); + int (*resume)(struct wiphy *); + int (*set_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *); + int (*del_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *); + int (*flush_pmksa)(struct wiphy *, struct net_device *); + int (*start_ap)(struct wiphy *, struct net_device *, struct cfg80211_ap_settings *); + int (*stop_ap)(struct wiphy *, struct net_device *, unsigned int); + int (*change_beacon)(struct wiphy *, struct net_device *, struct cfg80211_ap_update *); + int (*del_station)(struct wiphy *, struct net_device *, struct station_del_parameters *); + int (*change_station)(struct wiphy *, struct net_device *, const uint8_t *, struct station_parameters *); int (*sched_scan_start)(struct wiphy *, struct net_device *, struct cfg80211_sched_scan_request *); - int (*sched_scan_stop)(struct wiphy *, struct net_device *, u64); + int (*sched_scan_stop)(struct wiphy *, struct net_device *, uint64_t); void (*update_mgmt_frame_registrations)(struct wiphy *, struct wireless_dev *, struct mgmt_frame_regs *); - int (*mgmt_tx)(struct wiphy *, struct wireless_dev *, struct cfg80211_mgmt_tx_params *, u64 *); - int (*cancel_remain_on_channel)(struct wiphy *, struct wireless_dev *, u64); - int (*get_channel)(struct wiphy *, struct wireless_dev *, struct cfg80211_chan_def *); - int (*crit_proto_start)(struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, u16); + int (*mgmt_tx)(struct wiphy *, struct wireless_dev *, struct cfg80211_mgmt_tx_params *, uint64_t *); + int (*cancel_remain_on_channel)(struct wiphy *, struct wireless_dev *, uint64_t); + int (*get_channel)(struct wiphy *, struct wireless_dev *, unsigned int, struct cfg80211_chan_def *); + int (*crit_proto_start)(struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, uint16_t); void (*crit_proto_stop)(struct wiphy *, struct wireless_dev *); - int (*tdls_oper)(struct wiphy *, struct net_device *, const u8 *, enum nl80211_tdls_operation); - int (*update_connect_params)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *, u32); - int (*set_pmk)(struct wiphy *, struct net_device *, const struct cfg80211_pmk_conf *); - int (*del_pmk)(struct wiphy *, struct net_device *, const u8 *); - int (*remain_on_channel)(struct wiphy *, struct wireless_dev *, struct linuxkpi_ieee80211_channel *, unsigned int, u64 *); - int (*start_p2p_device)(struct wiphy *, struct wireless_dev *); - void (*stop_p2p_device)(struct wiphy *, struct wireless_dev *); + int (*tdls_oper)(struct wiphy *, struct net_device *, const uint8_t *, enum nl80211_tdls_operation); + int (*update_connect_params)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *, uint32_t); + int (*set_pmk)(struct wiphy *, struct net_device *, const struct cfg80211_pmk_conf *); + int (*del_pmk)(struct wiphy *, struct net_device *, const uint8_t *); + int (*remain_on_channel)(struct wiphy *, struct wireless_dev *, struct linuxkpi_ieee80211_channel *, unsigned int, uint64_t *); + int (*start_p2p_device)(struct wiphy *, struct wireless_dev *); + void (*stop_p2p_device)(struct wiphy *, struct wireless_dev *); + int (*dump_survey)(struct wiphy *, struct net_device *, int, struct survey_info *); + int (*external_auth)(struct wiphy *, struct net_device *, struct cfg80211_external_auth_params *); + int (*set_cqm_rssi_range_config)(struct wiphy *, struct net_device *, int, int); + }; @@ -1179,6 +1235,8 @@ void linuxkpi_wiphy_delayed_work_queue(struct wiphy *, struct wiphy_delayed_work *, unsigned long); void linuxkpi_wiphy_delayed_work_cancel(struct wiphy *, struct wiphy_delayed_work *); +void linuxkpi_wiphy_delayed_work_flush(struct wiphy *, + struct wiphy_delayed_work *); int linuxkpi_regulatory_set_wiphy_regd_sync(struct wiphy *wiphy, struct linuxkpi_ieee80211_regdomain *regd); @@ -1247,6 +1305,21 @@ wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked, /* -------------------------------------------------------------------------- */ +static inline int +cfg80211_register_netdevice(struct net_device *ndev) +{ + TODO(); + return (-ENXIO); +} + +static inline void +cfg80211_unregister_netdevice(struct net_device *ndev) +{ + TODO(); +} + +/* -------------------------------------------------------------------------- */ + static inline struct cfg80211_bss * cfg80211_get_bss(struct wiphy *wiphy, struct linuxkpi_ieee80211_channel *chan, const uint8_t *bssid, const uint8_t *ssid, size_t ssid_len, @@ -1309,15 +1382,15 @@ reg_query_regdb_wmm(uint8_t *alpha2, uint32_t center_freq, return (-ENODATA); } -static __inline const u8 * -cfg80211_find_ie_match(uint32_t f, const u8 *ies, size_t ies_len, - const u8 *match, int x, int y) +static __inline const uint8_t * +cfg80211_find_ie_match(uint32_t f, const uint8_t *ies, size_t ies_len, + const uint8_t *match, int x, int y) { TODO(); return (NULL); } -static __inline const u8 * +static __inline const uint8_t * cfg80211_find_ie(uint8_t eid, const uint8_t *ie, uint32_t ielen) { TODO(); @@ -1339,6 +1412,36 @@ cfg80211_pmsr_report(struct wireless_dev *wdev, TODO(); } +static inline int +nl80211_chan_width_to_mhz(enum nl80211_chan_width width) +{ + switch (width) { + case NL80211_CHAN_WIDTH_5: + return (5); + break; + case NL80211_CHAN_WIDTH_10: + return (10); + break; + case NL80211_CHAN_WIDTH_20_NOHT: + case NL80211_CHAN_WIDTH_20: + return (20); + break; + case NL80211_CHAN_WIDTH_40: + return (40); + break; + case NL80211_CHAN_WIDTH_80: + case NL80211_CHAN_WIDTH_80P80: + return (80); + break; + case NL80211_CHAN_WIDTH_160: + return (160); + break; + case NL80211_CHAN_WIDTH_320: + return (320); + break; + } +} + static inline void cfg80211_chandef_create(struct cfg80211_chan_def *chandef, struct linuxkpi_ieee80211_channel *chan, enum nl80211_channel_type chan_type) @@ -1377,6 +1480,12 @@ cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef) return (false); } +static inline int +cfg80211_chandef_get_width(const struct cfg80211_chan_def *chandef) +{ + return (nl80211_chan_width_to_mhz(chandef->width)); +} + static __inline bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy, const struct cfg80211_chan_def *chandef) { @@ -1688,8 +1797,8 @@ cfg80211_disconnected(struct net_device *ndev, uint16_t reason, } static __inline int -cfg80211_get_p2p_attr(const u8 *ie, u32 ie_len, - enum ieee80211_p2p_attr_ids attr, u8 *p, size_t p_len) +cfg80211_get_p2p_attr(const uint8_t *ie, uint32_t ie_len, + enum ieee80211_p2p_attr_ids attr, uint8_t *p, size_t p_len) { TODO(); return (-1); @@ -1725,13 +1834,13 @@ cfg80211_inform_bss_data(struct wiphy *wiphy, static __inline void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, uint64_t cookie, - const u8 *buf, size_t len, bool ack, gfp_t gfp) + const uint8_t *buf, size_t len, bool ack, gfp_t gfp) { TODO(); } static __inline void -cfg80211_michael_mic_failure(struct net_device *ndev, const uint8_t *addr, +cfg80211_michael_mic_failure(struct net_device *ndev, const uint8_t addr[ETH_ALEN], enum nl80211_key_type key_type, int _x, void *p, gfp_t gfp) { TODO(); @@ -1751,8 +1860,8 @@ cfg80211_del_sta(struct net_device *ndev, const uint8_t *addr, gfp_t gfp) } static __inline void -cfg80211_port_authorized(struct net_device *ndev, const uint8_t *bssid, - gfp_t gfp) +cfg80211_port_authorized(struct net_device *ndev, const uint8_t *addr, + const uint8_t *bitmap, uint8_t len, gfp_t gfp) { TODO(); } @@ -1935,7 +2044,7 @@ cfg80211_background_radar_event(struct wiphy *wiphy, TODO(); } -static __inline const u8 * +static __inline const uint8_t * cfg80211_find_ext_ie(uint8_t eid, const uint8_t *p, size_t len) { TODO(); @@ -2033,6 +2142,14 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype iftype) return (NULL); } +static inline int +cfg80211_external_auth_request(struct net_device *ndev, + struct cfg80211_external_auth_params *params, gfp_t gfp) +{ + TODO(); + return (-ENXIO); +} + static inline uint16_t ieee80211_get_he_6ghz_capa(const struct ieee80211_supported_band *sband, enum nl80211_iftype iftype) @@ -2041,36 +2158,6 @@ ieee80211_get_he_6ghz_capa(const struct ieee80211_supported_band *sband, return (0); } -static inline int -nl80211_chan_width_to_mhz(enum nl80211_chan_width width) -{ - switch (width) { - case NL80211_CHAN_WIDTH_5: - return (5); - break; - case NL80211_CHAN_WIDTH_10: - return (10); - break; - case NL80211_CHAN_WIDTH_20_NOHT: - case NL80211_CHAN_WIDTH_20: - return (20); - break; - case NL80211_CHAN_WIDTH_40: - return (40); - break; - case NL80211_CHAN_WIDTH_80: - case NL80211_CHAN_WIDTH_80P80: - return (80); - break; - case NL80211_CHAN_WIDTH_160: - return (160); - break; - case NL80211_CHAN_WIDTH_320: - return (320); - break; - } -} - static __inline ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file, char *buf, size_t bufsize, const char __user *userbuf, size_t count, @@ -2093,6 +2180,13 @@ wiphy_locked_debugfs_write(struct wiphy *wiphy, struct file *file, return (-ENXIO); } +static inline void +cfg80211_cqm_rssi_notify(struct net_device *dev, + enum nl80211_cqm_rssi_threshold_event rssi_te, int32_t rssi, gfp_t gfp) +{ + TODO(); +} + /* -------------------------------------------------------------------------- */ static inline void @@ -2140,6 +2234,12 @@ wiphy_delayed_work_cancel(struct wiphy *wiphy, struct wiphy_delayed_work *wdwk) linuxkpi_wiphy_delayed_work_cancel(wiphy, wdwk); } +static inline void +wiphy_delayed_work_flush(struct wiphy *wiphy, struct wiphy_delayed_work *wdwk) +{ + linuxkpi_wiphy_delayed_work_flush(wiphy, wdwk); +} + /* -------------------------------------------------------------------------- */ #define wiphy_err(_wiphy, _fmt, ...) \ diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h index 8de03410c6b6..523836b52a40 100644 --- a/sys/compat/linuxkpi/common/include/net/mac80211.h +++ b/sys/compat/linuxkpi/common/include/net/mac80211.h @@ -166,7 +166,7 @@ enum ieee80211_bss_changed { #define WLAN_AKM_SUITE_PSK_SHA256 WLAN_AKM_SUITE(6) /* TDLS 7 */ #define WLAN_AKM_SUITE_SAE WLAN_AKM_SUITE(8) -/* FToSAE 9 */ +#define WLAN_AKM_SUITE_FT_OVER_SAE WLAN_AKM_SUITE(9) /* AP peer key 10 */ /* 802.1x suite B 11 */ /* 802.1x suite B 384 12 */ @@ -857,7 +857,8 @@ struct ieee80211_vif_chanctx_switch { }; struct ieee80211_prep_tx_info { - u16 duration; + uint16_t duration; + uint16_t subtype; bool success; bool was_assoc; int link_id; @@ -904,27 +905,6 @@ struct linuxkpi_ieee80211_tim_ie { }; #define ieee80211_tim_ie linuxkpi_ieee80211_tim_ie -struct survey_info { /* net80211::struct ieee80211_channel_survey */ - /* TODO FIXME */ - uint32_t filled; -#define SURVEY_INFO_TIME 0x0001 -#define SURVEY_INFO_TIME_RX 0x0002 -#define SURVEY_INFO_TIME_SCAN 0x0004 -#define SURVEY_INFO_TIME_TX 0x0008 -#define SURVEY_INFO_TIME_BSS_RX 0x0010 -#define SURVEY_INFO_TIME_BUSY 0x0020 -#define SURVEY_INFO_IN_USE 0x0040 -#define SURVEY_INFO_NOISE_DBM 0x0080 - uint32_t noise; - uint64_t time; - uint64_t time_bss_rx; - uint64_t time_busy; - uint64_t time_rx; - uint64_t time_scan; - uint64_t time_tx; - struct ieee80211_channel *channel; -}; - enum ieee80211_iface_iter { IEEE80211_IFACE_ITER_NORMAL = BIT(0), IEEE80211_IFACE_ITER_RESUME_ALL = BIT(1), @@ -1553,6 +1533,15 @@ ieee80211_iter_chan_contexts_atomic(struct ieee80211_hw *hw, } static __inline void +ieee80211_iter_chan_contexts_mtx(struct ieee80211_hw *hw, + void (*iterfunc)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, void *), + void *arg) +{ + IMPROVE("XXX LKPI80211 TODO MTX\n"); + linuxkpi_ieee80211_iterate_chan_contexts(hw, iterfunc, arg); +} + +static __inline void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, void (*iterfunc)(void *, struct ieee80211_sta *), void *arg) { @@ -2063,7 +2052,7 @@ ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw, struct ieee80211_txq *txq) static __inline void ieee80211_update_mu_groups(struct ieee80211_vif *vif, - u_int _i, uint8_t *ms, uint8_t *up) + u_int link_id, const uint8_t *ms, const uint8_t *up) { TODO(); } diff --git a/sys/compat/linuxkpi/common/include/net/netmem.h b/sys/compat/linuxkpi/common/include/net/netmem.h new file mode 100644 index 000000000000..c8de09a2e8c2 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/net/netmem.h @@ -0,0 +1,21 @@ +/*- + * Copyright (c) 2023-2025 Bjoern A. Zeeb + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#ifndef _LINUXKPI_NET_NETMEM_H +#define _LINUXKPI_NET_NETMEM_H + +struct page_pool; + +struct netmem_desc { + struct page_pool *pp; +}; + +#define pp_page_to_nmdesc(page) \ + (_Generic((page), \ + const struct page *: (const struct netmem_desc *)(page), \ + struct page *: (struct netmem_desc *)(page))) + +#endif /* _LINUXKPI_NET_NETMEM_H */ diff --git a/sys/compat/linuxkpi/common/include/net/page_pool.h b/sys/compat/linuxkpi/common/include/net/page_pool.h deleted file mode 100644 index 2dc8f74b31f3..000000000000 --- a/sys/compat/linuxkpi/common/include/net/page_pool.h +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * Copyright (c) 2023 Bjoern A. Zeeb - * - * 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 THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR 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. - */ - -#ifndef _LINUXKPI_NET_PAGE_POOL_H -#define _LINUXKPI_NET_PAGE_POOL_H - -#include <linux/kernel.h> /* pr_debug */ -#include <linux/types.h> -#include <linux/dma-mapping.h> -#include <linux/netdevice.h> - -struct device; - -struct page_pool_params { - struct device *dev; - uint32_t flags; - uint32_t order; - uint32_t pool_size; - uint32_t max_len; - uint32_t offset; - int nid; /* NUMA */ - enum dma_data_direction dma_dir; - struct napi_struct *napi; -}; - -struct page_pool { -}; - -#define PP_FLAG_DMA_MAP BIT(0) -#define PP_FLAG_DMA_SYNC_DEV BIT(1) -#define PP_FLAG_PAGE_FRAG BIT(2) - -static inline struct page_pool * -page_pool_create(const struct page_pool_params *ppparams) -{ - - pr_debug("%s: TODO\n", __func__); - return (NULL); -} - -static inline void -page_pool_destroy(struct page_pool *ppool) -{ - - pr_debug("%s: TODO\n", __func__); -} - -static inline struct page * -page_pool_dev_alloc_frag(struct page_pool *ppool, uint32_t *offset, - size_t size) -{ - - pr_debug("%s: TODO\n", __func__); - return (NULL); -} - -static inline dma_addr_t -page_pool_get_dma_addr(struct page *page) -{ - - pr_debug("%s: TODO\n", __func__); - return (0); -} - -static inline enum dma_data_direction -page_pool_get_dma_dir(const struct page_pool *ppool) -{ - - pr_debug("%s: TODO\n", __func__); - return (DMA_BIDIRECTIONAL); -} - -static inline void -page_pool_put_full_page(struct page_pool *ppool, struct page *page, - bool allow_direct) -{ - - pr_debug("%s: TODO\n", __func__); -} - -static inline int -page_pool_ethtool_stats_get_count(void) -{ - - pr_debug("%s: TODO\n", __func__); - return (0); -} - -static inline uint8_t * -page_pool_ethtool_stats_get_strings(uint8_t *x) -{ - - pr_debug("%s: TODO\n", __func__); - return (x); -} - -#endif /* _LINUXKPI_NET_PAGE_POOL_H */ diff --git a/sys/compat/linuxkpi/common/include/net/page_pool/helpers.h b/sys/compat/linuxkpi/common/include/net/page_pool/helpers.h new file mode 100644 index 000000000000..3469c39c7757 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/net/page_pool/helpers.h @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2023-2025 Bjoern A. Zeeb + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#ifndef _LINUXKPI_NET_PAGE_POOL_HELPERS_H +#define _LINUXKPI_NET_PAGE_POOL_HELPERS_H + +#include <linux/kernel.h> /* pr_debug */ +#include <linux/types.h> +#include <linux/dma-mapping.h> +#include <net/page_pool/types.h> + +static inline struct page_pool * +page_pool_create(const struct page_pool_params *ppparams) +{ + + pr_debug("%s: TODO\n", __func__); + return (NULL); +} + +static inline void +page_pool_destroy(struct page_pool *ppool) +{ + + pr_debug("%s: TODO\n", __func__); +} + +static inline struct page * +page_pool_dev_alloc_frag(struct page_pool *ppool, uint32_t *offset, + size_t size) +{ + + pr_debug("%s: TODO\n", __func__); + return (NULL); +} + +static inline dma_addr_t +page_pool_get_dma_addr(struct page *page) +{ + + pr_debug("%s: TODO\n", __func__); + return (0); +} + +static inline enum dma_data_direction +page_pool_get_dma_dir(const struct page_pool *ppool) +{ + + pr_debug("%s: TODO\n", __func__); + return (DMA_BIDIRECTIONAL); +} + +static inline void +page_pool_put_full_page(struct page_pool *ppool, struct page *page, + bool allow_direct) +{ + + pr_debug("%s: TODO\n", __func__); +} + +static inline int +page_pool_ethtool_stats_get_count(void) +{ + + pr_debug("%s: TODO\n", __func__); + return (0); +} + +static inline uint8_t * +page_pool_ethtool_stats_get_strings(uint8_t *x) +{ + + pr_debug("%s: TODO\n", __func__); + return (x); +} + +#endif /* _LINUXKPI_NET_PAGE_POOL_HELPERS_H */ diff --git a/sys/compat/linuxkpi/common/include/net/page_pool/types.h b/sys/compat/linuxkpi/common/include/net/page_pool/types.h new file mode 100644 index 000000000000..6747be50b9b2 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/net/page_pool/types.h @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2023-2025 Bjoern A. Zeeb + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#ifndef _LINUXKPI_NET_PAGE_POOL_TYPES_H +#define _LINUXKPI_NET_PAGE_POOL_TYPES_H + +#include <linux/types.h> +#include <linux/dma-mapping.h> +#include <net/netmem.h> + +struct device; +struct napi_struct; + +struct page_pool_params { + struct device *dev; + uint32_t flags; + uint32_t order; + uint32_t pool_size; + uint32_t max_len; + uint32_t offset; + int nid; /* NUMA */ + enum dma_data_direction dma_dir; + struct napi_struct *napi; +}; + +struct page_pool { +}; + +#define PP_FLAG_DMA_MAP BIT(0) +#define PP_FLAG_DMA_SYNC_DEV BIT(1) +#define PP_FLAG_PAGE_FRAG BIT(2) + +#endif /* _LINUXKPI_NET_PAGE_POOL_TYPES_H */ diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index bc4b334de28e..0dc3b2631804 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -7833,7 +7833,7 @@ lkpi_wiphy_delayed_work_timer(struct timer_list *tl) struct wiphy_delayed_work *wdwk; wdwk = timer_container_of(wdwk, tl, timer); - wiphy_work_queue(wdwk->wiphy, &wdwk->work); + wiphy_work_queue(wdwk->wiphy, &wdwk->work); } void @@ -7858,6 +7858,16 @@ linuxkpi_wiphy_delayed_work_cancel(struct wiphy *wiphy, wiphy_work_cancel(wiphy, &wdwk->work); } +void +linuxkpi_wiphy_delayed_work_flush(struct wiphy *wiphy, + struct wiphy_delayed_work *wdwk) +{ + lockdep_assert_held(&wiphy->mtx); + + del_timer_sync(&wdwk->timer); + wiphy_work_flush(wiphy, &wdwk->work); +} + /* -------------------------------------------------------------------------- */ struct wiphy * diff --git a/sys/compat/linuxkpi/common/src/linux_80211_macops.c b/sys/compat/linuxkpi/common/src/linux_80211_macops.c index 1046b753574f..04f9f6d7e7fc 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211_macops.c +++ b/sys/compat/linuxkpi/common/src/linux_80211_macops.c @@ -42,7 +42,7 @@ if (linuxkpi_debug_80211 & D80211_TRACE_MO) \ printf("LKPI_80211_TRACE_MO %s:%d: %d %d %lu: " fmt "\n", \ __func__, __LINE__, curcpu, curthread->td_tid, \ - jiffies, __VA_ARGS__) + jiffies, ##__VA_ARGS__) #else #define LKPI_80211_TRACE_MO(...) do { } while(0) #endif diff --git a/sys/dev/vmm/vmm_dev.c b/sys/dev/vmm/vmm_dev.c index 4961b21180e1..ebbceb25b69e 100644 --- a/sys/dev/vmm/vmm_dev.c +++ b/sys/dev/vmm/vmm_dev.c @@ -14,6 +14,7 @@ #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/mman.h> +#include <sys/priv.h> #include <sys/proc.h> #include <sys/queue.h> #include <sys/sx.h> @@ -470,6 +471,12 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, if (ioctl == NULL) return (ENOTTY); + if ((ioctl->flags & VMMDEV_IOCTL_PRIV_CHECK_DRIVER) != 0) { + error = priv_check(td, PRIV_DRIVER); + if (error != 0) + return (error); + } + if ((ioctl->flags & VMMDEV_IOCTL_XLOCK_MEMSEGS) != 0) vm_xlock_memsegs(sc->vm); else if ((ioctl->flags & VMMDEV_IOCTL_SLOCK_MEMSEGS) != 0) @@ -656,10 +663,10 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, error = EINVAL; break; } - regvals = malloc(sizeof(regvals[0]) * vmregset->count, M_VMMDEV, - M_WAITOK); - regnums = malloc(sizeof(regnums[0]) * vmregset->count, M_VMMDEV, - M_WAITOK); + regvals = mallocarray(vmregset->count, sizeof(regvals[0]), + M_VMMDEV, M_WAITOK); + regnums = mallocarray(vmregset->count, sizeof(regnums[0]), + M_VMMDEV, M_WAITOK); error = copyin(vmregset->regnums, regnums, sizeof(regnums[0]) * vmregset->count); if (error == 0) @@ -682,10 +689,10 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, error = EINVAL; break; } - regvals = malloc(sizeof(regvals[0]) * vmregset->count, M_VMMDEV, - M_WAITOK); - regnums = malloc(sizeof(regnums[0]) * vmregset->count, M_VMMDEV, - M_WAITOK); + regvals = mallocarray(vmregset->count, sizeof(regvals[0]), + M_VMMDEV, M_WAITOK); + regnums = mallocarray(vmregset->count, sizeof(regnums[0]), + M_VMMDEV, M_WAITOK); error = copyin(vmregset->regnums, regnums, sizeof(regnums[0]) * vmregset->count); if (error == 0) diff --git a/sys/dev/vmm/vmm_dev.h b/sys/dev/vmm/vmm_dev.h index 410066c49cf2..2881a7063565 100644 --- a/sys/dev/vmm/vmm_dev.h +++ b/sys/dev/vmm/vmm_dev.h @@ -44,6 +44,7 @@ struct vmmdev_ioctl { #define VMMDEV_IOCTL_LOCK_ALL_VCPUS 0x08 #define VMMDEV_IOCTL_ALLOC_VCPU 0x10 #define VMMDEV_IOCTL_MAYBE_ALLOC_VCPU 0x20 +#define VMMDEV_IOCTL_PRIV_CHECK_DRIVER 0x40 int flags; }; diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 00732d55cd46..267b60ffb5bc 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -1088,6 +1088,7 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) else { if (!(flags & (JAIL_USE_DESC | JAIL_AT_DESC | JAIL_GET_DESC | JAIL_OWN_DESC))) { + error = EINVAL; vfs_opterror(opts, "unexpected desc"); goto done_errmsg; } @@ -2518,6 +2519,7 @@ kern_jail_get(struct thread *td, struct uio *optuio, int flags) } else if (error == 0) { if (!(flags & (JAIL_USE_DESC | JAIL_AT_DESC | JAIL_GET_DESC | JAIL_OWN_DESC))) { + error = EINVAL; vfs_opterror(opts, "unexpected desc"); goto done; } diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index 03184c1fb678..f3a8410a2258 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -2533,7 +2533,7 @@ vxlan_encap4(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, ifp = sc->vxl_ifp; srcaddr = sc->vxl_src_addr.in4.sin_addr; - srcport = vxlan_pick_source_port(sc, m); + srcport = htons(vxlan_pick_source_port(sc, m)); dstaddr = fvxlsa->in4.sin_addr; dstport = fvxlsa->in4.sin_port; @@ -2644,7 +2644,7 @@ vxlan_encap6(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa, ifp = sc->vxl_ifp; srcaddr = &sc->vxl_src_addr.in6.sin6_addr; - srcport = vxlan_pick_source_port(sc, m); + srcport = htons(vxlan_pick_source_port(sc, m)); dstaddr = &fvxlsa->in6.sin6_addr; dstport = fvxlsa->in6.sin6_port; diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c index 4c9b1fa53f7a..24b4be89af48 100644 --- a/sys/riscv/vmm/vmm.c +++ b/sys/riscv/vmm/vmm.c @@ -954,8 +954,7 @@ vcpu_get_state(struct vcpu *vcpu, int *hostcpu) int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval) { - - if (reg >= VM_REG_LAST) + if (reg < 0 || reg >= VM_REG_LAST) return (EINVAL); return (vmmops_getreg(vcpu->cookie, reg, retval)); @@ -966,7 +965,7 @@ vm_set_register(struct vcpu *vcpu, int reg, uint64_t val) { int error; - if (reg >= VM_REG_LAST) + if (reg < 0 || reg >= VM_REG_LAST) return (EINVAL); error = vmmops_setreg(vcpu->cookie, reg, val); if (error || reg != VM_REG_GUEST_SEPC) diff --git a/sys/riscv/vmm/vmm_dev_machdep.c b/sys/riscv/vmm/vmm_dev_machdep.c index ba15d8dcd79e..c736b10dc9c0 100644 --- a/sys/riscv/vmm/vmm_dev_machdep.c +++ b/sys/riscv/vmm/vmm_dev_machdep.c @@ -67,18 +67,13 @@ int vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, int fflag, struct thread *td) { - struct vm_run *vmrun; - struct vm_aplic_descr *aplic; - struct vm_irq *vi; - struct vm_exception *vmexc; - struct vm_gla2gpa *gg; - struct vm_msi *vmsi; int error; error = 0; switch (cmd) { case VM_RUN: { struct vm_exit *vme; + struct vm_run *vmrun; vmrun = (struct vm_run *)data; vme = vm_exitinfo(vcpu); @@ -90,34 +85,52 @@ vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, caddr_t data, error = copyout(vme, vmrun->vm_exit, sizeof(*vme)); break; } - case VM_INJECT_EXCEPTION: + case VM_INJECT_EXCEPTION: { + struct vm_exception *vmexc; + vmexc = (struct vm_exception *)data; error = vm_inject_exception(vcpu, vmexc->scause); break; - case VM_GLA2GPA_NOFAULT: + } + case VM_GLA2GPA_NOFAULT: { + struct vm_gla2gpa *gg; + gg = (struct vm_gla2gpa *)data; error = vm_gla2gpa_nofault(vcpu, &gg->paging, gg->gla, gg->prot, &gg->gpa, &gg->fault); KASSERT(error == 0 || error == EFAULT, ("%s: vm_gla2gpa unknown error %d", __func__, error)); break; - case VM_ATTACH_APLIC: + } + case VM_ATTACH_APLIC: { + struct vm_aplic_descr *aplic; + aplic = (struct vm_aplic_descr *)data; error = vm_attach_aplic(vm, aplic); break; - case VM_RAISE_MSI: + } + case VM_RAISE_MSI: { + struct vm_msi *vmsi; + vmsi = (struct vm_msi *)data; error = vm_raise_msi(vm, vmsi->msg, vmsi->addr, vmsi->bus, vmsi->slot, vmsi->func); break; - case VM_ASSERT_IRQ: + } + case VM_ASSERT_IRQ: { + struct vm_irq *vi; + vi = (struct vm_irq *)data; error = vm_assert_irq(vm, vi->irq); break; - case VM_DEASSERT_IRQ: + } + case VM_DEASSERT_IRQ: { + struct vm_irq *vi; + vi = (struct vm_irq *)data; error = vm_deassert_irq(vm, vi->irq); break; + } default: error = ENOTTY; break; diff --git a/sys/sys/ata.h b/sys/sys/ata.h index 5e9c2bcb9aa0..9ce822214f6d 100644 --- a/sys/sys/ata.h +++ b/sys/sys/ata.h @@ -347,8 +347,11 @@ struct ata_params { #define ATA_STATUS_BUSY 0x80 /* ATA Error Register */ +/* COMMAND TIMEOUT 0x01 */ #define ATA_ERROR_ABORT 0x04 #define ATA_ERROR_ID_NOT_FOUND 0x10 +/* UNCORRECTABLE ERROR 0x40 */ +/* INTERFACE CRC 0x80 */ /* ATA HPA Features */ #define ATA_HPA_FEAT_MAX_ADDR 0x00 diff --git a/sys/sys/param.h b/sys/sys/param.h index 8a71693cff3d..7cfa3c6aa4a8 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -74,7 +74,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1600001 +#define __FreeBSD_version 1600002 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, |