git: ad7741ff693a - main - ibcore: Fix possible memory leak in ib_mad_post_receive_mads()

2022-05-19 Thread Hans Petter Selasky
The branch main has been updated by hselasky:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ad7741ff693a39bab59b75e432bd922a62f3ef0a

commit ad7741ff693a39bab59b75e432bd922a62f3ef0a
Author: Hans Petter Selasky 
AuthorDate: 2022-05-19 08:06:42 +
Commit: Hans Petter Selasky 
CommitDate: 2022-05-19 08:13:06 +

ibcore: Fix possible memory leak in ib_mad_post_receive_mads()

If ib_dma_mapping_error() returns non-zero value,
ib_mad_post_receive_mads() will jump out of loops and return -ENOMEM
without freeing mad_priv. Fix this memory-leak problem by freeing
mad_priv in this case.

Linux commit:
a17f4bed811c60712d8131883cdba11a105d0161

PR: 264057
MFC after:  1 week
Sponsored by:   NVIDIA Networking
---
 sys/ofed/drivers/infiniband/core/ib_mad.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/ofed/drivers/infiniband/core/ib_mad.c 
b/sys/ofed/drivers/infiniband/core/ib_mad.c
index 5f9c353052e8..9de97d749f6d 100644
--- a/sys/ofed/drivers/infiniband/core/ib_mad.c
+++ b/sys/ofed/drivers/infiniband/core/ib_mad.c
@@ -2874,6 +2874,7 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info 
*qp_info,
 DMA_FROM_DEVICE);
if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device,
  sg_list.addr))) {
+   kfree(mad_priv);
ret = -ENOMEM;
break;
}



git: 527762b2f776 - main - mlx4: Fix a memory leak bug.

2022-05-19 Thread Hans Petter Selasky
The branch main has been updated by hselasky:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=527762b2f776381569bd662ce236d2845234c0a7

commit 527762b2f776381569bd662ce236d2845234c0a7
Author: Hans Petter Selasky 
AuthorDate: 2022-05-19 08:10:48 +
Commit: Hans Petter Selasky 
CommitDate: 2022-05-19 08:13:06 +

mlx4: Fix a memory leak bug.

In function mlx4_opreq_action(), pointer "mailbox" is not released,
when mlx4_cmd_box() return and error, causing a memory leak bug.
Fix this issue by going to "out" label, mlx4_free_cmd_mailbox() can
free this pointer.

Linux commit:
febfd9d3c7f74063e8e630b15413ca91b567f963

PR: 264056
MFC after:  1 week
Sponsored by:   NVIDIA Networking
---
 sys/dev/mlx4/mlx4_core/mlx4_fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/mlx4/mlx4_core/mlx4_fw.c b/sys/dev/mlx4/mlx4_core/mlx4_fw.c
index 68aa7e76c79d..de83a3bf5a76 100644
--- a/sys/dev/mlx4/mlx4_core/mlx4_fw.c
+++ b/sys/dev/mlx4/mlx4_core/mlx4_fw.c
@@ -2702,7 +2702,7 @@ void mlx4_opreq_action(struct work_struct *work)
if (err) {
mlx4_err(dev, "Failed to retrieve required operation: 
%d\n",
 err);
-   return;
+   goto out;
}
MLX4_GET(modifier, outbox, GET_OP_REQ_MODIFIER_OFFSET);
MLX4_GET(token, outbox, GET_OP_REQ_TOKEN_OFFSET);



git: 190abf86bb45 - main - Fix the name of Makefile.aarch64

2022-05-19 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=190abf86bb455a5b423ca46d309c4492a2d41a94

commit 190abf86bb455a5b423ca46d309c4492a2d41a94
Author: Andrew Turner 
AuthorDate: 2022-05-12 12:50:59 +
Commit: Andrew Turner 
CommitDate: 2022-05-19 10:30:21 +

Fix the name of Makefile.aarch64

Makefile.arm64 relies on being included via Makefile.${MACHINE}. This
only works when arm64 is the only aarch64 architecture. Switch to
Makefile.aarch64 so downstream CheriBSD can use the file when building
for Morello which uses a differen ${MACHINE} value.

Sponsored by:   Innovate UK
---
 usr.sbin/{Makefile.arm64 => Makefile.aarch64} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/usr.sbin/Makefile.arm64 b/usr.sbin/Makefile.aarch64
similarity index 100%
rename from usr.sbin/Makefile.arm64
rename to usr.sbin/Makefile.aarch64



git: 11a6ecd4258b - main - Handle cas failure when the compare succeeds

2022-05-19 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=11a6ecd4258b9108fb19420ec5db297f6d99a842

commit 11a6ecd4258b9108fb19420ec5db297f6d99a842
Author: Andrew Turner 
AuthorDate: 2022-05-09 14:28:56 +
Commit: Andrew Turner 
CommitDate: 2022-05-19 10:30:21 +

Handle cas failure when the compare succeeds

When locking a priority inherit mutex we perform a compare and swap
operation to try and acquire the mutex. This may fail even when the
compare succeeds.

Check and handle this case.

PR: 263825
Reviewed by:kib, markj
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35150
---
 sys/kern/kern_umtx.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 2f666bdcdc7b..d63381d76eb8 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -2262,6 +2262,17 @@ do_lock_pi(struct thread *td, struct umutex *m, uint32_t 
flags,
break;
}
 
+   /*
+* Nobody owns it, but the acquire failed. This can happen
+* with ll/sc atomics.
+*/
+   if (owner == UMUTEX_UNOWNED) {
+   error = thread_check_susp(td, true);
+   if (error != 0)
+   break;
+   continue;
+   }
+
/*
 * Avoid overwriting a possible error from sleep due
 * to the pending signal with suspension check result.



git: 88ac318759f2 - main - Support LSE atomics in the arm64 casue* functions

2022-05-19 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=88ac318759f28f34aa991ecc6f336326ec00c501

commit 88ac318759f28f34aa991ecc6f336326ec00c501
Author: Andrew Turner 
AuthorDate: 2022-05-17 13:52:30 +
Commit: Andrew Turner 
CommitDate: 2022-05-19 10:30:21 +

Support LSE atomics in the arm64 casue* functions

As with atomic(9) use the ARMv8.1 Large System Extension atomic
instructions to implement the userspace compare and swap functions.

Reviewed by:kib
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35234
---
 sys/arm64/arm64/support.S   | 52 +++-
 sys/arm64/arm64/support_ifunc.c | 58 +
 sys/conf/files.arm64|  1 +
 3 files changed, 105 insertions(+), 6 deletions(-)

diff --git a/sys/arm64/arm64/support.S b/sys/arm64/arm64/support.S
index 4771814a9b45..885af5676159 100644
--- a/sys/arm64/arm64/support.S
+++ b/sys/arm64/arm64/support.S
@@ -56,9 +56,9 @@ fsu_fault_nopcb:
 END(fsu_fault)
 
 /*
- * int casueword32(volatile uint32_t *, uint32_t, uint32_t *, uint32_t)
+ * int casueword32_llsc(volatile uint32_t *, uint32_t, uint32_t *, uint32_t)
  */
-ENTRY(casueword32)
+ENTRY(casueword32_llsc)
check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb
adr x6, fsu_fault   /* Load the fault handler */
mov w5, #1
@@ -73,12 +73,32 @@ ENTRY(casueword32)
str w4, [x2]/* Store the read data */
mov w0, w5  /* Result same as store status */
ret /* Return */
-END(casueword32)
+END(casueword32_llsc)
 
 /*
- * int casueword(volatile u_long *, u_long, u_long *, u_long)
+ * int casueword32_lse(volatile uint32_t *, uint32_t, uint32_t *, uint32_t)
  */
-ENTRY(casueword)
+ENTRY(casueword32_lse)
+   check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb
+   adr x6, fsu_fault   /* Load the fault handler */
+   SET_FAULT_HANDLER(x6, x4)   /* And set it */
+   ENTER_USER_ACCESS(w6, x4)
+   mov w7, w1  /* Back up the compare value */
+   .arch_extension lse
+   cas w1, w3, [x0]/* Compare and Swap */
+   .arch_extension nolse
+   cmp w1, w7  /* Check if successful */
+   csetw0, ne  /* Return 0 on success, 1 on failure */
+   EXIT_USER_ACCESS(w6)
+   SET_FAULT_HANDLER(xzr, x6)  /* Reset the fault handler */
+   str w1, [x2]/* Store the read data */
+   ret /* Return */
+END(casueword32_lse)
+
+/*
+ * int casueword_llsc(volatile u_long *, u_long, u_long *, u_long)
+ */
+ENTRY(casueword_llsc)
check_user_access 0, (VM_MAXUSER_ADDRESS-7), fsu_fault_nopcb
adr x6, fsu_fault   /* Load the fault handler */
mov w5, #1
@@ -93,7 +113,27 @@ ENTRY(casueword)
str x4, [x2]/* Store the read data */
mov w0, w5  /* Result same as store status */
ret /* Return */
-END(casueword)
+END(casueword_llsc)
+
+/*
+ * int casueword_lse(volatile u_long *, u_long, u_long *, u_long)
+ */
+ENTRY(casueword_lse)
+   check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb
+   adr x6, fsu_fault   /* Load the fault handler */
+   SET_FAULT_HANDLER(x6, x4)   /* And set it */
+   ENTER_USER_ACCESS(w6, x4)
+   mov x7, x1  /* Back up the compare value */
+   .arch_extension lse
+   cas x1, x3, [x0]/* Compare and Swap */
+   .arch_extension nolse
+   cmp x1, x7  /* Check if successful */
+   csetw0, ne  /* Return 0 on success, 1 on failure */
+   EXIT_USER_ACCESS(w6)
+   SET_FAULT_HANDLER(xzr, x6)  /* Reset the fault handler */
+   str x1, [x2]/* Store the read data */
+   ret /* Return */
+END(casueword_lse)
 
 .macro fsudata insn, ret_reg, user_arg
adr x7, fsu_fault   /* Load the fault handler */
diff --git a/sys/arm64/arm64/support_ifunc.c b/sys/arm64/arm64/support_ifunc.c
new file mode 100644
index ..8abf3f3c75af
--- /dev/null
+++ b/sys/arm64/arm64/support_ifunc.c
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Andrew Turner under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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 for

git: f9ca52bab510 - main - Use getpagesize in gcore to find the page size

2022-05-19 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f9ca52bab510ff97c6a3c513ddce698a0d19934c

commit f9ca52bab510ff97c6a3c513ddce698a0d19934c
Author: Andrew Turner 
AuthorDate: 2022-05-13 11:56:14 +
Commit: Andrew Turner 
CommitDate: 2022-05-19 10:32:26 +

Use getpagesize in gcore to find the page size

Reviewed by:markj
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35194
---
 usr.bin/gcore/elfcore.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c
