A Windows process started without a standard handle, such as a detached
process or a --windows-gui executable started from Explorer, has
descriptors 0 to 2 whose _get_osfhandle is -2. fcntl then threw on their
unknown file type, which stopped Halo: Combat Evolved (PPSA99500) at
start-up. Open NUL on each of them when libc loads, as Linux and macOS
already open /dev/null on a closed standard descriptor.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the sceNetInetPton conflict with #10275: the macOS leading-zero check moves into its convert lambda for AF_INET, so the dotted IPv4 tail of IPv6 text is checked too.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
rewatchSettledImports passed an import's 64 KiB-rounded span to
Rewatch. For an import whose size is not a block multiple the span's
last block holds pages past the allocation, the walk fails on them, and
the import stayed compared for good. Pass the import's own pages; the
shared-block and live storage image checks still use the block span.
Rewatch took only whole 64 KiB blocks, so an unwatched import whose
size or base is not a block multiple could only be offered its rounded
span, and that span reaches pages the import does not own: uncommitted
ones fail the write-watch walk and nothing returns, committed ones of a
neighbour return with it. Rewatch now takes ranges in 4 KiB pages, as
WriteWatchCoverage::Restore already does, and still stamps every block
a range touches as a CPU store.
agc_write_tracking_rewatch_import_pages (Windows) covers a 0xc4000-byte
import, one starting 0x1000 into a block, one sharing its last block
with another unwatched import, and a whole-block import.
Case 6 of settleInitialDccTests imports the target's color, DCC and CMASK
region and its FMASK region off the GPU lock, so both settles are pending
at the first use. The color loop's WatchedAfterSettle submits a settle
batch, and submitSettleBatch puts every wanted settle in it, the FMASK's
included. By the FMASK check the FMASK is back in the write watch, so the
case passes with and without the previous commit: 2 settle reads
submitted either way on an RTX 3070.
Keep case 6 as the case where both settles are pending, and add a case
where only the FMASK's is. The target's import is made and settled under
the GPU lock with WatchedAfterSettle before the FMASK's import exists, so
its color, DCC and CMASK planes are watched with no compared import over
them. The FMASK then gets its own 64 KiB import off the GPU lock, between
unregistered 64 KiB gaps, compared with its deferred settle wanted. The
case checks those preconditions and that no settle read is submitted
before the first use. The settle counters do not tell the color loop from
the FMASK check, so the case requires exactly one settle read for the
whole use: the FMASK's.
With the previous commit the target is accepted and its FMASK returns to
the write watch. Without it the FMASK check refuses the target with
"native FMASK contents require watched guest memory" and no settle read
is submitted.
Refs https://github.com/boykopovar/AnyPS5/issues/9724
#7948 requires the FMASK of an eight-fragment DCC target to be
write-watched at the initial import and at each reuse. On Windows an
FMASK in a host import whose deferred settle has not run yet is still
compared, so the target is refused with "native FMASK contents require
watched guest memory" after the previous commit has settled its color and
metadata ranges.
Call WatchedAfterSettle for the FMASK range at both checks, as the initial
import already does for the color, DCC and CMASK ranges. A range that is
unwatched without an import awaiting its read is still refused, and
nothing changes off Windows.
Four-sample targets take no FMASK range, so this changes nothing for them.
Refs https://github.com/boykopovar/AnyPS5/issues/9724
Rush 2 Recompiled (PPSA69423) and Wave Race 64 Recompiled (PPSA69424)
stop on Windows with "initial multisampled DCC contents require watched
guest memory" (https://github.com/boykopovar/AnyPS5/issues/9724). Their
multisampled color target lives in a 784 KiB host import made at map
time. An import under 1 MiB stays compared until a later lookup reaps
its deferred settle read, and the titles draw to the target first.
When an initial multisampled DCC import needs a range whose import still
waits for its settle read, submit that read now if it is still wanted,
wait for its fence and return the import to the write watch before the
check. This builds on #8527's ordering: the read goes through its
main-queue batch with barriers around it, so it runs after every earlier
main-queue access, and the wait happens under the GPU mutex that
submission holds.
An import that is not a whole number of 64 KiB blocks, such as these
titles' 0xc4000 bytes, never got a deferred read, and Rewatch refuses a
range that does not start and end on a block. Such an import now waits
for this path alone. It returns to the write watch with its partial
blocks whole, each stamped as a CPU store, unless another compared
import or a live storage image shares them.
Imports that stay compared for any other reason still do, an explicitly
unwatched range is still refused, and APS5_NO_DEFERRED_SETTLES still
keeps these imports compared.
Kept both sides in StandardExceptions.cpp: main's system_category and error_code value at offset 4 plus this PR's SceV2 types; the shared ThrowCppError and the test's ErrorCode follow the new layout. No exports overlap.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The prosper console oracle measured SCE_KERNEL_ERROR_EINVAL for creating
a semaphore with an initial count above the maximum, a maximum of 0, a
negative initial count or a null name, for polling 0 or more than the
maximum, and for signalling 0. These threw, or polled past the maximum
returned EBUSY, and signalling 0 succeeded.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Apple clang rejects reinterpret_cast from const void* to a function
pointer ("casts away qualifiers") in StandardExceptions.cpp, so
libc/src/exception/Exports.cpp, which includes it, failed to build on
macOS after std::system_category landed. On macOS the vtable slot is
const_cast first. Linux and Windows compile the same code as before.