• Michael Kelley's avatar
    x86/ioremap: Add hypervisor callback for private MMIO mapping in coco VM · 88e378d4
    Michael Kelley authored
    Current code always maps MMIO devices as shared (decrypted) in a
    confidential computing VM. But Hyper-V guest VMs on AMD SEV-SNP with vTOM
    use a paravisor running in VMPL0 to emulate some devices, such as the
    IO-APIC and TPM. In such a case, the device must be accessed as private
    (encrypted) because the paravisor emulates the device at an address below
    vTOM, where all accesses are encrypted.
    
    Add a new hypervisor callback to determine if an MMIO address should
    be mapped private. The callback allows hypervisor-specific code to handle
    any quirks, the use of a paravisor, etc. in determining whether a mapping
    must be private. If the callback is not used by a hypervisor, default
    to returning "false", which is consistent with normal coco VM behavior.
    
    Use this callback as another special case to check for when doing
    ioremap().  Just checking the starting address is sufficient as an
    ioremap range must be all private or all shared.
    
    Also make the callback in early boot IO-APIC mapping code that uses the
    fixmap.
    
      [ bp: Touchups. ]
    Signed-off-by: default avatarMichael Kelley <mikelley@microsoft.com>
    Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/1678329614-3482-2-git-send-email-mikelley@microsoft.com
    88e378d4
ioremap.c 24.9 KB