Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support XVDs with ResiliencyEnabled flag #13

Open
emoose opened this issue Mar 20, 2019 · 3 comments
Open

Support XVDs with ResiliencyEnabled flag #13

emoose opened this issue Mar 20, 2019 · 3 comments

Comments

@emoose
Copy link
Owner

emoose commented Mar 20, 2019

Seems this flag is a recent-ish addition, wasn't seen in some older XVD utils/drivers at least.

Most hash block related functions check for this flag, and if set multiply their return value by 2 (XiComputeHashBackingBlockNumber, XiNumberHashPagesForLevel, XiNumberHashPages...), so it seems Resiliency probably allows for a second set of hash tables to be included in the XVD (reminiscent of the second set of hash blocks inside 360's STFS)

Unsure what makes this secondary hash-table get used instead of the primary, IIRC STFS had a field which would choose the tables to use (with that field being one of the last things to be written to the file), doesn't seem XVD has any field like that though, so maybe it depends on the top level hash instead?

xvdtool doesn't support files with this flag at all yet, adding support for reading them should be pretty straight-forward, but I'm uncertain about rehashing... will need to look into it some more.

@emoose
Copy link
Owner Author

emoose commented Mar 28, 2019

Looks like hash blocks have a SequenceNumber at 0xFF0, seems xvdd compares this number to the next hash blocks SequenceNumber (0x1FF0), with the highest one being treated as the actual hash block? (seen in XiUpdateIntermediateHashPage)

AFAIK the SequenceNumber field in the XVD header is used as the next SequenceNumber in the hash blocks (see xrefs to XiUpdateIntermediateHashPage)

There's also some resilient-related fields at the end of the XVD header (0xFF4) which only seem populated in images with ResiliencyEnabled. XiRestartXvd seems to make heavy use of these fields, will have to look into it further (there's also XiPhysicalGetCheckpointOffset which returns a constant 0x1000, some ResiliencyEnabled files seem to have 0x10 bytes stored there, a hash?)
(those resilient-fields are also duplicated at 0x1FF4?)

Also XiVerifyResilientHashChain sounds interesting, gonna have to look into reversing that...

@tuxuser
Copy link
Collaborator

tuxuser commented Mar 28, 2019

HashBlock counter sounds like it could relate to the way datatUnitNumber for HashEntries is calculate ?!

@emoose
Copy link
Owner Author

emoose commented Mar 28, 2019

Hmm maybe, I think that 0xFF0 number only gets set for resiliency-flagged images though, but then again IIRC I did see some 0xFF0 / 0x1FF0 offsets being checked during crypto (before I knew what those offsets were for), probably worth checking out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants