Re: git: 108de784513d - main - Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME

2024-06-01 Thread Nuno Teixeira
Hello,

Having issues building graphics/mesa-dri:

./src/intel/common/xe/intel_gem.c:72:9: error: duplicate case value '4'
   72 |case CLOCK_BOOTTIME:
  | ^
/usr/include/sys/_clock_id.h:81:25: note: expanded from macro
'CLOCK_BOOTTIME'
   81 | #define CLOCK_BOOTTIME  CLOCK_MONOTONIC
  | ^
/usr/include/sys/_clock_id.h:56:26: note: expanded from macro
'CLOCK_MONOTONIC'
   56 | #define CLOCK_MONOTONIC 4
  | ^
./src/intel/common/xe/intel_gem.c:66:9: note: previous case defined here
   66 |case CLOCK_MONOTONIC:
  | ^
/usr/include/sys/_clock_id.h:56:26: note: expanded from macro
'CLOCK_MONOTONIC'
   56 | #define CLOCK_MONOTONIC 4
  | ^
1 error generated.

Thanks

Warner Losh  escreveu (sexta, 31/05/2024 à(s) 15:47):

> The branch main has been updated by imp:
>
> URL:
> https://cgit.FreeBSD.org/src/commit/?id=108de784513d87bbe850e7b003a73e26b5b54caa
>
> commit 108de784513d87bbe850e7b003a73e26b5b54caa
> Author: Val Packett 
> AuthorDate: 2024-05-31 14:45:02 +
> Commit: Warner Losh 
> CommitDate: 2024-05-31 14:45:02 +
>
> Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME
>
> The suspend-awareness situation with monotonic clocks across platforms
> is kind of a mess, let's try not making it worse.
>
> On Linux, CLOCK_MONOTONIC does NOT count suspended time, and
> CLOCK_BOOTTIME was introduced to INCLUDE suspended time.
>
> On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and CLOCK_UPTIME
> was introduced to EXCLUDE suspended time.
>
> On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME_RAW.
>
> Right now, we do not have a monotonic clock that counts suspended time.
> We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTIME as a
> preprocessor alias, both being effectively `CLOCK_MONOTONIC` for now.
>
> When we introduce a suspend-aware clock in the future, it would make a
> lot more sense to do it the OpenBSD/macOS way, i.e. to make
> CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME exclude
> it,
> because that's what the name CLOCK_UPTIME implies: a deviation from the
> default intended for the uptime command to allow it to only show the
> time the system was actually up and not suspended.
>
> Let's change the define right now to make sure software using the
> define
> would not end up using the ID of the wrong clock in the future, and fix
> the IDs in the Linux compat code to match the expected changes too.
>
> See https://bugzilla.mozilla.org/show_bug.cgi?id=1824084
> for more discussion.
>
> Fixes:  155f15118a77 ("clock_gettime: Add Linux aliases for
> CLOCK_*")
> Fixes:  25ada637362d ("Map Linux CLOCK_BOOTTIME to native
> CLOCK_UPTIME.")
> Sponsored by:   https://www.patreon.com/valpackett
> Reviewed by:kib, imp
> Differential Revision:  https://reviews.freebsd.org/D39270
> ---
>  sys/compat/linux/linux_time.c | 6 +++---
>  sys/sys/_clock_id.h   | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c
> index e9e5cf075210..f4dd26dd3d2a 100644
> --- a/sys/compat/linux/linux_time.c
> +++ b/sys/compat/linux/linux_time.c
> @@ -287,7 +287,7 @@ linux_to_native_clockid(clockid_t *n, clockid_t l)
> *n = CLOCK_REALTIME;
> break;
> case LINUX_CLOCK_MONOTONIC:
> -   *n = CLOCK_MONOTONIC;
> +   *n = CLOCK_UPTIME;
> break;
> case LINUX_CLOCK_PROCESS_CPUTIME_ID:
> *n = CLOCK_PROCESS_CPUTIME_ID;
> @@ -300,10 +300,10 @@ linux_to_native_clockid(clockid_t *n, clockid_t l)
> break;
> case LINUX_CLOCK_MONOTONIC_COARSE:
> case LINUX_CLOCK_MONOTONIC_RAW:
> -   *n = CLOCK_MONOTONIC_FAST;
> +   *n = CLOCK_UPTIME_FAST;
> break;
> case LINUX_CLOCK_BOOTTIME:
> -   *n = CLOCK_UPTIME;
> +   *n = CLOCK_MONOTONIC;
> break;
> case LINUX_CLOCK_REALTIME_ALARM:
> case LINUX_CLOCK_BOOTTIME_ALARM:
> diff --git a/sys/sys/_clock_id.h b/sys/sys/_clock_id.h
> index 47a551428dc3..728346a0f0ab 100644
> --- a/sys/sys/_clock_id.h
> +++ b/sys/sys/_clock_id.h
> @@ -78,7 +78,7 @@
>   * Linux compatible names.
>   */
>  #if __BSD_VISIBLE
> -#defineCLOCK_BOOTTIME  CLOCK_UPTIME
> +#defineCLOCK_BOOTTIME  CLOCK_MONOTONIC
>  #defineCLOCK_REALTIME_COARSE   CLOCK_REALTIME_FAST
>  #defineCLOCK_MONOTONIC_COARSE  CLOCK_MONOTONIC_FAST
>  #endif
>
>

-- 
Nuno Teixeira
FreeBSD UNIX: Web:  https://FreeBSD.org


git: 339b47f01985 - stable/14 - x86/iommu: extract useful utilities into x86_iommu.c

2024-06-01 Thread Konstantin Belousov
The branch stable/14 has been updated by kib:

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

commit 339b47f01985628ccc4c3e9a29c36f26edb034c3
Author: Konstantin Belousov 
AuthorDate: 2024-05-25 00:47:26 +
Commit: Konstantin Belousov 
CommitDate: 2024-06-01 09:24:24 +

x86/iommu: extract useful utilities into x86_iommu.c

(cherry picked from commit 40d951bc5932deb87635f5c1780a6706d0c7c012)
---
 sys/conf/files.x86|   1 +
 sys/x86/include/iommu.h   |   1 +
 sys/x86/iommu/intel_ctx.c |  25 +++
 sys/x86/iommu/intel_dmar.h|   9 +--
 sys/x86/iommu/intel_drv.c |   7 +-
 sys/x86/iommu/intel_fault.c   |   1 +
 sys/x86/iommu/intel_idpgtbl.c |  77 ++--
 sys/x86/iommu/intel_intrmap.c |   3 +-
 sys/x86/iommu/intel_qi.c  |   3 +-
 sys/x86/iommu/intel_quirks.c  |   1 +
 sys/x86/iommu/intel_reg.h |  15 +---
 sys/x86/iommu/intel_utils.c   | 128 +++--
 sys/x86/iommu/iommu_utils.c   | 164 ++
 sys/x86/iommu/x86_iommu.h |  62 
 14 files changed, 302 insertions(+), 195 deletions(-)

diff --git a/sys/conf/files.x86 b/sys/conf/files.x86
index 15781eea8fee..445bbf9091ba 100644
--- a/sys/conf/files.x86
+++ b/sys/conf/files.x86
@@ -320,6 +320,7 @@ x86/iommu/intel_intrmap.c   optionalacpi iommu pci
 x86/iommu/intel_qi.c   optionalacpi iommu pci
 x86/iommu/intel_quirks.c   optionalacpi iommu pci
 x86/iommu/intel_utils.coptionalacpi iommu pci
+x86/iommu/iommu_utils.coptionalacpi iommu pci
 x86/isa/atrtc.cstandard
 x86/isa/clock.cstandard
 x86/isa/isa.c  optionalisa
diff --git a/sys/x86/include/iommu.h b/sys/x86/include/iommu.h
index a95480b53acc..98c6661aa8e3 100644
--- a/sys/x86/include/iommu.h
+++ b/sys/x86/include/iommu.h
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #endif /* !_MACHINE_IOMMU_H_ */
diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c
index 65ca88b052ed..444640570df7 100644
--- a/sys/x86/iommu/intel_ctx.c
+++ b/sys/x86/iommu/intel_ctx.c
@@ -66,6 +66,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static MALLOC_DEFINE(M_DMAR_CTX, "dmar_ctx", "Intel DMAR Context");
@@ -85,7 +86,7 @@ dmar_ensure_ctx_page(struct dmar_unit *dmar, int bus)
/*
 * Allocated context page must be linked.
 */
-   ctxm = dmar_pgalloc(dmar->ctx_obj, 1 + bus, IOMMU_PGF_NOALLOC);
+   ctxm = iommu_pgalloc(dmar->ctx_obj, 1 + bus, IOMMU_PGF_NOALLOC);
if (ctxm != NULL)
return;
 
@@ -96,14 +97,14 @@ dmar_ensure_ctx_page(struct dmar_unit *dmar, int bus)
 * threads are equal.
 */
TD_PREP_PINNED_ASSERT;
-   ctxm = dmar_pgalloc(dmar->ctx_obj, 1 + bus, IOMMU_PGF_ZERO |
+   ctxm = iommu_pgalloc(dmar->ctx_obj, 1 + bus, IOMMU_PGF_ZERO |
IOMMU_PGF_WAITOK);
-   re = dmar_map_pgtbl(dmar->ctx_obj, 0, IOMMU_PGF_NOALLOC, &sf);
+   re = iommu_map_pgtbl(dmar->ctx_obj, 0, IOMMU_PGF_NOALLOC, &sf);
re += bus;
dmar_pte_store(&re->r1, DMAR_ROOT_R1_P | (DMAR_ROOT_R1_CTP_MASK &
VM_PAGE_TO_PHYS(ctxm)));
dmar_flush_root_to_ram(dmar, re);
-   dmar_unmap_pgtbl(sf);
+   iommu_unmap_pgtbl(sf);
TD_PINNED_ASSERT;
 }
 
@@ -115,7 +116,7 @@ dmar_map_ctx_entry(struct dmar_ctx *ctx, struct sf_buf 
**sfp)
 
dmar = CTX2DMAR(ctx);
 
-   ctxp = dmar_map_pgtbl(dmar->ctx_obj, 1 + PCI_RID2BUS(ctx->context.rid),
+   ctxp = iommu_map_pgtbl(dmar->ctx_obj, 1 + PCI_RID2BUS(ctx->context.rid),
IOMMU_PGF_NOALLOC | IOMMU_PGF_WAITOK, sfp);
ctxp += ctx->context.rid & 0xff;
return (ctxp);
@@ -188,7 +189,7 @@ ctx_id_entry_init(struct dmar_ctx *ctx, dmar_ctx_entry_t 
*ctxp, bool move,
("ctx %p non-null pgtbl_obj", ctx));
ctx_root = NULL;
} else {
-   ctx_root = dmar_pgalloc(domain->pgtbl_obj, 0,
+   ctx_root = iommu_pgalloc(domain->pgtbl_obj, 0,
IOMMU_PGF_NOALLOC);
}
 
@@ -274,7 +275,7 @@ domain_init_rmrr(struct dmar_domain *domain, device_t dev, 
int bus,
"region (%jx, %jx) corrected\n",
domain->iodom.iommu->unit, start, end);
}
-   entry->end += DMAR_PAGE_SIZE * 0x20;
+   entry->end += IOMMU_PAGE_SIZE * 0x20;
}
size = OFF_TO_IDX(entry->end - entry->start);
ma = malloc(sizeof(vm_page_t) * size, M_TEMP, M_WAITOK);
@@ -603,9 +604,9 @@ dmar_get_ctx_for_dev1(struct dmar_unit *dmar, device_t dev, 
uint16_t rid,
func, rid, domain->domain, domain->mgaw,
domain->

git: ce75bfcac9cf - main - nvme: Change namespace device name

2024-06-01 Thread Chuck Tuffli
The branch main has been updated by chuck:

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

commit ce75bfcac9cfe0bdd2285faea86019455c6fa7ea
Author: Chuck Tuffli 
AuthorDate: 2024-06-01 11:08:24 +
Commit: Chuck Tuffli 
CommitDate: 2024-06-01 11:14:14 +

nvme: Change namespace device name

Changes the device name for NVMe and NVMe-oF namespaces from using "ns"
to "n" to be more compatible with other operating systems. For example,
a device which was previously /dev/nvme0ns1 is now /dev/nvme0n1.

Preserves the existing functionality by creating alias from nvmeXnY to
nvmeXnsY.

Reviewed by:imp
MFC after:  1 month
Relnotes:   yes
Differential Revision:  https://reviews.freebsd.org/D45414
---
 sys/dev/nvme/nvme_ctrlr.c   | 4 ++--
 sys/dev/nvme/nvme_ns.c  | 8 ++--
 sys/dev/nvmf/host/nvmf_ns.c | 8 ++--
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index d9bd1fce2864..155aedf2f31a 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1478,8 +1478,8 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, 
device_t dev)
md_args.mda_mode = 0600;
md_args.mda_unit = device_get_unit(dev);
md_args.mda_si_drv1 = (void *)ctrlr;
-   status = make_dev_s(&md_args, &ctrlr->cdev, "nvme%d",
-   device_get_unit(dev));
+   status = make_dev_s(&md_args, &ctrlr->cdev, "%s",
+   device_get_nameunit(dev));
if (status != 0)
return (ENXIO);
 
diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c
index 201cf9188c1e..b19fc8664407 100644
--- a/sys/dev/nvme/nvme_ns.c
+++ b/sys/dev/nvme/nvme_ns.c
@@ -604,10 +604,12 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t id,
md_args.mda_unit = unit;
md_args.mda_mode = 0600;
md_args.mda_si_drv1 = ns;
-   res = make_dev_s(&md_args, &ns->cdev, "nvme%dns%d",
-   device_get_unit(ctrlr->dev), ns->id);
+   res = make_dev_s(&md_args, &ns->cdev, "%sn%d",
+   device_get_nameunit(ctrlr->dev), ns->id);
if (res != 0)
return (ENXIO);
+   ns->cdev->si_drv2 = make_dev_alias(ns->cdev, "%sns%d",
+   device_get_nameunit(ctrlr->dev), ns->id);
 
ns->cdev->si_flags |= SI_UNMAPPED;
 
@@ -618,6 +620,8 @@ void
 nvme_ns_destruct(struct nvme_namespace *ns)
 {
 
+   if (ns->cdev->si_drv2 != NULL)
+   destroy_dev(ns->cdev->si_drv2);
if (ns->cdev != NULL)
destroy_dev(ns->cdev);
 }
diff --git a/sys/dev/nvmf/host/nvmf_ns.c b/sys/dev/nvmf/host/nvmf_ns.c
index 3428cbadc974..30acbe815dbe 100644
--- a/sys/dev/nvmf/host/nvmf_ns.c
+++ b/sys/dev/nvmf/host/nvmf_ns.c
@@ -49,7 +49,7 @@ ns_printf(struct nvmf_namespace *ns, const char *fmt, ...)
sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
sbuf_set_drain(&sb, sbuf_printf_drain, NULL);
 
-   sbuf_printf(&sb, "%sns%u: ", device_get_nameunit(ns->sc->dev),
+   sbuf_printf(&sb, "%sn%u: ", device_get_nameunit(ns->sc->dev),
ns->id);
 
va_start(ap, fmt);
@@ -371,10 +371,12 @@ nvmf_init_ns(struct nvmf_softc *sc, uint32_t id,
mda.mda_gid = GID_WHEEL;
mda.mda_mode = 0600;
mda.mda_si_drv1 = ns;
-   error = make_dev_s(&mda, &ns->cdev, "%sns%u",
+   error = make_dev_s(&mda, &ns->cdev, "%sn%u",
device_get_nameunit(sc->dev), id);
if (error != 0)
goto fail;
+   ns->cdev->si_drv2 = make_dev_alias(ns->cdev, "%sns%u",
+   device_get_nameunit(sc->dev), id);
 
ns->cdev->si_flags |= SI_UNMAPPED;
 
@@ -418,6 +420,8 @@ nvmf_destroy_ns(struct nvmf_namespace *ns)
TAILQ_HEAD(, bio) bios;
struct bio *bio;
 
+   if (ns->cdev->si_drv2 != NULL)
+   destroy_dev(ns->cdev->si_drv2);
destroy_dev(ns->cdev);
 
/*



git: 166ec3e86aa4 - main - mitigations.7: uncomment reference to recently added section

2024-06-01 Thread Ed Maste
The branch main has been updated by emaste:

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

commit 166ec3e86aa4a48bdf2a56ee065f0173bbb8f745
Author: Ed Maste 
AuthorDate: 2024-06-01 11:52:31 +
Commit: Ed Maste 
CommitDate: 2024-06-01 11:55:09 +

mitigations.7: uncomment reference to recently added section

A brief description of supervisor mode memory access protection was
added in 72ece341b427.  Uncomment the existing reference to this section
in the table of contents.

Fixes: 72ece341b427 ("mitigations.7: mention supervisor mode memory...")
Sponsored by:   The FreeBSD Foundation
---
 share/man/man7/mitigations.7 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/share/man/man7/mitigations.7 b/share/man/man7/mitigations.7
index afb88de56e86..a322c9a917da 100644
--- a/share/man/man7/mitigations.7
+++ b/share/man/man7/mitigations.7
@@ -56,8 +56,8 @@ Relocation Read-Only (RELRO)
 Bind Now
 .\".It
 .\"Stack Smashing Protection (SSP)
-.\".It
-.\"Supervisor Mode Memory Protection
+.It
+Supervisor Mode Memory Protection
 .It
 Hardware Vulnerability Mitigation Controls
 .It



Re: git: 108de784513d - main - Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME

2024-06-01 Thread Warner Losh
On Sat, Jun 1, 2024, 4:37 AM Nuno Teixeira  wrote:

> Hello,
>
> Having issues building graphics/mesa-dri:
>
> ../src/intel/common/xe/intel_gem.c:72:9: error: duplicate case value '4'
>72 |case CLOCK_BOOTTIME:
>   | ^
> /usr/include/sys/_clock_id.h:81:25: note: expanded from macro
> 'CLOCK_BOOTTIME'
>81 | #define CLOCK_BOOTTIME  CLOCK_MONOTONIC
>   | ^
> /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> 'CLOCK_MONOTONIC'
>56 | #define CLOCK_MONOTONIC 4
>   | ^
> ../src/intel/common/xe/intel_gem.c:66:9: note: previous case defined here
>66 |case CLOCK_MONOTONIC:
>   | ^
> /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> 'CLOCK_MONOTONIC'
>56 | #define CLOCK_MONOTONIC 4
>   | ^
> 1 error generated.
>

Mesa needs to be updated to not assume these are distinct values.

Warner


> Thanks
>
> Warner Losh  escreveu (sexta, 31/05/2024 à(s) 15:47):
>
>> The branch main has been updated by imp:
>>
>> URL:
>> https://cgit.FreeBSD.org/src/commit/?id=108de784513d87bbe850e7b003a73e26b5b54caa
>>
>> commit 108de784513d87bbe850e7b003a73e26b5b54caa
>> Author: Val Packett 
>> AuthorDate: 2024-05-31 14:45:02 +
>> Commit: Warner Losh 
>> CommitDate: 2024-05-31 14:45:02 +
>>
>> Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME
>>
>> The suspend-awareness situation with monotonic clocks across platforms
>> is kind of a mess, let's try not making it worse.
>>
>> On Linux, CLOCK_MONOTONIC does NOT count suspended time, and
>> CLOCK_BOOTTIME was introduced to INCLUDE suspended time.
>>
>> On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and
>> CLOCK_UPTIME
>> was introduced to EXCLUDE suspended time.
>>
>> On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME_RAW.
>>
>> Right now, we do not have a monotonic clock that counts suspended
>> time.
>> We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTIME as a
>> preprocessor alias, both being effectively `CLOCK_MONOTONIC` for now.
>>
>> When we introduce a suspend-aware clock in the future, it would make a
>> lot more sense to do it the OpenBSD/macOS way, i.e. to make
>> CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME exclude
>> it,
>> because that's what the name CLOCK_UPTIME implies: a deviation from
>> the
>> default intended for the uptime command to allow it to only show the
>> time the system was actually up and not suspended.
>>
>> Let's change the define right now to make sure software using the
>> define
>> would not end up using the ID of the wrong clock in the future, and
>> fix
>> the IDs in the Linux compat code to match the expected changes too.
>>
>> See https://bugzilla.mozilla.org/show_bug.cgi?id=1824084
>> for more discussion.
>>
>> Fixes:  155f15118a77 ("clock_gettime: Add Linux aliases for
>> CLOCK_*")
>> Fixes:  25ada637362d ("Map Linux CLOCK_BOOTTIME to native
>> CLOCK_UPTIME.")
>> Sponsored by:   https://www.patreon.com/valpackett
>> Reviewed by:kib, imp
>> Differential Revision:  https://reviews.freebsd.org/D39270
>> ---
>>  sys/compat/linux/linux_time.c | 6 +++---
>>  sys/sys/_clock_id.h   | 2 +-
>>  2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_timec
>> index e9e5cf075210..f4dd26dd3d2a 100644
>> --- a/sys/compat/linux/linux_time.c
>> +++ b/sys/compat/linux/linux_time.c
>> @@ -287,7 +287,7 @@ linux_to_native_clockid(clockid_t *n, clockid_t l)
>> *n = CLOCK_REALTIME;
>> break;
>> case LINUX_CLOCK_MONOTONIC:
>> -   *n = CLOCK_MONOTONIC;
>> +   *n = CLOCK_UPTIME;
>> break;
>> case LINUX_CLOCK_PROCESS_CPUTIME_ID:
>> *n = CLOCK_PROCESS_CPUTIME_ID;
>> @@ -300,10 +300,10 @@ linux_to_native_clockid(clockid_t *n, clockid_t l)
>> break;
>> case LINUX_CLOCK_MONOTONIC_COARSE:
>> case LINUX_CLOCK_MONOTONIC_RAW:
>> -   *n = CLOCK_MONOTONIC_FAST;
>> +   *n = CLOCK_UPTIME_FAST;
>> break;
>> case LINUX_CLOCK_BOOTTIME:
>> -   *n = CLOCK_UPTIME;
>> +   *n = CLOCK_MONOTONIC;
>> break;
>> case LINUX_CLOCK_REALTIME_ALARM:
>> case LINUX_CLOCK_BOOTTIME_ALARM:
>> diff --git a/sys/sys/_clock_id.h b/sys/sys/_clock_id.h
>> index 47a551428dc3..728346a0f0ab 100644
>> --- a/sys/sys/_clock_id.h
>> +++ b/sys/sys/_clock_id.h
>> @@ -78,7 +78,7 @@
>>   * Linux compatible names.
>>   */
>>  #if __BSD_VISIBLE
>> -#defineCLOCK_BOOTTIME  CLOCK_UPTIME
>> +#defineCLOCK_BOOTTIME  CLOCK_MONOTONIC
>>  #defineCLOCK_REALTIME_COARSE   CLOCK_REALTIME_FA

Re: git: 108de784513d - main - Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME

2024-06-01 Thread Cy Schubert
In message 
, Warner Losh writes:
> --0d72080619d34a39
> Content-Type: text/plain; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
> On Sat, Jun 1, 2024, 4:37=E2=80=AFAM Nuno Teixeira  wr=
> ote:
>
> > Hello,
> >
> > Having issues building graphics/mesa-dri:
> >
> > ../src/intel/common/xe/intel_gem.c:72:9: error: duplicate case value '4'
> >72 |case CLOCK_BOOTTIME:
> >   | ^
> > /usr/include/sys/_clock_id.h:81:25: note: expanded from macro
> > 'CLOCK_BOOTTIME'
> >81 | #define CLOCK_BOOTTIME  CLOCK_MONOTONIC
> >   | ^
> > /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> > 'CLOCK_MONOTONIC'
> >56 | #define CLOCK_MONOTONIC 4
> >   | ^
> > ../src/intel/common/xe/intel_gem.c:66:9: note: previous case defined here
> >66 |case CLOCK_MONOTONIC:
> >   | ^
> > /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> > 'CLOCK_MONOTONIC'
> >56 | #define CLOCK_MONOTONIC 4
> >   | ^
> > 1 error generated.
> >
>
> Mesa needs to be updated to not assume these are distinct values.

You should be able to resolve this with,

--- src/intel/common/xe/intel_gem.c.orig2024-05-22 09:48:39.0 
-0700
+++ src/intel/common/xe/intel_gem.c 2024-06-01 06:28:22.268439000 -0700
@@ -69,8 +69,10 @@
 #endif
case CLOCK_REALTIME:
 #ifdef CLOCK_BOOTTIME
+#if CLOCK_BOOTTIME != CLOCK_MONOTONIC
case CLOCK_BOOTTIME:
 #endif
+#endif
 #ifdef CLOCK_TAI
case CLOCK_TAI:
 #endif


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  https://FreeBSD.org
NTP:   Web:  https://nwtime.org

e^(i*pi)+1=0


>
> Warner
>
>
> > Thanks
> >
> > Warner Losh  escreveu (sexta, 31/05/2024 =C3=A0(s) 15:47=
> ):
> >
> >> The branch main has been updated by imp:
> >>
> >> URL:
> >> https://cgit.FreeBSD.org/src/commit/?id=3D108de784513d87bbe850e7b003a73e=
> 26b5b54caa
> >>
> >> commit 108de784513d87bbe850e7b003a73e26b5b54caa
> >> Author: Val Packett 
> >> AuthorDate: 2024-05-31 14:45:02 +
> >> Commit: Warner Losh 
> >> CommitDate: 2024-05-31 14:45:02 +
> >>
> >> Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME
> >>
> >> The suspend-awareness situation with monotonic clocks across platfor=
> ms
> >> is kind of a mess, let's try not making it worse.
> >>
> >> On Linux, CLOCK_MONOTONIC does NOT count suspended time, and
> >> CLOCK_BOOTTIME was introduced to INCLUDE suspended time.
> >>
> >> On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and
> >> CLOCK_UPTIME
> >> was introduced to EXCLUDE suspended time.
> >>
> >> On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME_RAW.
> >>
> >> Right now, we do not have a monotonic clock that counts suspended
> >> time.
> >> We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTIME as a
> >> preprocessor alias, both being effectively `CLOCK_MONOTONIC` for now=
> .
> >>
> >> When we introduce a suspend-aware clock in the future, it would make=
>  a
> >> lot more sense to do it the OpenBSD/macOS way, i.e. to make
> >> CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME exclude
> >> it,
> >> because that's what the name CLOCK_UPTIME implies: a deviation from
> >> the
> >> default intended for the uptime command to allow it to only show the
> >> time the system was actually up and not suspended.
> >>
> >> Let's change the define right now to make sure software using the
> >> define
> >> would not end up using the ID of the wrong clock in the future, and
> >> fix
> >> the IDs in the Linux compat code to match the expected changes too.
> >>
> >> See https://bugzilla.mozilla.org/show_bug.cgi?id=3D1824084
> >> for more discussion.
> >>
> >> Fixes:  155f15118a77 ("clock_gettime: Add Linux aliases for
> >> CLOCK_*")
> >> Fixes:  25ada637362d ("Map Linux CLOCK_BOOTTIME to native
> >> CLOCK_UPTIME.")
> >> Sponsored by:   https://www.patreon.com/valpackett
> >> Reviewed by:kib, imp
> >> Differential Revision:  https://reviews.freebsd.org/D39270
> >> ---
> >>  sys/compat/linux/linux_time.c | 6 +++---
> >>  sys/sys/_clock_id.h   | 2 +-
> >>  2 files changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time=
> .c
> >> index e9e5cf075210..f4dd26dd3d2a 100644
> >> --- a/sys/compat/linux/linux_time.c
> >> +++ b/sys/compat/linux/linux_time.c
> >> @@ -287,7 +287,7 @@ linux_to_native_clockid(clockid_t *n, clockid_t l)
> >> *n =3D CLOCK_REALTIME;
> >> break;
> >> case LINUX_CLOCK_MONOTONIC:
> >> -   *n =3D CLOCK_MONOTONIC;
> >> +   *n =3D CLOCK_UPTIME;
> >> break;
> >> case LINUX_CLOCK_PROCESS_CPUTIME_ID:
> >> 

Re: git: 108de784513d - main - Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME

2024-06-01 Thread Warner Losh
On Sat, Jun 1, 2024 at 9:31 AM Cy Schubert 
wrote:

> In message
>  om>
> , Warner Losh writes:
> > --0d72080619d34a39
> > Content-Type: text/plain; charset="UTF-8"
> > Content-Transfer-Encoding: quoted-printable
> >
> > On Sat, Jun 1, 2024, 4:37=E2=80=AFAM Nuno Teixeira 
> wr=
> > ote:
> >
> > > Hello,
> > >
> > > Having issues building graphics/mesa-dri:
> > >
> > > ../src/intel/common/xe/intel_gem.c:72:9: error: duplicate case value
> '4'
> > >72 |case CLOCK_BOOTTIME:
> > >   | ^
> > > /usr/include/sys/_clock_id.h:81:25: note: expanded from macro
> > > 'CLOCK_BOOTTIME'
> > >81 | #define CLOCK_BOOTTIME  CLOCK_MONOTONIC
> > >   | ^
> > > /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> > > 'CLOCK_MONOTONIC'
> > >56 | #define CLOCK_MONOTONIC 4
> > >   | ^
> > > ../src/intel/common/xe/intel_gem.c:66:9: note: previous case defined
> here
> > >66 |case CLOCK_MONOTONIC:
> > >   | ^
> > > /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> > > 'CLOCK_MONOTONIC'
> > >56 | #define CLOCK_MONOTONIC 4
> > >   | ^
> > > 1 error generated.
> > >
> >
> > Mesa needs to be updated to not assume these are distinct values.
>
> You should be able to resolve this with,
>
> --- src/intel/common/xe/intel_gem.c.orig2024-05-22
> 09:48:39.0 -0700
> +++ src/intel/common/xe/intel_gem.c 2024-06-01 06:28:22.268439000 -0700
> @@ -69,8 +69,10 @@
>  #endif
> case CLOCK_REALTIME:
>  #ifdef CLOCK_BOOTTIME
> +#if CLOCK_BOOTTIME != CLOCK_MONOTONIC
> case CLOCK_BOOTTIME:
>  #endif
> +#endif
>  #ifdef CLOCK_TAI
> case CLOCK_TAI:
>  #endif
>

Yea, that should do it. I was going to look at this when I got back from
BSDcan (mostly because
my talk is this morning), but thanks for beating me to it.  I woke up grump
and it was bugging me
on the walk over to the conference I was a little short in my first reply,
but since you proposed a
fix, I feel less guilty... :) Thanks!

Warner

Warner

Warner

> --
> Cheers,
> Cy Schubert 
> FreeBSD UNIX: Web:  https://FreeBSD.org
> NTP:   Web:  https://nwtime.org
>
> e^(i*pi)+1=0
>
>
> >
> > Warner
> >
> >
> > > Thanks
> > >
> > > Warner Losh  escreveu (sexta, 31/05/2024 =C3=A0(s)
> 15:47=
> > ):
> > >
> > >> The branch main has been updated by imp:
> > >>
> > >> URL:
> > >>
> https://cgit.FreeBSD.org/src/commit/?id=3D108de784513d87bbe850e7b003a73e=
> > 26b5b54caa
> > >>
> > >> commit 108de784513d87bbe850e7b003a73e26b5b54caa
> > >> Author: Val Packett 
> > >> AuthorDate: 2024-05-31 14:45:02 +
> > >> Commit: Warner Losh 
> > >> CommitDate: 2024-05-31 14:45:02 +
> > >>
> > >> Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME
> > >>
> > >> The suspend-awareness situation with monotonic clocks across
> platfor=
> > ms
> > >> is kind of a mess, let's try not making it worse.
> > >>
> > >> On Linux, CLOCK_MONOTONIC does NOT count suspended time, and
> > >> CLOCK_BOOTTIME was introduced to INCLUDE suspended time.
> > >>
> > >> On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and
> > >> CLOCK_UPTIME
> > >> was introduced to EXCLUDE suspended time.
> > >>
> > >> On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME_RAW.
> > >>
> > >> Right now, we do not have a monotonic clock that counts suspended
> > >> time.
> > >> We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTIME
> as a
> > >> preprocessor alias, both being effectively `CLOCK_MONOTONIC` for
> now=
> > .
> > >>
> > >> When we introduce a suspend-aware clock in the future, it would
> make=
> >  a
> > >> lot more sense to do it the OpenBSD/macOS way, i.e. to make
> > >> CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME
> exclude
> > >> it,
> > >> because that's what the name CLOCK_UPTIME implies: a deviation
> from
> > >> the
> > >> default intended for the uptime command to allow it to only show
> the
> > >> time the system was actually up and not suspended.
> > >>
> > >> Let's change the define right now to make sure software using the
> > >> define
> > >> would not end up using the ID of the wrong clock in the future,
> and
> > >> fix
> > >> the IDs in the Linux compat code to match the expected changes
> too.
> > >>
> > >> See https://bugzilla.mozilla.org/show_bug.cgi?id=3D1824084
> > >> for more discussion.
> > >>
> > >> Fixes:  155f15118a77 ("clock_gettime: Add Linux aliases
> for
> > >> CLOCK_*")
> > >> Fixes:  25ada637362d ("Map Linux CLOCK_BOOTTIME to native
> > >> CLOCK_UPTIME.")
> > >> Sponsored by:   https://www.patreon.com/valpackett
> > >> Reviewed by:kib, imp
> > >> Differential Revision:  https://reviews.freebsd.org/D39270
> > >> ---
> > >>  sys/compat/linux/linux_time.c

git: 4b72bab96e89 - main - mdconfig: don't print NUL in the options list

2024-06-01 Thread Warner Losh
The branch main has been updated by imp:

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

commit 4b72bab96e8978eaed30fd44f7f51e1b4918d4db
Author: Alan Somers 
AuthorDate: 2024-05-31 21:13:03 +
Commit: Warner Losh 
CommitDate: 2024-06-01 14:08:16 +

mdconfig: don't print NUL in the options list

Fixes:  b01988d5e570
Sponsored by: Axcient
Reviewed by: imp, Ricardo Branco
Pull Request: https://github.com/freebsd/freebsd-src/pull/1268
---
 sbin/mdconfig/mdconfig.c | 38 ++--
 sbin/mdconfig/tests/mdconfig_test.sh | 20 +++
 2 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index d49eb6ed08e5..abcb34c1fed1 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -409,7 +409,7 @@ print_options(const char *dev, const char *file)
 {
struct md_ioctl mdiox;
int unit;
-   char sep = '\0';
+   const char *sep = "";
 
if (sscanf(dev, "md%d", &unit) != 1)
err(1, "invalid device: %s", dev);
@@ -427,40 +427,40 @@ print_options(const char *dev, const char *file)
 
printf("\t");
if (mdiox.md_options & MD_ASYNC) {
-   printf("%casync", sep);
-   sep = ',';
+   printf("%sasync", sep);
+   sep = ",";
}
if (mdiox.md_options & MD_CACHE) {
-   printf("%ccache", sep);
-   sep = ',';
+   printf("%scache", sep);
+   sep = ",";
}
if (mdiox.md_options & MD_CLUSTER) {
-   printf("%ccluster", sep);
-   sep = ',';
+   printf("%scluster", sep);
+   sep = ",";
}
if (mdiox.md_options & MD_COMPRESS) {
-   printf("%ccompress", sep);
-   sep = ',';
+   printf("%scompress", sep);
+   sep = ",";
}
if (mdiox.md_options & MD_FORCE) {
-   printf("%cforce", sep);
-   sep = ',';
+   printf("%sforce", sep);
+   sep = ",";
}
if (mdiox.md_options & MD_READONLY) {
-   printf("%creadonly", sep);
-   sep = ',';
+   printf("%sreadonly", sep);
+   sep = ",";
}
if (mdiox.md_options & MD_RESERVE) {
-   printf("%creserve", sep);
-   sep = ',';
+   printf("%sreserve", sep);
+   sep = ",";
}
if (mdiox.md_options & MD_VERIFY) {
-   printf("%cverify", sep);
-   sep = ',';
+   printf("%sverify", sep);
+   sep = ",";
}
if (mdiox.md_options & MD_MUSTDEALLOC) {
-   printf("%cmustdealloc", sep);
-   sep = ',';
+   printf("%smustdealloc", sep);
+   sep = ",";
}
 }
 
diff --git a/sbin/mdconfig/tests/mdconfig_test.sh 
b/sbin/mdconfig/tests/mdconfig_test.sh
index 655b7fd63b40..ea87ff5d542d 100755
--- a/sbin/mdconfig/tests/mdconfig_test.sh
+++ b/sbin/mdconfig/tests/mdconfig_test.sh
@@ -296,6 +296,25 @@ attach_size_rounddown_cleanup()
cleanup_common
 }
 
+atf_test_case query_verbose cleanup
+query_verbose()
+{
+   atf_set "descr" "mdconfig -lv should print device details"
+}
+query_verbose_body()
+{
+   atf_check -s exit:0 -o save:mdconfig.out \
+   -x 'mdconfig -a -t swap -s 1m -o reserve -o force'
+   md=$(cat mdconfig.out)
+   atf_check -s exit:0 \
+   -o 
match:"$md[[:space:]]+swap[[:space:]]+1024K[[:space:]]+[-][[:space:]]+[-][[:space:]]+force,reserve"
 \
+   -x "mdconfig -lv -u $md"
+}
+query_verbose_cleanup()
+{
+   cleanup_common
+}
+
 atf_init_test_cases()
 {
atf_add_test_case attach_vnode_non_explicit_type
@@ -307,4 +326,5 @@ atf_init_test_cases()
atf_add_test_case attach_swap
atf_add_test_case attach_with_specific_unit_number
atf_add_test_case attach_size_rounddown
+   atf_add_test_case query_verbose
 }



Re: git: 108de784513d - main - Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME

2024-06-01 Thread Cy Schubert
In message 
, Warner Losh writes:
> --dcc9a90619d4664c
> Content-Type: text/plain; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
> On Sat, Jun 1, 2024 at 9:31=E2=80=AFAM Cy Schubert  om>
> wrote:
>
> > In message
> >  > om>
> > , Warner Losh writes:
> > > --0d72080619d34a39
> > > Content-Type: text/plain; charset=3D"UTF-8"
> > > Content-Transfer-Encoding: quoted-printable
> > >
> > > On Sat, Jun 1, 2024, 4:37=3DE2=3D80=3DAFAM Nuno Teixeira  sd.org>
> > wr=3D
> > > ote:
> > >
> > > > Hello,
> > > >
> > > > Having issues building graphics/mesa-dri:
> > > >
> > > > ../src/intel/common/xe/intel_gem.c:72:9: error: duplicate case value
> > '4'
> > > >72 |case CLOCK_BOOTTIME:
> > > >   | ^
> > > > /usr/include/sys/_clock_id.h:81:25: note: expanded from macro
> > > > 'CLOCK_BOOTTIME'
> > > >81 | #define CLOCK_BOOTTIME  CLOCK_MONOTONIC
> > > >   | ^
> > > > /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> > > > 'CLOCK_MONOTONIC'
> > > >56 | #define CLOCK_MONOTONIC 4
> > > >   | ^
> > > > ../src/intel/common/xe/intel_gem.c:66:9: note: previous case defined
> > here
> > > >66 |case CLOCK_MONOTONIC:
> > > >   | ^
> > > > /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> > > > 'CLOCK_MONOTONIC'
> > > >56 | #define CLOCK_MONOTONIC 4
> > > >   | ^
> > > > 1 error generated.
> > > >
> > >
> > > Mesa needs to be updated to not assume these are distinct values.
> >
> > You should be able to resolve this with,
> >
> > --- src/intel/common/xe/intel_gem.c.orig2024-05-22
> > 09:48:39.0 -0700
> > +++ src/intel/common/xe/intel_gem.c 2024-06-01 06:28:22.268439000 -07=
> 00
> > @@ -69,8 +69,10 @@
> >  #endif
> > case CLOCK_REALTIME:
> >  #ifdef CLOCK_BOOTTIME
> > +#if CLOCK_BOOTTIME !=3D CLOCK_MONOTONIC
> > case CLOCK_BOOTTIME:
> >  #endif
> > +#endif
> >  #ifdef CLOCK_TAI
> > case CLOCK_TAI:
> >  #endif
> >
>
> Yea, that should do it. I was going to look at this when I got back from
> BSDcan (mostly because
> my talk is this morning), but thanks for beating me to it.  I woke up grump
> and it was bugging me
> on the walk over to the conference I was a little short in my first reply,
> but since you proposed a
> fix, I feel less guilty... :) Thanks!

I just put it out there. I'm outside, again, today continuing to build that 
new fence. I can submit a poudriere review or PR for X11 maintainer 
approval.

I'll need to show the WPA ports a little loving attention at that time too.

Maybe tonight.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  https://FreeBSD.org
NTP:   Web:  https://nwtime.org

e^(i*pi)+1=0


>
> Warner
>
> Warner
>
> Warner
>
> > --
> > Cheers,
> > Cy Schubert 
> > FreeBSD UNIX: Web:  https://FreeBSD.org
> > NTP:   Web:  https://nwtime.org
> >
> > e^(i*pi)+1=3D0
> >
> >
> > >
> > > Warner
> > >
> > >
> > > > Thanks
> > > >
> > > > Warner Losh  escreveu (sexta, 31/05/2024 =3DC3=3DA0(=
> s)
> > 15:47=3D
> > > ):
> > > >
> > > >> The branch main has been updated by imp:
> > > >>
> > > >> URL:
> > > >>
> > https://cgit.FreeBSD.org/src/commit/?id=3D3D108de784513d87bbe850e7b003a73=
> e=3D
> > > 26b5b54caa
> > > >>
> > > >> commit 108de784513d87bbe850e7b003a73e26b5b54caa
> > > >> Author: Val Packett 
> > > >> AuthorDate: 2024-05-31 14:45:02 +
> > > >> Commit: Warner Losh 
> > > >> CommitDate: 2024-05-31 14:45:02 +
> > > >>
> > > >> Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTI=
> ME
> > > >>
> > > >> The suspend-awareness situation with monotonic clocks across
> > platfor=3D
> > > ms
> > > >> is kind of a mess, let's try not making it worse.
> > > >>
> > > >> On Linux, CLOCK_MONOTONIC does NOT count suspended time, and
> > > >> CLOCK_BOOTTIME was introduced to INCLUDE suspended time.
> > > >>
> > > >> On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and
> > > >> CLOCK_UPTIME
> > > >> was introduced to EXCLUDE suspended time.
> > > >>
> > > >> On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME_RAW.
> > > >>
> > > >> Right now, we do not have a monotonic clock that counts suspende=
> d
> > > >> time.
> > > >> We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTIME
> > as a
> > > >> preprocessor alias, both being effectively `CLOCK_MONOTONIC` for
> > now=3D
> > > .
> > > >>
> > > >> When we introduce a suspend-aware clock in the future, it would
> > make=3D
> > >  a
> > > >> lot more sense to do it the OpenBSD/macOS way, i.e. to make
> > > >> CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME
> > exclude
> > > >> it,
> > > >> because that's what the name CLOCK_UPTIME implies: a deviation
> > from
> > > >> the
> > > >> default intended for

git: 297bb39b6f0f - main - mitigations.7: move SSP documentation from security.7 to here

2024-06-01 Thread Ed Maste
The branch main has been updated by emaste:

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

commit 297bb39b6f0fcfc5d571dc77008eb7acf138d279
Author: Ed Maste 
AuthorDate: 2024-06-01 12:07:38 +
Commit: Ed Maste 
CommitDate: 2024-06-01 15:09:30 +

mitigations.7: move SSP documentation from security.7 to here

Stack Smashing Protection (SSP) is a software vulnerability mitigation,
and fits with this page.  Add a note to the beginning of security.7
providing a more explicit cross reference to mitigations.7.

Reviewed by:kevans
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45435
---
 share/man/man7/mitigations.7 | 82 +++---
 share/man/man7/security.7| 85 +---
 2 files changed, 87 insertions(+), 80 deletions(-)

diff --git a/share/man/man7/mitigations.7 b/share/man/man7/mitigations.7
index a322c9a917da..e5ff439455e3 100644
--- a/share/man/man7/mitigations.7
+++ b/share/man/man7/mitigations.7
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 31, 2024
+.Dd June 1, 2024
 .Dt MITIGATIONS 7
 .Os
 .Sh NAME
@@ -54,8 +54,8 @@ Write XOR Execute page protection policy
 Relocation Read-Only (RELRO)
 .It
 Bind Now
-.\".It
-.\"Stack Smashing Protection (SSP)
+.It
+Stack Overflow Protection
 .It
 Supervisor Mode Memory Protection
 .It
@@ -232,7 +232,81 @@ preventing attacks on the relocation table.
 Note that this results in a nonstandard Application Binary Interface (ABI),
 and it is possible that some applications may not function correctly.
 .\"
-.\".Ss Stack Smashing Protection (SSP)
+.Ss Stack Overflow Protection
+.Fx
+supports stack overflow protection using the Stack Smashing Protector
+.Pq SSP
+compiler feature.
+In userland, SSP adds a per-process randomized canary at the end of every stack
+frame which is checked for corruption upon return from the function.
+In the kernel, a single randomized canary is used globally except on aarch64,
+which has a
+.Dv PERTHREAD_SSP
+.Xr config 8
+option to enable per-thread randomized canaries.
+If stack corruption is detected, then the process aborts to avoid potentially
+malicious execution as a result of the corruption.
+SSP may be enabled or disabled when building
+.Fx
+base with the
+.Xr src.conf 5
+SSP knob.
+.Pp
+When
+.Va WITH_SSP
+is enabled, which is the default, world is built with the
+.Fl fstack-protector-strong
+compiler option.
+The kernel is built with the
+.Fl fstack-protector
+option.
+.Pp
+In addition to SSP, a
+.Dq FORTIFY_SOURCE
+implementation is supported up to level 2 by defining
+.Va _FORTIFY_SOURCE
+to
+.Dv 1
+or
+.Dv 2
+before including any
+.Fx
+headers.
+.Fx
+world builds can set
+.Va FORTIFY_SOURCE
+to provide a default value for
+.Va _FORTIFY_SOURCE .
+When enabled,
+.Dq FORTIFY_SOURCE
+enables extra bounds checking in various functions that accept buffers to be
+written into.
+These functions currently have extra bounds checking support:
+.Bl -column -offset indent "snprintf" "memmove" "strncpy" "vsnprintf" 
"readlink"
+.It bcopyTa bzeroTa fgets Ta getcwdTa gets
+.It memcpy   Ta memmove  Ta memsetTa read  Ta readlink
+.It snprintf Ta sprintf  Ta stpcpyTa stpncpy   Ta strcat
+.It strcpy   Ta strncat  Ta strncpy   Ta vsnprintf Ta vsprintf
+.El
+.Pp
+.Dq FORTIFY_SOURCE
+requires compiler support from
+.Xr clang 1
+or
+.Xr gcc 1 ,
+which provide the
+.Xr __builtin_object_size 3
+function that is used to determine the bounds of an object.
+This feature works best at optimization levels
+.Fl O1
+and above, as some object sizes may be less obvious without some data that the
+compiler would collect in an optimization pass.
+.Pp
+Similar to SSP, violating the bounds of an object will cause the program to
+abort in an effort to avoid malicious execution.
+This effectively provides finer-grained protection than SSP for some class of
+function and system calls, along with some protection for buffers allocated as
+part of the program data.
 .\"
 .Ss Supervisor mode memory protection
 Certain processors include features that prevent unintended access to memory
diff --git a/share/man/man7/security.7 b/share/man/man7/security.7
index 2e690e35d534..7cb906304861 100644
--- a/share/man/man7/security.7
+++ b/share/man/man7/security.7
@@ -26,13 +26,21 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 5, 2023
+.Dd June 1, 2024
 .Dt SECURITY 7
 .Os
 .Sh NAME
 .Nm security
 .Nd introduction to security under FreeBSD
 .Sh DESCRIPTION
+See
+.Xr mitigations 7
+for a description of vulnerability mitigations in
+.Fx .
+This man page documents other
+.Fx
+security related topics.
+.Pp
 Security is a function that begins and ends with the system administrator.
 While all
 .Bx
@@ -939,81 +947,6 @@ 

git: 2468e20df43f - main - boot/zfs: Sync the definition of dsl_dataset_phys with OpenZFS

2024-06-01 Thread Mark Johnston
The branch main has been updated by markj:

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

commit 2468e20df43fdc8e5042e45a42235cf00e65e4b1
Author: Mark Johnston 
AuthorDate: 2024-05-04 16:12:21 +
Commit: Mark Johnston 
CommitDate: 2024-06-01 15:12:12 +

boot/zfs: Sync the definition of dsl_dataset_phys with OpenZFS

No functional change intended.

MFC after:  1 week
---
 sys/cddl/boot/zfs/zfsimpl.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/cddl/boot/zfs/zfsimpl.h b/sys/cddl/boot/zfs/zfsimpl.h
index fcaf407bcb75..0ce38384abbf 100644
--- a/sys/cddl/boot/zfs/zfsimpl.h
+++ b/sys/cddl/boot/zfs/zfsimpl.h
@@ -1465,7 +1465,10 @@ typedef struct dsl_dataset_phys {
uint64_t ds_guid;
uint64_t ds_flags;
blkptr_t ds_bp;
-   uint64_t ds_pad[8]; /* pad out to 320 bytes for good measure */
+   uint64_t ds_next_clones_obj;/* DMU_OT_DSL_CLONES */
+   uint64_t ds_props_obj;  /* DMU_OT_DSL_PROPS for snaps */
+   uint64_t ds_userrefs_obj;   /* DMU_OT_USERREFS */
+   uint64_t ds_pad[5]; /* pad out to 320 bytes for good measure */
 } dsl_dataset_phys_t;
 
 typedef struct dsl_deadlist_phys {



git: be2f92a96b96 - main - makefs/zfs: Add a helper function for adding ZAP entries

2024-06-01 Thread Mark Johnston
The branch main has been updated by markj:

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

commit be2f92a96b96149fccb4ec9e9f9c42ee29b455e6
Author: Mark Johnston 
AuthorDate: 2024-06-01 15:16:18 +
Commit: Mark Johnston 
CommitDate: 2024-06-01 15:16:18 +

makefs/zfs: Add a helper function for adding ZAP entries

Some ZAPs are used to represent sets, in which keys and values are the
same.  Add a helper function for this case.  No functional change
intended.

MFC after:  1 week
---
 usr.sbin/makefs/zfs/dsl.c | 4 +---
 usr.sbin/makefs/zfs/zap.c | 9 +
 usr.sbin/makefs/zfs/zfs.h | 1 +
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/makefs/zfs/dsl.c b/usr.sbin/makefs/zfs/dsl.c
index 93083f286e81..f7264b9d2ca7 100644
--- a/usr.sbin/makefs/zfs/dsl.c
+++ b/usr.sbin/makefs/zfs/dsl.c
@@ -490,7 +490,6 @@ dsl_dir_finalize_props(zfs_dsl_dir_t *dir)
 static void
 dsl_dir_finalize(zfs_opt_t *zfs, zfs_dsl_dir_t *dir, void *arg __unused)
 {
-   char key[32];
zfs_dsl_dir_t *cdir;
dnode_phys_t *snapnames;
zfs_dsl_dataset_t *headds;
@@ -519,8 +518,7 @@ dsl_dir_finalize(zfs_opt_t *zfs, zfs_dsl_dir_t *dir, void 
*arg __unused)
objset_root_blkptr_copy(os, &headds->phys->ds_bp);
 
zfs->snapds->phys->ds_num_children++;
-   snprintf(key, sizeof(key), "%jx", (uintmax_t)headds->dsid);
-   zap_add_uint64(zfs->cloneszap, key, headds->dsid);
+   zap_add_uint64_self(zfs->cloneszap, headds->dsid);
 
bytes = objset_space(os);
headds->phys->ds_used_bytes = bytes;
diff --git a/usr.sbin/makefs/zfs/zap.c b/usr.sbin/makefs/zfs/zap.c
index 2437ee3bfd1e..d01f7527adf9 100644
--- a/usr.sbin/makefs/zfs/zap.c
+++ b/usr.sbin/makefs/zfs/zap.c
@@ -166,6 +166,15 @@ zap_add_uint64(zfs_zap_t *zap, const char *name, uint64_t 
val)
zap_add(zap, name, sizeof(uint64_t), 1, (uint8_t *)&val);
 }
 
+void
+zap_add_uint64_self(zfs_zap_t *zap, uint64_t val)
+{
+   char name[32];
+
+   snprintf(name, sizeof(name), "%jx", (uintmax_t)val);
+   zap_add(zap, name, sizeof(uint64_t), 1, (uint8_t *)&val);
+}
+
 void
 zap_add_string(zfs_zap_t *zap, const char *name, const char *val)
 {
diff --git a/usr.sbin/makefs/zfs/zfs.h b/usr.sbin/makefs/zfs/zfs.h
index 9af090b14912..ff94c270bbf6 100644
--- a/usr.sbin/makefs/zfs/zfs.h
+++ b/usr.sbin/makefs/zfs/zfs.h
@@ -159,6 +159,7 @@ void vdev_fini(zfs_opt_t *zfs);
 zfs_zap_t *zap_alloc(zfs_objset_t *, dnode_phys_t *);
 void zap_add(zfs_zap_t *, const char *, size_t, size_t, const uint8_t *);
 void zap_add_uint64(zfs_zap_t *, const char *, uint64_t);
+void zap_add_uint64_self(zfs_zap_t *, uint64_t);
 void zap_add_string(zfs_zap_t *, const char *, const char *);
 bool zap_entry_exists(zfs_zap_t *, const char *);
 void zap_write(zfs_opt_t *, zfs_zap_t *);



git: 4bddff0833d3 - main - libdtrace: Work around a warning from flex

2024-06-01 Thread Mark Johnston
The branch main has been updated by markj:

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

commit 4bddff0833d3efee77a099b3ef447fbae1e63d21
Author: Mark Johnston 
AuthorDate: 2024-06-01 15:16:26 +
Commit: Mark Johnston 
CommitDate: 2024-06-01 15:16:26 +

libdtrace: Work around a warning from flex

When compiling dt_lex.l, flex produces warnings of the form:

  dt_lex.l:413: warning, trailing context made variable due to preceding 
'|' action
  dt_lex.l:412: warning, dangerous trailing context
  dt_lex.l:412: warning, dangerous trailing context

Here, trailing context refers to the use of "$", which expands to "/\n".

The meaning behind these warnings is described in the first two
paragraphs of the flex manual's DEFICIENCIES/BUGS section:

  Some trailing context patterns cannot be properly matched and generate
  warning messages ("dangerous trailing context").  These are patterns
  where the ending of the first part of the rule matches the beginning of
  the second part, such as "zx*/xy*", where the 'x*' matches the 'x' at
  the beginning of the trailing context.  (Note that the POSIX draft
  states that the text matched by such patterns is undefined.)

  For some trailing context rules, parts which are actually fixed-length
  are not recognized as such, leading to the above mentioned performance
  loss.  In particular, parts using '|' or {n} (such as "foo{3}") are
  always considered variable-length.

Here, the warnings appear to be bogus in this case.  The lexer has no
problem matching either of the referenced patterns, e.g.,

  printf("foobar

or

  # 1 "asdfasdf

Introduce a small amount of code duplication to silence the warning.

MFC after:  2 weeks
---
 cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l 
b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
index d50369bb57c9..756a48b9c45f 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
@@ -407,7 +407,7 @@ if (yypcb->pcb_token != 0) {
 
 {RGX_FP}   yyerror("floating-point constants are not permitted\n");
 
-\"{RGX_STR}$ |
+\"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal");
 \"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal");
 
 \"{RGX_STR}\" |



git: cb6b5e8ab9cf - main - dtrace tests: Fix loading of the test kernel module

2024-06-01 Thread Mark Johnston
The branch main has been updated by markj:

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

commit cb6b5e8ab9cfe3938855826fa3de0f58dacd364e
Author: Mark Johnston 
AuthorDate: 2024-06-01 15:16:33 +
Commit: Mark Johnston 
CommitDate: 2024-06-01 15:16:33 +

dtrace tests: Fix loading of the test kernel module

The old way is racy and can cause two instances, running in parallel, to
attempt to load dtrace_test, and only one will succeed.  This caused
errors when running dtrace tests in parallel.

MFC after:  1 week
---
 cddl/usr.sbin/dtrace/tests/tools/dtest.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cddl/usr.sbin/dtrace/tests/tools/dtest.sh 
b/cddl/usr.sbin/dtrace/tests/tools/dtest.sh
index d2f3dc4ed8df..a6634bea43a6 100755
--- a/cddl/usr.sbin/dtrace/tests/tools/dtest.sh
+++ b/cddl/usr.sbin/dtrace/tests/tools/dtest.sh
@@ -100,7 +100,7 @@ readonly STDOUT=$(mktemp)
 readonly TFILE=$(basename $1)
 readonly EXOUT=${TFILE}.out
 
-kldstat -q -m dtrace_test || kldload dtrace_test
+kldload -n dtrace_test
 cd $(dirname $1)
 runtest
 RESULT=$?



git: 397e83df75e0 - main - dtrace tests: Regenerate makefiles after commit d0b2dbfa0ecf

2024-06-01 Thread Mark Johnston
The branch main has been updated by markj:

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

commit 397e83df75e0fcd0d3fcb95ae4d794cb7600fc89
Author: Mark Johnston 
AuthorDate: 2024-06-01 15:16:39 +
Commit: Mark Johnston 
CommitDate: 2024-06-01 15:16:39 +

dtrace tests: Regenerate makefiles after commit d0b2dbfa0ecf
---
 cddl/usr.sbin/dtrace/tests/amd64/arrays/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/aggs/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/arrays/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/assocs/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/begin/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/buffering/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/cg/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/clauses/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/cpc/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/decls/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/drops/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/end/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/enum/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/env/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/error/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/exit/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/funcs/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/grammar/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/include/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/inline/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/io/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/ip/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/java_api/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/json/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/kinst/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/lexer/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/mdb/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/mib/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/misc/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/nfs/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/operators/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/pid/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/pointers/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/pragma/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/predicates/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/print/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/printa/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/printf/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/privs/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/probes/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/proc/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/providers/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/raise/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/rates/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/safety/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/scalars/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/sched/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/scripting/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/sdt/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/speculation/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/stability/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/stack/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/stop/Makefile | 1 -
 cddl/usr.sbin/dtrace/tests/common/strlen/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/struct/Makefile   | 1 -
 cddl/usr.sbin/dtrace/tests/common/sugar/Makefile| 1 -
 cddl/usr.sbin/dtrace/tests/common/syscall/Makefile  | 1 -
 cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile | 1 -
 cddl/usr.sbin/dtrac

git: 9d449caddd4f - main - md: round-trip the MUSTDEALLOC and RESERVE options

2024-06-01 Thread Alan Somers
The branch main has been updated by asomers:

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

commit 9d449caddd4f442ba4ebfd2edafa1aef4fcba4c8
Author: Alan Somers 
AuthorDate: 2024-06-01 18:00:03 +
Commit: Alan Somers 
CommitDate: 2024-06-01 18:40:19 +

md: round-trip the MUSTDEALLOC and RESERVE options

If those options are requested when the device is created, ensure that
they will be reported by MDIOCQUERY.

MFC after:  2 weeks
Reviewed by:imp
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1270
---
 sys/dev/md/md.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 267554031f23..af05373ae1d8 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -1345,7 +1345,7 @@ mdcreate_malloc(struct md_s *sc, struct md_req *mdr)
sc->fwsectors = mdr->md_fwsectors;
if (mdr->md_fwheads != 0)
sc->fwheads = mdr->md_fwheads;
-   sc->flags = mdr->md_options & (MD_COMPRESS | MD_FORCE);
+   sc->flags = mdr->md_options & (MD_COMPRESS | MD_FORCE | MD_RESERVE);
sc->indir = dimension(sc->mediasize / sc->sectorsize);
sc->uma = uma_zcreate(sc->name, sc->sectorsize, NULL, NULL, NULL, NULL,
0x1ff, 0);
@@ -1470,7 +1470,7 @@ mdcreate_vnode(struct md_s *sc, struct md_req *mdr, 
struct thread *td)
snprintf(sc->ident, sizeof(sc->ident), "MD-DEV%ju-INO%ju",
(uintmax_t)vattr.va_fsid, (uintmax_t)vattr.va_fileid);
sc->flags = mdr->md_options & (MD_ASYNC | MD_CACHE | MD_FORCE |
-   MD_VERIFY);
+   MD_VERIFY | MD_MUSTDEALLOC);
if (!(flags & FWRITE))
sc->flags |= MD_READONLY;
sc->vnode = nd.ni_vp;



git: 0f1d148cfd15 - main - pci: Use kobj typedefs for new-bus method prototypes

2024-06-01 Thread John Baldwin
The branch main has been updated by jhb:

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

commit 0f1d148cfd1503eb5c4bcc4c4689c4219dbb605f
Author: John Baldwin 
AuthorDate: 2024-06-01 20:24:29 +
Commit: John Baldwin 
CommitDate: 2024-06-01 20:24:29 +

pci: Use kobj typedefs for new-bus method prototypes

Reviewed by:kp, imp
Differential Revision:  https://reviews.freebsd.org/D45405
---
 sys/dev/pci/pci.c |  22 +++
 sys/dev/pci/pci_private.h | 156 +++---
 2 files changed, 75 insertions(+), 103 deletions(-)

diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index cbab4b50392f..2cb8b4ce9fcc 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -88,6 +88,16 @@
(((cfg)->hdrtype == PCIM_HDRTYPE_NORMAL && reg == PCIR_BIOS) || \
 ((cfg)->hdrtype == PCIM_HDRTYPE_BRIDGE && reg == PCIR_BIOS_1))
 
+static device_probe_t  pci_probe;
+
+static bus_reset_post_t pci_reset_post;
+static bus_reset_prepare_t pci_reset_prepare;
+static bus_reset_child_t pci_reset_child;
+static bus_hint_device_unit_t pci_hint_device_unit;
+static bus_remap_intr_t pci_remap_intr_method;
+
+static pci_get_id_tpci_get_id_method;
+
 static int pci_has_quirk(uint32_t devid, int quirk);
 static pci_addr_t  pci_mapbase(uint64_t mapreg);
 static const char  *pci_maptype(uint64_t mapreg);
@@ -103,7 +113,6 @@ static void pci_assign_interrupt(device_t bus, 
device_t dev,
int force_route);
 static int pci_add_map(device_t bus, device_t dev, int reg,
struct resource_list *rl, int force, int prefetch);
-static int pci_probe(device_t dev);
 static voidpci_load_vendor_data(void);
 static int pci_describe_parse_line(char **ptr, int *vendor,
int *device, char **desc);
@@ -125,17 +134,6 @@ static int pci_msi_blacklisted(void);
 static int pci_msix_blacklisted(void);
 static voidpci_resume_msi(device_t dev);
 static voidpci_resume_msix(device_t dev);
-static int pci_remap_intr_method(device_t bus, device_t dev,
-   u_int irq);
-static voidpci_hint_device_unit(device_t acdev, device_t child,
-   const char *name, int *unitp);
-static int pci_reset_post(device_t dev, device_t child);
-static int pci_reset_prepare(device_t dev, device_t child);
-static int pci_reset_child(device_t dev, device_t child,
-   int flags);
-
-static int pci_get_id_method(device_t dev, device_t child,
-   enum pci_id_type type, uintptr_t *rid);
 static struct pci_devinfo * pci_fill_devinfo(device_t pcib, device_t bus, int 
d,
 int b, int s, int f, uint16_t vid, uint16_t did);
 
diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h
index 6645488d4929..f97a4df5471b 100644
--- a/sys/dev/pci/pci_private.h
+++ b/sys/dev/pci/pci_private.h
@@ -48,6 +48,71 @@ struct pci_softc {
 extern int pci_do_power_resume;
 extern int pci_do_power_suspend;
 
+
+device_attach_tpci_attach;
+device_detach_tpci_detach;
+device_resume_tpci_resume;
+
+bus_print_child_t  pci_print_child;
+bus_probe_nomatch_tpci_probe_nomatch;
+bus_read_ivar_tpci_read_ivar;
+bus_write_ivar_t   pci_write_ivar;
+bus_driver_added_t pci_driver_added;
+bus_setup_intr_t   pci_setup_intr;
+bus_teardown_intr_tpci_teardown_intr;
+
+bus_get_dma_tag_t  pci_get_dma_tag;
+bus_get_resource_list_tpci_get_resource_list;
+bus_delete_resource_t  pci_delete_resource;
+bus_alloc_resource_t   pci_alloc_resource;
+bus_release_resource_t pci_release_resource;
+bus_activate_resource_tpci_activate_resource;
+bus_deactivate_resource_t pci_deactivate_resource;
+bus_child_deleted_tpci_child_deleted;
+bus_child_detached_t   pci_child_detached;
+bus_child_pnpinfo_tpci_child_pnpinfo_method;
+bus_child_location_t   pci_child_location_method;
+bus_get_device_path_t  pci_get_device_path_method;
+bus_suspend_child_tpci_suspend_child;
+bus_resume_child_t pci_resume_child;
+bus_rescan_t   pci_rescan_method;
+
+pci_read_config_t  pci_read_config_method;
+pci_write_config_t pci_write_config_method;
+pci_enable_busmaster_t pci_enable_busmaster_method;
+pci_disable_busmaster_tpci_disable_busmaster_method;
+pci_enable_io_tpci_enable_io_method;
+pci_disable_io_t   pci_disable_io_method;
+pci_get_vpd_ident_tpci_get_vpd_ident_method;
+pci_get_vpd_readonly_t pci_get_vpd_readonly_method;
+pci_get_powerstate_t   pci_get_powerstate_method;
+pci_set_powerstate_t   pci_set_powerstate_method;
+pci_assign_interrupt_t pci_assign_interrupt_method;
+pci_find_cap_t pci_find_

git: c7c037fad186 - main - bhnd: Remove orphaned driver for the BHND USB core

2024-06-01 Thread John Baldwin
The branch main has been updated by jhb:

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

commit c7c037fad1862c18e3e9635b06194a4ca00ac3c1
Author: John Baldwin 
AuthorDate: 2024-06-01 20:25:12 +
Commit: John Baldwin 
CommitDate: 2024-06-01 20:25:12 +

bhnd: Remove orphaned driver for the BHND USB core

This was only connected to the build for MIPS and has been
disconnected from the build since MIPS was removed.

Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D45432
---
 sys/dev/bhnd/cores/usb/bhnd_ehci.c   | 258 
 sys/dev/bhnd/cores/usb/bhnd_ohci.c   | 220 --
 sys/dev/bhnd/cores/usb/bhnd_usb.c| 549 ---
 sys/dev/bhnd/cores/usb/bhnd_usbvar.h |  60 
 4 files changed, 1087 deletions(-)

diff --git a/sys/dev/bhnd/cores/usb/bhnd_ehci.c 
b/sys/dev/bhnd/cores/usb/bhnd_ehci.c
deleted file mode 100644
index 765d7eaaa144..
--- a/sys/dev/bhnd/cores/usb/bhnd_ehci.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
- * Copyright (c) 2010, Aleksandr Rybalko 
- * All rights reserved.
- *
- * Developed by Semihalf.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of MARVELL nor the names of contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include 
-/*
- * BHND attachment driver for the USB Enhanced Host Controller.
- * Ported from ZRouter with insignificant adaptations for FreeBSD11.
- */
-
-#include "opt_bus.h"
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#defineEHCI_HC_DEVSTR  "Broadcom EHCI"
-
-#defineUSB_BRIDGE_INTR_CAUSE   0x210
-#defineUSB_BRIDGE_INTR_MASK0x214
-
-static device_attach_t bhnd_ehci_attach;
-static device_detach_t bhnd_ehci_detach;
-
-static int bhnd_ehci_probe(device_t self);
-static voidbhnd_ehci_post_reset(struct ehci_softc *ehci_softc);
-
-static int
-bhnd_ehci_probe(device_t self)
-{
-
-   device_set_desc(self, EHCI_HC_DEVSTR);
-
-   return (BUS_PROBE_DEFAULT);
-}
-
-static void
-bhnd_ehci_post_reset(struct ehci_softc *ehci_softc)
-{
-uint32_t   usbmode;
-
-/* Force HOST mode */
-usbmode = EOREAD4(ehci_softc, EHCI_USBMODE_NOLPM);
-usbmode &= ~EHCI_UM_CM;
-usbmode |= EHCI_UM_CM_HOST;
-EOWRITE4(ehci_softc, EHCI_USBMODE_NOLPM, usbmode);
-}
-
-static int
-bhnd_ehci_attach(device_t self)
-{
-   ehci_softc_t*sc;
-   int  err;
-   int  rid;
-
-   sc = device_get_softc(self);
-   /* initialise some bus fields */
-   sc->sc_bus.parent = self;
-   sc->sc_bus.devices = sc->sc_devices;
-   sc->sc_bus.devices_max = EHCI_MAX_DEVICES;
-   sc->sc_bus.usbrev = USB_REV_2_0;
-   sc->sc_bus.dma_bits = 32;
-
-   /* get all DMA memory */
-   if ((err = usb_bus_mem_alloc_all(&sc->sc_bus, USB_GET_DMA_TAG(self),
-   &ehci_iterate_hw_softc)) != 0) {
-   BHND_ERROR_DEV(self, "can't allocate DMA memory: %d", err);
-   return (ENOMEM);
-   }
-
-   rid = 0;
-   sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, 
-   RF_ACTIVE);
-   if (!sc->sc_io_r

git: e461c7bc7dde - main - mdconfig: remove the "cluster" option.

2024-06-01 Thread Alan Somers
The branch main has been updated by asomers:

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

commit e461c7bc7dde5dc84dc9e04cb623c6f567bfe6e5
Author: Alan Somers 
AuthorDate: 2024-06-01 18:38:16 +
Commit: Alan Somers 
CommitDate: 2024-06-01 23:31:04 +

mdconfig: remove the "cluster" option.

It's never had any effect.  The kernel ignores it.  Remove it from the
documentation.  But continue to parse it on the command line, for
backwards-compatibility.

Reviewed by:imp
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1271
---
 sbin/mdconfig/mdconfig.8 |  4 +---
 sbin/mdconfig/mdconfig.c | 31 +++
 2 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/sbin/mdconfig/mdconfig.8 b/sbin/mdconfig/mdconfig.8
index 73d4b30aac35..9a86a9c686fd 100644
--- a/sbin/mdconfig/mdconfig.8
+++ b/sbin/mdconfig/mdconfig.8
@@ -33,7 +33,7 @@
 .\" SUCH DAMAGE.
 .\" from: src/usr.sbin/vnconfig/vnconfig.8,v 1.19 2000/12/27 15:30:29
 .\"
-.Dd August 27, 2021
+.Dd June 1, 2024
 .Dt MDCONFIG 8
 .Os
 .Sh NAME
@@ -230,8 +230,6 @@ option tends to waste memory by giving unwanted double 
caching,
 but it saves time if there is memory to spare.
 .It Oo Cm no Oc Ns Cm reserve
 Allocate and reserve all needed storage from the start, rather than as needed.
-.It Oo Cm no Oc Ns Cm cluster
-Enable clustering on this disk.
 .It Oo Cm no Oc Ns Cm compress
 Enable/disable compression features to reduce memory usage.
 .It Oo Cm no Oc Ns Cm force
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index abcb34c1fed1..4b03dd81e591 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -87,7 +87,7 @@ usage(void)
 "   mdconfig -l [-v] [-n] [-f file] [-u unit]\n"
 "   mdconfig file\n");
fprintf(stderr, "\t\ttype = {malloc, vnode, swap}\n");
-   fprintf(stderr, "\t\toption = {async, cache, cluster, compress,\n");
+   fprintf(stderr, "\t\toption = {async, cache, compress,\n");
fprintf(stderr, "\t\t  force, mustdealloc, readonly, ro,\n");
fprintf(stderr, "\t\t  reserve, verify}\n");
fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%db (B),\n");
@@ -156,13 +156,13 @@ main(int argc, char **argv)
mdio.md_options |= MD_AUTOUNIT | MD_COMPRESS;
} else if (!strcmp(optarg, "vnode")) {
mdio.md_type = MD_VNODE;
-   mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | 
MD_COMPRESS;
+   mdio.md_options |= MD_AUTOUNIT | MD_COMPRESS;
} else if (!strcmp(optarg, "swap")) {
mdio.md_type = MD_SWAP;
-   mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | 
MD_COMPRESS;
+   mdio.md_options |= MD_AUTOUNIT | MD_COMPRESS;
} else if (!strcmp(optarg, "null")) {
mdio.md_type = MD_NULL;
-   mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | 
MD_COMPRESS;
+   mdio.md_options |= MD_AUTOUNIT | MD_COMPRESS;
} else
errx(1, "unknown type: %s", optarg);
break;
@@ -182,10 +182,15 @@ main(int argc, char **argv)
mdio.md_options |= MD_CACHE;
else if (!strcmp(optarg, "nocache"))
mdio.md_options &= ~MD_CACHE;
-   else if (!strcmp(optarg, "cluster"))
-   mdio.md_options |= MD_CLUSTER;
-   else if (!strcmp(optarg, "nocluster"))
-   mdio.md_options &= ~MD_CLUSTER;
+   /*
+* For backwards-compatibility, continue to recognize
+* "cluster"
+*/
+   else if (!strcmp(optarg, "cluster") ||
+!strcmp(optarg, "nocluster"))
+   {
+   warnx("Option cluster is ignored");
+   }
else if (!strcmp(optarg, "compress"))
mdio.md_options |= MD_COMPRESS;
else if (!strcmp(optarg, "nocompress"))
@@ -282,13 +287,11 @@ main(int argc, char **argv)
if (fflag != NULL || argc > 0) {
/* Imply ``-t vnode'' */
mdio.md_type = MD_VNODE;
-   mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
-   MD_COMPRESS;
+   mdio.md_options |= MD_AUTOUNIT | MD_COMPRESS;
} else if (sflag != NULL) {
/* Imply 

Re: git: 108de784513d - main - Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME

2024-06-01 Thread Cy Schubert
Hi eduardo@,

Patches for mesa-dri, wpa-supplicant* and hostapd* have been pushed.
These ports are no longer broken under the latest 15-CURRENT now.

-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  https://FreeBSD.org
NTP:   Web:  https://nwtime.org

e^(i*pi)+1=0


On Sat, 1 Jun 2024 09:37:00 +0100
Nuno Teixeira  wrote:

> Hello,
> 
> Having issues building graphics/mesa-dri:
> 
> ../src/intel/common/xe/intel_gem.c:72:9: error: duplicate case value '4'
>72 |case CLOCK_BOOTTIME:
>   | ^
> /usr/include/sys/_clock_id.h:81:25: note: expanded from macro
> 'CLOCK_BOOTTIME'
>81 | #define CLOCK_BOOTTIME  CLOCK_MONOTONIC
>   | ^
> /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> 'CLOCK_MONOTONIC'
>56 | #define CLOCK_MONOTONIC 4
>   | ^
> ../src/intel/common/xe/intel_gem.c:66:9: note: previous case defined here
>66 |case CLOCK_MONOTONIC:
>   | ^
> /usr/include/sys/_clock_id.h:56:26: note: expanded from macro
> 'CLOCK_MONOTONIC'
>56 | #define CLOCK_MONOTONIC 4
>   | ^
> 1 error generated.
> 
> Thanks
> 
> Warner Losh  escreveu (sexta, 31/05/2024 à(s) 15:47):
> 
> > The branch main has been updated by imp:
> >
> > URL:
> > https://cgit.FreeBSD.org/src/commit/?id=108de784513d87bbe850e7b003a73e26b5b54caa
> >
> > commit 108de784513d87bbe850e7b003a73e26b5b54caa
> > Author: Val Packett 
> > AuthorDate: 2024-05-31 14:45:02 +
> > Commit: Warner Losh 
> > CommitDate: 2024-05-31 14:45:02 +
> >
> > Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME
> >
> > The suspend-awareness situation with monotonic clocks across platforms
> > is kind of a mess, let's try not making it worse.
> >
> > On Linux, CLOCK_MONOTONIC does NOT count suspended time, and
> > CLOCK_BOOTTIME was introduced to INCLUDE suspended time.
> >
> > On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and CLOCK_UPTIME
> > was introduced to EXCLUDE suspended time.
> >
> > On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME_RAW.
> >
> > Right now, we do not have a monotonic clock that counts suspended time.
> > We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTIME as a
> > preprocessor alias, both being effectively `CLOCK_MONOTONIC` for now.
> >
> > When we introduce a suspend-aware clock in the future, it would make a
> > lot more sense to do it the OpenBSD/macOS way, i.e. to make
> > CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME exclude
> > it,
> > because that's what the name CLOCK_UPTIME implies: a deviation from the
> > default intended for the uptime command to allow it to only show the
> > time the system was actually up and not suspended.
> >
> > Let's change the define right now to make sure software using the
> > define
> > would not end up using the ID of the wrong clock in the future, and fix
> > the IDs in the Linux compat code to match the expected changes too.
> >
> > See https://bugzilla.mozilla.org/show_bug.cgi?id=1824084
> > for more discussion.
> >
> > Fixes:  155f15118a77 ("clock_gettime: Add Linux aliases for
> > CLOCK_*")
> > Fixes:  25ada637362d ("Map Linux CLOCK_BOOTTIME to native
> > CLOCK_UPTIME.")
> > Sponsored by:   https://www.patreon.com/valpackett
> > Reviewed by:kib, imp
> > Differential Revision:  https://reviews.freebsd.org/D39270
> > ---
> >  sys/compat/linux/linux_time.c | 6 +++---
> >  sys/sys/_clock_id.h   | 2 +-
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c
> > index e9e5cf075210..f4dd26dd3d2a 100644
> > --- a/sys/compat/linux/linux_time.c
> > +++ b/sys/compat/linux/linux_time.c
> > @@ -287,7 +287,7 @@ linux_to_native_clockid(clockid_t *n, clockid_t l)
> > *n = CLOCK_REALTIME;
> > break;
> > case LINUX_CLOCK_MONOTONIC:
> > -   *n = CLOCK_MONOTONIC;
> > +   *n = CLOCK_UPTIME;
> > break;
> > case LINUX_CLOCK_PROCESS_CPUTIME_ID:
> > *n = CLOCK_PROCESS_CPUTIME_ID;
> > @@ -300,10 +300,10 @@ linux_to_native_clockid(clockid_t *n, clockid_t l)
> > break;
> > case LINUX_CLOCK_MONOTONIC_COARSE:
> > case LINUX_CLOCK_MONOTONIC_RAW:
> > -   *n = CLOCK_MONOTONIC_FAST;
> > +   *n = CLOCK_UPTIME_FAST;
> > break;
> > case LINUX_CLOCK_BOOTTIME:
> > -   *n = CLOCK_UPTIME;
> > +   *n = CLOCK_MONOTONIC;
> > break;
> > case LINUX_CLOCK_REALTIME_ALARM:
> > case LINUX_CLOCK_BOOTTIME_ALARM:
> > diff --git a/sys/sys/_clock_id.h b/sys/sys/_clock_id.h
> > index 47a551428dc3..728346a0f0ab 100644
> > --