From: sashiko-bot@kernel.org
To: "Nikolay Borisov" <nik.borisov@suse.com>, x86@kernel.org
Cc: mhocko@suse.com, kas@kernel.org, ljs@kernel.org,
linux-mm@kvack.org, "Dan Williams" <dan.j.williams@intel.com>,
"Kees Cook" <kees@kernel.org>, "Ingo Molnar" <mingo@kernel.org>,
"Vishal Annapurve" <vannapurve@google.com>,
"Kirill Shutemov" <kirill.shutemov@linux.intel.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Suzuki K Poulose" <suzuki.poulose@arm.com>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Naveen N Rao (AMD)" <naveen@kernel.org>
Subject: Re: [RESEND PATCH] x86/devmem: Drop /dev/mem access for confidential guests
Date: Wed, 25 Nov 2026 16:01:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-233694@kernel.org> (raw)
In-Reply-To: <20261124160025.738362-2-nik.borisov@suse.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] x86/kconfig: unmet DEVMEM dependency when selecting
STRICT_DEVMEM
- [Medium] char/mem: confidential guest check in open_port() blocks
/dev/port
--
commit 044352a94dad5df8ad0a8efbc1156eb4b277903b
Author: Dan Williams <djbw@kernel.org>
x86/devmem: Drop /dev/mem access for confidential guests
This commit selects STRICT_DEVMEM and IO_STRICT_DEVMEM for INTEL_TDX_GUEST
and AMD_MEM_ENCRYPT, and blocks opening /dev/mem in confidential guests by
returning -EPERM when CC_ATTR_GUEST_MEM_ENCRYPT is active.
Link: https://sources.debian.org/src/libdebian-installer/0.125/src/system/subarch-x86-linux.c/?hl=113#L93 [2]
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 58dce0b66179b..7a212f8363e35 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -901,6 +901,8 @@ config INTEL_TDX_GUEST
> depends on X86_X2APIC
> depends on EFI_STUB
> depends on PARAVIRT
> + select STRICT_DEVMEM
> + select IO_STRICT_DEVMEM
> select ARCH_HAS_CC_PLATFORM
> select X86_MEM_ENCRYPT
> select X86_MCE
> @@ -1490,6 +1492,8 @@ 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
> + select IO_STRICT_DEVMEM
> select DMA_COHERENT_POOL
> select ARCH_USE_MEMREMAP_PROT
> select INSTRUCTION_DECODER
[Severity: Medium]
Does selecting STRICT_DEVMEM and IO_STRICT_DEVMEM here trigger an unmet
direct dependency warning when CONFIG_DEVMEM is disabled?
In lib/Kconfig.debug, STRICT_DEVMEM depends on MMU && DEVMEM, and
IO_STRICT_DEVMEM depends on STRICT_DEVMEM. Because DEVMEM is an
independent user-configurable option, building with CONFIG_DEVMEM=n and
either CONFIG_INTEL_TDX_GUEST=y or CONFIG_AMD_MEM_ENCRYPT=y warns on
unmet direct dependencies for STRICT_DEVMEM (and fails the configuration
step under KCONFIG_WERROR).
Note that simply gating the selects with "if DEVMEM" would leave
CONFIG_IO_STRICT_DEVMEM disabled when CONFIG_DEVMEM=n, which would leave
iomem_is_exclusive() inactive for PCI sysfs MMIO mappings unless
STRICT_DEVMEM also drops its dependency on DEVMEM.
> diff --git a/mm/char-mem.c b/mm/char-mem.c
> index 53ce0034a4c13..c06970238bf49 100644
> --- a/mm/char-mem.c
> +++ b/mm/char-mem.c
[ ... ]
> @@ -609,6 +610,15 @@ static int open_port(struct inode *inode, struct file *filp)
> if (rc)
> return rc;
>
> + /*
> + * Enforce encrypted mapping consistency and avoid unaccepted
> + * memory conflicts, "lockdown" /dev/mem for confidential
> + * guests.
> + */
> + if (IS_ENABLED(CONFIG_STRICT_DEVMEM) &&
> + cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
> + return -EPERM;
> +
> if (iminor(inode) != DEVMEM_MINOR)
> return 0;
[Severity: Medium]
Does placing this check before the DEVMEM_MINOR check unintentionally
block /dev/port in confidential guests as well?
open_port() is shared as the .open handler for both mem_fops (/dev/mem)
and port_fops (/dev/port). Because the CC_ATTR_GUEST_MEM_ENCRYPT check runs
before "if (iminor(inode) != DEVMEM_MINOR) return 0;", opening /dev/port
will also fail with -EPERM whenever CONFIG_STRICT_DEVMEM is enabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124160025.738362-2-nik.borisov@suse.com?part=1
next prev parent reply other threads:[~2026-11-25 16:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 16:00 [RESEND PATCH] x86/devmem: Drop /dev/mem access for confidential guests Nikolay Borisov
2026-11-24 16:29 ` Arnd Bergmann
2026-11-24 16:36 ` Dave Hansen
2026-11-24 17:10 ` Pedro Falcato
2026-11-24 17:35 ` Greg Kroah-Hartman
2026-11-24 17:53 ` Nikolay Borisov
2026-11-25 5:06 ` Greg Kroah-Hartman
2026-11-24 17:57 ` Nikolay Borisov
2026-11-25 16:51 ` Naveen N Rao
2026-11-26 7:17 ` Nikolay Borisov
2026-11-25 16:01 ` sashiko-bot [this message]
2026-11-26 8:28 ` Nikolay Borisov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-233694@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arnd@arndb.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=kas@kernel.org \
--cc=kees@kernel.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=naveen@kernel.org \
--cc=nik.borisov@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=vannapurve@google.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox