powerpc/altivec: initialize vrsave to all regs active
libunwind uses vrsave to determine which registers to restore, but
vrsave is never actually updated in modern OSs including FreeBSD. This
leads to libunwind not restoring any altivec registers, resulting in
strange behaviors.
With this change gdb can now print a backtrace without crashing.
Patch originally provided by pkubaj.
MFC after: 3 days
bxe: Always return uint64_t from bxe_hilo
The interface counters are always uint64_t, so truncating to a signed
long only results in weird sign-extension errors on 32-bit platforms.
Reported by: llm-postcr
Fixes: df3601781d3e ("- Use if_inc_counter() to increment...")
imgact_binmisc: fix validation of new entries
The magic offset and size are both uint32_t, so their sum may wrap and
pass the IBE_MATCH_MAX check with an offset far outside of the image
header. Any exec that's checked against such an entry will then read
well beyond the header.
The name and interpreter length checks also read the byte following the
string before checking its index, so either one may fill its field
without a terminating NUL as long as the next field starts with one. A
full-length interpreter then overflows the normalization buffer in
imgact_binmisc_populate_interp() by a byte. An unterminated name is
instead truncated, which lets the same name be added more than once
since the duplicate check compares against the truncated copy.
Avoid the wrap and require both strings to be terminated within their
fields, and add regression tests for each. Note that these are only
reachable by root on the host.
[2 lines not shown]
imgact_binmisc: fix matching of magic bytes >= 0x80 without a mask
The image header is a char *, so on platforms with a signed char each
header byte is sign-extended before it's compared against the unsigned
magic. Any magic byte >= 0x80 then fails to match unless IBF_USE_MASK
is set, as the mask happens to strip the sign extension.
Compare the header as uint8_t instead, and add a regression test.
Reviewed by: imp, kib, markj
Differential Revision: https://reviews.freebsd.org/D62130
binmiscctl.8: restructure the 'add' definition, note short options
The previous version just used long prose to describe the different
options available, which makes it hard to work in the short options that
are defined. It's debatably also a less effective way to describe this.
Use a more standard option list and describe each option individually.
While we're here, fix the spelling of 'indent' later on.
Note that the descriptions are largely unchanged.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D62150
imgact_binmisc: enforce IBE_MAX_ENTRIES under the list lock
The sysctl handler checked the entry count without the list lock, but
the handlers are MPSAFE so concurrent adds may push the count past
IBE_MAX_ENTRIES. Once past, the == check never matches again and the
limit stops being enforced at all.
Add a check under the lock in imgact_binmisc_add_entry() and use >=,
drop the stale comment claiming that sysctl serializes us, and add a
test that fills the table. The test can't reliably hit the race, but
it at least covers the limit.
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D62129
imgact_binmisc: don't leak the namei buffer with IBF_PRE_OPEN
namei(9) leaves the pathname buffer for the caller to free on success,
so we leak one from the NAMEI zone each time an entry is added with
IBF_PRE_OPEN. Free it once we've grabbed the vnode.
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D62128
tests: add some basic tests for imgact_binmisc
These cover managing entries through binmiscctl(8) and exec'ing images
through matching entries, including interpreter argument and macro
expansion, masked magic at an offset, and pre-opened interpreters.
A small helper is included to execve(2) an image directly, so that we
can check for ENOEXEC without sh(1) trying to run the image as a script
instead. This will be expanded in future commits to include other
useful functionality that binmiscctl(8) cannot provide.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D62126
[RISCV][CFI] Implement resetCFIToInitialState for RISCVFrameLowering (#245548)
RISCVFrameLowering enables `CFIFixup` but left
`resetCFIToInitialState()` as a no-op, leaving stale CFA offsets and
callee-saved register rules active when transitioning from a framed
block to a frameless block.
Override `resetCFIToInitialState()` to reset the CFA to SP + 0 and emit
`.cfi_same_value` for callee-saved registers, updating affected test
expectations.
Close #240683
[MLIR][NVVM] Add compare and set Op (#247175)
This patch adds the compare and set Op which perform comparison
and return boolean vector mask of 1's or 0's.
Lit tests are added to verify the lowering to the intrinsics.
PTX ISA Reference:
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#comparison-and-selection-instructions-set
Assisted-by: Claude Code
---------
Signed-off-by: DharuniRAcharya <dharunira at nvidia.com>
[clang] Remove unused includes (NFC) (#247478)
This patch removes unused #include directives across .cpp files under
clang/tools/ and clang/utils/. Identified by clang-include-cleaner and
verified locally.
Assisted-by: Antigravity
[bazel] Add -lrt to openmp (#247866)
When using the hermetic toolchain, which targets glibc 2.28 by default,
this is required. It doesn't hurt newer glibc versions
Rank an omitted directive like an explicit NOTHING
A WHEN clause that omits its directive was ranked without its runtime
condition, and the unguarded candidate of a match_any WHEN clause kept
only the condition's key. To still see the condition, isStrictSubset
counted a key without a condition trait as that trait, whatever its
polarity, and an omitted match_any clause whose static traits don't
match lost both its traits and its key. So, unlike an explicit NOTHING:
- An omitted match_none clause with `condition(a)` made a selector with
`condition(a)` a strict subset of it, although it requires `a` to be
false.
- An omitted match_any clause with `vendor(gnu)` didn't make a selector
with the same condition a strict subset of it.
- An omitted clause lost its condition's score.
Build an omitted directive's candidates the same way as an explicit
NOTHING; explicitness still only breaks ties. The unguarded candidate
of a match_any WHEN clause keeps the condition trait without its score,
so every runtime condition key now comes with a condition trait, and
[5 lines not shown]
[AMDGPU] Respect retained occupancy when comparing schedules
The scheduler can discard a schedule that spills fewer registers
because it compares occupancy beyond what the function can retain.
Cap both pressure comparisons at the function's retained occupancy.
A synthetic gfx1200 kernel spills 16 SGPRs instead of 32 at the same
two-wave limit.
AI assisted.