Remove x86-specific code from generic headers
v3 cover Remove x86-specific code from generic headers
Hello,
This version is mostly about splitting up patch 2/3 into three separate patches, as suggested by Christoph Hellwig. Two other changes are a fix in patch 1 which wasn't selecting ARCH_HAS_MEM_ENCRYPT for s390 spotted by Janani and removal of sme_active and sev_active symbol exports as suggested by Christoph Hellwig.
These patches are applied on top of today's dma-mapping/for-next.
I don't have a way to test SME, SEV, nor s390's PEF so the patches have only been build tested.
Changelog
Since v2:
- Patch "x86,s390: Move ARCH_HAS_MEM_ENCRYPT definition to arch/Kconfig"
- Added "select ARCH_HAS_MEM_ENCRYPT" to config S390. Suggested by Janani.
- Patch "DMA mapping: Move SME handling to x86-specific files"
- Split up into 3 new patches. Suggested by Christoph Hellwig.
- Patch "swiotlb: Remove call to sme_active()"
- New patch.
- Patch "dma-mapping: Remove dma_check_mask()"
- New patch.
- Patch "x86,s390/mm: Move sme_active() and sme_me_mask to x86-specific header"
- New patch.
- Removed export of sme_active symbol. Suggested by Christoph Hellwig.
- Patch "fs/core/vmcore: Move sev_active() reference to x86 arch code"
- Removed export of sev_active symbol. Suggested by Christoph Hellwig.
- Patch "s390/mm: Remove sev_active() function"
- New patch.
Since v1:
- Patch "x86,s390: Move ARCH_HAS_MEM_ENCRYPT definition to arch/Kconfig"
- Remove definition of ARCH_HAS_MEM_ENCRYPT from s390/Kconfig as well.
- Reworded patch title and message a little bit.
- Patch "DMA mapping: Move SME handling to x86-specific files"
- Adapt s390's <asm/mem_encrypt.h> as well.
- Remove dma_check_mask() from kernel/dma/mapping.c. Suggested by Christoph Hellwig.
Thiago Jung Bauermann (6):
x86,s390: Move ARCH_HAS_MEM_ENCRYPT definition to arch/Kconfig
swiotlb: Remove call to sme_active()
dma-mapping: Remove dma_check_mask()
x86,s390/mm: Move sme_active() and sme_me_mask to x86-specific header fs/core/vmcore: Move sev_active() reference to x86 arch code s390/mm: Remove sev_active() function
arch/Kconfig | 3 +++ arch/s390/Kconfig | 4 +--- arch/s390/include/asm/mem_encrypt.h | 5 +---- arch/s390/mm/init.c | 8 +------- arch/x86/Kconfig | 4 +--- arch/x86/include/asm/mem_encrypt.h | 10 ++++++++++ arch/x86/kernel/crash_dump_64.c | 5 +++++ arch/x86/mm/mem_encrypt.c | 2 -- fs/proc/vmcore.c | 8 ++++---- include/linux/crash_dump.h | 14 ++++++++++++++ include/linux/mem_encrypt.h | 15 +-------------- kernel/dma/mapping.c | 8 -------- kernel/dma/swiotlb.c | 3 +-- 13 files changed, 42 insertions(+), 47 deletions(-)
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v3 1/6 x86,s390: Move ARCH_HAS_MEM_ENCRYPT definition to arch/Kconfig
powerpc is also going to use this feature, so put it in a generic location.
--- arch/Kconfig | 3 +++ arch/s390/Kconfig | 4 +--- arch/x86/Kconfig | 4 +--- 3 files changed, 5 insertions(+), 6 deletions(-)
arch/Kconfig +3 -0
@@ -935,6 +935,9 @@ config LOCK_EVENT_COUNTS the chance of application behavior change because of timing differences. The counts are reported via debugfs. +config ARCH_HAS_MEM_ENCRYPT + bool + source "kernel/gcov/Kconfig" source "scripts/gcc-plugins/Kconfig"
arch/s390/Kconfig +1 -3
@@ -1,7 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -config ARCH_HAS_MEM_ENCRYPT - def_bool y - config MMU def_bool y
@@ -68,6 +65,7 @@ config S390 select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX
arch/x86/Kconfig +1 -3
@@ -68,6 +68,7 @@ config X86 select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_KCOV if X86_64 + select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PMEM_API if X86_64 select ARCH_HAS_PTE_SPECIAL
@@ -1520,9 +1521,6 @@ config X86_CPA_STATISTICS helps to determine the effectiveness of preserving large and huge page mappings when mapping protections are changed. -config ARCH_HAS_MEM_ENCRYPT - def_bool y - config AMD_MEM_ENCRYPT bool "AMD Secure Memory Encryption (SME) support" depends on X86_64 && CPU_SUP_AMD
PATCH v3 2/6 swiotlb: Remove call to sme_active()
In reply to Thiago Jung Bauermannsme_active() is an x86-specific function so it's better not to call it from generic code.
There's no need to mention which memory encryption feature is active, so just use a more generic message. Besides, other architectures will have different names for similar technology.
--- kernel/dma/swiotlb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/dma/swiotlb.c +1 -2
@@ -459,8 +459,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,panic ("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer" );if (mem_encrypt_active ()) -pr_warn_once ("%s is active and system is using DMA bounce buffers\n" , -sme_active () ?"SME" :"SEV" ); +pr_warn_once ("Memory encryption is active and system is using DMA bounce buffers\n" ); mask =dma_get_seg_boundary (hwdev);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 2/6] swiotlb: Remove call to sme_active()
Quoted 8 lines · Thiago Jung Bauermann
sme_active()is an x86-specific function so it's better not to call it from generic code.There's no need to mention which memory encryption feature is active, so just use a more generic message. Besides, other architectures will have different names for similar technology.
Signed-off-by Thiago Jung Bauermann <[email protected]>
Looks good,
Re: [PATCH v3 2/6] swiotlb: Remove call to sme_active()
In reply to Thiago Jung BauermannQuoted 8 lines · Thiago Jung Bauermann
sme_active()is an x86-specific function so it's better not to call it from generic code.There's no need to mention which memory encryption feature is active, so just use a more generic message. Besides, other architectures will have different names for similar technology.
Signed-off-by Thiago Jung Bauermann <[email protected]>
Quoted 19 lines
--- kernel/dma/swiotlb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)kernel/dma/swiotlb.c +1
-2@@ -459,8 +459,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,panic ("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer" );if (mem_encrypt_active ()) -pr_warn_once ("%s is active and system is using DMA bounce buffers\n" , -sme_active () ?"SME" :"SEV" ); +pr_warn_once ("Memory encryption is active and system is using DMA bounce buffers\n" ); mask =dma_get_seg_boundary (hwdev);
PATCH v3 3/6 dma-mapping: Remove dma_check_mask()
In reply to Thiago Jung Bauermannsme_active() is an x86-specific function so it's better not to call it from generic code. Christoph Hellwig mentioned that "There is no reason why we should have a special debug printk just for one specific reason why there is a requirement for a large DMA mask.", so just remove dma_check_mask().
--- kernel/dma/mapping.c | 8 -------- 1 file changed, 8 deletions(-)
kernel/dma/mapping.c +0 -8
@@ -291,12 +291,6 @@ void dma_free_attrs(struct device *dev, size_t size, void *cpu_addr, }EXPORT_SYMBOL (dma_free_attrs); -static inline void dma_check_mask (struct device *dev,u64 mask) -{ -if (sme_active () && (mask < (((u64 )sme_get_me_mask () <<1 ) -1 ))) -dev_warn (dev,"SME is active, device will require DMA bounce buffers\n" ); -} -int dma_supported (struct device *dev,u64 mask) {const struct dma_map_ops *ops =get_dma_ops (dev);
@@ -327,7 +321,6 @@ int dma_set_mask(struct device *dev, u64 mask)return -EIO ;arch_dma_set_mask (dev, mask); -dma_check_mask (dev, mask); *dev->dma_mask = mask;return 0 ; }
@@ -345,7 +338,6 @@ int dma_set_coherent_mask(struct device *dev, u64 mask)if (!dma_supported (dev, mask))return -EIO ; -dma_check_mask (dev, mask); dev->coherent_dma_mask = mask;return 0 ; }
Re: [PATCH v3 3/6] dma-mapping: Remove dma_check_mask()
Quoted 6 lines · Thiago Jung Bauermann
sme_active()is an x86-specific function so it's better not to call it from generic code. Christoph Hellwig mentioned that "There is no reason why we should have a special debug printk just for one specific reason why there is a requirement for a large DMA mask.", so just removedma_check_mask().Signed-off-by Thiago Jung Bauermann <[email protected]>
Looks good,
Re: [PATCH v3 3/6] dma-mapping: Remove dma_check_mask()
In reply to Thiago Jung BauermannQuoted 6 lines · Thiago Jung Bauermann
sme_active()is an x86-specific function so it's better not to call it from generic code. Christoph Hellwig mentioned that "There is no reason why we should have a special debug printk just for one specific reason why there is a requirement for a large DMA mask.", so just removedma_check_mask().Signed-off-by Thiago Jung Bauermann <[email protected]>
Quoted 38 lines
--- kernel/dma/mapping.c | 8 -------- 1 file changed, 8 deletions(-)kernel/dma/mapping.c +0
-8@@ -291,12 +291,6 @@ void dma_free_attrs(struct device *dev, size_t size, void *cpu_addr, }EXPORT_SYMBOL (dma_free_attrs); -static inline void dma_check_mask (struct device *dev,u64 mask) -{ -if (sme_active () && (mask < (((u64 )sme_get_me_mask () <<1 ) -1 ))) -dev_warn (dev,"SME is active, device will require DMA bounce buffers\n" ); -} -int dma_supported (struct device *dev,u64 mask) {const struct dma_map_ops *ops =get_dma_ops (dev);@@ -327,7 +321,6 @@ int dma_set_mask(struct device *dev, u64 mask)return -EIO ;arch_dma_set_mask (dev, mask); -dma_check_mask (dev, mask); *dev->dma_mask = mask;return 0 ; }@@ -345,7 +338,6 @@ int dma_set_coherent_mask(struct device *dev, u64 mask)if (!dma_supported (dev, mask))return -EIO ; -dma_check_mask (dev, mask); dev->coherent_dma_mask = mask;return 0 ; }
PATCH v3 4/6 x86,s390/mm: Move sme_active() and sme_me_mask to x86-specific header
In reply to Thiago Jung BauermannNow that generic code doesn't reference them, move sme_active() and sme_me_mask to x86's <asm/mem_encrypt.h>.
Also remove the export for sme_active() since it's only used in files that won't be built as modules. sme_me_mask on the other hand is used in arch/x86/kvm/svm.c (via __sme_set() and __psp_pa()) which can be built as a module so its export needs to stay.
--- arch/s390/include/asm/mem_encrypt.h | 4 +--- arch/x86/include/asm/mem_encrypt.h | 10 ++++++++++ arch/x86/mm/mem_encrypt.c | 1 - include/linux/mem_encrypt.h | 14 +------------- 4 files changed, 12 insertions(+), 17 deletions(-)
arch/s390/include/asm/mem_encrypt.h +1 -3
@@ -4,9 +4,7 @@#ifndef __ASSEMBLY__ -#define sme_me_mask 0ULL - -static inline bool sme_active (void ) {return false; } +static inline bool mem_encrypt_active (void ) {return false; }extern bool sev_active (void );int set_memory_encrypted (unsigned long addr,int numpages);
arch/x86/include/asm/mem_encrypt.h +10 -0
@@ -92,6 +92,16 @@ early_set_memory_encrypted(unsigned long vaddr, unsigned long size) { return 0;extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[]; +static inline bool mem_encrypt_active (void ) +{ +return sme_me_mask; +} + +static inline u64 sme_get_me_mask (void ) +{ +return sme_me_mask; +} +#endif /* __ASSEMBLY__ */ #endif /* __X86_MEM_ENCRYPT_H__ */
arch/x86/mm/mem_encrypt.c +0 -1
@@ -344,7 +344,6 @@ bool sme_active(void) {return sme_me_mask && !sev_enabled; } -EXPORT_SYMBOL (sme_active);bool sev_active (void ) {
include/linux/mem_encrypt.h +1 -13
@@ -18,23 +18,11 @@#else /* !CONFIG_ARCH_HAS_MEM_ENCRYPT */ -#define sme_me_mask 0ULL - -static inline bool sme_active (void ) {return false; } +static inline bool mem_encrypt_active (void ) {return false; }static inline bool sev_active (void ) {return false; }#endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */ -static inline bool mem_encrypt_active (void ) -{ -return sme_me_mask; -} - -static inline u64 sme_get_me_mask (void ) -{ -return sme_me_mask; -} -#ifdef CONFIG_AMD_MEM_ENCRYPT /* * The __sme_set() and __sme_clr() macros are useful for adding or removing
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 4/6] x86,s390/mm: Move sme_active() and sme_me_mask to x86-specific header
Quoted 9 lines · Thiago Jung Bauermann
Now that generic code doesn't reference them, move
sme_active()andsme_me_maskto x86's <asm/mem_encrypt.h>.Also remove the export for
sme_active()since it's only used in files that won't be built as modules.sme_me_maskon the other hand is used inarch/x86/kvm/svm.c(via__sme_set()and__psp_pa()) which can be built as a module so its export needs to stay.Signed-off-by Thiago Jung Bauermann <[email protected]>
Looks good,
Re: [PATCH v3 4/6] x86,s390/mm: Move sme_active() and sme_me_mask to x86-specific header
In reply to Thiago Jung BauermannQuoted 7 lines · Thiago Jung Bauermann
Now that generic code doesn't reference them, move
sme_active()andsme_me_maskto x86's <asm/mem_encrypt.h>.Also remove the export for
sme_active()since it's only used in files that won't be built as modules.sme_me_maskon the other hand is used inarch/x86/kvm/svm.c(via__sme_set()and__psp_pa()) which can be built as a module so its export needs to stay.
You may want to try and build the out-of-tree nvidia driver just to be sure you can remove the EXPORT_SYMBOL(). But I believe that was related to the DMA mask check, which now removed, may no longer be a problem.
Quoted 2 lines
Signed-off-by Thiago Jung Bauermann <[email protected]>
Quoted 85 lines
--- arch/s390/include/asm/mem_encrypt.h | 4 +--- arch/x86/include/asm/mem_encrypt.h | 10 ++++++++++ arch/x86/mm/mem_encrypt.c | 1 - include/linux/mem_encrypt.h | 14 +------------- 4 files changed, 12 insertions(+), 17 deletions(-)arch/s390/include/asm/mem_encrypt.h +1
-3@@ -4,9 +4,7 @@#ifndef __ASSEMBLY__ -#define sme_me_mask 0ULL - -static inline bool sme_active (void ) {return false; } +static inline bool mem_encrypt_active (void ) {return false; }extern bool sev_active (void );int set_memory_encrypted (unsigned long addr,int numpages);arch/x86/include/asm/mem_encrypt.h +10
-0@@ -92,6 +92,16 @@ early_set_memory_encrypted(unsigned long vaddr, unsigned long size) { return 0;extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[]; +static inline bool mem_encrypt_active (void ) +{ +return sme_me_mask; +} + +static inline u64 sme_get_me_mask (void ) +{ +return sme_me_mask; +} +#endif /* __ASSEMBLY__ */ #endif /* __X86_MEM_ENCRYPT_H__ */ arch/x86/mm/mem_encrypt.c +0
-1@@ -344,7 +344,6 @@ bool sme_active(void) {return sme_me_mask && !sev_enabled; } -EXPORT_SYMBOL (sme_active);bool sev_active (void ) {include/linux/mem_encrypt.h +1
-13@@ -18,23 +18,11 @@#else /* !CONFIG_ARCH_HAS_MEM_ENCRYPT */ -#define sme_me_mask 0ULL - -static inline bool sme_active (void ) {return false; } +static inline bool mem_encrypt_active (void ) {return false; }static inline bool sev_active (void ) {return false; }#endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */ -static inline bool mem_encrypt_active (void ) -{ -return sme_me_mask; -} - -static inline u64 sme_get_me_mask (void ) -{ -return sme_me_mask; -} -#ifdef CONFIG_AMD_MEM_ENCRYPT /* * The __sme_set() and __sme_clr() macros are useful for adding or removing
Re: [PATCH v3 4/6] x86,s390/mm: Move sme_active() and sme_me_mask to x86-specific header
Quoted 3 lines · Thomas
You may want to try and build the out-of-tree nvidia driver just to be sure you can remove the
EXPORT_SYMBOL(). But I believe that was related to the DMA mask check, which now removed, may no longer be a problem.
Out of tree driver simply don't matter for kernel development decisions.
PATCH v3 5/6 fs/core/vmcore: Move sev_active() reference to x86 arch code
In reply to Thiago Jung BauermannSecure Encrypted Virtualization is an x86-specific feature, so it shouldn't appear in generic kernel code because it forces non-x86 architectures to define the sev_active() function, which doesn't make a lot of sense.
To solve this problem, add an x86 elfcorehdr_read() function to override the generic weak implementation. To do that, it's necessary to make read_from_oldmem() public so that it can be used outside of vmcore.c.
Also, remove the export for sev_active() since it's only used in files that won't be built as modules.
--- arch/x86/kernel/crash_dump_64.c | 5 +++++ arch/x86/mm/mem_encrypt.c | 1 - fs/proc/vmcore.c | 8 ++++---- include/linux/crash_dump.h | 14 ++++++++++++++ include/linux/mem_encrypt.h | 1 - 5 files changed, 23 insertions(+), 6 deletions(-)
arch/x86/kernel/crash_dump_64.c +5 -0
@@ -70,3 +70,8 @@ ssize_t copy_oldmem_page_encrypted(unsigned long pfn, char *buf, size_t csize, {return __copy_oldmem_page (pfn, buf, csize, offset, userbuf, true); } + +ssize_t elfcorehdr_read (char *buf,size_t count,u64 *ppos) +{ +return read_from_oldmem (buf, count, ppos,0 ,sev_active ()); +}
arch/x86/mm/mem_encrypt.c +0 -1
@@ -349,7 +349,6 @@ bool sev_active(void) {return sme_me_mask && sev_enabled; } -EXPORT_SYMBOL (sev_active);/* Override for DMA direct allocation check - ARCH_HAS_FORCE_DMA_UNENCRYPTED */ bool force_dma_unencrypted (struct device *dev)
fs/proc/vmcore.c +4 -4
@@ -100,9 +100,9 @@ static int pfn_is_ram(unsigned long pfn) }/* Reads a page from the oldmem device from given offset. */ -static ssize_t read_from_oldmem (char *buf,size_t count, -u64 *ppos,int userbuf, -bool encrypted) +ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted) {unsigned long pfn, offset;size_t nr_bytes;
@@ -166,7 +166,7 @@ void __weak elfcorehdr_free(unsigned long long addr)*/ ssize_t __weak elfcorehdr_read (char *buf,size_t count,u64 *ppos) { -return read_from_oldmem (buf, count, ppos,0 ,sev_active ()); +return read_from_oldmem (buf, count, ppos,0 , false); }/*
include/linux/crash_dump.h +14 -0
@@ -115,4 +115,18 @@ static inline int vmcore_add_device_dump(struct vmcoredd_data *data)return -EOPNOTSUPP ; }#endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */ + +#ifdef CONFIG_PROC_VMCORE +ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted); +#else +static inline ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted) +{ +return -EOPNOTSUPP ; +} +#endif /* CONFIG_PROC_VMCORE */ +#endif /* LINUX_CRASHDUMP_H */
include/linux/mem_encrypt.h +0 -1
@@ -19,7 +19,6 @@#else /* !CONFIG_ARCH_HAS_MEM_ENCRYPT */ static inline bool mem_encrypt_active (void ) {return false; } -static inline bool sev_active (void ) {return false; }#endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */
Re: [PATCH v3 5/6] fs/core/vmcore: Move sev_active() reference to x86 arch code
Quoted 10 lines · Thiago Jung Bauermann
Secure Encrypted Virtualization is an x86-specific feature, so it shouldn't appear in generic kernel code because it forces non-x86 architectures to define the
sev_active()function, which doesn't make a lot of sense.To solve this problem, add an x86
elfcorehdr_read()function to override the generic weak implementation. To do that, it's necessary to makeread_from_oldmem()public so that it can be used outside ofvmcore.c.Also, remove the export for
sev_active()since it's only used in files that won't be built as modules.
I have to say I find the __weak overrides of the vmcore files very confusing and which we'd have a better scheme there. But as this fits into that scheme and allows to remove the AMD SME vs SEV knowledge from the core I'm fine with it.
Re: [PATCH v3 5/6] fs/core/vmcore: Move sev_active() reference to x86 arch code
In reply to Thiago Jung BauermannQuoted 4 lines · Thiago Jung Bauermann
Secure Encrypted Virtualization is an x86-specific feature, so it shouldn't appear in generic kernel code because it forces non-x86 architectures to define the
sev_active()function, which doesn't make a lot of sense.
Quoted 8 lines
To solve this problem, add an x86
elfcorehdr_read()function to override the generic weak implementation. To do that, it's necessary to makeread_from_oldmem()public so that it can be used outside ofvmcore.c.Also, remove the export for
sev_active()since it's only used in files that won't be built as modules.Signed-off-by Thiago Jung Bauermann <[email protected]>
Adding Lianbo and Baoquan, who recently worked on this, for their review.
Thanks,
Tom
Quoted 95 lines
--- arch/x86/kernel/crash_dump_64.c | 5 +++++ arch/x86/mm/mem_encrypt.c | 1 - fs/proc/vmcore.c | 8 ++++---- include/linux/crash_dump.h | 14 ++++++++++++++ include/linux/mem_encrypt.h | 1 - 5 files changed, 23 insertions(+), 6 deletions(-)arch/x86/kernel/crash_dump_64.c +5
-0@@ -70,3 +70,8 @@ ssize_t copy_oldmem_page_encrypted(unsigned long pfn, char *buf, size_t csize, {return __copy_oldmem_page (pfn, buf, csize, offset, userbuf, true); } + +ssize_t elfcorehdr_read (char *buf,size_t count,u64 *ppos) +{ +return read_from_oldmem (buf, count, ppos,0 ,sev_active ()); +}arch/x86/mm/mem_encrypt.c +0
-1@@ -349,7 +349,6 @@ bool sev_active(void) {return sme_me_mask && sev_enabled; } -EXPORT_SYMBOL (sev_active);/* Override for DMA direct allocation check - ARCH_HAS_FORCE_DMA_UNENCRYPTED */ bool force_dma_unencrypted (struct device *dev)fs/proc/vmcore.c +4
-4@@ -100,9 +100,9 @@ static int pfn_is_ram(unsigned long pfn) }/* Reads a page from the oldmem device from given offset. */ -static ssize_t read_from_oldmem (char *buf,size_t count, -u64 *ppos,int userbuf, -bool encrypted) +ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted) {unsigned long pfn, offset;size_t nr_bytes;@@ -166,7 +166,7 @@ void __weak elfcorehdr_free(unsigned long long addr)*/ ssize_t __weak elfcorehdr_read (char *buf,size_t count,u64 *ppos) { -return read_from_oldmem (buf, count, ppos,0 ,sev_active ()); +return read_from_oldmem (buf, count, ppos,0 , false); }/* include/linux/crash_dump.h +14
-0@@ -115,4 +115,18 @@ static inline int vmcore_add_device_dump(struct vmcoredd_data *data)return -EOPNOTSUPP ; }#endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */ + +#ifdef CONFIG_PROC_VMCORE +ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted); +#else +static inline ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted) +{ +return -EOPNOTSUPP ; +} +#endif /* CONFIG_PROC_VMCORE */ +#endif /* LINUX_CRASHDUMP_H */ include/linux/mem_encrypt.h +0
-1@@ -19,7 +19,6 @@#else /* !CONFIG_ARCH_HAS_MEM_ENCRYPT */ static inline bool mem_encrypt_active (void ) {return false; } -static inline bool sev_active (void ) {return false; }#endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */
lijiang
Reviewed-byRe: [PATCH v3 5/6] fs/core/vmcore: Move sev_active() reference to x86 arch code
Quoted 9 lines · Thomas
Quoted 8 lines · Thiago Jung Bauermann
Secure Encrypted Virtualization is an x86-specific feature, so it shouldn't appear in generic kernel code because it forces non-x86 architectures to define the
sev_active()function, which doesn't make a lot of sense.To solve this problem, add an x86
elfcorehdr_read()function to override the generic weak implementation. To do that, it's necessary to makeread_from_oldmem()public so that it can be used outside ofvmcore.c.
Quoted 7 lines
Quoted 4 lines
Also, remove the export for
sev_active()since it's only used in files that won't be built as modules.Signed-off-by Thiago Jung Bauermann <[email protected]>Adding Lianbo and Baoquan, who recently worked on this, for their review.
This change looks good to me.
Thanks.
Lianbo
Quoted 98 lines
Thanks,
TomQuoted 95 lines
--- arch/x86/kernel/crash_dump_64.c | 5 +++++ arch/x86/mm/mem_encrypt.c | 1 - fs/proc/vmcore.c | 8 ++++---- include/linux/crash_dump.h | 14 ++++++++++++++ include/linux/mem_encrypt.h | 1 - 5 files changed, 23 insertions(+), 6 deletions(-)arch/x86/kernel/crash_dump_64.c +5
-0@@ -70,3 +70,8 @@ ssize_t copy_oldmem_page_encrypted(unsigned long pfn, char *buf, size_t csize, {return __copy_oldmem_page (pfn, buf, csize, offset, userbuf, true); } + +ssize_t elfcorehdr_read (char *buf,size_t count,u64 *ppos) +{ +return read_from_oldmem (buf, count, ppos,0 ,sev_active ()); +}arch/x86/mm/mem_encrypt.c +0
-1@@ -349,7 +349,6 @@ bool sev_active(void) {return sme_me_mask && sev_enabled; } -EXPORT_SYMBOL (sev_active);/* Override for DMA direct allocation check - ARCH_HAS_FORCE_DMA_UNENCRYPTED */ bool force_dma_unencrypted (struct device *dev)fs/proc/vmcore.c +4
-4@@ -100,9 +100,9 @@ static int pfn_is_ram(unsigned long pfn) }/* Reads a page from the oldmem device from given offset. */ -static ssize_t read_from_oldmem (char *buf,size_t count, -u64 *ppos,int userbuf, -bool encrypted) +ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted) {unsigned long pfn, offset;size_t nr_bytes;@@ -166,7 +166,7 @@ void __weak elfcorehdr_free(unsigned long long addr)*/ ssize_t __weak elfcorehdr_read (char *buf,size_t count,u64 *ppos) { -return read_from_oldmem (buf, count, ppos,0 ,sev_active ()); +return read_from_oldmem (buf, count, ppos,0 , false); }/* include/linux/crash_dump.h +14
-0@@ -115,4 +115,18 @@ static inline int vmcore_add_device_dump(struct vmcoredd_data *data)return -EOPNOTSUPP ; }#endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */ + +#ifdef CONFIG_PROC_VMCORE +ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted); +#else +static inline ssize_t read_from_oldmem (char *buf,size_t count, +u64 *ppos,int userbuf, +bool encrypted) +{ +return -EOPNOTSUPP ; +} +#endif /* CONFIG_PROC_VMCORE */ +#endif /* LINUX_CRASHDUMP_H */ include/linux/mem_encrypt.h +0
-1@@ -19,7 +19,6 @@#else /* !CONFIG_ARCH_HAS_MEM_ENCRYPT */ static inline bool mem_encrypt_active (void ) {return false; } -static inline bool sev_active (void ) {return false; }#endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */
Re: [PATCH v3 5/6] fs/core/vmcore: Move sev_active() reference to x86 arch code
Hello Lianbo,
Quoted 13 lines · lijiang
Quoted 12 lines · Thomas
Quoted 11 lines · Thiago Jung Bauermann
Secure Encrypted Virtualization is an x86-specific feature, so it shouldn't appear in generic kernel code because it forces non-x86 architectures to define the
sev_active()function, which doesn't make a lot of sense.To solve this problem, add an x86
elfcorehdr_read()function to override the generic weak implementation. To do that, it's necessary to makeread_from_oldmem()public so that it can be used outside ofvmcore.c.Also, remove the export for
sev_active()since it's only used in files that won't be built as modules.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Thiago Jung Bauermann <[email protected]>Adding Lianbo and Baoquan, who recently worked on this, for their review.
This change looks good to me.
Reviewed-by Lianbo Jiang <[email protected]>
Thanks for your review!
Signature · 2 lines
Thiago Jung Bauermann IBM Linux Technology Center
PATCH v3 6/6 s390/mm: Remove sev_active() function
In reply to Thiago Jung BauermannAll references to sev_active() were moved to arch/x86 so we don't need to define it for s390 anymore.
--- arch/s390/include/asm/mem_encrypt.h | 1 - arch/s390/mm/init.c | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-)
arch/s390/include/asm/mem_encrypt.h +0 -1
@@ -5,7 +5,6 @@#ifndef __ASSEMBLY__static inline bool mem_encrypt_active (void ) {return false; } -extern bool sev_active (void );int set_memory_encrypted (unsigned long addr,int numpages);int set_memory_decrypted (unsigned long addr,int numpages);
arch/s390/mm/init.c +1 -7
@@ -155,15 +155,9 @@ int set_memory_decrypted(unsigned long addr, int numpages)return 0 ; } -/* are we a protected virtualization guest? */ -bool sev_active (void ) -{ -return is_prot_virt_guest (); -} -bool force_dma_unencrypted (struct device *dev) { -return sev_active (); +return is_prot_virt_guest (); }/* protected virtualization */
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 6/6] s390/mm: Remove sev_active() function
arch/s390/mm/init.c int set_memory_decrypted(unsigned long addr, int numpages) · line 161
Quoted 11 lines
arch/s390/mm/init.c +1
-7-/* are we a protected virtualization guest? */ -bool sev_active (void ) -{ -return is_prot_virt_guest (); -} -bool force_dma_unencrypted (struct device *dev) { -return sev_active (); +return is_prot_virt_guest (); }
Do we want to keep the comment for force_dma_unencrypted?
Otherwise looks good:
Halil Pasic
Reviewed-byRe: [PATCH v3 6/6] s390/mm: Remove sev_active() function
Quoted 5 lines · On Thu, 18 Jul 2019 10:44:56 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 5 lines
arch/s390/mm/init.c +0
-5-/* are we a protected virtualization guest? */ -bool sev_active (void ) -{ -return is_prot_virt_guest (); -}
Quoted 8 lines
arch/s390/mm/init.c int set_memory_decrypted(unsigned long addr, int numpages) · line 161
Quoted 6 lines
arch/s390/mm/init.c +1
-2-bool force_dma_unencrypted (struct device *dev) { -return sev_active (); +return is_prot_virt_guest (); }Do we want to keep the comment for
force_dma_unencrypted?
Yes we do. With the comment transferred:
Quoted 4 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Re: [PATCH v3 6/6] s390/mm: Remove sev_active() function
Quoted 17 lines · Halil Pasic
Quoted 5 lines · On Thu, 18 Jul 2019 10:44:56 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 5 lines
(quoted diff) +0
-5-/* are we a protected virtualization guest? */ -bool sev_active(void) -{ - return is_prot_virt_guest(); -}Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +1
-2- bool force_dma_unencrypted(struct device *dev) { - return sev_active(); + return is_prot_virt_guest(); }Do we want to keep the comment for
force_dma_unencrypted?
Quoted 3 lines
Yes we do. With the comment transferred:
Reviewed-by Halil Pasic <[email protected]>
Thanks for your review.
Here is the new version. Should I send a new patch series with this patch and the Reviewed-by on the other ones?
Signature · 19 lines
Thiago Jung Bauermann IBM Linux Technology Center From 1726205c73fb9e29feaa3d8909c5a1b0f2054c04 Mon Sep 17 00:00:00 2001 From: Thiago Jung Bauermann <[email protected]> Date: Mon, 15 Jul 2019 20:50:43 -0300 Subject: [PATCH v4] s390/mm: Remove sev_active() function All references to sev_active() were moved to arch/x86 so we don't need to define it for s390 anymore. Signed-off-by: Thiago Jung Bauermann <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Halil Pasic <[email protected]> --- arch/s390/include/asm/mem_encrypt.h | 1 - arch/s390/mm/init.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-)
arch/s390/include/asm/mem_encrypt.h +0 -1
@@ -5,7 +5,6 @@#ifndef __ASSEMBLY__static inline bool mem_encrypt_active (void ) {return false; } -extern bool sev_active (void );int set_memory_encrypted (unsigned long addr,int numpages);int set_memory_decrypted (unsigned long addr,int numpages);
arch/s390/mm/init.c +1 -6
@@ -156,14 +156,9 @@ int set_memory_decrypted(unsigned long addr, int numpages) }/* are we a protected virtualization guest? */ -bool sev_active (void ) -{ -return is_prot_virt_guest (); -} -bool force_dma_unencrypted (struct device *dev) { -return sev_active (); +return is_prot_virt_guest (); }/* protected virtualization */
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 6/6] s390/mm: Remove sev_active() function
In reply to Christoph HellwigQuoted 14 lines · Christoph Hellwig
arch/s390/mm/init.c int set_memory_decrypted(unsigned long addr, int numpages) · line 161
Quoted 11 lines
arch/s390/mm/init.c +1
-7-/* are we a protected virtualization guest? */ -bool sev_active (void ) -{ -return is_prot_virt_guest (); -} -bool force_dma_unencrypted (struct device *dev) { -return sev_active (); +return is_prot_virt_guest (); }Do we want to keep the comment for
force_dma_unencrypted?
Quoted 3 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Thank you for your review on al these patches.
Signature · 2 lines
Thiago Jung Bauermann IBM Linux Technology Center
Quoted 8 lines · Thiago Jung Bauermann
Hello,
This version is mostly about splitting up patch 2/3 into three separate patches, as suggested by Christoph Hellwig. Two other changes are a fix in patch 1 which wasn't selecting
ARCH_HAS_MEM_ENCRYPTfor s390 spotted by Janani and removal ofsme_activeandsev_activesymbol exports as suggested by Christoph Hellwig.
Quoted 4 lines
These patches are applied on top of today's dma-mapping/for-next.
I don't have a way to test SME, SEV, nor s390's PEF so the patches have only been build tested.
I'll try and get this tested quickly to be sure everything works for SME and SEV.
Thanks,
Tom
Quoted 61 lines
Changelog
Since v2:
- Patch "x86,s390: Move
ARCH_HAS_MEM_ENCRYPTdefinition toarch/Kconfig"
- Added "selectARCH_HAS_MEM_ENCRYPT" to config S390. Suggested by Janani.- Patch "DMA mapping: Move SME handling to x86-specific files"
- Split up into 3 new patches. Suggested by Christoph Hellwig.- Patch "swiotlb: Remove call to
sme_active()"
- New patch.- Patch "dma-mapping: Remove
dma_check_mask()"
- New patch.- Patch "x86,s390/mm: Move
sme_active()andsme_me_maskto x86-specific header"
- New patch.
- Removed export ofsme_activesymbol. Suggested by Christoph Hellwig.- Patch "
fs/core/vmcore: Movesev_active()reference to x86 arch code"
- Removed export ofsev_activesymbol. Suggested by Christoph Hellwig.- Patch "s390/mm: Remove
sev_active()function"
- New patch.Since v1:
- Patch "x86,s390: Move
ARCH_HAS_MEM_ENCRYPTdefinition toarch/Kconfig"
- Remove definition ofARCH_HAS_MEM_ENCRYPTfrom s390/Kconfig as well.
- Reworded patch title and message a little bit.- Patch "DMA mapping: Move SME handling to x86-specific files"
- Adapt s390's <asm/mem_encrypt.h> as well.
- Removedma_check_mask()fromkernel/dma/mapping.c. Suggested by Christoph Hellwig.Thiago Jung Bauermann (6):
x86,s390: MoveARCH_HAS_MEM_ENCRYPTdefinition toarch/Kconfig
swiotlb: Remove call tosme_active()
dma-mapping: Removedma_check_mask()
x86,s390/mm: Movesme_active()andsme_me_maskto x86-specific headerfs/core/vmcore: Movesev_active()reference to x86 arch code s390/mm: Removesev_active()functionarch/Kconfig | 3 +++ arch/s390/Kconfig | 4 +--- arch/s390/include/asm/mem_encrypt.h | 5 +---- arch/s390/mm/init.c | 8 +------- arch/x86/Kconfig | 4 +--- arch/x86/include/asm/mem_encrypt.h | 10 ++++++++++ arch/x86/kernel/crash_dump_64.c | 5 +++++ arch/x86/mm/mem_encrypt.c | 2 -- fs/proc/vmcore.c | 8 ++++---- include/linux/crash_dump.h | 14 ++++++++++++++ include/linux/mem_encrypt.h | 15 +-------------- kernel/dma/mapping.c | 8 -------- kernel/dma/swiotlb.c | 3 +-- 13 files changed, 42 insertions(+), 47 deletions(-)
Quoted 9 lines · Thomas
Quoted 8 lines · Thiago Jung Bauermann
Hello,
This version is mostly about splitting up patch 2/3 into three separate patches, as suggested by Christoph Hellwig. Two other changes are a fix in patch 1 which wasn't selecting
ARCH_HAS_MEM_ENCRYPTfor s390 spotted by Janani and removal ofsme_activeandsev_activesymbol exports as suggested by Christoph Hellwig.
Quoted 7 lines
Quoted 4 lines
These patches are applied on top of today's dma-mapping/for-next.
I don't have a way to test SME, SEV, nor s390's PEF so the patches have only been build tested.
I'll try and get this tested quickly to be sure everything works for SME and SEV.
Thanks! And thanks for reviewing the patches.
Signature · 2 lines
Thiago Jung Bauermann IBM Linux Technology Center
Quoted 12 lines · Thiago Jung Bauermann
Quoted 9 lines · Thomas
Quoted 8 lines · Thiago Jung Bauermann
Hello,
This version is mostly about splitting up patch 2/3 into three separate patches, as suggested by Christoph Hellwig. Two other changes are a fix in patch 1 which wasn't selecting
ARCH_HAS_MEM_ENCRYPTfor s390 spotted by Janani and removal ofsme_activeandsev_activesymbol exports as suggested by Christoph Hellwig.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
These patches are applied on top of today's dma-mapping/for-next.
I don't have a way to test SME, SEV, nor s390's PEF so the patches have only been build tested.
I'll try and get this tested quickly to be sure everything works for SME and SEV.
Built and tested both SME and SEV and everything appears to be working well (not extensive testing, but should be good enough).
Thanks,
Tom
Quoted 3 lines
Thanks! And thanks for reviewing the patches.
Quoted 15 lines · Thomas
Quoted 14 lines · Thiago Jung Bauermann
Quoted 11 lines · Thomas
Quoted 10 lines · Thiago Jung Bauermann
Hello,
This version is mostly about splitting up patch 2/3 into three separate patches, as suggested by Christoph Hellwig. Two other changes are a fix in patch 1 which wasn't selecting
ARCH_HAS_MEM_ENCRYPTfor s390 spotted by Janani and removal ofsme_activeandsev_activesymbol exports as suggested by Christoph Hellwig.These patches are applied on top of today's dma-mapping/for-next.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I don't have a way to test SME, SEV, nor s390's PEF so the patches have only been build tested.
I'll try and get this tested quickly to be sure everything works for SME and SEV.
Built and tested both SME and SEV and everything appears to be working well (not extensive testing, but should be good enough).
Great news. Thanks for testing!
Signature · 2 lines
Thiago Jung Bauermann IBM Linux Technology Center