• Dave Jiang's avatar
    x86/asm: Add an enqcmds() wrapper for the ENQCMDS instruction · 7f5933f8
    Dave Jiang authored
    Currently, the MOVDIR64B instruction is used to atomically submit
    64-byte work descriptors to devices. Although it can encounter errors
    like device queue full, command not accepted, device not ready, etc when
    writing to a device MMIO, MOVDIR64B can not report back on errors from
    the device itself. This means that MOVDIR64B users need to separately
    interact with a device to see if a descriptor was successfully queued,
    which slows down device interactions.
    
    ENQCMD and ENQCMDS also atomically submit 64-byte work descriptors
    to devices. But, they *can* report back errors directly from the
    device, such as if the device was busy, or device not enabled or does
    not support the command. This immediate feedback from the submission
    instruction itself reduces the number of interactions with the device
    and can greatly increase efficiency.
    
    ENQCMD can be used at any privilege level, but can effectively only
    submit work on behalf of the current process. ENQCMDS is a ring0-only
    instruction and can explicitly specify a process context instead of
    being tied to the current process or needing to reprogram the IA32_PASID
    MSR.
    
    Use ENQCMDS for work submission within the kernel because a Process
    Address ID (PASID) is setup to translate the kernel virtual address
    space. This PASID is provided to ENQCMDS from the descriptor structure
    submitted to the device and not retrieved from IA32_PASID MSR, which is
    setup for the current user address space.
    
    See Intel Software Developer’s Manual for more information on the
    instructions.
    
     [ bp:
       - Make operand constraints like movdir64b() because both insns are
         basically doing the same thing, more or less.
       - Fixup comments and cleanup. ]
    
    Link: https://lkml.kernel.org/r/20200924180041.34056-3-dave.jiang@intel.comSigned-off-by: default avatarDave Jiang <dave.jiang@intel.com>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Reviewed-by: default avatarTony Luck <tony.luck@intel.com>
    Link: https://lkml.kernel.org/r/20201005151126.657029-3-dave.jiang@intel.com
    7f5933f8
special_insns.h 7.04 KB