This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add RMPQUERY to SNP instructions
ClosedPublic

Authored by GGanesh on Jan 10 2023, 9:31 PM.

Details

Summary

Add RMPQUERY to the list of SNP instructions.
Tech Documentation: https://www.amd.com/system/files/TechDocs/24594.pdf

Diff Detail

Event Timeline

GGanesh created this revision.Jan 10 2023, 9:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 10 2023, 9:31 PM
GGanesh requested review of this revision.Jan 10 2023, 9:31 PM

Is it worth adding a SNP feature predicate to X86.td? Are they ever going to be exposed as intrinsics or just asm?

Is it worth adding a SNP feature predicate to X86.td? Are they ever going to be exposed as intrinsics or just asm?

SNP is there from znver3. We earlier planned to add some intrinsics. Then decided that these instructions will be system instructions so will be just asm. May be if we decide to add those intrinsics in future, we will have the predicate then. At present, I will not be adding the intrinsics. For znver3, we initially had the predicate as placeholder and then removed it as the intrinsics weren't there.

craig.topper added inline comments.Jan 12 2023, 12:03 PM
llvm/lib/Target/X86/X86InstrSNP.td
43

Defs doesn't reflect this additional sentence from the spec

Upon completion, a return code is stored in EAX. rFLAGS bits OF, ZF, AF, PF and SF are set based on
return code.
RKSimon added inline comments.Jan 12 2023, 1:06 PM
llvm/lib/Target/X86/X86InstrSNP.td
43

All the SNP instructions seem to be missing this in fact - and many update RAX/EAX with a return code as well.

GGanesh updated this revision to Diff 494026.Feb 1 2023, 11:49 AM

Updated the SNP instructions for the review comments!

RKSimon added inline comments.Feb 2 2023, 2:20 AM
llvm/lib/Target/X86/X86InstrSNP.td
38

Looking at the description in APM3 - it uses RDX as well (for permissions)

Modifies RMP permissions for a guest page. The guest virtual address is specified in the RAX register.
The page size is specified in RCX[0]. The target VMPL and its permissions are specified in the RDX
register as follows:
43

Uses RCX as well?

Reads an RMP permission mask for a guest page. The guest virtual address is specified in the RAX
register. The target VMPL is specified in RDX[7:0]. RMP permissions for the specified VMPL are
returned in RDX[63:8] and the RCX register as shown below
GGanesh updated this revision to Diff 494790.Feb 3 2023, 8:18 PM

Modified RMPADJUST instruction definition.

RMPQUERY doesn't use RCX as source. It is used only while returning the permissions.

RKSimon accepted this revision.Feb 4 2023, 7:59 AM

LGTM - cheers

This revision is now accepted and ready to land.Feb 4 2023, 7:59 AM
This revision was landed with ongoing or failed builds.Feb 5 2023, 9:17 PM
This revision was automatically updated to reflect the committed changes.