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

[Validator] Check size of PSV. #6924

Merged
merged 15 commits into from
Oct 3, 2024
Merged

Conversation

python3kgae
Copy link
Contributor

Check size of PSV part matches the PSVVersion.
Updated DxilPipelineStateValidation::ReadOrWrite to read based on initInfo.PSVVersion.
And return fail when size mismatch in RWMode::Read.

Fixes #6817

Check size of PSV part matches the PSVVersion.
Updated DxilPipelineStateValidation::ReadOrWrite to read based on initInfo.PSVVersion.
And return fail when size mismatch in RWMode::Read.

Fixes microsoft#6817
Copy link
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not block loading of newer PSV versions. Need to do this only in the validator code.

include/dxc/DxilContainer/DxilPipelineStateValidation.h Outdated Show resolved Hide resolved
Copy link
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the comments, we should be checking the string and index tables more thoroughly:

  • check that string table is well formed - size is aligned, buffer ends with \0
  • check that accesses to string table entries are in-bounds, before using the value.
  • check that accesses to index table entries are in-bounds, and that the (index+1)+size is within dword size of index table, before using the index array.

Then use PSVInitInfo to calculate correct size of PSV.
Copy link
Contributor

github-actions bot commented Sep 19, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

docs/ReleaseNotes.md Outdated Show resolved Hide resolved
Copy link
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly, I think we need to do away with the extra size check based on module facts, since it would only hit this, after other checks passed, when it would be better to report a more specific mismatch later.

Copy link
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@bob80905
Copy link
Collaborator

bob80905 commented Oct 2, 2024

Couple other questions that may not need resolution:
The validation procedure changes in certain cases:

  • what if there are no resources?
  • what if string table size is 0? Is that possible?
  • what if there are no SemanticIndexTableEntries? Is that possible?

Are these cases worth testing?

@python3kgae
Copy link
Contributor Author

Couple other questions that may not need resolution: The validation procedure changes in certain cases:

  • what if there are no resources?
  • what if string table size is 0? Is that possible?
  • what if there are no SemanticIndexTableEntries? Is that possible?

Are these cases worth testing?

Added test to force these values to 0.

No resources happen a lot.
String table size will be 0 when no signature and PSVVersion <=2 (PSVVersion 3 added entry name which makes string table size always > 0).
SemanticIndexTableEntries will be 0 when no signature.

@bob80905
Copy link
Collaborator

bob80905 commented Oct 2, 2024

Couple other questions that may not need resolution: The validation procedure changes in certain cases:

  • what if there are no resources?
  • what if string table size is 0? Is that possible?
  • what if there are no SemanticIndexTableEntries? Is that possible?

Are these cases worth testing?

Added test to force these values to 0.

No resources happen a lot. String table size will be 0 when no signature and PSVVersion <=2 (PSVVersion 3 added entry name which makes string table size always > 0). SemanticIndexTableEntries will be 0 when no signature.

Thanks, this is good, though what I meant to ask for at first was a test that ensures that the PSV is valid when there are no resources / 0 table size / no semantic index table entries. It would ensure that the PSV won't contain the table size as a part if the table size is 0. But these tests seem to be another way to validate that.

@python3kgae python3kgae merged commit 9221570 into microsoft:main Oct 3, 2024
12 checks passed
@python3kgae python3kgae deleted the psv_size branch October 3, 2024 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow string table in the PSV0 part to have a different order than DXC during validation
3 participants