Skip to content

fix(drivers): query real HVC block capacity instead of hardcoding 512 GiB - #13

Merged
AprilNEA merged 1 commit into
masterfrom
fix/hvc-blk-capacity
Jul 19, 2026
Merged

fix(drivers): query real HVC block capacity instead of hardcoding 512 GiB#13
AprilNEA merged 1 commit into
masterfrom
fix/hvc-blk-capacity

Conversation

@AprilNEA

Copy link
Copy Markdown
Member

The bug (permanent Docker corruption on VZ→HV switch)

arcbox_hvc_blk hardcodes the disk capacity:

/* Large default capacity — VMM validates sector range. */
set_capacity(disk, (sector_t)1 << 30);   /* 512 GiB */

"VMM validates sector range" only bounds I/O — the size the kernel and filesystem see is just wrong. docker.img is an 8 TiB sparse file whose Btrfs metadata is grown (btrfs resize max) to the visible device size on each boot:

  • Under VZ, the guest sees the real 8 TiB → metadata total_bytes = 8 TiB.
  • Switch to the HV backend → the guest sees only the hardcoded 512 GiB → Btrfs refuses to mount (open_ctree failed: … total_bytes should be at most 549755813888 but found 8796093022208) → dockerd never starts → Docker permanently broken (host persists backend=hv, so restart/reboot never self-heals). Data is intact; switching back to VZ recovers.

100% reproducible for any existing user who toggles HV.

Fix

Add ARCBOX_HVC_BLK_CAPACITY (0xC2000004) and query it per device in arcbox_probe_one, using the host's real capacity_sectors (already tracked host-side). Falls back to the previous fixed size when res.a0 <= 0, so old-host / new-guest keeps the prior behavior; new-host / old-guest is unaffected. The host half is arcbox PR #453.

Test plan

  • Change mirrors the existing arcbox_hvc_flush HVC-call shape; CI builds arm64/x86 configs.
  • End-to-end: with arcbox #453, boot the System VM under HV and confirm the guest disk reports 8 TiB and Btrfs mounts (needs a boot-assets release carrying this kernel).

… GiB

arcbox_hvc_blk hardcoded set_capacity to (sector_t)1<<30 (512 GiB) with
'VMM validates sector range' — but that only bounds I/O; the size the
kernel and filesystem see was simply wrong. docker.img is an 8 TiB sparse
file whose Btrfs metadata is grown to the visible size on each boot. Under
VZ the guest saw 8 TiB; switching to the HV backend exposed only the
hardcoded 512 GiB, so Btrfs refused to mount the data disk (open_ctree
failed: total_bytes should be at most 549755813888 but found
8796093022208), permanently breaking Docker until the engine was switched
back.

Add ARCBOX_HVC_BLK_CAPACITY (0xC2000004) and query it per device, using
the host's real capacity_sectors. Falls back to the previous fixed size
when the host predates the call, so old-host/new-guest is unchanged.
@greptile-apps

greptile-apps Bot commented Jul 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates the HVC block driver to report the real backing disk size. The main changes are:

  • Adds the ARCBOX_HVC_BLK_CAPACITY HVC call ID.
  • Queries each device capacity during arcbox_probe_one.
  • Keeps the previous 512 GiB capacity as a fallback for older hosts.

Confidence Score: 5/5

Safe to merge with minimal risk.

The change is narrowly scoped and preserves old-host behavior when the capacity query returns a non-positive value.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The kernel-capacity-01-before proof shows that build-kernel.sh parses successfully.
  • The kernel-capacity-source-proof log records the relevant driver definitions and call sites used for validation.
  • The kernel-capacity-build-attempt log shows a build progression reaching driver injection but failing due to a missing flex tool.
  • The kernel-capacity-02-after proof confirms that all capacity-query, fallback, and order checks pass with exit code 0.
  • An accompanying Python source artifact is available for deeper review of the kernel-capacity checks.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
drivers/arcbox_hvc_blk.c Adds a host capacity query for HVC block devices with the previous 512 GiB value retained as fallback.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Guest as arcbox_hvc_blk guest driver
participant Host as ArcBox HV host
participant Block as Linux block layer

Guest->>Host: HVC ARCBOX_HVC_BLK_CAPACITY(idx)
alt Host supports capacity query
    Host-->>Guest: capacity_sectors in res.a0
else Old host or invalid result
    Host-->>Guest: "<= 0"
    Guest->>Guest: use ARCBOX_HVC_DEFAULT_SECTORS
end
Guest->>Block: set_capacity(disk, sectors)
Guest->>Block: add_disk(disk)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Guest as arcbox_hvc_blk guest driver
participant Host as ArcBox HV host
participant Block as Linux block layer

Guest->>Host: HVC ARCBOX_HVC_BLK_CAPACITY(idx)
alt Host supports capacity query
    Host-->>Guest: capacity_sectors in res.a0
else Old host or invalid result
    Host-->>Guest: "<= 0"
    Guest->>Guest: use ARCBOX_HVC_DEFAULT_SECTORS
end
Guest->>Block: set_capacity(disk, sectors)
Guest->>Block: add_disk(disk)
Loading

Reviews (1): Last reviewed commit: "fix(drivers): query real HVC block capac..." | Re-trigger Greptile

@AprilNEA
AprilNEA merged commit 67de771 into master Jul 19, 2026
4 checks passed
@linear-code

linear-code Bot commented Jul 19, 2026

Copy link
Copy Markdown

ABX-467

@AprilNEA
AprilNEA deleted the fix/hvc-blk-capacity branch July 19, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant