hle: add BluetoothHid, DeviceService and Usbd stubs #1031

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

@⁠defektu on GitHub · 2026-10-04 01:02 UTC · original
defektu:pr/mfgt-hle → main · +128 −0 · 4 files · 1 commits · merged 2026-10-04 23:04 UTC

Adds minimal BluetoothHid, DeviceService and Usbd stubs and registers their exports. USB event polling sleeps for 16 ms; DeviceService leaves output memory untouched because its layout is unverified.

**@⁠defektu** on GitHub · 2026-10-04 01:02 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1031) `defektu:pr/mfgt-hle` → `main` · +128 −0 · 4 files · 1 commits · merged 2026-10-04 23:04 UTC Adds minimal BluetoothHid, DeviceService and Usbd stubs and registers their exports. USB event polling sleeps for 16 ms; DeviceService leaves output memory untouched because its layout is unverified.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:40:59 +00:00
github manually merged commit fb5a9ee476 into gh-pr/1031/base 2026-11-26 09:41:00 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-04 01:11 UTC · original · edited 2026-10-04 23:06 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fa8aeb5-ac1a-4369-a3bb-15ff6e9c94f5
📥 Commits

Reviewing files that changed from the base of the PR and between db17585277 and c38d9048e14b55ff85aadf8499ad929ef4e1e7b5.

📒 Files selected for processing (7)
  • src/kernel/eventQueue.cpp
  • src/kernel/eventQueue.h
  • src/libs/libAmpr.cpp
  • src/libs/libBluetoothHid.cpp
  • src/libs/libDeviceService.cpp
  • src/libs/libUsbd.cpp
  • src/libs/libs.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The event queue now registers, deletes, and triggers AMPR events using the AMPR filter. APR kernel-event execution calls the new AMPR trigger function. The change also adds Bluetooth HID, DeviceService, and USB device library implementations and registers them during library initialization.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c38d9

The change routes AMPR completion events through a dedicated filter and adds minimal stub device libraries. No concrete merge-blocking defect was established in the supplied evidence.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to c38d9

A newly supported device-information call writes 64 bytes without a confirmed output-buffer contract. Incompatible callers could suffer memory corruption. Exploitability is unproven, and the changes do not demonstrate new privileged device access.

Retained concerns

  • Medium · security · inferred: The new DeviceService output contract assumes writable 64-byte storage despite an explicitly unconfirmed ABI. If a caller supplies a smaller allocation, the write can corrupt adjacent state in the emulator process. No such caller or exploit was verified, and existing raw-pointer capabilities limit the evidence for a new authority boundary.
Security review details

Security Blast Radius

  • inferred — The supported exposure is a guest invoking the newly resolved DeviceService import with an output pointer. A bad pointer or incompatible allocation can affect memory or availability of the emulator process. No new cross-service, tenant, credential or physical-device authority is demonstrated by this path.

Security Findings and Attack Paths

  • inferred — The potential corruption path is guest-supplied out_info to the registered query handler to a fixed 64-byte memset. The prior unresolved handler returned zero without touching output memory. Whether a real consumer allocates less than 64 bytes remains unresolved, so this is an inferred contract risk rather than a verified exploit.

Trust Boundaries and Controls

  • observed — The existing runtime resolves imports to function addresses and executes guest entry code natively. Existing input-library handlers already write directly through guest ABI pointers. These unchanged capabilities are counterevidence to treating this new zeroing operation as independently granting host-memory or sandbox-escape authority.

Resilience and Maintainability Implications

  • observed — AMPR add and delete wrappers still suppress underlying operation failures and return success; that weakness predates this PR. Completion triggering instead propagates errors to the APR worker. The filter split does not establish a worsening of this existing failure-reporting behavior.

Hardening Proposals

  • proposed — Establish the DeviceService output ABI and caller-capacity guarantee before relying on the fixed-size write. If that contract cannot be established, prefer a documented unsupported behavior over guessing the writable extent. A guest-range check alone would not prove that the caller's object is large enough.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the BluetoothHid, DeviceService, and Usbd stubs. It omits the AMPR event-queue change, but it accurately covers a substantial part of the changeset.
Description check ✅ Passed The description is related to the new library stubs and their registration. However, it says DeviceService leaves output memory untouched, while the change summary says the handler zeroes 64 bytes whe…
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-04 01:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1031#issuecomment-5975277648) · edited 2026-10-04 23:06 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1031?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `2fa8aeb5-ac1a-4369-a3bb-15ff6e9c94f5` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between db1758527751125592f57bf02f29616fa0643159 and c38d9048e14b55ff85aadf8499ad929ef4e1e7b5. </details> <details> <summary>📒 Files selected for processing (7)</summary> * `src/kernel/eventQueue.cpp` * `src/kernel/eventQueue.h` * `src/libs/libAmpr.cpp` * `src/libs/libBluetoothHid.cpp` * `src/libs/libDeviceService.cpp` * `src/libs/libUsbd.cpp` * `src/libs/libs.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The event queue now registers, deletes, and triggers AMPR events using the AMPR filter. APR kernel-event execution calls the new AMPR trigger function. The change also adds Bluetooth HID, DeviceService, and USB device library implementations and registers them during library initialization. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"c38d9048e14b55ff85aadf8499ad929ef4e1e7b5" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `c38d9` <!-- final_review_risk_coverage:{"sourceCommitId":"c38d9048e14b55ff85aadf8499ad929ef4e1e7b5","coveredCommitId":"c38d9048e14b55ff85aadf8499ad929ef4e1e7b5","kind":"reviewed"} --> The change routes AMPR completion events through a dedicated filter and adds minimal stub device libraries. No concrete merge-blocking defect was established in the supplied evidence. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🟡 Moderate_ · up to `c38d9` A newly supported device-information call writes 64 bytes without a confirmed output-buffer contract. Incompatible callers could suffer memory corruption. Exploitability is unproven, and the changes do not demonstrate new privileged device access. **Retained concerns** - **Medium · security · inferred:** The new DeviceService output contract assumes writable 64-byte storage despite an explicitly unconfirmed ABI. If a caller supplies a smaller allocation, the write can corrupt adjacent state in the emulator process. No such caller or exploit was verified, and existing raw-pointer capabilities limit the evidence for a new authority boundary. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The supported exposure is a guest invoking the newly resolved DeviceService import with an output pointer. A bad pointer or incompatible allocation can affect memory or availability of the emulator process. No new cross-service, tenant, credential or physical-device authority is demonstrated by this path. **Security Findings and Attack Paths** - _inferred_ — The potential corruption path is guest-supplied out_info to the registered query handler to a fixed 64-byte memset. The prior unresolved handler returned zero without touching output memory. Whether a real consumer allocates less than 64 bytes remains unresolved, so this is an inferred contract risk rather than a verified exploit. **Trust Boundaries and Controls** - _observed_ — The existing runtime resolves imports to function addresses and executes guest entry code natively. Existing input-library handlers already write directly through guest ABI pointers. These unchanged capabilities are counterevidence to treating this new zeroing operation as independently granting host-memory or sandbox-escape authority. **Resilience and Maintainability Implications** - _observed_ — AMPR add and delete wrappers still suppress underlying operation failures and return success; that weakness predates this PR. Completion triggering instead propagates errors to the APR worker. The filter split does not establish a worsening of this existing failure-reporting behavior. **Hardening Proposals** - _proposed_ — Establish the DeviceService output ABI and caller-capacity guarantee before relying on the fixed-size write. If that contract cannot be established, prefer a documented unsupported behavior over guessing the writable extent. A guest-range check alone would not prove that the caller's object is large enough. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 7 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Title check | ✅ Passed | The title clearly describes the BluetoothHid, DeviceService, and Usbd stubs. It omits the AMPR event-queue change, but it accurately covers a substantial part of the changeset. | | Description check | ✅ Passed | The description is related to the new library stubs and their registration. However, it says DeviceService leaves output memory untouched, while the change summary says the handler zeroes 64 bytes whe… | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1031)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.