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(-)
powerpc is also going to use this feature, so put it in a generic location.
Signed-off-by: Thiago Jung Bauermann <redacted>
Reviewed-by: Thomas Gleixner <redacted>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
arch/Kconfig | 3 +++
arch/s390/Kconfig | 4 +---
arch/x86/Kconfig | 4 +---
3 files changed, 5 insertions(+), 6 deletions(-)
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 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.
Signed-off-by: Thiago Jung Bauermann <redacted>
---
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(-)
@@ -100,9 +100,9 @@ static int pfn_is_ram(unsigned long pfn)}/* Reads a page from the oldmem device from given offset. */-staticssize_tread_from_oldmem(char*buf,size_tcount,-u64*ppos,intuserbuf,-boolencrypted)+ssize_tread_from_oldmem(char*buf,size_tcount,+u64*ppos,intuserbuf,+boolencrypted){unsignedlongpfn,offset;size_tnr_bytes;
@@ -166,7 +166,7 @@ void __weak elfcorehdr_free(unsigned long long addr)*/ssize_t__weakelfcorehdr_read(char*buf,size_tcount,u64*ppos){-returnread_from_oldmem(buf,count,ppos,0,sev_active());+returnread_from_oldmem(buf,count,ppos,0,false);}/*
Now 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.
Signed-off-by: Thiago Jung Bauermann <redacted>
---
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(-)
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 remove dma_check_mask().
Signed-off-by: Thiago Jung Bauermann <redacted>
---
kernel/dma/mapping.c | 8 --------
1 file changed, 8 deletions(-)
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 <redacted>
---
kernel/dma/swiotlb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -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);
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 <redacted>
---
arch/s390/include/asm/mem_encrypt.h | 1 -
arch/s390/mm/init.c | 8 +-------
2 files changed, 1 insertion(+), 8 deletions(-)
@@ -155,15 +155,9 @@ int set_memory_decrypted(unsigned long addr, int numpages)return0;}-/* are we a protected virtualization guest? */-boolsev_active(void)-{-returnis_prot_virt_guest();-}-boolforce_dma_unencrypted(structdevice*dev){-returnsev_active();+returnis_prot_virt_guest();}/* protected virtualization */
From: Christoph Hellwig <hch@lst.de> Date: 2019-07-18 08:42:22
On Thu, Jul 18, 2019 at 12:28:54AM -0300, Thiago Jung Bauermann wrote:
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 <redacted>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
From: Christoph Hellwig <hch@lst.de> Date: 2019-07-18 08:42:36
On Thu, Jul 18, 2019 at 12:28:55AM -0300, Thiago Jung Bauermann wrote:
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 remove dma_check_mask().
Signed-off-by: Thiago Jung Bauermann <redacted>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
From: Christoph Hellwig <hch@lst.de> Date: 2019-07-18 08:43:04
On Thu, Jul 18, 2019 at 12:28:56AM -0300, Thiago Jung Bauermann wrote:
Now 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.
Signed-off-by: Thiago Jung Bauermann <redacted>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
From: Christoph Hellwig <hch@lst.de> Date: 2019-07-18 08:44:22
On Thu, Jul 18, 2019 at 12:28:57AM -0300, Thiago Jung Bauermann wrote:
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 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.
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.
Reviewed-by: Christoph Hellwig <hch@lst.de>
On Thu, 18 Jul 2019 10:44:56 +0200
Christoph Hellwig [off-list ref] wrote:
quoted
quoted
-/* 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?
Yes we do. With the comment transferred:
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
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?
--
Thiago Jung Bauermann
IBM Linux Technology Center
From 1726205c73fb9e29feaa3d8909c5a1b0f2054c04 Mon Sep 17 00:00:00 2001
From: Thiago Jung Bauermann <redacted>
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 <redacted>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
---
arch/s390/include/asm/mem_encrypt.h | 1 -
arch/s390/mm/init.c | 7 +------
2 files changed, 1 insertion(+), 7 deletions(-)
@@ -156,14 +156,9 @@ int set_memory_decrypted(unsigned long addr, int numpages)}/* are we a protected virtualization guest? */-boolsev_active(void)-{-returnis_prot_virt_guest();-}-boolforce_dma_unencrypted(structdevice*dev){-returnsev_active();+returnis_prot_virt_guest();}/* protected virtualization */
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 <redacted>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
@@ -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);
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 remove dma_check_mask().
Signed-off-by: Thiago Jung Bauermann <redacted>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Now 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.
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.
Signed-off-by: Thiago Jung Bauermann <redacted>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
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 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.
Signed-off-by: Thiago Jung Bauermann <redacted>
Adding Lianbo and Baoquan, who recently worked on this, for their review.
Thanks,
Tom
@@ -100,9 +100,9 @@ static int pfn_is_ram(unsigned long pfn)}/* Reads a page from the oldmem device from given offset. */-staticssize_tread_from_oldmem(char*buf,size_tcount,-u64*ppos,intuserbuf,-boolencrypted)+ssize_tread_from_oldmem(char*buf,size_tcount,+u64*ppos,intuserbuf,+boolencrypted){unsignedlongpfn,offset;size_tnr_bytes;
@@ -166,7 +166,7 @@ void __weak elfcorehdr_free(unsigned long long addr)*/ssize_t__weakelfcorehdr_read(char*buf,size_tcount,u64*ppos){-returnread_from_oldmem(buf,count,ppos,0,sev_active());+returnread_from_oldmem(buf,count,ppos,0,false);}/*
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.
I'll try and get this tested quickly to be sure everything works for SME
and SEV.
Thanks,
Tom
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(-)
From: Christoph Hellwig <hch@lst.de> Date: 2019-07-18 17:57:03
On Thu, Jul 18, 2019 at 05:42:18PM +0000, Lendacky, Thomas wrote:
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.
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.
I'll try and get this tested quickly to be sure everything works for SME
and SEV.
Thanks! And thanks for reviewing the patches.
--
Thiago Jung Bauermann
IBM Linux Technology Center
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 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.
Signed-off-by: Thiago Jung Bauermann <redacted>
Adding Lianbo and Baoquan, who recently worked on this, for their review.
This change looks good to me.
Reviewed-by: Lianbo Jiang <redacted>
Thanks.
Lianbo
@@ -100,9 +100,9 @@ static int pfn_is_ram(unsigned long pfn)}/* Reads a page from the oldmem device from given offset. */-staticssize_tread_from_oldmem(char*buf,size_tcount,-u64*ppos,intuserbuf,-boolencrypted)+ssize_tread_from_oldmem(char*buf,size_tcount,+u64*ppos,intuserbuf,+boolencrypted){unsignedlongpfn,offset;size_tnr_bytes;
@@ -166,7 +166,7 @@ void __weak elfcorehdr_free(unsigned long long addr)*/ssize_t__weakelfcorehdr_read(char*buf,size_tcount,u64*ppos){-returnread_from_oldmem(buf,count,ppos,0,sev_active());+returnread_from_oldmem(buf,count,ppos,0,false);}/*
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.
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
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.
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!
--
Thiago Jung Bauermann
IBM Linux Technology Center
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 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.
Signed-off-by: Thiago Jung Bauermann <redacted>
Adding Lianbo and Baoquan, who recently worked on this, for their review.
This change looks good to me.
Reviewed-by: Lianbo Jiang <redacted>
Thanks for your review!
--
Thiago Jung Bauermann
IBM Linux Technology Center