index 1fcd14698a9e..6ef1f31d28cd 100644
--- a/usr.bin/gcore/elfcore.c
+++ b/usr.bin/gcore/elfcore.c
@@ -234,7 +234,7 @@ elf_coredump(int efd, int fd, pid_t pid)
/* Put notes. */
elf_putnotes(pid, sb, ¬esz);
/* Align up to a page boundary for the program segments. */
-   sbuf_end_section(sb, -1, PAGE_SIZE, 0);
+   sbuf_end_section(sb, -1, getpagesize(), 0);
if (sbuf_finish(sb) != 0)
err(1, "sbuf_finish");
hdr = sbuf_data(sb);
@@ -295,15 +295,17 @@ cb_put_phdr(struct map_entry *entry, void *closure)
 {
struct phdr_closure *phc = (struct phdr_closure *)closure;
Elf_Phdr *phdr = phc->phdr;
+   size_t page_size;
 
-   phc->offset = round_page(phc->offset);
+   page_size = getpagesize();
+   phc->offset = roundup2(phc->offset, page_size);
 
phdr->p_type = PT_LOAD;
phdr->p_offset = phc->offset;
phdr->p_vaddr = entry->start;
phdr->p_paddr = 0;
phdr->p_filesz = phdr->p_memsz = entry->end - entry->start;
-   phdr->p_align = PAGE_SIZE;
+   phdr->p_align = page_size;
phdr->p_flags = 0;
if (entry->protection & VM_PROT_READ)
phdr->p_flags |= PF_R;



git: 20feb7838da5 - stable/13 - ssh: update sshd_config for prohibit-password option

2022-05-19 Thread Ed Maste
The branch stable/13 has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=20feb7838da56a9ddef83042133a89ded8ee5b13

commit 20feb7838da56a9ddef83042133a89ded8ee5b13
Author: Ed Maste 
AuthorDate: 2022-05-10 14:08:21 +
Commit: Ed Maste 
CommitDate: 2022-05-19 11:36:10 +

ssh: update sshd_config for prohibit-password option

The PermitRootLogin option "prohibit-password" was added as a synonym
for "without-password" in 2015.  Then in 2017 these were swapped:
"prohibit-password" became the canonical option and "without-password"
became a deprecated synonym (in OpenSSH commit 071325f458).

The UsePAM description in sshd_config still mentioned
"without-password."  Update it to match the new canonical option.

Sponsored by:   The FreeBSD Foundation
MFC after:  1 week

(cherry picked from commit 0e12eb7b58ae29ccf52571e82af99c3a3a04b399)
---
 crypto/openssh/sshd_config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/openssh/sshd_config b/crypto/openssh/sshd_config
index eb9bdcc437fb..00b6c4366526 100644
--- a/crypto/openssh/sshd_config
+++ b/crypto/openssh/sshd_config
@@ -79,7 +79,7 @@ AuthorizedKeysFile.ssh/authorized_keys
 # be allowed through the KbdInteractiveAuthentication and
 # PasswordAuthentication.  Depending on your PAM configuration,
 # PAM authentication via KbdInteractiveAuthentication may bypass
-# the setting of "PermitRootLogin without-password".
+# the setting of "PermitRootLogin prohibit-password".
 # If you just want the PAM account and session checks to run without
 # PAM authentication, then enable this but set PasswordAuthentication
 # and KbdInteractiveAuthentication to 'no'.



git: d6f9bae2573a - stable/12 - ssh: update sshd_config for prohibit-password option

2022-05-19 Thread Ed Maste
The branch stable/12 has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d6f9bae2573a4439553b169c2568394d47cdc775

commit d6f9bae2573a4439553b169c2568394d47cdc775
Author: Ed Maste 
AuthorDate: 2022-05-10 14:08:21 +
Commit: Ed Maste 
CommitDate: 2022-05-19 11:37:02 +

ssh: update sshd_config for prohibit-password option

The PermitRootLogin option "prohibit-password" was added as a synonym
for "without-password" in 2015.  Then in 2017 these were swapped:
"prohibit-password" became the canonical option and "without-password"
became a deprecated synonym (in OpenSSH commit 071325f458).

The UsePAM description in sshd_config still mentioned
"without-password."  Update it to match the new canonical option.

Sponsored by:   The FreeBSD Foundation
MFC after:  1 week

(cherry picked from commit 0e12eb7b58ae29ccf52571e82af99c3a3a04b399)
---
 crypto/openssh/sshd_config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/openssh/sshd_config b/crypto/openssh/sshd_config
index eb9bdcc437fb..00b6c4366526 100644
--- a/crypto/openssh/sshd_config
+++ b/crypto/openssh/sshd_config
@@ -79,7 +79,7 @@ AuthorizedKeysFile.ssh/authorized_keys
 # be allowed through the KbdInteractiveAuthentication and
 # PasswordAuthentication.  Depending on your PAM configuration,
 # PAM authentication via KbdInteractiveAuthentication may bypass
-# the setting of "PermitRootLogin without-password".
+# the setting of "PermitRootLogin prohibit-password".
 # If you just want the PAM account and session checks to run without
 # PAM authentication, then enable this but set PasswordAuthentication
 # and KbdInteractiveAuthentication to 'no'.



git: 7eb6a92e3f93 - main - jexec man: Explain how PATH is adjusted.

2022-05-19 Thread Gleb Popov
The branch main has been updated by arrowd (ports committer):

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7eb6a92e3f938d419d3edc0399fc4c1d1018da15

commit 7eb6a92e3f938d419d3edc0399fc4c1d1018da15
Author: Gleb Popov 
AuthorDate: 2022-05-19 05:59:41 +
Commit: Gleb Popov 
CommitDate: 2022-05-19 13:58:32 +

jexec man: Explain how PATH is adjusted.

Add a sentence that explains that PATH is set to `/bin:/usr/bin`.
I had to dive into `jexec.c` to find this out.

Reviewed by:markj
Differential Revision: https://reviews.freebsd.org/D35251
---
 usr.sbin/jexec/jexec.8 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/usr.sbin/jexec/jexec.8 b/usr.sbin/jexec/jexec.8
index f7ff3337ad46..8b28061c7037 100644
--- a/usr.sbin/jexec/jexec.8
+++ b/usr.sbin/jexec/jexec.8
@@ -55,6 +55,8 @@ Execute in a clean environment.
 The environment is discarded except for
 .Ev HOME , SHELL , TERM , USER ,
 and anything from the login class capability database for the user.
+.Ev PATH
+is set to "/bin:/usr/bin".
 .It Fl u Ar username
 The user name from host environment as whom the
 .Ar command



Re: git: 190abf86bb45 - main - Fix the name of Makefile.aarch64

2022-05-19 Thread Jessica Clarke
On 19 May 2022, at 11:31, Andrew Turner  wrote:
> 
> The branch main has been updated by andrew:
> 
> URL: 
> https://cgit.FreeBSD.org/src/commit/?id=190abf86bb455a5b423ca46d309c4492a2d41a94
> 
> commit 190abf86bb455a5b423ca46d309c4492a2d41a94
> Author: Andrew Turner 
> AuthorDate: 2022-05-12 12:50:59 +
> Commit: Andrew Turner 
> CommitDate: 2022-05-19 10:30:21 +
> 
>Fix the name of Makefile.aarch64
> 
>Makefile.arm64 relies on being included via Makefile.${MACHINE}. This
>only works when arm64 is the only aarch64 architecture. Switch to
>Makefile.aarch64 so downstream CheriBSD can use the file when building
>for Morello which uses a differen ${MACHINE} value.

CheriBSD still has MACHINE=arm64 for Morello... so this should work
just fine with the MACHINE case in bsd.arch.inc.mk, whereas now you hit
the MACHINE_ARCH case for plain aarch64 and the MACHINE_CPUARCH case
for Morello. This seems worse to me?

Jess

>Sponsored by:   Innovate UK
> ---
> usr.sbin/{Makefile.arm64 => Makefile.aarch64} | 0
> 1 file changed, 0 insertions(+), 0 deletions(-)
> 
> diff --git a/usr.sbin/Makefile.arm64 b/usr.sbin/Makefile.aarch64
> similarity index 100%
> rename from usr.sbin/Makefile.arm64
> rename to usr.sbin/Makefile.aarch64




git: 3afe1c2e1817 - stable/13 - native-xtools: avoid libllvm while populating the sysroot

2022-05-19 Thread Kyle Evans
The branch stable/13 has been updated by kevans:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3afe1c2e181712afd0120e14267f92050de434f7

commit 3afe1c2e181712afd0120e14267f92050de434f7
Author: Kyle Evans 
AuthorDate: 2021-10-13 09:21:28 +
Commit: Kyle Evans 
CommitDate: 2022-05-19 15:05:53 +

native-xtools: avoid libllvm while populating the sysroot

Prior to 021385aba562, MK_CLANG=no was sufficient to avoid descending
into lib/clang, but the referenced change added a couple of other
enabling knobs. Turn those off, too, to continue avoiding libllvm.

With this change, we no longer end up with a libllvm using the wrong
default target triple; `poudriere jail -cx` works once again.

Reported by:bhughes, imp, probably others
Fixes:  021385aba562 ("Add WITH_LLVM_BINUTILS to install LLVM ...")

(cherry picked from commit e2e2c622c35f3e54dbae88e3de3e48c51dbb4ebd)
---
 Makefile.inc1 | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index b8431b5abe09..d378fbe466e3 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2807,6 +2807,10 @@ NXBMAKEARGS+= \
 NXBMAKEENV+= \
MAKEOBJDIRPREFIX=
 
+# This should match all of the knobs in lib/Makefile that it takes to avoid
+# descending into lib/clang!
+NXBTNOTOOLS=   MK_CLANG=no MK_LLD=no MK_LLDB=no MK_LLVM_BINUTILS=no
+
 .if make(native-xtools*) && \
 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
 .error Missing NXB_TARGET / NXB_TARGET_ARCH
@@ -2846,11 +2850,11 @@ native-xtools: .PHONY
# Populate includes/libraries sysroot that produce native binaries.
# This is split out from 'toolchain' above mostly so that target LLVM
# libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
-   # polluting the cross-compiler build.  The LLVM/GCC libs are skipped
+   # polluting the cross-compiler build.  The LLVM libs are skipped
# here to avoid the problem but are kept in 'toolchain' so that
# needed build tools are built.
-   ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no
-   ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no
+   ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes ${NXBTNOTOOLS}
+   ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries ${NXBTNOTOOLS}
 .if !defined(NO_OBJWALK)
${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
 .endif



git: 702e1e5d1ef6 - stable/12 - native-xtools: avoid libllvm while populating the sysroot

2022-05-19 Thread Kyle Evans
The branch stable/12 has been updated by kevans:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=702e1e5d1ef6b019db926a4bc714bed013a2392e

commit 702e1e5d1ef6b019db926a4bc714bed013a2392e
Author: Kyle Evans 
AuthorDate: 2021-10-13 09:21:28 +
Commit: Kyle Evans 
CommitDate: 2022-05-19 15:12:42 +

native-xtools: avoid libllvm while populating the sysroot

Prior to 021385aba562, MK_CLANG=no was sufficient to avoid descending
into lib/clang, but the referenced change added a couple of other
enabling knobs. Turn those off, too, to continue avoiding libllvm.

With this change, we no longer end up with a libllvm using the wrong
default target triple; `poudriere jail -cx` works once again.

Reported by:bhughes, imp, probably others
Fixes:  021385aba562 ("Add WITH_LLVM_BINUTILS to install LLVM ...")

(cherry picked from commit e2e2c622c35f3e54dbae88e3de3e48c51dbb4ebd)
---
 Makefile.inc1 | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index a714302a5744..3bfe99f2e6c3 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2544,6 +2544,10 @@ NXBMAKEARGS+= \
MK_WARNS=no \
MK_ZFS=no
 
+# This should match all of the knobs in lib/Makefile that it takes to avoid
+# descending into lib/clang!
+NXBTNOTOOLS=   MK_CLANG=no MK_LLD=no MK_LLDB=no MK_LLVM_BINUTILS=no MK_GCC=no
+
 .if make(native-xtools*) && \
 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
 .error Missing NXB_TARGET / NXB_TARGET_ARCH
@@ -2588,8 +2592,8 @@ native-xtools: .PHONY
# polluting the cross-compiler build.  The LLVM/GCC libs are skipped
# here to avoid the problem but are kept in 'toolchain' so that
# needed build tools are built.
-   ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no MK_GCC=no
-   ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no MK_GCC=no
+   ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes ${NXBTNOTOOLS}
+   ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries ${NXBTNOTOOLS}
# Clean out improper TARGET=MACHINE files
${_+_}cd ${.CURDIR}/gnu/usr.bin/cc/cc_tools; ${NXBTMAKE} cleandir
 .if !defined(NO_OBJWALK)



git: 21add93b5818 - main - makefs: Remove execute permission from in-tree test scripts

2022-05-19 Thread Mark Johnston
The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=21add93b58189322b00421f428917759a7034736

commit 21add93b58189322b00421f428917759a7034736
Author: Mark Johnston 
AuthorDate: 2022-03-23 17:32:17 +
Commit: Mark Johnston 
CommitDate: 2022-05-19 15:46:02 +

makefs: Remove execute permission from in-tree test scripts

Let the build system set it as needed.  No functional change intended.

MFC after:  1 week
Sponsored by:   The FreeBSD Foundation
---
 usr.sbin/makefs/tests/makefs_cd9660_tests.sh | 0
 usr.sbin/makefs/tests/makefs_ffs_tests.sh| 0
 usr.sbin/makefs/tests/makefs_tests_common.sh | 0
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/usr.sbin/makefs/tests/makefs_cd9660_tests.sh 
b/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
old mode 100755
new mode 100644
diff --git a/usr.sbin/makefs/tests/makefs_ffs_tests.sh 
b/usr.sbin/makefs/tests/makefs_ffs_tests.sh
old mode 100755
new mode 100644
diff --git a/usr.sbin/makefs/tests/makefs_tests_common.sh 
b/usr.sbin/makefs/tests/makefs_tests_common.sh
old mode 100755
new mode 100644



git: 47a57144af25 - main - cpuset: Byte swap cpuset for compat32 on big endian architectures

2022-05-19 Thread Justin Hibbits
The branch main has been updated by jhibbits:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=47a57144af25a7bd768b29272d50a36fdf2874ba

commit 47a57144af25a7bd768b29272d50a36fdf2874ba
Author: Justin Hibbits 
AuthorDate: 2022-05-12 20:38:22 +
Commit: Justin Hibbits 
CommitDate: 2022-05-19 15:49:55 +

cpuset: Byte swap cpuset for compat32 on big endian architectures

Summary:
BITSET uses long as its basic underlying type, which is dependent on the
compile type, meaning on 32-bit builds the basic type is 32 bits, but on
64-bit builds it's 64 bits.  On little endian architectures this doesn't
matter, because the LSB is always at the low bit, so the words get
effectively concatenated moving between 32-bit and 64-bit, but on
big-endian architectures it throws a wrench in, as setting bit 0 in
32-bit mode is equivalent to setting bit 32 in 64-bit mode.  To
demonstrate:

32-bit mode:

BIT_SET(foo, 0):0x0001

64-bit sees: 0x0001

cpuset is the only system interface that uses bitsets, so solve this
by swapping the integer sub-components at the copyin/copyout points.

Reviewed by:kib
MFC after:  3 days
Sponsored by:   Juniper Networks, Inc.
Differential Revision:  https://reviews.freebsd.org/D35225
---
 sys/compat/freebsd32/freebsd32_misc.c | 70 +--
 sys/kern/kern_cpuset.c| 32 ++--
 sys/sys/cpuset.h  |  9 +
 sys/sys/syscallsubr.h | 10 +++--
 4 files changed, 101 insertions(+), 20 deletions(-)

diff --git a/sys/compat/freebsd32/freebsd32_misc.c 
b/sys/compat/freebsd32/freebsd32_misc.c
index 25c7a4e17dc7..d4206fdd24aa 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -3310,13 +3310,72 @@ freebsd32_cpuset_getid(struct thread *td,
PAIR32TO64(id_t, uap->id), uap->setid));
 }
 
+static int
+copyin32_set(const void *u, void *k, size_t size)
+{
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   int rv;
+   struct bitset *kb = k;
+   int *p;
+
+   rv = copyin(u, k, size);
+   if (rv != 0)
+   return (rv);
+
+   p = (int *)kb->__bits;
+   /* Loop through swapping words.
+* `size' is in bytes, we need bits. */
+   for (int i = 0; i < __bitset_words(size * 8); i++) {
+   int tmp = p[0];
+   p[0] = p[1];
+   p[1] = tmp;
+   p += 2;
+   }
+   return (0);
+#else
+   return (copyin(u, k, size));
+#endif
+}
+
+static int
+copyout32_set(const void *k, void *u, size_t size)
+{
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   const struct bitset *kb = k;
+   struct bitset *ub = u;
+   const int *kp = (const int *)kb->__bits;
+   int *up = (int *)ub->__bits;
+   int rv;
+
+   for (int i = 0; i < __bitset_words(CPU_SETSIZE); i++) {
+   /* `size' is in bytes, we need bits. */
+   for (int i = 0; i < __bitset_words(size * 8); i++) {
+   rv = suword32(up, kp[1]);
+   if (rv == 0)
+   rv = suword32(up + 1, kp[0]);
+   if (rv != 0)
+   return (EFAULT);
+   }
+   }
+   return (0);
+#else
+   return (copyout(k, u, size));
+#endif
+}
+
+static const struct cpuset_copy_cb cpuset_copy32_cb = {
+   .copyin = copyin32_set,
+   .copyout = copyout32_set
+};
+
 int
 freebsd32_cpuset_getaffinity(struct thread *td,
 struct freebsd32_cpuset_getaffinity_args *uap)
 {
 
return (kern_cpuset_getaffinity(td, uap->level, uap->which,
-   PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
+   PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask,
+   &cpuset_copy32_cb));
 }
 
 int
@@ -3325,7 +3384,8 @@ freebsd32_cpuset_setaffinity(struct thread *td,
 {
 
return (user_cpuset_setaffinity(td, uap->level, uap->which,
-   PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
+   PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask,
+   &cpuset_copy32_cb));
 }
 
 int
@@ -3334,7 +3394,8 @@ freebsd32_cpuset_getdomain(struct thread *td,
 {
 
return (kern_cpuset_getdomain(td, uap->level, uap->which,
-   PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, 
uap->policy));
+   PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, 
uap->policy,
+   &cpuset_copy32_cb));
 }
 
 int
@@ -3343,7 +3404,8 @@ freebsd32_cpuset_setdomain(struct thread *td,
 {
 
return (kern_cpuset_setdomain(td, uap->level, uap->which,
-   PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, 
uap->policy));
+   PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, 
uap->policy,
+   &cpuset_copy32_cb));
 }
 
 int
diff --git a/sys/kern/kern_cpuset.c b/sys/kern

Re: git: 47a57144af25 - main - cpuset: Byte swap cpuset for compat32 on big endian architectures

2022-05-19 Thread Dmitry Chagin
On Thu, May 19, 2022 at 03:48:42PM +, Justin Hibbits wrote:
> The branch main has been updated by jhibbits:
> 
> URL: 
> https://cgit.FreeBSD.org/src/commit/?id=47a57144af25a7bd768b29272d50a36fdf2874ba
> 
> commit 47a57144af25a7bd768b29272d50a36fdf2874ba
> Author: Justin Hibbits 
> AuthorDate: 2022-05-12 20:38:22 +
> Commit: Justin Hibbits 
> CommitDate: 2022-05-19 15:49:55 +
> 
> cpuset: Byte swap cpuset for compat32 on big endian architectures
> 
> Summary:
> BITSET uses long as its basic underlying type, which is dependent on the
> compile type, meaning on 32-bit builds the basic type is 32 bits, but on
> 64-bit builds it's 64 bits.  On little endian architectures this doesn't
> matter, because the LSB is always at the low bit, so the words get
> effectively concatenated moving between 32-bit and 64-bit, but on
> big-endian architectures it throws a wrench in, as setting bit 0 in
> 32-bit mode is equivalent to setting bit 32 in 64-bit mode.  To
> demonstrate:
> 
> 32-bit mode:
> 
> BIT_SET(foo, 0):0x0001
> 
> 64-bit sees: 0x0001
> 
> cpuset is the only system interface that uses bitsets, so solve this
> by swapping the integer sub-components at the copyin/copyout points.
> 
> Reviewed by:kib
> MFC after:  3 days
> Sponsored by:   Juniper Networks, Inc.
> Differential Revision:  https://reviews.freebsd.org/D35225
> ---
>  sys/compat/freebsd32/freebsd32_misc.c | 70 
> +--
>  sys/kern/kern_cpuset.c| 32 ++--
>  sys/sys/cpuset.h  |  9 +
>  sys/sys/syscallsubr.h | 10 +++--
>  4 files changed, 101 insertions(+), 20 deletions(-)
> 
> diff --git a/sys/compat/freebsd32/freebsd32_misc.c 
> b/sys/compat/freebsd32/freebsd32_misc.c
> index 25c7a4e17dc7..d4206fdd24aa 100644
> --- a/sys/compat/freebsd32/freebsd32_misc.c
> +++ b/sys/compat/freebsd32/freebsd32_misc.c
> @@ -3310,13 +3310,72 @@ freebsd32_cpuset_getid(struct thread *td,
>   PAIR32TO64(id_t, uap->id), uap->setid));
>  }
>  
> +static int
> +copyin32_set(const void *u, void *k, size_t size)
> +{
> +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> + int rv;
> + struct bitset *kb = k;
> + int *p;
> +
> + rv = copyin(u, k, size);
> + if (rv != 0)
> + return (rv);
> +
> + p = (int *)kb->__bits;
> + /* Loop through swapping words.
> +  * `size' is in bytes, we need bits. */
> + for (int i = 0; i < __bitset_words(size * 8); i++) {
> + int tmp = p[0];
> + p[0] = p[1];
> + p[1] = tmp;
> + p += 2;
> + }
> + return (0);
> +#else
> + return (copyin(u, k, size));
> +#endif
> +}
> +
> +static int
> +copyout32_set(const void *k, void *u, size_t size)
> +{
> +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> + const struct bitset *kb = k;
> + struct bitset *ub = u;
> + const int *kp = (const int *)kb->__bits;
> + int *up = (int *)ub->__bits;
> + int rv;
> +
> + for (int i = 0; i < __bitset_words(CPU_SETSIZE); i++) {
> + /* `size' is in bytes, we need bits. */
> + for (int i = 0; i < __bitset_words(size * 8); i++) {
> + rv = suword32(up, kp[1]);
> + if (rv == 0)
> + rv = suword32(up + 1, kp[0]);
> + if (rv != 0)
> + return (EFAULT);
> + }
> + }
> + return (0);
> +#else
> + return (copyout(k, u, size));
> +#endif
> +}
> +
> +static const struct cpuset_copy_cb cpuset_copy32_cb = {
> + .copyin = copyin32_set,
> + .copyout = copyout32_set
> +};
> +
>  int
>  freebsd32_cpuset_getaffinity(struct thread *td,
>  struct freebsd32_cpuset_getaffinity_args *uap)
>  {
>  
>   return (kern_cpuset_getaffinity(td, uap->level, uap->which,
> - PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
> + PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask,
> + &cpuset_copy32_cb));
>  }
>  
>  int
> @@ -3325,7 +3384,8 @@ freebsd32_cpuset_setaffinity(struct thread *td,
>  {
>  
>   return (user_cpuset_setaffinity(td, uap->level, uap->which,
> - PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
> + PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask,
> + &cpuset_copy32_cb));
>  }
>  
>  int
> @@ -3334,7 +3394,8 @@ freebsd32_cpuset_getdomain(struct thread *td,
>  {
>  
>   return (kern_cpuset_getdomain(td, uap->level, uap->which,
> - PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, 
> uap->policy));
> + PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, 
> uap->policy,
> + &cpuset_copy32_cb));
>  }
>  
>  int
> @@ -3343,7 +3404,8 @@ freebsd32_cpuset_setdomain(struct thread *td,
>  {
>  
>   return (kern_cpuset_setdomain(td, uap->level, uap->w

git: 2479e381cd5f - main - kqueue: Trim trailing whitespace

2022-05-19 Thread Dmitry Chagin
The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2479e381cd5fe21c1f1c516ee42dfdd1fcc9abfc

commit 2479e381cd5fe21c1f1c516ee42dfdd1fcc9abfc
Author: Dmitry Chagin 
AuthorDate: 2022-05-19 16:52:02 +
Commit: Dmitry Chagin 
CommitDate: 2022-05-19 16:52:02 +

kqueue: Trim trailing whitespace

MFC after:  1 week
---
 sys/kern/kern_event.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index a49762d9453c..33607fe8c5f4 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -892,7 +892,7 @@ filt_timerdetach(struct knote *kn)
 static void
 filt_timertouch(struct knote *kn, struct kevent *kev, u_long type)
 {
-   struct kq_timer_cb_data *kc;
+   struct kq_timer_cb_data *kc;
struct kqueue *kq;
sbintime_t to;
int error;
@@ -929,7 +929,7 @@ filt_timertouch(struct knote *kn, struct kevent *kev, 
u_long type)
kn->kn_status &= ~KN_ACTIVE;
kn->kn_data = 0;
KQ_UNLOCK(kq);
-   
+
/* Reschedule timer based on new data/fflags */
kn->kn_sfflags = kev->fflags;
kn->kn_sdata = kev->data;
@@ -967,9 +967,9 @@ static int
 filt_userattach(struct knote *kn)
 {
 
-   /* 
+   /*
 * EVFILT_USER knotes are not attached to anything in the kernel.
-*/ 
+*/
kn->kn_hook = NULL;
if (kn->kn_fflags & NOTE_TRIGGER)
kn->kn_hookid = 1;
@@ -1587,7 +1587,7 @@ findkn:
 * note. Don't attempt to coalesce this with an
 * existing note.
 */
-   ;   
+   ;
} else if (kq->kq_knhashmask != 0) {
struct klist *list;
 
@@ -1709,7 +1709,7 @@ findkn:
 done_ev_add:
/*
 * We can get here with kn->kn_knlist == NULL.  This can happen when
-* the initial attach event decides that the event is "completed" 
+* the initial attach event decides that the event is "completed"
 * already, e.g., filt_procattach() is called on a zombie process.  It
 * will call filt_proc() which will remove it from the list, and NULL
 * kn_knlist.
@@ -2059,8 +2059,8 @@ retry:
KQ_LOCK(kq);
KQ_GLOBAL_UNLOCK(&kq_global, haskqglobal);
if (kn->kn_flags & (EV_CLEAR | EV_DISPATCH)) {
-   /* 
-* Manually clear knotes who weren't 
+   /*
+* Manually clear knotes who weren't
 * 'touch'ed.
 */
if (touch == 0 && kn->kn_flags & EV_CLEAR) {
@@ -2073,7 +2073,7 @@ retry:
kq->kq_count--;
} else
TAILQ_INSERT_TAIL(&kq->kq_head, kn, kn_tqe);
-   
+
kn->kn_status &= ~KN_SCAN;
kn_leave_flux(kn);
kn_list_unlock(knl);
@@ -2829,7 +2829,7 @@ knote_free(struct knote *kn)
 /*
  * Register the kev w/ the kq specified by fd.
  */
-int 
+int
 kqfd_register(int fd, struct kevent *kev, struct thread *td, int mflag)
 {
struct kqueue *kq;



git: 2cd662064a0c - main - linux(4): Handle cas failure on ll/sc operations

2022-05-19 Thread Dmitry Chagin
The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2cd662064a0cd8d179cbb5a06378fce0ec458747

commit 2cd662064a0cd8d179cbb5a06378fce0ec458747
Author: Dmitry Chagin 
AuthorDate: 2022-05-19 16:52:18 +
Commit: Dmitry Chagin 
CommitDate: 2022-05-19 16:52:18 +

linux(4): Handle cas failure on ll/sc operations

Follow the 11a6ecd4. Check and handle the case when the ll/sc casu fails
even when the compare succeeds.

For more details PR/263825, https://reviews.freebsd.org/D35150.

Obtained from:  Andrew@
MFC after:  2 weeks
---
 sys/compat/linux/linux_futex.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c
index 6825d13e1aab..8bcdc378cf70 100644
--- a/sys/compat/linux/linux_futex.c
+++ b/sys/compat/linux/linux_futex.c
@@ -410,6 +410,17 @@ linux_futex_lock_pi(struct thread *td, bool try, struct 
linux_futex_args *args)
break;
}
 
+   /*
+* Nobody owns it, but the acquire failed. This can happen
+* with ll/sc atomic.
+*/
+   if (owner == 0) {
+   error = thread_check_susp(td, true);
+   if (error != 0)
+   break;
+   continue;
+   }
+
/*
 * Avoid overwriting a possible error from sleep due
 * to the pending signal with suspension check result.



git: 6e2caba7a129 - main - arm64: Enable the floating-point exception traps

2022-05-19 Thread Dmitry Chagin
The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6e2caba7a1297eeda4f43e6377667d2e049f24f9

commit 6e2caba7a1297eeda4f43e6377667d2e049f24f9
Author: Dmitry Chagin 
AuthorDate: 2022-05-19 16:53:56 +
Commit: Dmitry Chagin 
CommitDate: 2022-05-19 16:53:56 +

arm64: Enable the floating-point exception traps

To enable it user-space needs to call feenableexcept().

FPE_FLTIDO has been added as the IDF bit can't be mapped to any existing
FPE code.

Reviewed by:andrew@
Differential revision:  https://reviews.freebsd.org/D35247
MFC after:  2 weeks
---
 sys/arm64/arm64/trap.c | 32 +++-
 sys/arm64/include/armreg.h |  8 
 sys/sys/signal.h   |  1 +
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c
index b664501b62fa..5bf6c3d1a81d 100644
--- a/sys/arm64/arm64/trap.c
+++ b/sys/arm64/arm64/trap.c
@@ -411,6 +411,29 @@ print_registers(struct trapframe *frame)
printf("spsr: %8x\n", frame->tf_spsr);
 }
 
+#ifdef VFP
+static void
+fpe_trap(struct thread *td, void *addr, uint32_t exception)
+{
+   int code;
+
+   code = FPE_FLTIDO;
+   if ((exception & ISS_FP_TFV) != 0) {
+   if ((exception & ISS_FP_IOF) != 0)
+   code = FPE_FLTINV;
+   else if ((exception & ISS_FP_DZF) != 0)
+   code = FPE_FLTDIV;
+   else if ((exception & ISS_FP_OFF) != 0)
+   code = FPE_FLTOVF;
+   else if ((exception & ISS_FP_UFF) != 0)
+   code = FPE_FLTUND;
+   else if ((exception & ISS_FP_IXF) != 0)
+   code = FPE_FLTRES;
+   }
+   call_trapsignal(td, SIGFPE, code, addr, exception);
+}
+#endif
+
 void
 do_el1h_sync(struct thread *td, struct trapframe *frame)
 {
@@ -556,11 +579,18 @@ do_el0_sync(struct thread *td, struct trapframe *frame)
 
switch (exception) {
case EXCP_FP_SIMD:
-   case EXCP_TRAP_FP:
 #ifdef VFP
vfp_restore_state();
 #else
panic("VFP exception in userland");
+#endif
+   break;
+   case EXCP_TRAP_FP:
+#ifdef VFP
+   fpe_trap(td, (void *)frame->tf_elr, esr);
+   userret(td, frame);
+#else
+   panic("VFP exception in userland");
 #endif
break;
case EXCP_SVC32:
diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h
index fbed7aa79c38..44b11617fbf1 100644
--- a/sys/arm64/include/armreg.h
+++ b/sys/arm64/include/armreg.h
@@ -265,6 +265,14 @@
 
 /* ESR_ELx */
 #defineESR_ELx_ISS_MASK0x01ff
+#define ISS_FP_TFV_SHIFT   23
+#define ISS_FP_TFV (0x01 << ISS_FP_TFV_SHIFT)
+#define ISS_FP_IOF 0x01
+#define ISS_FP_DZF 0x02
+#define ISS_FP_OFF 0x04
+#define ISS_FP_UFF 0x08
+#define ISS_FP_IXF 0x10
+#define ISS_FP_IDF 0x80
 #define ISS_INSN_FnV   (0x01 << 10)
 #define ISS_INSN_EA(0x01 << 9)
 #define ISS_INSN_S1PTW (0x01 << 7)
diff --git a/sys/sys/signal.h b/sys/sys/signal.h
index 9dae3ce04745..27014c20973a 100644
--- a/sys/sys/signal.h
+++ b/sys/sys/signal.h
@@ -339,6 +339,7 @@ struct siginfo32 {
 #define FPE_FLTRES 6   /* Floating point inexact result.   */
 #define FPE_FLTINV 7   /* Invalid floating point operation.*/
 #define FPE_FLTSUB 8   /* Subscript out of range.  */
+#define FPE_FLTIDO 9   /* Input denormal operation */
 
 /* codes for SIGTRAP */
 #define TRAP_BRKPT 1   /* Process breakpoint.  */



git: 9386e18b395d - main - linux(4): Move signal codes definitions to the appropriate header

2022-05-19 Thread Dmitry Chagin
The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=9386e18b395dd62f6d0cccad67af51e3ad1d2429

commit 9386e18b395dd62f6d0cccad67af51e3ad1d2429
Author: Dmitry Chagin 
AuthorDate: 2022-05-19 16:55:20 +
Commit: Dmitry Chagin 
CommitDate: 2022-05-19 16:55:20 +

linux(4): Move signal codes definitions to the appropriate header

In the Linux the struct siginfo related bits are placed into the siginfo.h
header.

MFC after:  2 weeks
---
 sys/compat/linux/linux_siginfo.h | 12 
 sys/compat/linux/linux_signal.h  | 12 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/sys/compat/linux/linux_siginfo.h b/sys/compat/linux/linux_siginfo.h
index cb5c3e76482c..eb9120a0208a 100644
--- a/sys/compat/linux/linux_siginfo.h
+++ b/sys/compat/linux/linux_siginfo.h
@@ -36,6 +36,18 @@
 #ifndef _LINUX_SIGINFO_H_
 #define _LINUX_SIGINFO_H_
 
+/*
+ * si_code values
+ */
+#defineLINUX_SI_USER   0   /* sent by kill, sigsend, raise 
*/
+#defineLINUX_SI_KERNEL 0x80/* sent by the kernel from 
somewhere */
+#defineLINUX_SI_QUEUE  -1  /* sent by sigqueue */
+#defineLINUX_SI_TIMER  -2  /* sent by timer expiration */
+#defineLINUX_SI_MESGQ  -3  /* sent by real time mesq state 
change */
+#defineLINUX_SI_ASYNCIO-4  /* sent by AIO completion */
+#defineLINUX_SI_SIGIO  -5  /* sent by queued SIGIO */
+#defineLINUX_SI_TKILL  -6  /* sent by tkill system call */
+
 typedef union l_sigval {
l_int   sival_int;
l_uintptr_t sival_ptr;
diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h
index 8d6022fc3cc7..75fe0b24e592 100644
--- a/sys/compat/linux/linux_signal.h
+++ b/sys/compat/linux/linux_signal.h
@@ -31,18 +31,6 @@
 #ifndef _LINUX_SIGNAL_H_
 #define _LINUX_SIGNAL_H_
 
-/*
- * si_code values
- */
-#defineLINUX_SI_USER   0   /* sent by kill, sigsend, raise 
*/
-#defineLINUX_SI_KERNEL 0x80/* sent by the kernel from 
somewhere */
-#defineLINUX_SI_QUEUE  -1  /* sent by sigqueue */
-#defineLINUX_SI_TIMER  -2  /* sent by timer expiration */
-#defineLINUX_SI_MESGQ  -3  /* sent by real time mesq state 
change */
-#defineLINUX_SI_ASYNCIO-4  /* sent by AIO completion */
-#defineLINUX_SI_SIGIO  -5  /* sent by queued SIGIO */
-#defineLINUX_SI_TKILL  -6  /* sent by tkill system call */
-
 int linux_do_sigaction(struct thread *, int, l_sigaction_t *, l_sigaction_t *);
 void siginfo_to_lsiginfo(const siginfo_t *si, l_siginfo_t *lsi, l_int sig);
 int lsiginfo_to_siginfo(struct thread *td, const l_siginfo_t *lsi,



git: 30301975637f - main - linux(4): Add kernel signal code definitions

2022-05-19 Thread Dmitry Chagin
The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=30301975637f85172fe18b73c863dabd8ad28296

commit 30301975637f85172fe18b73c863dabd8ad28296
Author: Dmitry Chagin 
AuthorDate: 2022-05-19 16:55:56 +
Commit: Dmitry Chagin 
CommitDate: 2022-05-19 16:55:56 +

linux(4): Add kernel signal code definitions

In the next commit I'll convert the native signal codes into the Linux 
codes,
since they are not 1:1 mapped.

MFC after:  2 weeks
---
 sys/compat/linux/linux_siginfo.h | 111 +++
 1 file changed, 111 insertions(+)

diff --git a/sys/compat/linux/linux_siginfo.h b/sys/compat/linux/linux_siginfo.h
index eb9120a0208a..b0c70e1b745e 100644
--- a/sys/compat/linux/linux_siginfo.h
+++ b/sys/compat/linux/linux_siginfo.h
@@ -48,6 +48,116 @@
 #defineLINUX_SI_SIGIO  -5  /* sent by queued SIGIO */
 #defineLINUX_SI_TKILL  -6  /* sent by tkill system call */
 
+/*
+ * SIGILL si_codes
+ */
+#defineLINUX_ILL_ILLOPC1   /* illegal opcode */
+#defineLINUX_ILL_ILLOPN2   /* illegal operand */
+#defineLINUX_ILL_ILLADR3   /* illegal addressing mode */
+#defineLINUX_ILL_ILLTRP4   /* illegal trap */
+#defineLINUX_ILL_PRVOPC5   /* privileged opcode */
+#defineLINUX_ILL_PRVREG6   /* privileged register */
+#defineLINUX_ILL_COPROC7   /* coprocessor error */
+#defineLINUX_ILL_BADSTK8   /* internal stack error */
+#defineLINUX_ILL_BADIADDR  9   /* unimplemented instruction 
address */
+#defineLINUX___ILL_BREAK   10  /* (ia64) illegal break */
+#defineLINUX___ILL_BNDMOD  11  /* (ia64) bundle-update 
(modification)
+* in progress
+*/
+
+/*
+ * SIGFPE si_codes
+ */
+#defineLINUX_FPE_INTDIV1   /* integer divide by zero */
+#defineLINUX_FPE_INTOVF2   /* integer overflow */
+#defineLINUX_FPE_FLTDIV3   /* floating point divide by 
zero */
+#defineLINUX_FPE_FLTOVF4   /* floating point overflow */
+#defineLINUX_FPE_FLTUND5   /* floating point underflow */
+#defineLINUX_FPE_FLTRES6   /* floating point inexact 
result */
+#defineLINUX_FPE_FLTINV7   /* floating point invalid 
operation */
+#defineLINUX_FPE_FLTSUB8   /* (ia64) subscript out of 
range */
+#defineLINUX___FPE_DECOVF  9   /* (ia64) decimal overflow */
+#defineLINUX___FPE_DECDIV  10  /* (ia64) decimal division by 
zero */
+#defineLINUX___FPE_DECERR  11  /* (ia64) packed decimal error 
*/
+#defineLINUX___FPE_INVASC  12  /* (ia64) invalid ASCII digit */
+#defineLINUX___FPE_INVDEC  13  /* (ia64) invalid decimal digit 
*/
+#defineLINUX_FPE_FLTUNK14  /* undiagnosed floating-point 
exception */
+#defineLINUX_FPE_CONDTRAP  15  /* trap on condition */
+
+/*
+ * SIGSEGV si_codes
+ */
+#defineLINUX_SEGV_MAPERR   1   /* address not mapped to object 
*/
+#defineLINUX_SEGV_ACCERR   2   /* invalid permissions for 
mapped object */
+#defineLINUX_SEGV_BNDERR   3   /* failed address bound checks 
*/
+#ifdef __ia64__
+#defineLINUX___SEGV_PSTKOVF4   /* paragraph stack overflow */
+#else
+#defineLINUX_SEGV_PKUERR   4   /* failed protection key checks 
*/
+#endif
+#defineLINUX_SEGV_ACCADI   5   /* ADI not enabled for mapped 
object */
+#defineLINUX_SEGV_ADIDERR  6   /* Disrupting MCD error */
+#defineLINUX_SEGV_ADIPERR  7   /* Precise MCD exception */
+#defineLINUX_SEGV_MTEAERR  8   /* Asynchronous ARM MTE error */
+#defineLINUX_SEGV_MTESERR  9   /* Synchronous ARM MTE 
exception */
+
+/*
+ * SIGBUS si_codes
+ */
+#defineLINUX_BUS_ADRALN1   /* invalid address alignment */
+#defineLINUX_BUS_ADRERR2   /* non-existent physical 
address */
+#defineLINUX_BUS_OBJERR3   /* object specific hardware 
error */
+
+#defineLINUX_BUS_MCEERR_AR 4   /* hardware memory error 
consumed
+* on a machine check:
+* action required
+*/
+#defineLINUX_BUS_MCEERR_AO 5   /* hardware memory error 
detected
+* in process but not consumed:
+* action optional
+*/
+
+/*
+ * SIGTRAP si_codes
+ */
+#defineLINUX_TRAP_BRKPT1   

git: a6f85b12bbe8 - main - linux(4): Convert the native kernel signal codes into the Linux codes

2022-05-19 Thread Dmitry Chagin
The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a6f85b12bbe8e50243350c77b0c5879d9e72f85b

commit a6f85b12bbe8e50243350c77b0c5879d9e72f85b
Author: Dmitry Chagin 
AuthorDate: 2022-05-19 16:56:50 +
Commit: Dmitry Chagin 
CommitDate: 2022-05-19 16:56:50 +

linux(4): Convert the native kernel signal codes into the Linux codes

MFC after:  2 weeks
---
 sys/compat/linux/linux_signal.c | 78 ++---
 1 file changed, 74 insertions(+), 4 deletions(-)

diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
index a9af0d726f56..9aecb8497f3b 100644
--- a/sys/compat/linux/linux_signal.c
+++ b/sys/compat/linux/linux_signal.c
@@ -65,7 +65,7 @@ static intlinux_tdksignal(struct thread *td, lwpid_t tid,
int tgid, int sig, ksiginfo_t *ksi);
 static int linux_tdsignal(struct thread *td, lwpid_t tid,
int tgid, int sig);
-static voidsicode_to_lsicode(int si_code, int *lsi_code);
+static voidsicode_to_lsicode(int sig, int si_code, int *lsi_code);
 static int linux_common_rt_sigtimedwait(struct thread *,
l_sigset_t *, struct timespec *, l_siginfo_t *,
l_size_t);
@@ -565,8 +565,62 @@ linux_tkill(struct thread *td, struct linux_tkill_args 
*args)
return (linux_tdsignal(td, args->tid, -1, sig));
 }
 
+static int
+sigfpe_sicode2lsicode(int si_code)
+{
+
+   switch (si_code) {
+   case FPE_INTOVF:
+   return (LINUX_FPE_INTOVF);
+   case FPE_INTDIV:
+   return (LINUX_FPE_INTDIV);
+   case FPE_FLTIDO:
+   return (LINUX_FPE_FLTUNK);
+   default:
+   return (si_code);
+   }
+}
+
+static int
+sigbus_sicode2lsicode(int si_code)
+{
+
+   switch (si_code) {
+   case BUS_OOMERR:
+   return (LINUX_BUS_MCEERR_AR);
+   default:
+   return (si_code);
+   }
+}
+
+static int
+sigsegv_sicode2lsicode(int si_code)
+{
+
+   switch (si_code) {
+   case SEGV_PKUERR:
+   return (LINUX_SEGV_PKUERR);
+   default:
+   return (si_code);
+   }
+}
+
+static int
+sigtrap_sicode2lsicode(int si_code)
+{
+
+   switch (si_code) {
+   case TRAP_DTRACE:
+   return (LINUX_TRAP_TRACE);
+   case TRAP_CAP:
+   return (LINUX_TRAP_UNK);
+   default:
+   return (si_code);
+   }
+}
+
 static void
-sicode_to_lsicode(int si_code, int *lsi_code)
+sicode_to_lsicode(int sig, int si_code, int *lsi_code)
 {
 
switch (si_code) {
@@ -592,7 +646,23 @@ sicode_to_lsicode(int si_code, int *lsi_code)
*lsi_code = LINUX_SI_TKILL;
break;
default:
-   *lsi_code = si_code;
+   switch (sig) {
+   case LINUX_SIGFPE:
+   *lsi_code = sigfpe_sicode2lsicode(si_code);
+   break;
+   case LINUX_SIGBUS:
+   *lsi_code = sigbus_sicode2lsicode(si_code);
+   break;
+   case LINUX_SIGSEGV:
+   *lsi_code = sigsegv_sicode2lsicode(si_code);
+   break;
+   case LINUX_SIGTRAP:
+   *lsi_code = sigtrap_sicode2lsicode(si_code);
+   break;
+   default:
+   *lsi_code = si_code;
+   break;
+   }
break;
}
 }
@@ -603,7 +673,7 @@ siginfo_to_lsiginfo(const siginfo_t *si, l_siginfo_t *lsi, 
l_int sig)
 
/* sig alredy converted */
lsi->lsi_signo = sig;
-   sicode_to_lsicode(si->si_code, &lsi->lsi_code);
+   sicode_to_lsicode(sig, si->si_code, &lsi->lsi_code);
 
switch (si->si_code) {
case SI_LWP:



git: 89737eb8290a - main - Fix the build after 47a57144

2022-05-19 Thread Dmitry Chagin
The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=89737eb8290a10d96b77afac1b68e4740b43353b

commit 89737eb8290a10d96b77afac1b68e4740b43353b
Author: Dmitry Chagin 
AuthorDate: 2022-05-19 18:40:59 +
Commit: Dmitry Chagin 
CommitDate: 2022-05-19 18:40:59 +

Fix the build after 47a57144
---
 sys/compat/linux/linux_misc.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index d8687945b0e8..652a9b4b5067 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -2239,6 +2239,11 @@ linux_sched_getparam(struct thread *td,
return (error);
 }
 
+static const struct cpuset_copy_cb copy_set = {
+   .copyin = copyin,
+   .copyout = copyout
+};
+
 /*
  * Get affinity of a process.
  */
@@ -2257,7 +2262,7 @@ linux_sched_getaffinity(struct thread *td,
PROC_UNLOCK(tdt->td_proc);
 
error = kern_cpuset_getaffinity(td, CPU_LEVEL_WHICH, CPU_WHICH_TID,
-   tid, args->len, (cpuset_t *)args->user_mask_ptr);
+   tid, args->len, (cpuset_t *)args->user_mask_ptr, ©_set);
if (error == ERANGE)
error = EINVAL;
if (error == 0)



git: b04f5d18b5fa - main - linux(4): To improve readability use FUTEX_UNOWNED instead of 0

2022-05-19 Thread Dmitry Chagin
The branch main has been updated by dchagin:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b04f5d18b5faad004a10f054d9c9072fcf31c29b

commit b04f5d18b5faad004a10f054d9c9072fcf31c29b
Author: Dmitry Chagin 
AuthorDate: 2022-05-19 18:42:38 +
Commit: Dmitry Chagin 
CommitDate: 2022-05-19 18:42:38 +

linux(4): To improve readability use FUTEX_UNOWNED instead of 0

MFC after:  2 weeks
---
 sys/compat/linux/linux_futex.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c
index 8bcdc378cf70..eb3ce3421465 100644
--- a/sys/compat/linux/linux_futex.c
+++ b/sys/compat/linux/linux_futex.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #defineFUTEX_SHARED0x8 /* shared futex */
+#defineFUTEX_UNOWNED   0
 
 #defineGET_SHARED(a)   (a->flags & FUTEX_SHARED) ? AUTO_SHARE : 
THREAD_SHARE
 
@@ -399,7 +400,7 @@ linux_futex_lock_pi(struct thread *td, bool try, struct 
linux_futex_args *args)
umtxq_unlock(&uq->uq_key);
for (;;) {
/* Try uncontested case first. */
-   rv = casueword32(args->uaddr, 0, &owner, em->em_tid);
+   rv = casueword32(args->uaddr, FUTEX_UNOWNED, &owner, 
em->em_tid);
/* The acquire succeeded. */
if (rv == 0) {
error = 0;
@@ -414,7 +415,7 @@ linux_futex_lock_pi(struct thread *td, bool try, struct 
linux_futex_args *args)
 * Nobody owns it, but the acquire failed. This can happen
 * with ll/sc atomic.
 */
-   if (owner == 0) {
+   if (owner == FUTEX_UNOWNED) {
error = thread_check_susp(td, true);
if (error != 0)
break;
@@ -441,7 +442,7 @@ linux_futex_lock_pi(struct thread *td, bool try, struct 
linux_futex_args *args)
 * Futex owner died, handle_futex_death() set the OWNER_DIED bit
 * and clear tid. Try to acquire it.
 */
-   if ((owner & FUTEX_TID_MASK) == 0) {
+   if ((owner & FUTEX_TID_MASK) == FUTEX_UNOWNED) {
old_owner = owner;
owner = owner & (FUTEX_WAITERS | FUTEX_OWNER_DIED);
owner |= em->em_tid;
@@ -486,7 +487,7 @@ linux_futex_lock_pi(struct thread *td, bool try, struct 
linux_futex_args *args)
 * Linux does some checks of futex state, we return EINVAL,
 * as the user space can take care of this.
 */
-   if ((owner & FUTEX_OWNER_DIED) != 0) {
+   if ((owner & FUTEX_OWNER_DIED) != FUTEX_UNOWNED) {
error = EINVAL;
break;
}
@@ -608,7 +609,7 @@ linux_futex_unlock_pi(struct thread *td, bool rb, struct 
linux_futex_args *args)
if (count > 1)
new_owner = FUTEX_WAITERS;
else
-   new_owner = 0;
+   new_owner = FUTEX_UNOWNED;
 
 again:
error = casueword32(args->uaddr, owner, &old, new_owner);



Re: git: 47a57144af25 - main - cpuset: Byte swap cpuset for compat32 on big endian architectures

2022-05-19 Thread Justin Hibbits
 
"Dmitry Chagin" dcha...@freebsd.org – May 19, 2022 12:49 PM
> On Thu, May 19, 2022 at 03:48:42PM +, Justin Hibbits wrote:
> > The branch main has been updated by jhibbits:
> > 
> > URL: 
> > https://cgit.FreeBSD.org/src/commit/?id=47a57144af25a7bd768b29272d50a36fdf2874ba
> > 
> > commit 47a57144af25a7bd768b29272d50a36fdf2874ba
> > Author: Justin Hibbits 
> > AuthorDate: 2022-05-12 20:38:22 +
> > Commit: Justin Hibbits 
> > CommitDate: 2022-05-19 15:49:55 +
> > 
> > cpuset: Byte swap cpuset for compat32 on big endian architectures
> > 
> > Summary:
> > BITSET uses long as its basic underlying type, which is dependent on the
> > compile type, meaning on 32-bit builds the basic type is 32 bits, but on
> > 64-bit builds it's 64 bits. On little endian architectures this doesn't
> > matter, because the LSB is always at the low bit, so the words get
> > effectively concatenated moving between 32-bit and 64-bit, but on
> > big-endian architectures it throws a wrench in, as setting bit 0 in
> > 32-bit mode is equivalent to setting bit 32 in 64-bit mode. To
> > demonstrate:
> > 
> > 32-bit mode:
> > 
> > BIT_SET(foo, 0): 0x0001
> > 
> > 64-bit sees: 0x0001
> > 
> > cpuset is the only system interface that uses bitsets, so solve this
> > by swapping the integer sub-components at the copyin/copyout points.
> > 
> > Reviewed by: kib
> > MFC after: 3 days
> > Sponsored by: Juniper Networks, Inc.
> > Differential Revision: https://reviews.freebsd.org/D35225
> > ---
> > sys/compat/freebsd32/freebsd32_misc.c | 70 
> > +--
> > sys/kern/kern_cpuset.c | 32 ++--
> > sys/sys/cpuset.h | 9 +
> > sys/sys/syscallsubr.h | 10 +++--
> > 4 files changed, 101 insertions(+), 20 deletions(-)
> > 
> > diff --git a/sys/compat/freebsd32/freebsd32_misc.c 
> > b/sys/compat/freebsd32/freebsd32_misc.c
> > index 25c7a4e17dc7..d4206fdd24aa 100644
> > --- a/sys/compat/freebsd32/freebsd32_misc.c
> > +++ b/sys/compat/freebsd32/freebsd32_misc.c
> > @@ -3310,13 +3310,72 @@ freebsd32_cpuset_getid(struct thread *td,
> > PAIR32TO64(id_t, uap->id), uap->setid));
> > }
> > 
> > +static int
> > +copyin32_set(const void *u, void *k, size_t size)
> > +{
> > +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> > + int rv;
> > + struct bitset *kb = k;
> > + int *p;
> > +
> > + rv = copyin(u, k, size);
> > + if (rv != 0)
> > + return (rv);
> > +
> > + p = (int *)kb->__bits;
> > + /* Loop through swapping words.
> > + * `size' is in bytes, we need bits. */
> > + for (int i = 0; i < __bitset_words(size * 8); i++) {
> > + int tmp = p[0];
> > + p[0] = p[1];
> > + p[1] = tmp;
> > + p += 2;
> > + }
> > + return (0);
> > +#else
> > + return (copyin(u, k, size));
> > +#endif
> > +}
> > +
> > +static int
> > +copyout32_set(const void *k, void *u, size_t size)
> > +{
> > +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> > + const struct bitset *kb = k;
> > + struct bitset *ub = u;
> > + const int *kp = (const int *)kb->__bits;
> > + int *up = (int *)ub->__bits;
> > + int rv;
> > +
> > + for (int i = 0; i < __bitset_words(CPU_SETSIZE); i++) {
> > + /* `size' is in bytes, we need bits. */
> > + for (int i = 0; i < __bitset_words(size * 8); i++) {
> > + rv = suword32(up, kp[1]);
> > + if (rv == 0)
> > + rv = suword32(up + 1, kp[0]);
> > + if (rv != 0)
> > + return (EFAULT);
> > + }
> > + }
> > + return (0);
> > +#else
> > + return (copyout(k, u, size));
> > +#endif
> > +}
> > +
> > +static const struct cpuset_copy_cb cpuset_copy32_cb = {
> > + .copyin = copyin32_set,
> > + .copyout = copyout32_set
> > +};
> > +
> > int
> > freebsd32_cpuset_getaffinity(struct thread *td,
> > struct freebsd32_cpuset_getaffinity_args *uap)
> > {
> > 
> > return (kern_cpuset_getaffinity(td, uap->level, uap->which,
> > - PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
> > + PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask,
> > + &cpuset_copy32_cb));
> > }
> > 
> > int
> > @@ -3325,7 +3384,8 @@ freebsd32_cpuset_setaffinity(struct thread *td,
> > {
> > 
> > return (user_cpuset_setaffinity(td, uap->level, uap->which,
> > - PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
> > + PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask,
> > + &cpuset_copy32_cb));
> > }
> > 
> > int
> > @@ -3334,7 +3394,8 @@ freebsd32_cpuset_getdomain(struct thread *td,
> > {
> > 
> > return (kern_cpuset_getdomain(td, uap->level, uap->which,
> > - PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy));
> > + PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy,
> > + &cpuset_copy32_cb));
> > }
> > 
> > int
> > @@ -3343,7 +3404,8 @@ freebsd32_cpuset_setdomain(struct thread *td,
> > {
> > 
> > return (kern_cpuset_setdomain(td, uap->level, uap->which,
> > - PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy));
> > + PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy,
> > + &cpuset_copy32_cb));
> > }
> > 
> > int
> > diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c

git: b2aa64d05bd8 - stable/13 - Bump __FreeBSD_version for new variants of *DRIVER_MODULE*().

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b2aa64d05bd8b04a1bdb63f2a5f9de39c600b463

commit b2aa64d05bd8b04a1bdb63f2a5f9de39c600b463
Author: John Baldwin 
AuthorDate: 2022-05-19 21:20:53 +
Commit: John Baldwin 
CommitDate: 2022-05-19 21:20:53 +

Bump __FreeBSD_version for new variants of *DRIVER_MODULE*().

This is a direct commit to stable/13.

The devclass argument and global devclass variables will not be
removed on stable branches, but bump the version just in case.
---
 sys/sys/param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/sys/param.h b/sys/sys/param.h
index a963a8486171..a0f1b9f7945b 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1301502  /* Master, propagated to newvers */
+#define __FreeBSD_version 1301503  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,



git: e343ebbfbe97 - main - src.libnames: Replace redundant += with =

2022-05-19 Thread Cy Schubert
The branch main has been updated by cy:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e343ebbfbe97104093ba1ab5d089e8363c170df5

commit e343ebbfbe97104093ba1ab5d089e8363c170df5
Author: Cy Schubert 
AuthorDate: 2022-05-18 01:59:13 +
Commit: Cy Schubert 
CommitDate: 2022-05-19 22:33:45 +

src.libnames: Replace redundant += with =

The += for unique assignments is equivalent to =. Make these confusing
assignments simply assignments.

Reviewed by:emaste
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D35242
---
 share/mk/src.libnames.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
index 26106a71715f..d97166e4b0e0 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -379,8 +379,8 @@ _DP_heimbase=   pthread
 _DP_heimipcc=  heimbase roken pthread
 _DP_heimipcs=  heimbase roken pthread
 _DP_kafs5= asn1 krb5 roken
-_DP_krb5+= asn1 com_err crypt crypto hx509 roken wind heimbase heimipcc
-_DP_gssapi_krb5+=  gssapi krb5 crypto roken asn1 com_err
+_DP_krb5=  asn1 com_err crypt crypto hx509 roken wind heimbase heimipcc
+_DP_gssapi_krb5=   gssapi krb5 crypto roken asn1 com_err
 _DP_lzma=  md pthread
 _DP_ucl=   m
 _DP_vmmapi=util



git: 87c5ff0648a8 - main - cxgbe/iw_cxgbe: c4iw_zero_addr should not use IN_ZERONET.

2022-05-19 Thread Navdeep Parhar
The branch main has been updated by np:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=87c5ff0648a8e88b71a66994e1f9ca127fd4ed83

commit 87c5ff0648a8e88b71a66994e1f9ca127fd4ed83
Author: Navdeep Parhar 
AuthorDate: 2022-05-19 19:25:30 +
Commit: Navdeep Parhar 
CommitDate: 2022-05-19 22:55:08 +

cxgbe/iw_cxgbe: c4iw_zero_addr should not use IN_ZERONET.

c4iw_zero_addr is supposed to check for all-zero addresses but was using
IN_ZERONET (which does something different) for IPv4 addresses.  Fix it
by simply checking for 0 as is done for IPv6 addresses.

Reported by:karels@
MFC after:  3 days
Sponsored by:   Chelsio Communications
---
 sys/dev/cxgbe/iw_cxgbe/cm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c
index 93d824730735..31a401c8ef48 100644
--- a/sys/dev/cxgbe/iw_cxgbe/cm.c
+++ b/sys/dev/cxgbe/iw_cxgbe/cm.c
@@ -938,8 +938,7 @@ static inline int c4iw_zero_addr(struct sockaddr *addr)
struct in6_addr *ip6;
 
if (addr->sa_family == AF_INET)
-   return IN_ZERONET(
-   ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr));
+   return (((struct sockaddr_in *)addr)->sin_addr.s_addr == 0);
else {
ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
return (ip6->s6_addr32[0] | ip6->s6_addr32[1] |



git: b4600b137808 - stable/13 - hptiop: Store softc pointer in si_drv1 of cdev.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b4600b13780847f8c9e4369ee1fa2bf7b8913399

commit b4600b13780847f8c9e4369ee1fa2bf7b8913399
Author: John Baldwin 
AuthorDate: 2022-04-21 17:29:13 +
Commit: John Baldwin 
CommitDate: 2022-05-19 21:31:53 +

hptiop: Store softc pointer in si_drv1 of cdev.

Rather than fetching the softc using the controller's unit number as
an index into the devclass.

Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D34993

(cherry picked from commit 517a8a715a8aa94071c058491d22c464a7962f74)
---
 sys/dev/hptiop/hptiop.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/sys/dev/hptiop/hptiop.c b/sys/dev/hptiop/hptiop.c
index eddc8da5bd8e..4091a8fb2822 100644
--- a/sys/dev/hptiop/hptiop.c
+++ b/sys/dev/hptiop/hptiop.c
@@ -166,7 +166,7 @@ static struct cdevsw hptiop_cdevsw = {
 };
 
 #define hba_from_dev(dev) \
-   ((struct hpt_iop_hba *)devclass_get_softc(hptiop_devclass, 
dev2unit(dev)))
+   ((struct hpt_iop_hba *)((dev)->si_drv1))
 
 #define BUS_SPACE_WRT4_ITL(offset, value) bus_space_write_4(hba->bar0t,\
hba->bar0h, offsetof(struct hpt_iopmu_itl, offset), (value))
@@ -1874,6 +1874,7 @@ static int hptiop_probe(device_t dev)
 
 static int hptiop_attach(device_t dev)
 {
+   struct make_dev_args args;
struct hpt_iop_hba *hba = (struct hpt_iop_hba *)device_get_softc(dev);
struct hpt_iop_request_get_config  iop_config;
struct hpt_iop_request_set_config  set_config;
@@ -2071,10 +2072,14 @@ static int hptiop_attach(device_t dev)
hba->ops->enable_intr(hba);
hba->initialized = 1;
 
-   hba->ioctl_dev = make_dev(&hptiop_cdevsw, unit,
-   UID_ROOT, GID_WHEEL /*GID_OPERATOR*/,
-   S_IRUSR | S_IWUSR, "%s%d", driver_name, unit);
+   make_dev_args_init(&args);
+   args.mda_devsw = &hptiop_cdevsw;
+   args.mda_uid = UID_ROOT;
+   args.mda_gid = GID_WHEEL /*GID_OPERATOR*/;
+   args.mda_mode = S_IRUSR | S_IWUSR;
+   args.mda_si_drv1 = hba;
 
+   make_dev_s(&args, &hba->ioctl_dev, "%s%d", driver_name, unit);
 
return 0;
 



git: da567228b6c0 - stable/13 - arcmsr: Store softc pointer in si_drv1 of cdev.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=da567228b6c0f4f03844705a6be616c2bd04b26e

commit da567228b6c0f4f03844705a6be616c2bd04b26e
Author: John Baldwin 
AuthorDate: 2022-04-21 17:29:14 +
Commit: John Baldwin 
CommitDate: 2022-05-19 21:32:50 +

arcmsr: Store softc pointer in si_drv1 of cdev.

Rather than fetching the softc using the controller's unit number as
an index into the devclass.

Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D35004

(cherry picked from commit a9e5e04e6468e7ad9d17a8fe73b2bc7091894934)
---
 sys/dev/arcmsr/arcmsr.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c
index f91877f92e02..f64093a94e7f 100644
--- a/sys/dev/arcmsr/arcmsr.c
+++ b/sys/dev/arcmsr/arcmsr.c
@@ -240,8 +240,7 @@ static struct cdevsw arcmsr_cdevsw={
 */
 static int arcmsr_open(struct cdev *dev, int flags, int fmt, struct thread 
*proc)
 {
-   int unit = dev2unit(dev);
-   struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, 
unit);
+   struct AdapterControlBlock *acb = dev->si_drv1;
 
if (acb == NULL) {
return ENXIO;
@@ -254,8 +253,7 @@ static int arcmsr_open(struct cdev *dev, int flags, int 
fmt, struct thread *proc
 */
 static int arcmsr_close(struct cdev *dev, int flags, int fmt, struct thread 
*proc)
 {
-   int unit = dev2unit(dev);
-   struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, 
unit);
+   struct AdapterControlBlock *acb = dev->si_drv1;
 
if (acb == NULL) {
return ENXIO;
@@ -268,8 +266,7 @@ static int arcmsr_close(struct cdev *dev, int flags, int 
fmt, struct thread *pro
 */
 static int arcmsr_ioctl(struct cdev *dev, u_long ioctl_cmd, caddr_t arg, int 
flags, struct thread *proc)
 {
-   int unit = dev2unit(dev);
-   struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, 
unit);
+   struct AdapterControlBlock *acb = dev->si_drv1;
 
if (acb == NULL) {
return ENXIO;
@@ -4932,6 +4929,7 @@ irq_alloc_failed:
 */
 static int arcmsr_attach(device_t dev)
 {
+   struct make_dev_args args;
struct AdapterControlBlock *acb=(struct AdapterControlBlock 
*)device_get_softc(dev);
u_int32_t unit=device_get_unit(dev);
struct ccb_setasync csa;
@@ -5000,7 +4998,13 @@ irqx:
xpt_action((union ccb *)&csa);
ARCMSR_LOCK_RELEASE(&acb->isr_lock);
/* Create the control device.  */
-   acb->ioctl_dev = make_dev(&arcmsr_cdevsw, unit, UID_ROOT, GID_WHEEL /* 
GID_OPERATOR */, S_IRUSR | S_IWUSR, "arcmsr%d", unit);
+   make_dev_args_init(&args);
+   args.mda_devsw = &arcmsr_cdevsw;
+   args.mda_uid = UID_ROOT;
+   args.mda_gid = GID_WHEEL /* GID_OPERATOR */;
+   args.mda_mode = S_IRUSR | S_IWUSR;
+   args.mda_si_drv1 = acb;
+   (void)make_dev_s(&args, &acb->ioctl_dev, "arcmsr%d", unit);

(void)make_dev_alias(acb->ioctl_dev, "arc%d", unit);
arcmsr_callout_init(&acb->devmap_callout);



git: aee33ff46759 - stable/13 - pcm: Remove dead code from sound_modevent.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=aee33ff4675935881190f28c154c2c804c73f826

commit aee33ff4675935881190f28c154c2c804c73f826
Author: John Baldwin 
AuthorDate: 2022-04-21 17:29:14 +
Commit: John Baldwin 
CommitDate: 2022-05-19 21:32:56 +

pcm: Remove dead code from sound_modevent.

Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D34997

(cherry picked from commit 8109ec9d894a0fe7ccbbf627aeb7b111c337266e)
---
 sys/dev/sound/pcm/sound.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index dcc2180fe88a..a9d24703dbb0 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -1427,12 +1427,9 @@ static int
 sound_modevent(module_t mod, int type, void *data)
 {
int ret;
-#if 0
-   return (midi_modevent(mod, type, data));
-#else
-   ret = 0;
 
-   switch(type) {
+   ret = 0;
+   switch (type) {
case MOD_LOAD:
pcmsg_unrhdr = new_unrhdr(1, INT_MAX, NULL);
break;
@@ -1449,7 +1446,6 @@ sound_modevent(module_t mod, int type, void *data)
}
 
return ret;
-#endif
 }
 
 DEV_MODULE(sound, sound_modevent, NULL);



git: d2ebb215b8cf - stable/13 - arcmsr: Remove never-true NULL check from cdev callbacks.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d2ebb215b8cf5f9f931c611332de352e26a11bf3

commit d2ebb215b8cf5f9f931c611332de352e26a11bf3
Author: John Baldwin 
AuthorDate: 2022-04-21 17:29:14 +
Commit: John Baldwin 
CommitDate: 2022-05-19 21:33:02 +

arcmsr: Remove never-true NULL check from cdev callbacks.

si_drv1 will always hold a non-NULL pointer.

Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D35005

(cherry picked from commit 108adb2ff52c73a92837452ef3ed641053bd1b6f)
---
 sys/dev/arcmsr/arcmsr.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c
index f64093a94e7f..6a21a91fda58 100644
--- a/sys/dev/arcmsr/arcmsr.c
+++ b/sys/dev/arcmsr/arcmsr.c
@@ -240,11 +240,6 @@ static struct cdevsw arcmsr_cdevsw={
 */
 static int arcmsr_open(struct cdev *dev, int flags, int fmt, struct thread 
*proc)
 {
-   struct AdapterControlBlock *acb = dev->si_drv1;
-
-   if (acb == NULL) {
-   return ENXIO;
-   }
return (0);
 }
 /*
@@ -253,11 +248,6 @@ static int arcmsr_open(struct cdev *dev, int flags, int 
fmt, struct thread *proc
 */
 static int arcmsr_close(struct cdev *dev, int flags, int fmt, struct thread 
*proc)
 {
-   struct AdapterControlBlock *acb = dev->si_drv1;
-
-   if (acb == NULL) {
-   return ENXIO;
-   }
return 0;
 }
 /*
@@ -268,9 +258,6 @@ static int arcmsr_ioctl(struct cdev *dev, u_long ioctl_cmd, 
caddr_t arg, int fla
 {
struct AdapterControlBlock *acb = dev->si_drv1;
 
-   if (acb == NULL) {
-   return ENXIO;
-   }
return (arcmsr_iop_ioctlcmd(acb, ioctl_cmd, arg));
 }
 /*



git: 7fe4c7b59e03 - stable/13 - acpi_toshiba: Use device_get_softc in attach.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7fe4c7b59e030e81dc1227ff649176e99f6de9c9

commit 7fe4c7b59e030e81dc1227ff649176e99f6de9c9
Author: John Baldwin 
AuthorDate: 2022-04-21 17:29:15 +
Commit: John Baldwin 
CommitDate: 2022-05-19 21:33:09 +

acpi_toshiba: Use device_get_softc in attach.

Rather than a detour via the devclass and hardcoding unit 0.

While here, remove a check for sc being NULL.  It will never be NULL
when attach is called.

Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D35010

(cherry picked from commit 1ac10fa429370731be57dee76b19896e01764b76)
---
 sys/dev/acpi_support/acpi_toshiba.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/dev/acpi_support/acpi_toshiba.c 
b/sys/dev/acpi_support/acpi_toshiba.c
index c5233579d560..208cc36c9a59 100644
--- a/sys/dev/acpi_support/acpi_toshiba.c
+++ b/sys/dev/acpi_support/acpi_toshiba.c
@@ -562,9 +562,7 @@ acpi_toshiba_video_attach(device_t dev)
 {
struct  acpi_toshiba_softc *sc;
 
-   sc = devclass_get_softc(acpi_toshiba_devclass, 0);
-   if (sc == NULL)
-   return (ENXIO);
+   sc = device_get_softc(dev);
sc->video_handle = acpi_get_handle(dev);
return (0);
 }



git: c7f0b91ba269 - stable/13 - smapi: Store softc pointer in si_drv1 of cdev.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c7f0b91ba2693e50f32402e1094f51c6431b4768

commit c7f0b91ba2693e50f32402e1094f51c6431b4768
Author: John Baldwin 
AuthorDate: 2022-05-05 23:35:19 +
Commit: John Baldwin 
CommitDate: 2022-05-19 22:01:50 +

smapi: Store softc pointer in si_drv1 of cdev.

Rather than fetching the softc using the device's unit number as an
index into the devclass.

Differential Revision:  https://reviews.freebsd.org/D35063

(cherry picked from commit d4f988e1886fee0c89443b6937bf47b6439f80b0)
---
 sys/i386/bios/smapi.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/sys/i386/bios/smapi.c b/sys/i386/bios/smapi.c
index 5b82df87e980..653399e1ca58 100644
--- a/sys/i386/bios/smapi.c
+++ b/sys/i386/bios/smapi.c
@@ -102,16 +102,9 @@ extern int smapi32_new(u_long, u_short,
 static int
 smapi_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct 
thread *td)
 {
-   struct smapi_softc *sc;
+   struct smapi_softc *sc = dev->si_drv1;
int error;
 
-   error = 0;
-   sc = devclass_get_softc(smapi_devclass, dev2unit(dev)); 
-if (sc == NULL) {
-error = ENXIO;
-goto fail;
-}
-
switch (cmd) {
case SMAPIOGHEADER:
bcopy((caddr_t)sc->header, data,
@@ -127,7 +120,6 @@ smapi_ioctl (struct cdev *dev, u_long cmd, caddr_t data, 
int fflag, struct threa
error = ENOTTY;
}
 
-fail:
return (error);
 }
 
@@ -204,6 +196,7 @@ bad:
 static int
 smapi_attach (device_t dev)
 {
+   struct make_dev_args args;
struct smapi_softc *sc;
int error;
 
@@ -224,12 +217,17 @@ smapi_attach (device_t dev)
sc->header->prot32_segment +
sc->header->prot32_offset);
 
-sc->cdev = make_dev(&smapi_cdevsw,
-   device_get_unit(sc->dev),
-   UID_ROOT, GID_WHEEL, 0600,
-   "%s%d",
+   make_dev_args_init(&args);
+   args.mda_devsw = &smapi_cdevsw;
+   args.mda_uid = UID_ROOT;
+   args.mda_gid = GID_WHEEL;
+   args.mda_mode = 0600;
+   args.mda_si_drv1 = sc;
+error = make_dev_s(&args, &sc->cdev, "%s%d",
smapi_cdevsw.d_name,
device_get_unit(sc->dev));
+   if (error != 0)
+   goto bad;
 
device_printf(dev, "Version: %d.%02d, Length: %d, Checksum: 0x%02x\n",
bcd2bin(sc->header->version_major),



git: f02bf967fcd3 - stable/13 - pbio: Store softc in si_drv1 for character devices.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f02bf967fcd3e6e544aa08c014ec0fabc1714aad

commit f02bf967fcd3e6e544aa08c014ec0fabc1714aad
Author: John Baldwin 
AuthorDate: 2022-05-05 23:38:25 +
Commit: John Baldwin 
CommitDate: 2022-05-19 22:01:50 +

pbio: Store softc in si_drv1 for character devices.

The port number is still stored in the unit (si_drv0) but is the
entire unit value now.

While here, removed checks for NULL softc since those can never happen
from cdevsw routines.  This also resulted in the close method becoming
a no-op, so it has been removed.

Differential Revision:  https://reviews.freebsd.org/D35078

(cherry picked from commit 0db65574bbb9e379ebf3ce027fc7607fdc9118fd)
---
 sys/dev/pbio/pbio.c | 74 +
 1 file changed, 23 insertions(+), 51 deletions(-)

diff --git a/sys/dev/pbio/pbio.c b/sys/dev/pbio/pbio.c
index 4b5f0e9fc819..042a92e39f42 100644
--- a/sys/dev/pbio/pbio.c
+++ b/sys/dev/pbio/pbio.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
 
 /* Function prototypes (these should all be static) */
 static d_open_tpbioopen;
-static d_close_t   pbioclose;
 static d_read_tpbioread;
 static d_write_t   pbiowrite;
 static d_ioctl_t   pbioioctl;
@@ -81,8 +80,9 @@ static char *port_names[] = {"a", "b", "ch", "cl"};
 
 #definePBIO_PNAME(n)   (port_names[(n)])
 
-#defineUNIT(dev)   (dev2unit(dev) >> 2)
-#definePORT(dev)   (dev2unit(dev) & 0x3)
+#definePORT(dev)   (dev2unit(dev))
+
+#definepbio_addr(dev)  ((dev)->si_drv1)
 
 #definePBIOPRI ((PZERO + 5) | PCATCH)
 
@@ -90,7 +90,6 @@ static struct cdevsw pbio_cdevsw = {
.d_version = D_VERSION,
.d_flags = D_NEEDGIANT,
.d_open = pbioopen,
-   .d_close = pbioclose,
.d_read = pbioread,
.d_write = pbiowrite,
.d_ioctl = pbioioctl,
@@ -132,8 +131,6 @@ static device_method_t pbio_methods[] = {
 };
 
 static devclass_t  pbio_devclass;
-#definepbio_addr(unit) \
-   ((struct pbio_softc *) devclass_get_softc(pbio_devclass, unit))
 
 static char driver_name[] = "pbio";
 
@@ -218,6 +215,7 @@ pbioprobe(device_t dev)
 static int
 pbioattach (device_t dev)
 {
+   struct make_dev_args args;
int unit;
int i;
int rid;
@@ -238,9 +236,17 @@ pbioattach (device_t dev)
 */
sc->iomode = 0x9b;  /* All ports to input */
 
-   for (i = 0; i < PBIO_NPORTS; i++)
-   sc->pd[i].port = make_dev(&pbio_cdevsw, (unit << 2) + i, 0, 0,
-   0600, "pbio%d%s", unit, PBIO_PNAME(i));
+   for (i = 0; i < PBIO_NPORTS; i++) {
+   make_dev_args_init(&args);
+   args.mda_devsw = &pbio_cdevsw;
+   args.mda_uid = 0;
+   args.mda_gid = 0;
+   args.mda_mode = 0600;
+   args.mda_unit = i;
+   args.mda_si_drv1 = sc;
+   (void)make_dev_s(&args, &sc->pd[i].port, "pbio%d%s", unit,
+   PBIO_PNAME(i));
+   }
return (0);
 }
 
@@ -249,13 +255,10 @@ pbioioctl (struct cdev *dev, u_long cmd, caddr_t data, 
int flag,
 struct thread *td)
 {
struct pbio_softc *scp;
-   int port, unit;
+   int port;
 
-   unit = UNIT(dev);
port = PORT(dev);
-   scp = pbio_addr(unit);
-   if (scp == NULL)
-   return (ENODEV);
+   scp = pbio_addr(dev);
switch (cmd) {
case PBIO_SETDIFF:
scp->pd[port].diff = *(int *)data;
@@ -285,14 +288,11 @@ static  int
 pbioopen(struct cdev *dev, int oflags, int devtype, struct thread *td)
 {
struct pbio_softc *scp;
-   int ocfg, port, unit;
+   int ocfg, port;
int portbit;/* Port configuration bit */
 
-   unit = UNIT(dev);
port = PORT(dev);
-   scp = pbio_addr(unit);
-   if (scp == NULL)
-   return (ENODEV);
+   scp = pbio_addr(dev);
 
switch (port) {
case 0: portbit = 0x10; break;  /* Port A */
@@ -315,20 +315,6 @@ pbioopen(struct cdev *dev, int oflags, int devtype, struct 
thread *td)
return (0);
 }
 
-static  int
-pbioclose(struct cdev *dev, int fflag, int devtype, struct thread *td)
-{
-   struct pbio_softc *scp;
-   int unit;
-
-   unit = UNIT(dev);
-   scp = pbio_addr(unit);
-   if (scp == NULL)
-   return (ENODEV);
-
-   return (0);
-}
-
 /*
  * Return the value of a given port on a given I/O base address
  * Handles the split C port nibbles and blocking
@@ -374,14 +360,11 @@ static  int
 pbioread(struct cdev *dev, struct uio *uio, int ioflag)
 {
struct pbio_softc *scp;
-   int err, i, port, ret, toread, unit;
+   int err, i, port, ret, toread;
char val;
 
-   unit = 

git: c6960a68817c - stable/13 - pbio: Axe bus_space tag/handle using bus_read/write_1 instead.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c6960a68817cc124e3c4ead10850f5a2e4f517e2

commit c6960a68817cc124e3c4ead10850f5a2e4f517e2
Author: John Baldwin 
AuthorDate: 2022-05-05 23:38:51 +
Commit: John Baldwin 
CommitDate: 2022-05-19 22:01:50 +

pbio: Axe bus_space tag/handle using bus_read/write_1 instead.

Differential Revision:  https://reviews.freebsd.org/D35079

(cherry picked from commit bb81a138c36aad8359e3599b14b46817ea00e16a)
---
 sys/dev/pbio/pbio.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/sys/dev/pbio/pbio.c b/sys/dev/pbio/pbio.c
index 042a92e39f42..837b419e298c 100644
--- a/sys/dev/pbio/pbio.c
+++ b/sys/dev/pbio/pbio.c
@@ -117,8 +117,6 @@ struct pbio_softc {
int iomode; /* Virtualized I/O mode port value */
/* The real port is write-only */
struct resource *res;
-   bus_space_tag_t bst;
-   bus_space_handle_t bsh;
 };
 
 typedefstruct pbio_softc *sc_p;
@@ -146,14 +144,14 @@ static __inline uint8_t
 pbinb(struct pbio_softc *scp, int off)
 {
 
-   return bus_space_read_1(scp->bst, scp->bsh, off);
+   return (bus_read_1(scp->res, off));
 }
 
 static __inline void
 pboutb(struct pbio_softc *scp, int off, uint8_t val)
 {
 
-   bus_space_write_1(scp->bst, scp->bsh, off, val);
+   bus_write_1(scp->res, off, val);
 }
 
 static int
@@ -174,8 +172,6 @@ pbioprobe(device_t dev)
return (ENXIO);
 
 #ifdef GENERIC_PBIO_PROBE
-   scp->bst = rman_get_bustag(scp->res);
-   scp->bsh = rman_get_bushandle(scp->res);
/*
 * try see if the device is there.
 * This probe works only if the device has no I/O attached to it
@@ -228,8 +224,6 @@ pbioattach (device_t dev)
IO_PBIOSIZE, RF_ACTIVE);
if (sc->res == NULL)
return (ENXIO);
-   sc->bst = rman_get_bustag(sc->res);
-   sc->bsh = rman_get_bushandle(sc->res);
 
/*
 * Store whatever seems wise.



git: bde0080b3dec - stable/13 - pbio: Return BUS_PROBE_DEFAULT from probe instead of 0.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bde0080b3decbc668bbda64d427b441794f92790

commit bde0080b3decbc668bbda64d427b441794f92790
Author: John Baldwin 
AuthorDate: 2022-05-05 23:39:19 +
Commit: John Baldwin 
CommitDate: 2022-05-19 22:01:50 +

pbio: Return BUS_PROBE_DEFAULT from probe instead of 0.

0 should only be returned from probe in legacy drivers that need to
preserve softc state between probe and attach.

Differential Revision:  https://reviews.freebsd.org/D35080

(cherry picked from commit 4942e8df472bdb49e72a8c9b60e8189bdb037b8c)
---
 sys/dev/pbio/pbio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/pbio/pbio.c b/sys/dev/pbio/pbio.c
index 837b419e298c..516ec3a73408 100644
--- a/sys/dev/pbio/pbio.c
+++ b/sys/dev/pbio/pbio.c
@@ -200,7 +200,7 @@ pbioprobe(device_t dev)
/* Set all ports to input */
/* pboutb(scp, PBIO_CFG, 0x9b); */
bus_release_resource(dev, SYS_RES_IOPORT, rid, scp->res);
-   return (0);
+   return (BUS_PROBE_DEFAULT);
 }
 
 /*



git: e6464fce46f2 - stable/13 - nvdimm_e820: Use driver->name in identify method.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e6464fce46f27a53c467420938b55231bb7f50ee

commit e6464fce46f27a53c467420938b55231bb7f50ee
Author: John Baldwin 
AuthorDate: 2022-05-06 21:42:02 +
Commit: John Baldwin 
CommitDate: 2022-05-19 22:01:50 +

nvdimm_e820: Use driver->name in identify method.

Reviewed by:kib
Differential Revision:  https://reviews.freebsd.org/D35077

(cherry picked from commit 216ca4cee1189ce1dd38b293c9dd431eb5ff8b02)
---
 sys/dev/nvdimm/nvdimm_e820.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/dev/nvdimm/nvdimm_e820.c b/sys/dev/nvdimm/nvdimm_e820.c
index 66bdff937dc5..0ba8cfbc7868 100644
--- a/sys/dev/nvdimm/nvdimm_e820.c
+++ b/sys/dev/nvdimm/nvdimm_e820.c
@@ -257,15 +257,15 @@ nvdimm_e820_remove_spas(device_t dev)
 }
 
 static void
-nvdimm_e820_identify(driver_t *driver __unused, device_t parent)
+nvdimm_e820_identify(driver_t *driver, device_t parent)
 {
device_t child;
caddr_t kmdp;
 
-   if (resource_disabled(NVDIMM_E820, 0))
+   if (resource_disabled(driver->name, 0))
return;
/* Just create a single instance of the fake bus. */
-   if (device_find_child(parent, NVDIMM_E820, -1) != NULL)
+   if (device_find_child(parent, driver->name, -1) != NULL)
return;
 
kmdp = preload_search_by_type("elf kernel");
@@ -278,9 +278,9 @@ nvdimm_e820_identify(driver_t *driver __unused, device_t 
parent)
if (smapbase == NULL)
return;
 
-   child = BUS_ADD_CHILD(parent, 0, NVDIMM_E820, -1);
+   child = BUS_ADD_CHILD(parent, 0, driver->name, -1);
if (child == NULL)
-   device_printf(parent, "add %s child failed\n", NVDIMM_E820);
+   device_printf(parent, "add %s child failed\n", driver->name);
 }
 
 static int



git: 80893ea32be0 - stable/13 - pbio: Add locking and remove D_NEEDGIANT.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=80893ea32be08797049b36dc14e2210e40a4f5b8

commit 80893ea32be08797049b36dc14e2210e40a4f5b8
Author: John Baldwin 
AuthorDate: 2022-05-05 23:40:04 +
Commit: John Baldwin 
CommitDate: 2022-05-19 22:01:50 +

pbio: Add locking and remove D_NEEDGIANT.

Use a sx lock to permit uiomove directly into/out of the the per-port
buffers.  In addition, the sx lock provides a stronger guarantee that
I think this driver wants which is to single-thread read and write
calls even while paused.  Finally, replace tsleep with dummy wait
channels with calls to pause_sig to more clearly communicate the
intent.

Differential Revision:  https://reviews.freebsd.org/D35081

(cherry picked from commit 51f481235c29fb38b92fb08a830385e39df80093)
---
 sys/dev/pbio/pbio.c | 54 ++---
 1 file changed, 31 insertions(+), 23 deletions(-)

diff --git a/sys/dev/pbio/pbio.c b/sys/dev/pbio/pbio.c
index 516ec3a73408..0fd841cd5720 100644
--- a/sys/dev/pbio/pbio.c
+++ b/sys/dev/pbio/pbio.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #include/* pbio IOCTL definitions */
 #include 
 #include 
+#include 
 #include 
 
 /* Function prototypes (these should all be static) */
@@ -84,11 +85,8 @@ static char *port_names[] = {"a", "b", "ch", "cl"};
 
 #definepbio_addr(dev)  ((dev)->si_drv1)
 
-#definePBIOPRI ((PZERO + 5) | PCATCH)
-
 static struct cdevsw pbio_cdevsw = {
.d_version = D_VERSION,
-   .d_flags = D_NEEDGIANT,
.d_open = pbioopen,
.d_read = pbioread,
.d_write = pbiowrite,
@@ -117,6 +115,7 @@ struct pbio_softc {
int iomode; /* Virtualized I/O mode port value */
/* The real port is write-only */
struct resource *res;
+   struct sx lock;
 };
 
 typedefstruct pbio_softc *sc_p;
@@ -230,6 +229,7 @@ pbioattach (device_t dev)
 */
sc->iomode = 0x9b;  /* All ports to input */
 
+   sx_init(&sc->lock, "pbio");
for (i = 0; i < PBIO_NPORTS; i++) {
make_dev_args_init(&args);
args.mda_devsw = &pbio_cdevsw;
@@ -249,10 +249,12 @@ pbioioctl (struct cdev *dev, u_long cmd, caddr_t data, 
int flag,
 struct thread *td)
 {
struct pbio_softc *scp;
-   int port;
+   int error, port;
 
+   error = 0;
port = PORT(dev);
scp = pbio_addr(dev);
+   sx_xlock(&scp->lock);
switch (cmd) {
case PBIO_SETDIFF:
scp->pd[port].diff = *(int *)data;
@@ -273,16 +275,17 @@ pbioioctl (struct cdev *dev, u_long cmd, caddr_t data, 
int flag,
*(int *)data = scp->pd[port].opace;
break;
default:
-   return ENXIO;
+   error = ENXIO;
}
-   return (0);
+   sx_xunlock(&scp->lock);
+   return (error);
 }
 
 static  int
 pbioopen(struct cdev *dev, int oflags, int devtype, struct thread *td)
 {
struct pbio_softc *scp;
-   int ocfg, port;
+   int error, ocfg, port;
int portbit;/* Port configuration bit */
 
port = PORT(dev);
@@ -297,6 +300,8 @@ pbioopen(struct cdev *dev, int oflags, int devtype, struct 
thread *td)
}
ocfg = scp->iomode;
 
+   error = 0;
+   sx_xlock(&scp->lock);
if (oflags & FWRITE)
/* Writing == output; zero the bit */
pboutb(scp, PBIO_CFG, scp->iomode = (ocfg & (~portbit)));
@@ -304,9 +309,10 @@ pbioopen(struct cdev *dev, int oflags, int devtype, struct 
thread *td)
/* Reading == input; set the bit */
pboutb(scp, PBIO_CFG, scp->iomode = (ocfg | portbit));
else
-   return (EACCES);
+   error = EACCES;
+   sx_xunlock(&scp->lock);
 
-   return (0);
+   return (error);
 }
 
 /*
@@ -341,8 +347,7 @@ portval(int port, struct pbio_softc *scp, char *val)
scp->pd[port].oldval = *val;
return (0);
}
-   err = tsleep((caddr_t)&(scp->pd[port].diff), PBIOPRI,
-"pbiopl", max(1, scp->pd[port].ipace));
+   err = pause_sig("pbiopl", max(1, scp->pd[port].ipace));
if (err == EINTR)
return (EINTR);
} else
@@ -354,26 +359,28 @@ static  int
 pbioread(struct cdev *dev, struct uio *uio, int ioflag)
 {
struct pbio_softc *scp;
-   int err, i, port, ret, toread;
+   int err, i, port, toread;
char val;
 
port = PORT(dev);
scp = pbio_addr(dev);
 
+   err = 0;
+   sx_xlock(&scp->lock);
while (uio->uio_resid > 0) {
toread = min(uio->uio_resid, PBIO_BUF

git: 6967516a2727 - stable/13 - qlxgb/qlxgbe/qlxge: Fix build without INET and/or without INET6.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6967516a27275d3985d2ee9f8d3db5805438ddbb

commit 6967516a27275d3985d2ee9f8d3db5805438ddbb
Author: John Baldwin 
AuthorDate: 2022-04-22 22:18:05 +
Commit: John Baldwin 
CommitDate: 2022-05-20 00:22:07 +

qlxgb/qlxgbe/qlxge: Fix build without INET and/or without INET6.

This is in preparation for adding these drivers to amd64 NOTES.

(cherry picked from commit 618aa8cd0ae0edca7d9a4e37ff242a6bb77bbccc)
---
 sys/dev/qlxgb/qla_hw.c  |  4 
 sys/dev/qlxgb/qla_isr.c |  7 ++-
 sys/dev/qlxgb/qla_os.c  |  8 ++--
 sys/dev/qlxgb/qla_os.h  |  2 ++
 sys/dev/qlxgbe/ql_hw.c  |  6 ++
 sys/dev/qlxgbe/ql_isr.c |  9 -
 sys/dev/qlxgbe/ql_os.c  |  8 ++--
 sys/dev/qlxgbe/ql_os.h  |  2 ++
 sys/dev/qlxge/qls_hw.c  | 10 ++
 sys/dev/qlxge/qls_isr.c | 16 +---
 sys/dev/qlxge/qls_os.c  | 12 ++--
 sys/dev/qlxge/qls_os.h  |  2 ++
 12 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/sys/dev/qlxgb/qla_hw.c b/sys/dev/qlxgb/qla_hw.c
index 6144df147ee4..3936a7399435 100644
--- a/sys/dev/qlxgb/qla_hw.c
+++ b/sys/dev/qlxgb/qla_hw.c
@@ -1776,6 +1776,7 @@ qla_update_link_state(qla_host_t *ha)
 int
 qla_config_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
int i;
 qla_hw_t *hw = &ha->hw;
struct lro_ctrl *lro;
@@ -1792,12 +1793,14 @@ qla_config_lro(qla_host_t *ha)
ha->flags.lro_init = 1;
 
QL_DPRINT2((ha->pci_dev, "%s: LRO initialized\n", __func__));
+#endif
return (0);
 }
 
 void
 qla_free_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
int i;
 qla_hw_t *hw = &ha->hw;
struct lro_ctrl *lro;
@@ -1810,6 +1813,7 @@ qla_free_lro(qla_host_t *ha)
tcp_lro_free(lro);
}
ha->flags.lro_init = 0;
+#endif
 }
 
 void
diff --git a/sys/dev/qlxgb/qla_isr.c b/sys/dev/qlxgb/qla_isr.c
index 271baa886d1b..7966fc53b84f 100644
--- a/sys/dev/qlxgb/qla_isr.c
+++ b/sys/dev/qlxgb/qla_isr.c
@@ -139,9 +139,12 @@ qla_rx_intr(qla_host_t *ha, uint64_t data, uint32_t 
sds_idx,
mp->m_pkthdr.csum_flags = 0;
}
 
+#if defined(INET) || defined(INET6)
if (lro->lro_cnt && (tcp_lro_rx(lro, mp, 0) == 0)) {
/* LRO packet has been successfully queued */
-   } else {
+   } else
+#endif
+   {
(*ifp->if_input)(ifp, mp);
}
 
@@ -322,7 +325,9 @@ qla_rcv_isr(qla_host_t *ha, uint32_t sds_idx, uint32_t 
count)
}
}
 
+#if defined(INET) || defined(INET6)
tcp_lro_flush_all(lro);
+#endif
 
if (hw->sds[sds_idx].sdsr_next != comp_idx) {
QL_UPDATE_SDS_CONSUMER_INDEX(ha, sds_idx, comp_idx);
diff --git a/sys/dev/qlxgb/qla_os.c b/sys/dev/qlxgb/qla_os.c
index ab436867771e..9a8a02dfeb20 100644
--- a/sys/dev/qlxgb/qla_os.c
+++ b/sys/dev/qlxgb/qla_os.c
@@ -792,7 +792,9 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
int ret = 0;
struct ifreq *ifr = (struct ifreq *)data;
+#ifdef INET
struct ifaddr *ifa = (struct ifaddr *)data;
+#endif
qla_host_t *ha;
 
ha = (qla_host_t *)ifp->if_softc;
@@ -802,6 +804,7 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
QL_DPRINT4((ha->pci_dev, "%s: SIOCSIFADDR (0x%lx)\n",
__func__, cmd));
 
+#ifdef INET
if (ifa->ifa_addr->sa_family == AF_INET) {
ifp->if_flags |= IFF_UP;
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
@@ -818,9 +821,10 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
qla_config_ipv4_addr(ha,
(IA_SIN(ifa)->sin_addr.s_addr));
}
-   } else {
-   ether_ioctl(ifp, cmd, data);
+   break;
}
+#endif
+   ether_ioctl(ifp, cmd, data);
break;
 
case SIOCSIFMTU:
diff --git a/sys/dev/qlxgb/qla_os.h b/sys/dev/qlxgb/qla_os.h
index 1ee4f8d1ce61..fddae501b8b3 100644
--- a/sys/dev/qlxgb/qla_os.h
+++ b/sys/dev/qlxgb/qla_os.h
@@ -36,6 +36,8 @@
 #ifndef _QLA_OS_H_
 #define _QLA_OS_H_
 
+#include "opt_inet.h"
+
 #include 
 #include 
 #include 
diff --git a/sys/dev/qlxgbe/ql_hw.c b/sys/dev/qlxgbe/ql_hw.c
index 9580a99c47b2..717089427d0a 100644
--- a/sys/dev/qlxgbe/ql_hw.c
+++ b/sys/dev/qlxgbe/ql_hw.c
@@ -2757,6 +2757,7 @@ qla_config_rss_ind_table(qla_host_t *ha)
 static int
 qla_config_soft_lro(qla_host_t *ha)
 {
+#if defined(INET) || defined(INET6)
 int i;
 qla_hw_t *hw = &ha->hw;
 struct lro_ctrl *lro;
@@ -2786,12 +2787,14 @@ qla_config_soft_lro(qla_host_t *ha)
 }
 
 QL_DPRINT2(ha, (ha->pci_dev, "%s: LRO initialized\n", __func__));
+#endif
 return (0);
 }
 
 static void
 qla_drain_soft_lro(qla_host_t *ha)
 {
+#if defi

git: 4aadd86586eb - stable/13 - amd64 NOTES: Add entries for qlxgb, glxgbe, and glxge.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4aadd86586ebdc135c9e16640efc27ae97f7c60d

commit 4aadd86586ebdc135c9e16640efc27ae97f7c60d
Author: John Baldwin 
AuthorDate: 2022-04-22 22:18:06 +
Commit: John Baldwin 
CommitDate: 2022-05-20 00:22:22 +

amd64 NOTES: Add entries for qlxgb, glxgbe, and glxge.

(cherry picked from commit f2d166d5322e557ff1388a5419ed694187fc1dbc)
---
 sys/amd64/conf/NOTES | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES
index b13d19760768..d85d11d1e5d2 100644
--- a/sys/amd64/conf/NOTES
+++ b/sys/amd64/conf/NOTES
@@ -304,6 +304,9 @@ device  cpufreq
 # mlx4ib: Mellanox ConnectX HCA InfiniBand
 # mlx4en: Mellanox ConnectX HCA Ethernet
 # nfe: nVidia nForce MCP on-board Ethernet Networking (BSD open source)
+# qlxgb: QLogic 3200 and 8200 series 10 Gigabit Ethernet & CNA Adapter
+# qlxgbe: QLogic 8300 series 10 Gigabit Ethernet & CNA Adapter
+# qlxge: QLogic 8100 series 10 Gigabit Ethernet & CNA Adapter
 # sfxge: Solarflare SFC9000 family 10Gb Ethernet adapters
 # vmx: VMware VMXNET3 Ethernet (BSD open source)
 # wpi: Intel 3945ABG Wireless LAN controller
@@ -324,6 +327,9 @@ device  mlx4# Shared code module between IB 
and Ethernet
 device mlx4ib  # Mellanox ConnectX HCA InfiniBand
 device mlx4en  # Mellanox ConnectX HCA Ethernet
 device nfe # nVidia nForce MCP on-board Ethernet
+device qlxgb   # QLogic 3200/8200 Ethernet
+device qlxgbe  # QLogic 8300 Ethernet
+device qlxge   # QLogic 8100 Ethernet
 device sfxge   # Solarflare SFC9000 10Gb Ethernet
 device vmx # VMware VMXNET3 Ethernet
 device wpi # Intel 3945ABG wireless NICs.



git: 57120a1140de - stable/13 - amd64 NOTES: Sort the axp entry.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=57120a1140deef749ea44709e176f16ea5eab647

commit 57120a1140deef749ea44709e176f16ea5eab647
Author: John Baldwin 
AuthorDate: 2022-04-22 22:18:06 +
Commit: John Baldwin 
CommitDate: 2022-05-20 00:22:15 +

amd64 NOTES: Sort the axp entry.

(cherry picked from commit 5bf623bbcdfaa5be2d639317b601f2019ba3ed28)
---
 sys/amd64/conf/NOTES | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES
index 54ca25e42c40..b13d19760768 100644
--- a/sys/amd64/conf/NOTES
+++ b/sys/amd64/conf/NOTES
@@ -286,6 +286,8 @@ device  cpufreq
 # Network interfaces:
 #
 
+# axp: AMD EPYC integrated NIC
+#  Requires the miibus module
 # bxe:  Broadcom NetXtreme II (BCM5771X/BCM578XX) PCIe 10Gb Ethernet
 #   adapters.
 # ice: Intel 800 Series Physical Function
@@ -307,6 +309,7 @@ device  cpufreq
 # wpi: Intel 3945ABG Wireless LAN controller
 #  Requires the wpi firmware module
 
+device axp # AMD EPYC integrated NIC
 device bxe # Broadcom NetXtreme II BCM5771X/BCM578XX 10GbE
 device igc # Intel I225 2.5G Ethernet
 device ipw # Intel 2100 wireless NICs.
@@ -324,7 +327,6 @@ device  nfe # nVidia nForce MCP 
on-board Ethernet
 device sfxge   # Solarflare SFC9000 10Gb Ethernet
 device vmx # VMware VMXNET3 Ethernet
 device wpi # Intel 3945ABG wireless NICs.
-device axp # AMD EPYC integrated NIC
 
 # IEEE 802.11 adapter firmware modules
 



git: 6835ace58091 - stable/13 - setkey(8): Clarify language around AEAD ciphers.

2022-05-19 Thread John Baldwin
The branch stable/13 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6835ace580917ec512eb96cf9c456f4acc161247

commit 6835ace580917ec512eb96cf9c456f4acc161247
Author: John Baldwin 
AuthorDate: 2022-04-27 19:18:52 +
Commit: John Baldwin 
CommitDate: 2022-05-20 00:35:34 +

setkey(8): Clarify language around AEAD ciphers.

AEAD ciphers for IPsec combine both encryption and authentication.  As
such, ESP configurations using an AEAD cipher should not use a
seperate authentication algorithm via -A.  However, this was not
apparent from the setkey manpage and 12.x and earlier did not perform
sufficient argument validation permitting users to pair an explicit -A
such as SHA256-HMAC with AES-GCM.  (The result was a non-standard
combination of AES-CTR with the specified MAC, but with the wrong
initial block counter (and thus different keystream) compared to using
AES-CTR as the cipher.)

Attempt to clarify this in the manpage by explicitly calling out AEAD
ciphers (currently only AES-GCM) and noting that AEAD ciphers should
not use -A.

While here, explicitly note which authentication algorithms can be
used with esp vs esp-old.  Also add subsection headings for the
different algorithm lists and tidy some language.

I did not convert the tables to column lists (Bl -column) though that
would probably be more correct than using literal blocks (Bd
-literal).

PR: 263379
Reviewed by:Pau Amma , markj
Differential Revision:  https://reviews.freebsd.org/D34947

(cherry picked from commit e6dede145616ed8f98c629c23a2ba206b812c921)
---
 sbin/setkey/setkey.8 | 58 +---
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/sbin/setkey/setkey.8 b/sbin/setkey/setkey.8
index 0d271b84792e..38417d194c66 100644
--- a/sbin/setkey/setkey.8
+++ b/sbin/setkey/setkey.8
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 4, 2020
+.Dd April 27, 2022
 .Dt SETKEY 8
 .Os
 .\"
@@ -328,7 +328,8 @@ Specify hard/soft life time duration of the SA.
 .It Ar algorithm
 .Bl -tag -width Fl -compact
 .It Fl E Ar ealgo Ar key
-Specify an encryption algorithm
+Specify an encryption or Authenticated Encryption with Associated Data
+(AEAD) algorithm
 .Ar ealgo
 for ESP.
 .It Xo
@@ -573,13 +574,9 @@ for details.
 .El
 .\"
 .Sh ALGORITHMS
-The following list shows the supported algorithms.
-The
-.Sy protocol
-and
-.Sy algorithm
-are almost completely orthogonal.
-The following list of authentication algorithms can be used as
+The following lists show the supported algorithms.
+.Ss Authentication Algorithms
+The following authentication algorithms can be used as
 .Ar aalgo
 in the
 .Fl A Ar aalgo
@@ -588,21 +585,21 @@ of the
 parameter:
 .Bd -literal -offset indent
 algorithm  keylen (bits)   comment
-hmac-sha1  160 ah: rfc2404
-   160 ah-old: 128bit ICV (no document)
+hmac-sha1  160 ah/esp: rfc2404
+   160 ah-old/esp-old: 128bit ICV (no document)
 null   0 to 2048   for debugging
-hmac-sha2-256  256 ah: 128bit ICV (RFC4868)
-   256 ah-old: 128bit ICV (no document)
-hmac-sha2-384  384 ah: 192bit ICV (RFC4868)
-   384 ah-old: 128bit ICV (no document)
-hmac-sha2-512  512 ah: 256bit ICV (RFC4868)
-   512 ah-old: 128bit ICV (no document)
-aes-xcbc-mac   128 ah: 96bit ICV (RFC3566)
-   128 ah-old: 128bit ICV (no document)
+hmac-sha2-256  256 ah/esp: 128bit ICV (RFC4868)
+   256 ah-old/esp-old: 128bit ICV (no document)
+hmac-sha2-384  384 ah/esp: 192bit ICV (RFC4868)
+   384 ah-old/esp-old: 128bit ICV (no document)
+hmac-sha2-512  512 ah/esp: 256bit ICV (RFC4868)
+   512 ah-old/esp-old: 128bit ICV (no document)
+aes-xcbc-mac   128 ah/esp: 96bit ICV (RFC3566)
+   128 ah-old/esp-old: 128bit ICV (no document)
 tcp-md58 to 640tcp: rfc2385
 .Ed
-.Pp
-The following is the list of encryption algorithms that can be used as the
+.Ss Encryption Algorithms
+The following encryption algorithms can be used as the
 .Ar ealgo
 in the
 .Fl E Ar ealgo
@@ -614,14 +611,23 @@ algorithm keylen (bits)   comment
 null   0 to 2048   rfc2410
 aes-cbc128/192/256 rfc3602
 aes-ctr160/224/288 rfc3686
-aes-gcm-16 160/224/288 rfc4106
+aes-gcm-16 160/224/288 AEAD; rfc4106
 .Ed
 .Pp
 Note that the first 128/192/256 bits of a key for
-.Li aes-ctr or aes-gcm-16
-will be used as AES key, and remaining 32 bits will be used as nonce.
+.Li aes-ctr
+or
+.Li aes-gcm-16
+will be used as the AES key,
+and the remainin

git: f01978f464ce - stable/13 - nfsd: Add a sanity check for Owner/OwnerGroup string length

2022-05-19 Thread Rick Macklem
The branch stable/13 has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f01978f464cea1cffeb1a66a18f92d98380dd7f2

commit f01978f464cea1cffeb1a66a18f92d98380dd7f2
Author: Rick Macklem 
AuthorDate: 2022-05-04 20:58:22 +
Commit: Rick Macklem 
CommitDate: 2022-05-20 00:36:22 +

nfsd: Add a sanity check for Owner/OwnerGroup string length

Robert Morris reported that, if a client sends an absurdly
large Owner/OwnerGroup string, the kernel malloc() for the
large size string can block forever.

This patch adds a sanity limit for Owner/OwnerGroup string
length.  Since the RFCs do not specify any limit and FreeBSD
can handle a group name greater than 1Kbyte, the limit is
set at a generous 10Kbytes.

PR: 260546

(cherry picked from commit ef4edb70c909fc2b1de867601c2230597d07daa0)
---
 sys/fs/nfs/nfs.h| 7 +++
 sys/fs/nfs/nfs_commonsubs.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/fs/nfs/nfs.h b/sys/fs/nfs/nfs.h
index 1a29a7e1d6ec..ffd612331c1f 100644
--- a/sys/fs/nfs/nfs.h
+++ b/sys/fs/nfs/nfs.h
@@ -143,6 +143,13 @@
 
 #defineNFS_READDIRBLKSIZ   DIRBLKSIZ   /* Minimal 
nm_readdirsize */
 
+/*
+ * The NFSv4 RFCs do not define an upper limit on the length of Owner and
+ * OwnerGroup strings.  Since FreeBSD handles a group name > 1024bytes in
+ * length, set a generous sanity limit of 10Kbytes.
+ */
+#defineNFSV4_MAXOWNERGROUPLEN  (10 * 1024)
+
 /*
  * Oddballs
  */
diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index 51071a6f03ca..eb6746ec3041 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -1838,7 +1838,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
case NFSATTRBIT_OWNER:
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
j = fxdr_unsigned(int, *tl);
-   if (j < 0) {
+   if (j < 0 || j > NFSV4_MAXOWNERGROUPLEN) {
error = NFSERR_BADXDR;
goto nfsmout;
}
@@ -1871,7 +1871,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
case NFSATTRBIT_OWNERGROUP:
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
j = fxdr_unsigned(int, *tl);
-   if (j < 0) {
+   if (j < 0 || j > NFSV4_MAXOWNERGROUPLEN) {
error =  NFSERR_BADXDR;
goto nfsmout;
}



git: 6aaf8a8b1bcf - stable/12 - setkey(8): Clarify language around AEAD ciphers.

2022-05-19 Thread John Baldwin
The branch stable/12 has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6aaf8a8b1bcf500aa7342043d43007ff9c52cd65

commit 6aaf8a8b1bcf500aa7342043d43007ff9c52cd65
Author: John Baldwin 
AuthorDate: 2022-04-27 19:18:52 +
Commit: John Baldwin 
CommitDate: 2022-05-20 00:42:24 +

setkey(8): Clarify language around AEAD ciphers.

AEAD ciphers for IPsec combine both encryption and authentication.  As
such, ESP configurations using an AEAD cipher should not use a
seperate authentication algorithm via -A.  However, this was not
apparent from the setkey manpage and 12.x and earlier did not perform
sufficient argument validation permitting users to pair an explicit -A
such as SHA256-HMAC with AES-GCM.  (The result was a non-standard
combination of AES-CTR with the specified MAC, but with the wrong
initial block counter (and thus different keystream) compared to using
AES-CTR as the cipher.)

Attempt to clarify this in the manpage by explicitly calling out AEAD
ciphers (currently only AES-GCM) and noting that AEAD ciphers should
not use -A.

While here, explicitly note which authentication algorithms can be
used with esp vs esp-old.  Also add subsection headings for the
different algorithm lists and tidy some language.

I did not convert the tables to column lists (Bl -column) though that
would probably be more correct than using literal blocks (Bd
-literal).

PR: 263379
Reviewed by:Pau Amma , markj
Differential Revision:  https://reviews.freebsd.org/D34947

(cherry picked from commit e6dede145616ed8f98c629c23a2ba206b812c921)
---
 sbin/setkey/setkey.8 | 74 
 1 file changed, 40 insertions(+), 34 deletions(-)

diff --git a/sbin/setkey/setkey.8 b/sbin/setkey/setkey.8
index a9653a3b25d4..38e04aa412ed 100644
--- a/sbin/setkey/setkey.8
+++ b/sbin/setkey/setkey.8
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 4, 2020
+.Dd April 27, 2022
 .Dt SETKEY 8
 .Os
 .\"
@@ -328,7 +328,8 @@ Specify hard/soft life time duration of the SA.
 .It Ar algorithm
 .Bl -tag -width Fl -compact
 .It Fl E Ar ealgo Ar key
-Specify an encryption algorithm
+Specify an encryption or Authenticated Encryption with Associated Data
+(AEAD) algorithm
 .Ar ealgo
 for ESP.
 .It Xo
@@ -573,13 +574,9 @@ for details.
 .El
 .\"
 .Sh ALGORITHMS
-The following list shows the supported algorithms.
-The
-.Sy protocol
-and
-.Sy algorithm
-are almost completely orthogonal.
-The following list of authentication algorithms can be used as
+The following lists show the supported algorithms.
+.Ss Authentication Algorithms
+The following authentication algorithms can be used as
 .Ar aalgo
 in the
 .Fl A Ar aalgo
@@ -588,29 +585,29 @@ of the
 parameter:
 .Bd -literal -offset indent
 algorithm  keylen (bits)   comment
-hmac-md5   128 ah: rfc2403
-   128 ah-old: rfc2085
-hmac-sha1  160 ah: rfc2404
-   160 ah-old: 128bit ICV (no document)
-keyed-md5  128 ah: 96bit ICV (no document)
-   128 ah-old: rfc1828
-keyed-sha1 160 ah: 96bit ICV (no document)
-   160 ah-old: 128bit ICV (no document)
+hmac-md5   128 ah/esp: rfc2403
+   128 ah-old/esp-old: rfc2085
+hmac-sha1  160 ah/esp: rfc2404
+   160 ah-old/esp-old: 128bit ICV (no document)
+keyed-md5  128 ah/esp: 96bit ICV (no document)
+   128 ah-old/esp-old: rfc1828
+keyed-sha1 160 ah/esp: 96bit ICV (no document)
+   160 ah-old/esp-old: 128bit ICV (no document)
 null   0 to 2048   for debugging
-hmac-sha2-256  256 ah: 128bit ICV (RFC4868)
-   256 ah-old: 128bit ICV (no document)
-hmac-sha2-384  384 ah: 192bit ICV (RFC4868)
-   384 ah-old: 128bit ICV (no document)
-hmac-sha2-512  512 ah: 256bit ICV (RFC4868)
-   512 ah-old: 128bit ICV (no document)
-hmac-ripemd160 160 ah: 96bit ICV (RFC2857)
-   ah-old: 128bit ICV (no document)
-aes-xcbc-mac   128 ah: 96bit ICV (RFC3566)
-   128 ah-old: 128bit ICV (no document)
+hmac-sha2-256  256 ah/esp: 128bit ICV (RFC4868)
+   256 ah-old/esp-old: 128bit ICV (no document)
+hmac-sha2-384  384 ah/esp: 192bit ICV (RFC4868)
+   384 ah-old/esp-old: 128bit ICV (no document)
+hmac-sha2-512  512 ah/esp: 256bit ICV (RFC4868)
+   512 ah-old/esp-old: 128bit ICV (no document)
+hmac-ripemd160 160 ah/esp: 96bit ICV (RFC2857)
+   ah-old/e

git: c0ea059da22f - stable/12 - nfsd: Add a sanity check for Owner/OwnerGroup string length

2022-05-19 Thread Rick Macklem
The branch stable/12 has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c0ea059da22f0f1f20ee43db536a74032f140429

commit c0ea059da22f0f1f20ee43db536a74032f140429
Author: Rick Macklem 
AuthorDate: 2022-05-04 20:58:22 +
Commit: Rick Macklem 
CommitDate: 2022-05-20 00:43:22 +

nfsd: Add a sanity check for Owner/OwnerGroup string length

Robert Morris reported that, if a client sends an absurdly
large Owner/OwnerGroup string, the kernel malloc() for the
large size string can block forever.

This patch adds a sanity limit for Owner/OwnerGroup string
length.  Since the RFCs do not specify any limit and FreeBSD
can handle a group name greater than 1Kbyte, the limit is
set at a generous 10Kbytes.

PR: 260546

(cherry picked from commit ef4edb70c909fc2b1de867601c2230597d07daa0)
---
 sys/fs/nfs/nfs.h| 7 +++
 sys/fs/nfs/nfs_commonsubs.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/fs/nfs/nfs.h b/sys/fs/nfs/nfs.h
index de35f40f40d0..b6af8902ca98 100644
--- a/sys/fs/nfs/nfs.h
+++ b/sys/fs/nfs/nfs.h
@@ -143,6 +143,13 @@
 
 #defineNFS_READDIRBLKSIZ   DIRBLKSIZ   /* Minimal 
nm_readdirsize */
 
+/*
+ * The NFSv4 RFCs do not define an upper limit on the length of Owner and
+ * OwnerGroup strings.  Since FreeBSD handles a group name > 1024bytes in
+ * length, set a generous sanity limit of 10Kbytes.
+ */
+#defineNFSV4_MAXOWNERGROUPLEN  (10 * 1024)
+
 /*
  * Oddballs
  */
diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index c7271cffe1ab..3ccfb6cce0d2 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -1815,7 +1815,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
case NFSATTRBIT_OWNER:
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
j = fxdr_unsigned(int, *tl);
-   if (j < 0) {
+   if (j < 0 || j > NFSV4_MAXOWNERGROUPLEN) {
error = NFSERR_BADXDR;
goto nfsmout;
}
@@ -1848,7 +1848,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
case NFSATTRBIT_OWNERGROUP:
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
j = fxdr_unsigned(int, *tl);
-   if (j < 0) {
+   if (j < 0 || j > NFSV4_MAXOWNERGROUPLEN) {
error =  NFSERR_BADXDR;
goto nfsmout;
}



git: 85eb99f9a471 - main - LinuxKPI: implement pcie_capability_set_word()

2022-05-19 Thread Bjoern A. Zeeb
The branch main has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=85eb99f9a47151f90565a1fb37395b8302c2978c

commit 85eb99f9a47151f90565a1fb37395b8302c2978c
Author: Bjoern A. Zeeb 
AuthorDate: 2022-05-18 22:36:31 +
Commit: Bjoern A. Zeeb 
CommitDate: 2022-05-20 01:09:08 +

LinuxKPI: implement pcie_capability_set_word()

Implement pcie_capability_set_word() using the already available
read/write functions.
Also define the completion timeout disable value to our PCI one.
Both needed by a driver update.

Sponsored by:   The FreeBSD Foundation
MFC after:  3 days
Reviewed by:manu, hselasky
Differential Revision: https://reviews.freebsd.org/D35250
---
 sys/compat/linuxkpi/common/include/linux/pci.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h 
b/sys/compat/linuxkpi/common/include/linux/pci.h
index 35a0f70669fb..d87cf51cf173 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -129,6 +129,7 @@ 
MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice",\
 #definePCI_EXP_DEVCAP2 PCIER_DEVICE_CAP2   /* 
Device Capabilities 2 */
 #definePCI_EXP_DEVCTL2 PCIER_DEVICE_CTL2   /* 
Device Control 2 */
 #definePCI_EXP_DEVCTL2_LTR_EN  PCIEM_CTL2_LTR_ENABLE
+#definePCI_EXP_DEVCTL2_COMP_TMOUT_DIS  PCIEM_CTL2_COMP_TIMO_DISABLE
 #definePCI_EXP_LNKCAP2 PCIER_LINK_CAP2 /* Link 
Capabilities 2 */
 #definePCI_EXP_LNKCTL2 PCIER_LINK_CTL2 /* Link 
Control 2 */
 #definePCI_EXP_LNKSTA2 PCIER_LINK_STA2 /* Link 
Status 2 */
@@ -1141,6 +1142,22 @@ pcie_capability_write_word(struct pci_dev *dev, int pos, 
u16 val)
return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val);
 }
 
+static inline int
+pcie_capability_set_word(struct pci_dev *dev, int pos, uint16_t val)
+{
+   int error;
+   uint16_t v;
+
+   error = pcie_capability_read_word(dev, pos, &v);
+   if (error != 0)
+   return (error);
+
+   v |= val;
+
+   error = pcie_capability_write_word(dev, pos, v);
+   return (error);
+}
+
 static inline int pcie_get_minimum_link(struct pci_dev *dev,
 enum pci_bus_speed *speed, enum pcie_link_width *width)
 {



git: d296b65d8992 - main - LinuxKPI: 802.11 updates

2022-05-19 Thread Bjoern A. Zeeb
The branch main has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d296b65d899249da24a8b277554df4af93357b36

commit d296b65d899249da24a8b277554df4af93357b36
Author: Bjoern A. Zeeb 
AuthorDate: 2022-05-18 22:39:57 +
Commit: Bjoern A. Zeeb 
CommitDate: 2022-05-20 01:11:22 +

LinuxKPI: 802.11 updates

Add more values to the ieee80211_min_mpdu_start_spacing enum with
two missing given we do not know how they are called.  Also update
the reference while here.

Add struct ieee80211_hdr_3addr and correct the comment on the
ieee80211_hdr to match the one in net80211 to avoid future confusion.

Sponsored by:   The FreeBSD Foundation
MFC after:  3 days
---
 sys/compat/linuxkpi/common/include/linux/ieee80211.h | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h 
b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
index e0aa558fe273..c131a6c69495 100644
--- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
@@ -130,9 +130,15 @@ enum wlan_ht_cap_sm_ps {
 #defineWLAN_KEY_LEN_CCMP   16
 #defineWLAN_KEY_LEN_GCMP_256   32
 
-/* 9.4.2.56.3, Table 9-163 Subfields of the A-MPDU Parameters field */
+/* 802.11-2020, 9.4.2.55.3, Table 9-185 Subfields of the A-MPDU Parameters 
field */
 enum ieee80211_min_mpdu_start_spacing {
IEEE80211_HT_MPDU_DENSITY_NONE  = 0,
+#if 0
+   IEEE80211_HT_MPDU_DENSITY_XXX   = 1,/* 1/4 us */
+   IEEE80211_HT_MPDU_DENSITY_YYY   = 2,/* 1/2 us */
+#endif
+   IEEE80211_HT_MPDU_DENSITY_1 = 3,/* 1 us */
+   IEEE80211_HT_MPDU_DENSITY_2 = 4,/* 2 us */
IEEE80211_HT_MPDU_DENSITY_4 = 5,/* 4us */
IEEE80211_HT_MPDU_DENSITY_8 = 6,/* 8us */
IEEE80211_HT_MPDU_DENSITY_16= 7,/* 16us */
@@ -350,7 +356,7 @@ enum ieee80211_tx_rate_flags {
 
 #defineIEEE80211_HT_CTL_LEN4
 
-struct ieee80211_hdr { /* net80211::ieee80211_frame */
+struct ieee80211_hdr { /* net80211::ieee80211_frame_addr4 */
 __le16 frame_control;
 __le16 duration_id;
uint8_t addr1[ETH_ALEN];
@@ -360,6 +366,15 @@ struct ieee80211_hdr { /* 
net80211::ieee80211_frame */
uint8_t addr4[ETH_ALEN];
 };
 
+struct ieee80211_hdr_3addr {   /* net80211::ieee80211_frame */
+__le16 frame_control;
+__le16 duration_id;
+   uint8_t addr1[ETH_ALEN];
+   uint8_t addr2[ETH_ALEN];
+   uint8_t addr3[ETH_ALEN];
+   __le16  seq_ctrl;
+};
+
 struct ieee80211_vendor_ie {
 };
 



git: f2ab91608440 - main - [vlan + lagg] add IFNET_EVENT_UPDATE_BAUDRATE event

2022-05-19 Thread Wojciech Macek
The branch main has been updated by wma:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f2ab91608440338e5574eff098ad4f69e4541a1d

commit f2ab91608440338e5574eff098ad4f69e4541a1d
Author: Andrey V. Elsukov 
AuthorDate: 2022-05-19 06:02:27 +
Commit: Wojciech Macek 
CommitDate: 2022-05-20 04:38:43 +

[vlan + lagg] add IFNET_EVENT_UPDATE_BAUDRATE event

use it to update if_baudrate for vlan interfaces created on the LACP lagg.

Differential revision:  https://reviews.freebsd.org/D33405
---
 sys/net/ieee8023ad_lacp.c |  2 ++
 sys/net/if_var.h  |  1 +
 sys/net/if_vlan.c | 35 +++
 3 files changed, 38 insertions(+)

diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c
index 1e2e638fcdf5..6656ebb2b400 100644
--- a/sys/net/ieee8023ad_lacp.c
+++ b/sys/net/ieee8023ad_lacp.c
@@ -1090,6 +1090,8 @@ lacp_update_portmap(struct lacp_softc *lsc)
speed = lacp_aggregator_bandwidth(la);
}
sc->sc_ifp->if_baudrate = speed;
+   EVENTHANDLER_INVOKE(ifnet_event, sc->sc_ifp,
+   IFNET_EVENT_UPDATE_BAUDRATE);
 
/* switch the active portmap over */
atomic_store_rel_int(&lsc->lsc_activemap, newmap);
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index e054c613e9e6..2c09795c6b36 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -515,6 +515,7 @@ EVENTHANDLER_DECLARE(ifnet_link_event, 
ifnet_link_event_handler_t);
 #define IFNET_EVENT_UP 0
 #define IFNET_EVENT_DOWN   1
 #define IFNET_EVENT_PCP2   /* priority code point, PCP */
+#defineIFNET_EVENT_UPDATE_BAUDRATE 3
 
 typedef void (*ifnet_event_fn)(void *, struct ifnet *ifp, int event);
 EVENTHANDLER_DECLARE(ifnet_event, ifnet_event_fn);
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 2bb5284c2129..dc7a5fcb0c73 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -221,6 +221,7 @@ static MALLOC_DEFINE(M_VLAN, vlanname, "802.1Q Virtual LAN 
Interface");
 
 static eventhandler_tag ifdetach_tag;
 static eventhandler_tag iflladdr_tag;
+static eventhandler_tag ifevent_tag;
 
 /*
  * if_vlan uses two module-level synchronizations primitives to allow 
concurrent
@@ -327,6 +328,7 @@ static  int vlan_clone_destroy(struct if_clone *, 
struct ifnet *);
 
 static void vlan_ifdetach(void *arg, struct ifnet *ifp);
 static  void vlan_iflladdr(void *arg, struct ifnet *ifp);
+static  void vlan_ifevent(void *arg, struct ifnet *ifp, int event);
 
 static  void vlan_lladdr_fn(void *arg, int pending);
 
@@ -673,6 +675,34 @@ vlan_setmulti(struct ifnet *ifp)
return (0);
 }
 
+/*
+ * A handler for interface ifnet events.
+ */
+static void
+vlan_ifevent(void *arg __unused, struct ifnet *ifp, int event)
+{
+   struct epoch_tracker et;
+   struct ifvlan *ifv;
+   struct ifvlantrunk *trunk;
+
+   if (event != IFNET_EVENT_UPDATE_BAUDRATE)
+   return;
+
+   NET_EPOCH_ENTER(et);
+   trunk = ifp->if_vlantrunk;
+   if (trunk == NULL) {
+   NET_EPOCH_EXIT(et);
+   return;
+   }
+
+   TRUNK_WLOCK(trunk);
+   VLAN_FOREACH(ifv, trunk) {
+   ifv->ifv_ifp->if_baudrate = ifp->if_baudrate;
+   }
+   TRUNK_WUNLOCK(trunk);
+   NET_EPOCH_EXIT(et);
+}
+
 /*
  * A handler for parent interface link layer address changes.
  * If the parent interface link layer address is changed we
@@ -886,6 +916,10 @@ vlan_modevent(module_t mod, int type, void *data)
vlan_iflladdr, NULL, EVENTHANDLER_PRI_ANY);
if (iflladdr_tag == NULL)
return (ENOMEM);
+   ifevent_tag = EVENTHANDLER_REGISTER(ifnet_event,
+   vlan_ifevent, NULL, EVENTHANDLER_PRI_ANY);
+   if (ifevent_tag == NULL)
+   return (ENOMEM);
VLAN_LOCKING_INIT();
vlan_input_p = vlan_input;
vlan_link_state_p = vlan_link_state;
@@ -916,6 +950,7 @@ vlan_modevent(module_t mod, int type, void *data)
 #endif
EVENTHANDLER_DEREGISTER(ifnet_departure_event, ifdetach_tag);
EVENTHANDLER_DEREGISTER(iflladdr_event, iflladdr_tag);
+   EVENTHANDLER_DEREGISTER(ifnet_event, ifevent_tag);
vlan_input_p = NULL;
vlan_link_state_p = NULL;
vlan_trunk_cap_p = NULL;