Skip to content

Remove x86-specific code from generic headers

Thiago Jung Bauermann linux-fsdevel linux-iommu linux-s390 linuxppc-dev lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3x86/Kconfig: Move ARCH_HAS_MEM_ENCRYPT to arch/Kconfigarch/Kconfig arch/x86/Kconfig+4 -32 replies
2/3DMA mapping: Move SME handling to x86-specific filesarch/x86/Kconfig arch/x86/include/asm/dma-mapping.h arch/x86/include/asm/mem_encrypt.h +4 more+25 -175 replies
3/3fs/core/vmcore: Move sev_active() reference to x86 arch codearch/x86/kernel/crash_dump_64.c fs/proc/vmcore.c include/linux/crash_dump.h +1 more+23 -511 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchThomas Gleixner
1/3R-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] Remove x86-specific code from generic headers

Hello,

Both powerpc¹ and s390² are adding <asm/mem_encrypt.h> headers. Currently, they have to supply definitions for functions and macros which only have a meaning on x86: sme_me_mask, sme_active() and sev_active().

Christoph Hellwig made a suggestion to "clean up the Kconfig and generic headers bits for memory encryption so that we don't need all this boilerplate code", and this is what this series does.

After this patch set, this is powerpc's <asm/mem_encrypt.h>:

    #ifndef _ASM_POWERPC_MEM_ENCRYPT_H
    #define _ASM_POWERPC_MEM_ENCRYPT_H

    #include <asm/svm.h>

    static inline bool mem_encrypt_active(void)
    {
	    return is_secure_guest();
    }

    static inline bool force_dma_unencrypted(struct device *dev)
    {
	    return is_secure_guest();
    }

    int set_memory_encrypted(unsigned long addr, int numpages);
    int set_memory_decrypted(unsigned long addr, int numpages);

    #endif /* _ASM_POWERPC_MEM_ENCRYPT_H */

I don't have a way to test SME nor SEV, so the patches have only been build tested. They assume the presence of the following two commits:

Commit 4eb5fec31e61 ("fs/proc/vmcore: Enable dumping of encrypted memory when SEV was active"), which is now in Linus' master branch;

Commit e67a5ed1f86f ("dma-direct: Force unencrypted DMA under SME for certain DMA masks"), which is in dma-mapping/for-next and comes from this patch:

https://lore.kernel.org/linux-iommu/10b83d9ff31bca88e94da2ff34e30619eb396078.1562785123.git.thomas.lendacky@amd.com/

Thiago Jung Bauermann (3):
x86/Kconfig: Move ARCH_HAS_MEM_ENCRYPT to arch/Kconfig DMA mapping: Move SME handling to x86-specific files fs/core/vmcore: Move sev_active() reference to x86 arch code

 arch/Kconfig                       |  3 +++
 arch/x86/Kconfig                   |  5 ++---
 arch/x86/include/asm/dma-mapping.h |  7 +++++++
 arch/x86/include/asm/mem_encrypt.h | 10 ++++++++++
 arch/x86/kernel/crash_dump_64.c    |  5 +++++
 fs/proc/vmcore.c                   |  8 ++++----
 include/linux/crash_dump.h         | 14 ++++++++++++++
 include/linux/mem_encrypt.h        | 15 +--------------
 kernel/dma/Kconfig                 |  3 +++
 kernel/dma/mapping.c               |  4 ++--
 kernel/dma/swiotlb.c               |  3 +--
 11 files changed, 52 insertions(+), 25 deletions(-)
Signature · 2 lines
¹ https://lore.kernel.org/linuxppc-dev/[email protected]/
² https://lore.kernel.org/kvm/[email protected]/