* Re: [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests
2026-11-30 12:00 [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests Nikolay Borisov
@ 2026-11-30 14:03 ` Naveen N Rao
2026-12-02 13:57 ` Arnd Bergmann
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Naveen N Rao @ 2026-11-30 14:03 UTC (permalink / raw)
To: Nikolay Borisov
Cc: x86, Dan Williams, Kees Cook, Ingo Molnar, Vishal Annapurve,
Arnd Bergmann, Greg Kroah-Hartman, Michael Ellerman,
Suzuki K Poulose, stable
On Mon, Nov 30, 2026 at 02:00:02PM +0200, Nikolay Borisov wrote:
> From: Dan Williams <dan.j.williams@intel.com>
>
> Nikolay reports that accessing BIOS data (first 1MB of the physical
> address space) via /dev/mem results in a "crash" / terminated VM
> (unhandled SEPT violation). See report [1] for details.
>
> The cause is ioremap() (via xlate_dev_mem_ptr()) establishes an
> unencrypted mapping where the kernel had established an encrypted
> mapping previously. The CPU enforces mapping consistency with a fault
> upon detecting a mismatch. A similar situation arises with devmem access
> to "unaccepted" confidential memory. In summary, it is fraught to allow
> uncoordinated userspace mapping of confidential memory.
>
> While there is an existing mitigation to simulate and redirect access to
> the BIOS data area with STRICT_DEVMEM=y, it is insufficient.
> Specifically, STRICT_DEVMEM=y traps read(2) access to the BIOS data
> area, and returns a zeroed buffer. However, it turns out the kernel
> fails to enforce the same via mmap(2), and a direct mapping is
> established. This is a hole, and unfortunately userspace has learned to
> exploit it [2].
>
> This means the kernel either needs: a mechanism to ensure consistent
> plus accepted "encrypted" mappings of this /dev/mem mmap() hole, close
> the hole by mapping the zero page in the mmap(2) path, block only BIOS
> data access and let typical STRICT_DEVMEM protect the rest, or disable
> /dev/mem altogether.
>
> The simplest option for now is to revoke memory access via /dev/mem for confidential guests.
> Require confidential guest userspace to jettison legacy dependencies on
> /dev/mem similar to how other legacy mechanisms are jettisoned for
> confidential operation. Recall that modern methods for BIOS data
> access are available like /sys/firmware/dmi/tables.
>
> Now, this begs the question what to do with PCI sysfs which allows
> userspace mappings of confidential MMIO with similar mapping consistency
> and acceptance expectations? Here, the existing mitigation of
> IO_STRICT_DEVMEM is likely sufficient. The kernel is expected to use
> request_mem_region() when toggling the state of MMIO. With
> IO_STRICT_DEVMEM that enforces kernel-exclusive access until
> release_mem_region(), i.e. mapping conflicts are prevented. However,
> this is left out for relevant series when secure MMIO support starts
> landing.
>
> Cc: x86@kernel.org
> Cc: Kees Cook <kees@kernel.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Vishal Annapurve <vannapurve@google.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Link: https://sources.debian.org/src/libdebian-installer/0.125/src/system/subarch-x86-linux.c/?hl=113#L93 [2]
> Reported-by: Nikolay Borisov <nik.borisov@suse.com>
> Closes: http://lore.kernel.org/20250318113604.297726-1-nik.borisov@suse.com [1]
> Fixes: 9aa6ea69852c ("x86/tdx: Make pages shared in ioremap()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
> ---
Also:
Fixes: 81256a50aa0f ("x86/mm: Make memremap(MEMREMAP_WB) map memory as encrypted by default")
... since SEV-SNP guests now terminate on read() of a non-RAM page in
the first 1 MB area (e.g., video ROM at 0xc0000).
Other than that, I have tested this patch and it prevents #VC due to
mmap()/read() issued on /dev/mem fd.
Acked-by: Naveen N Rao (AMD) <naveen@kernel.org>
Tested-by: Naveen N Rao (AMD) <naveen@kernel.org>
Thanks,
Naveen
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests
2026-11-30 12:00 [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests Nikolay Borisov
2026-11-30 14:03 ` Naveen N Rao
@ 2026-12-02 13:57 ` Arnd Bergmann
2026-12-02 13:59 ` Ard Biesheuvel
2026-12-03 23:08 ` Edgecombe, Rick P
3 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2026-12-02 13:57 UTC (permalink / raw)
To: Nikolay Borisov, x86
Cc: Naveen N Rao, Dan Williams, Kees Cook, Ingo Molnar,
Vishal Annapurve, Greg Kroah-Hartman, Michael Ellerman,
Suzuki K Poulose, stable
On Mon, Nov 30, 2026, at 13:00, Nikolay Borisov wrote:
> Cc: x86@kernel.org
> Cc: Kees Cook <kees@kernel.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Vishal Annapurve <vannapurve@google.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Link:
> https://sources.debian.org/src/libdebian-installer/0.125/src/system/subarch-x86-linux.c/?hl=113#L93
> [2]
> Reported-by: Nikolay Borisov <nik.borisov@suse.com>
> Closes:
> http://lore.kernel.org/20250318113604.297726-1-nik.borisov@suse.com [1]
> Fixes: 9aa6ea69852c ("x86/tdx: Make pages shared in ioremap()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests
2026-11-30 12:00 [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests Nikolay Borisov
2026-11-30 14:03 ` Naveen N Rao
2026-12-02 13:57 ` Arnd Bergmann
@ 2026-12-02 13:59 ` Ard Biesheuvel
2026-12-03 23:08 ` Edgecombe, Rick P
3 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2026-12-02 13:59 UTC (permalink / raw)
To: Nikolay Borisov, x86
Cc: naveen, Dan Williams, Kees Cook, Ingo Molnar, Vishal Annapurve,
Arnd Bergmann, Greg Kroah-Hartman, Michael Ellerman,
Suzuki K Poulose, stable
On Mon, 30 Nov 2026, at 13:00, Nikolay Borisov wrote:
> From: Dan Williams <dan.j.williams@intel.com>
>
> Nikolay reports that accessing BIOS data (first 1MB of the physical
> address space) via /dev/mem results in a "crash" / terminated VM
> (unhandled SEPT violation). See report [1] for details.
>
> The cause is ioremap() (via xlate_dev_mem_ptr()) establishes an
> unencrypted mapping where the kernel had established an encrypted
> mapping previously. The CPU enforces mapping consistency with a fault
> upon detecting a mismatch. A similar situation arises with devmem access
> to "unaccepted" confidential memory. In summary, it is fraught to allow
> uncoordinated userspace mapping of confidential memory.
>
> While there is an existing mitigation to simulate and redirect access to
> the BIOS data area with STRICT_DEVMEM=y, it is insufficient.
> Specifically, STRICT_DEVMEM=y traps read(2) access to the BIOS data
> area, and returns a zeroed buffer. However, it turns out the kernel
> fails to enforce the same via mmap(2), and a direct mapping is
> established. This is a hole, and unfortunately userspace has learned to
> exploit it [2].
>
> This means the kernel either needs: a mechanism to ensure consistent
> plus accepted "encrypted" mappings of this /dev/mem mmap() hole, close
> the hole by mapping the zero page in the mmap(2) path, block only BIOS
> data access and let typical STRICT_DEVMEM protect the rest, or disable
> /dev/mem altogether.
>
> The simplest option for now is to revoke memory access via /dev/mem for
> confidential guests.
> Require confidential guest userspace to jettison legacy dependencies on
> /dev/mem similar to how other legacy mechanisms are jettisoned for
> confidential operation. Recall that modern methods for BIOS data
> access are available like /sys/firmware/dmi/tables.
>
> Now, this begs the question what to do with PCI sysfs which allows
> userspace mappings of confidential MMIO with similar mapping consistency
> and acceptance expectations? Here, the existing mitigation of
> IO_STRICT_DEVMEM is likely sufficient. The kernel is expected to use
> request_mem_region() when toggling the state of MMIO. With
> IO_STRICT_DEVMEM that enforces kernel-exclusive access until
> release_mem_region(), i.e. mapping conflicts are prevented. However,
> this is left out for relevant series when secure MMIO support starts
> landing.
>
> Cc: x86@kernel.org
> Cc: Kees Cook <kees@kernel.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Vishal Annapurve <vannapurve@google.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Link:
> https://sources.debian.org/src/libdebian-installer/0.125/src/system/subarch-x86-linux.c/?hl=113#L93
> [2]
> Reported-by: Nikolay Borisov <nik.borisov@suse.com>
> Closes:
> http://lore.kernel.org/20250318113604.297726-1-nik.borisov@suse.com [1]
> Fixes: 9aa6ea69852c ("x86/tdx: Make pages shared in ioremap()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
> ---
>
> Changes in V3:
> * Only select STRICT_DEVMEM if DEVMEM is also selected (Sashiko,
> Naveen)
> * Remove superfluous check for CONFIG_STRICT_DEVMEM, devmem_is_allowed
> is only
> called when it's enabled
> * Slightly modify the last 2 paragraphs of the changelog to reflect
> that this no
> longer follows the LOCKDOWN model and simply revokes memory access. And
> explicilty call out the omission of IO_STRICT_DEVMEM
> * Removed tags as the patch is sufficiently different now.
>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests
2026-11-30 12:00 [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests Nikolay Borisov
` (2 preceding siblings ...)
2026-12-02 13:59 ` Ard Biesheuvel
@ 2026-12-03 23:08 ` Edgecombe, Rick P
2026-12-04 7:19 ` Nikolay Borisov
3 siblings, 1 reply; 6+ messages in thread
From: Edgecombe, Rick P @ 2026-12-03 23:08 UTC (permalink / raw)
To: nik.borisov@suse.com, x86@kernel.org
Cc: kees@kernel.org, mingo@kernel.org, gregkh@linuxfoundation.org,
Annapurve, Vishal, suzuki.poulose@arm.com, naveen@kernel.org,
dan.j.williams@intel.com, arnd@arndb.de, mpe@ellerman.id.au,
stable@vger.kernel.org
On Mon, 2026-11-30 at 14:00 +0200, Nikolay Borisov wrote:
> From: Dan Williams <dan.j.williams@intel.com>
>
> Nikolay reports that accessing BIOS data (first 1MB of the physical
> address space) via /dev/mem results in a "crash" / terminated VM
> (unhandled SEPT violation). See report [1] for details.
>
> The cause is ioremap() (via xlate_dev_mem_ptr()) establishes an
> unencrypted mapping where the kernel had established an encrypted
> mapping previously. The CPU enforces mapping consistency with a fault
> upon detecting a mismatch. A similar situation arises with devmem access
> to "unaccepted" confidential memory. In summary, it is fraught to allow
> uncoordinated userspace mapping of confidential memory.
>
> While there is an existing mitigation to simulate and redirect access to
> the BIOS data area with STRICT_DEVMEM=y, it is insufficient.
> Specifically, STRICT_DEVMEM=y traps read(2) access to the BIOS data
> area, and returns a zeroed buffer. However, it turns out the kernel
> fails to enforce the same via mmap(2), and a direct mapping is
> established. This is a hole, and unfortunately userspace has learned to
> exploit it [2].
>
> This means the kernel either needs: a mechanism to ensure consistent
> plus accepted "encrypted" mappings of this /dev/mem mmap() hole, close
> the hole by mapping the zero page in the mmap(2) path, block only BIOS
> data access and let typical STRICT_DEVMEM protect the rest, or disable
> /dev/mem altogether.
>
> The simplest option for now is to revoke memory access via /dev/mem for confidential guests.
Long line^
> Require confidential guest userspace to jettison legacy dependencies on
> /dev/mem similar to how other legacy mechanisms are jettisoned for
> confidential operation. Recall that modern methods for BIOS data
> access are available like /sys/firmware/dmi/tables.
At a high level the history of /dev/mem, is that various issues were found. To
prevent breaking userspace they were fixed behind optional Kconfig options,
which became kind of the default config over time. Right? Now another issue was
found with the BIOS range and mmap(). The proposal here is to remove the
/dev/mem altogether for coco VMs, in a potentially backward incompatible way
(offline Nikolay suggested this is not likely. I can see it). But this makes
coco special mandated behavior, removes possibly working cases, and doesn't fix
the issue for non-coco VMs.
Why not fix the mmap issue in the same way as the other /dev/mem lockdowns?
>
> Now, this begs the question what to do with PCI sysfs which allows
> userspace mappings of confidential MMIO with similar mapping consistency
> and acceptance expectations? Here, the existing mitigation of
> IO_STRICT_DEVMEM is likely sufficient. The kernel is expected to use
> request_mem_region() when toggling the state of MMIO. With
> IO_STRICT_DEVMEM that enforces kernel-exclusive access until
> release_mem_region(), i.e. mapping conflicts are prevented. However,
> this is left out for relevant series when secure MMIO support starts
> landing.
Hmm. Might be racy though?
>
> Cc: x86@kernel.org
> Cc: Kees Cook <kees@kernel.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Vishal Annapurve <vannapurve@google.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Link: https://sources.debian.org/src/libdebian-installer/0.125/src/system/subarch-x86-linux.c/?hl=113#L93 [2]
> Reported-by: Nikolay Borisov <nik.borisov@suse.com>
> Closes: http://lore.kernel.org/20250318113604.297726-1-nik.borisov@suse.com [1]
> Fixes: 9aa6ea69852c ("x86/tdx: Make pages shared in ioremap()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
> ---
>
> Changes in V3:
> * Only select STRICT_DEVMEM if DEVMEM is also selected (Sashiko, Naveen)
> * Remove superfluous check for CONFIG_STRICT_DEVMEM, devmem_is_allowed is only
> called when it's enabled
> * Slightly modify the last 2 paragraphs of the changelog to reflect that this no
> longer follows the LOCKDOWN model and simply revokes memory access. And
> explicilty call out the omission of IO_STRICT_DEVMEM
> * Removed tags as the patch is sufficiently different now.
>
> arch/x86/Kconfig | 2 ++
> arch/x86/mm/init.c | 9 +++++++++
> 2 files changed, 11 insertions(+)
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 3159852fd6b3..52daab4758cf 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -901,6 +901,7 @@ config INTEL_TDX_GUEST
> depends on X86_X2APIC
> depends on EFI_STUB
> depends on PARAVIRT
> + select STRICT_DEVMEM if DEVMEM
I think there are various recommendations to do this already for TDX guests.
There are quite a bit of lockdowns suggested for TDX guests that we don't
enforce in the kernel source. So why treat this one special?
> select ARCH_HAS_CC_PLATFORM
> select X86_MEM_ENCRYPT
> select X86_MCE
> @@ -1490,6 +1491,7 @@ config AMD_MEM_ENCRYPT
> bool "AMD Secure Memory Encryption (SME) support"
> depends on X86_64 && CPU_SUP_AMD
> depends on EFI_STUB
> + select STRICT_DEVMEM if DEVMEM
> select DMA_COHERENT_POOL
> select ARCH_USE_MEMREMAP_PROT
> select INSTRUCTION_DECODER
> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> index 079f8c7e9e3c..b4ff015cd770 100644
> --- a/arch/x86/mm/init.c
> +++ b/arch/x86/mm/init.c
> @@ -8,6 +8,7 @@
> #include <linux/kmemleak.h>
> #include <linux/sched/task.h>
> #include <linux/execmem.h>
> +#include <linux/cc_platform.h>
>
> #include <asm/set_memory.h>
> #include <asm/cpu_device_id.h>
> @@ -866,6 +867,14 @@ void __init poking_init(void)
> */
> int devmem_is_allowed(unsigned long pagenr)
> {
> + /*
> + * Enforce encrypted mapping consistency and avoid unaccepted
> + * memory conflicts, "lockdown" /dev/mem for confidential
> + * guests.
> + */
> + if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
> + return 0;
This includes SEV and SEV-ES which I'd think would not have the problem? Or at
least the same symptoms.
> +
> if (region_intersects(PFN_PHYS(pagenr), PAGE_SIZE,
> IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
> != REGION_DISJOINT) {
> --
> 2.56.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests
2026-12-03 23:08 ` Edgecombe, Rick P
@ 2026-12-04 7:19 ` Nikolay Borisov
0 siblings, 0 replies; 6+ messages in thread
From: Nikolay Borisov @ 2026-12-04 7:19 UTC (permalink / raw)
To: Edgecombe, Rick P, x86@kernel.org
Cc: kees@kernel.org, mingo@kernel.org, gregkh@linuxfoundation.org,
Annapurve, Vishal, suzuki.poulose@arm.com, naveen@kernel.org,
arnd@arndb.de, mpe@ellerman.id.au, stable@vger.kernel.org
On 4.12.26 г. 1:08 ч., Edgecombe, Rick P wrote:
> On Mon, 2026-11-30 at 14:00 +0200, Nikolay Borisov wrote:
>> From: Dan Williams <dan.j.williams@intel.com>
>>
>> Nikolay reports that accessing BIOS data (first 1MB of the physical
>> address space) via /dev/mem results in a "crash" / terminated VM
>> (unhandled SEPT violation). See report [1] for details.
>>
>> The cause is ioremap() (via xlate_dev_mem_ptr()) establishes an
>> unencrypted mapping where the kernel had established an encrypted
>> mapping previously. The CPU enforces mapping consistency with a fault
>> upon detecting a mismatch. A similar situation arises with devmem access
>> to "unaccepted" confidential memory. In summary, it is fraught to allow
>> uncoordinated userspace mapping of confidential memory.
>>
>> While there is an existing mitigation to simulate and redirect access to
>> the BIOS data area with STRICT_DEVMEM=y, it is insufficient.
>> Specifically, STRICT_DEVMEM=y traps read(2) access to the BIOS data
>> area, and returns a zeroed buffer. However, it turns out the kernel
>> fails to enforce the same via mmap(2), and a direct mapping is
>> established. This is a hole, and unfortunately userspace has learned to
>> exploit it [2].
>>
>> This means the kernel either needs: a mechanism to ensure consistent
>> plus accepted "encrypted" mappings of this /dev/mem mmap() hole, close
>> the hole by mapping the zero page in the mmap(2) path, block only BIOS
>> data access and let typical STRICT_DEVMEM protect the rest, or disable
>> /dev/mem altogether.
>>
>> The simplest option for now is to revoke memory access via /dev/mem for confidential guests.
>
> Long line^
>
>> Require confidential guest userspace to jettison legacy dependencies on
>> /dev/mem similar to how other legacy mechanisms are jettisoned for
>> confidential operation. Recall that modern methods for BIOS data
>> access are available like /sys/firmware/dmi/tables.
>
> At a high level the history of /dev/mem, is that various issues were found. To
> prevent breaking userspace they were fixed behind optional Kconfig options,
> which became kind of the default config over time. Right? Now another issue was
> found with the BIOS range and mmap(). The proposal here is to remove the
> /dev/mem altogether for coco VMs, in a potentially backward incompatible way
> (offline Nikolay suggested this is not likely. I can see it). But this makes
> coco special mandated behavior, removes possibly working cases, and doesn't fix
> the issue for non-coco VMs.
>
> Why not fix the mmap issue in the same way as the other /dev/mem lockdowns?
I'd like to refrain from adding more and more knobs.
>
>>
>> Now, this begs the question what to do with PCI sysfs which allows
>> userspace mappings of confidential MMIO with similar mapping consistency
>> and acceptance expectations? Here, the existing mitigation of
>> IO_STRICT_DEVMEM is likely sufficient. The kernel is expected to use
>> request_mem_region() when toggling the state of MMIO. With
>> IO_STRICT_DEVMEM that enforces kernel-exclusive access until
>> release_mem_region(), i.e. mapping conflicts are prevented. However,
>> this is left out for relevant series when secure MMIO support starts
>> landing.
>
> Hmm. Might be racy though?
Why would it be racy?
>
>>
>> Cc: x86@kernel.org
>> Cc: Kees Cook <kees@kernel.org>
>> Cc: Ingo Molnar <mingo@kernel.org>
>> Cc: Vishal Annapurve <vannapurve@google.com>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Link: https://sources.debian.org/src/libdebian-installer/0.125/src/system/subarch-x86-linux.c/?hl=113#L93 [2]
>> Reported-by: Nikolay Borisov <nik.borisov@suse.com>
>> Closes: http://lore.kernel.org/20250318113604.297726-1-nik.borisov@suse.com [1]
>> Fixes: 9aa6ea69852c ("x86/tdx: Make pages shared in ioremap()")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
>> ---
>>
>> Changes in V3:
>> * Only select STRICT_DEVMEM if DEVMEM is also selected (Sashiko, Naveen)
>> * Remove superfluous check for CONFIG_STRICT_DEVMEM, devmem_is_allowed is only
>> called when it's enabled
>> * Slightly modify the last 2 paragraphs of the changelog to reflect that this no
>> longer follows the LOCKDOWN model and simply revokes memory access. And
>> explicilty call out the omission of IO_STRICT_DEVMEM
>> * Removed tags as the patch is sufficiently different now.
>>
>> arch/x86/Kconfig | 2 ++
>> arch/x86/mm/init.c | 9 +++++++++
>> 2 files changed, 11 insertions(+)
>>
>> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
>> index 3159852fd6b3..52daab4758cf 100644
>> --- a/arch/x86/Kconfig
>> +++ b/arch/x86/Kconfig
>> @@ -901,6 +901,7 @@ config INTEL_TDX_GUEST
>> depends on X86_X2APIC
>> depends on EFI_STUB
>> depends on PARAVIRT
>> + select STRICT_DEVMEM if DEVMEM
>
> I think there are various recommendations to do this already for TDX guests.
> There are quite a bit of lockdowns suggested for TDX guests that we don't
> enforce in the kernel source. So why treat this one special?
>
>> select ARCH_HAS_CC_PLATFORM
>> select X86_MEM_ENCRYPT
>> select X86_MCE
>> @@ -1490,6 +1491,7 @@ config AMD_MEM_ENCRYPT
>> bool "AMD Secure Memory Encryption (SME) support"
>> depends on X86_64 && CPU_SUP_AMD
>> depends on EFI_STUB
>> + select STRICT_DEVMEM if DEVMEM
>> select DMA_COHERENT_POOL
>> select ARCH_USE_MEMREMAP_PROT
>> select INSTRUCTION_DECODER
>> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
>> index 079f8c7e9e3c..b4ff015cd770 100644
>> --- a/arch/x86/mm/init.c
>> +++ b/arch/x86/mm/init.c
>> @@ -8,6 +8,7 @@
>> #include <linux/kmemleak.h>
>> #include <linux/sched/task.h>
>> #include <linux/execmem.h>
>> +#include <linux/cc_platform.h>
>>
>> #include <asm/set_memory.h>
>> #include <asm/cpu_device_id.h>
>> @@ -866,6 +867,14 @@ void __init poking_init(void)
>> */
>> int devmem_is_allowed(unsigned long pagenr)
>> {
>> + /*
>> + * Enforce encrypted mapping consistency and avoid unaccepted
>> + * memory conflicts, "lockdown" /dev/mem for confidential
>> + * guests.
>> + */
>> + if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
>> + return 0;
>
> This includes SEV and SEV-ES which I'd think would not have the problem? Or at
> least the same symptoms.
On the contrary, SEV also experiences problems.
>
>> +
>> if (region_intersects(PFN_PHYS(pagenr), PAGE_SIZE,
>> IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
>> != REGION_DISJOINT) {
>> --
>> 2.56.0
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread