kernel: stop sign-extending batch-map protection and type #405

Manually merged
github merged 1 commit from gh-pr/405/head into gh-pr/405/base 2026-11-26 09:19:20 +00:00
Owner

@⁠brandostrong on GitHub · 2026-08-29 19:04 UTC · original
brandostrong:fix/batch-map-protection-sign → main · +9 −9 · 2 files · 1 commits · merged 2026-08-29 21:46 UTC

Problem

KernelBatchMapEntry::protection and ::type are char, signed on the build platforms, and every use passes them to an int. A protection of 0xf3 widens to 0xfffffff3.

Harmless for mapping, where only bits 0-5 are tested, but KernelQueryMemoryProtection returns the stored value straight to the guest — so a guest that maps with 0xf3 reads back 0xfffffff3. The LOGF in KernelBatchMap2 already casts both fields through unsigned char.

Change

char -> unsigned char. sizeof is unchanged and the existing static_assert still holds; the now-redundant cast in LOGF is removed.

Found while chasing an unrelated crash, with no game symptom to attribute to it.

AI assistance

Let me know if this is slop, claude caught and noted this whilst looking into an unrelated problem.

**@⁠brandostrong** on GitHub · 2026-08-29 19:04 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/405) `brandostrong:fix/batch-map-protection-sign` → `main` · +9 −9 · 2 files · 1 commits · merged 2026-08-29 21:46 UTC ## Problem `KernelBatchMapEntry::protection` and `::type` are `char`, signed on the build platforms, and every use passes them to an `int`. A protection of `0xf3` widens to `0xfffffff3`. Harmless for mapping, where only bits 0-5 are tested, but `KernelQueryMemoryProtection` returns the stored value straight to the guest — so a guest that maps with `0xf3` reads back `0xfffffff3`. The `LOGF` in `KernelBatchMap2` already casts both fields through `unsigned char`. ## Change `char` -> `unsigned char`. `sizeof` is unchanged and the existing `static_assert` still holds; the now-redundant cast in `LOGF` is removed. Found while chasing an unrelated crash, with no game symptom to attribute to it. ## AI assistance Let me know if this is slop, claude caught and noted this whilst looking into an unrelated problem.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:19:19 +00:00
github manually merged commit e629ee4b04 into gh-pr/405/base 2026-11-26 09:19:20 +00:00
Author
Owner

@⁠Nmzik on GitHub · 2026-08-29 21:46 UTC · original

It is valid bug actually!

**@⁠Nmzik** on GitHub · 2026-08-29 21:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/405#issuecomment-5465067174) It is valid bug actually!
This discussion has been locked. Commenting is limited to contributors.
No description provided.