From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69B2B1DB13A for ; Thu, 1 May 2025 20:03:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746129807; cv=none; b=umGdwieyp/D57WSv2iRlwVQtX7Ix3pOrbrDDIor2GjOW0Y+8Nojhhom24pyrd9VaJX1yVMj+4YdChkR4FElL58S7QmOk2LonPhxJuJBW2ldSTVcpjFHFbnf1/d2G9VllIV5M2m8Pj+lBEtC/WcWFQalYdzEQiW64uhxcAWpWsLQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746129807; c=relaxed/simple; bh=a4fF2rnq9c73XIGU80bI/SGsIe2nZ6yVNaTWRL7DRIw=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=ph1yUrTDUinDR0+72Yk9JYxVgIiXlQFBlKaIPiaKYtUUl9h5DQQptCbSjWXr24t7WTJyQusTNJSy4JMHKYy5fQoUj6qy+NbY4UZ+Oasa6slYFf+EskaxVlNUd0F+WsY5plYc1OyypoP23YIFJRLxy6vlHfDmVGUenp2mtdlmnt8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=tKXENaT4; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=poc9MR9N; arc=none smtp.client-ip=202.12.124.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="tKXENaT4"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="poc9MR9N" Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 236EB254015C; Thu, 1 May 2025 16:03:24 -0400 (EDT) Received: from phl-imap-11 ([10.202.2.101]) by phl-compute-05.internal (MEProxy); Thu, 01 May 2025 16:03:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1746129803; x=1746216203; bh=PJvrlBuargBsoDMpUJKUg9batdHN+WAF+1+xtO2/hU0=; b= tKXENaT401VHxdYYQOqF0t22cKLRfoDiNQfYL5GakB7mBlLvI40SBunwikm0qNoQ QKjKejNDKNyG7QVEY7o9yFzZ1KCjinnWjc3whNDoK+ZMSS+b5DSsLCSEEDLcHj8r ehWCPoeeFvTFGlyOXk5xY/CmcBqET4R3eMNrxfTjOOQifci1OC/kR+VJwPwf+TSf cfoTES4vmAEiVxaAkJb8LH0JhJqE+f9ZHCR5wrbjHxD/cNqOgQnGFYN/9q87gMkr neWnDwo77lhLTwCCZPbh0L+ZuhriPzUMaKIfcPgGMKl3TZCGtMylsYZjPg3PPEZE iTFzBYk+N3K5aLUsc1QY5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1746129803; x= 1746216203; bh=PJvrlBuargBsoDMpUJKUg9batdHN+WAF+1+xtO2/hU0=; b=p oc9MR9N0iYtULCwKHkBot6DmaVOFsjSazI8u3ObOwLaYp15kNXU5ZzQj1RMsrrcd yBKx+AaamNszAiidTDlHH64/FlrRlSOD6ndATmMaZr/zduGaJpv5Zv8KiBKXD7es p0L5GDSnWf6hX9gpMs57TilyOsxY4sWdm+eCwH8ME0vjYJRgoh2nHVXpvlvGWU1h +Z45TIBhF587j8nf3Pr9v8mk/oniq2u0ogq+OaRpZUk3pqcMkLofxDY8EjgOFURB 5UjdQWIElwJhF+dhgg+9Zm9x4lNLohPLAunOIExTJHos0nzfhIizv4pGl+iTraav 8n0VGN823KiufWQtyfOFg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvjedtgeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgfgsehtjeertder tddtnecuhfhrohhmpedftehrnhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnug gsrdguvgeqnecuggftrfgrthhtvghrnhepkeelvedvkeegkedutdelueeileettdetledu ffdvgeekveeljeeiuefffeejfeelnecuffhomhgrihhnpeguvggsihgrnhdrnhgvthenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrhhnuges rghrnhgusgdruggvpdhnsggprhgtphhtthhopedugedpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepshhuiihukhhirdhpohhulhhoshgvsegrrhhmrdgtohhmpdhrtghpthht ohepmhhpvgesvghllhgvrhhmrghnrdhiugdrrghupdhrtghpthhtohepvhgrnhhnrghpuh hrvhgvsehgohhoghhlvgdrtghomhdprhgtphhtthhopegurghnrdhjrdifihhllhhirghm shesihhnthgvlhdrtghomhdprhgtphhtthhopehkvggvsheskhgvrhhnvghlrdhorhhgpd hrtghpthhtohepmhhinhhgoheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepnhgrvhgv vghnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopeigkeeisehkvghrnhgvlhdrohhrgh dprhgtphhtthhopegurghvvgdrhhgrnhhsvghnsehlihhnuhigrdhinhhtvghlrdgtohhm X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 54B7E2220073; Thu, 1 May 2025 16:03:22 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: T3ad4a30312e33025 Date: Thu, 01 May 2025 22:01:02 +0200 From: "Arnd Bergmann" To: "Dan Williams" , "Dave Hansen" Cc: "Greg Kroah-Hartman" , "Ingo Molnar" , "Kees Cook" , "Kirill A. Shutemov" , "Michael Ellerman" , "Naveen N Rao" , "Nikolay Borisov" , stable@vger.kernel.org, "Suzuki K Poulose" , "Vishal Annapurve" , x86@kernel.org, linux-coco@lists.linux.dev Message-Id: <5f80ae16-8d41-4a68-b978-c1bb60fce3f1@app.fastmail.com> In-Reply-To: References: <20250430024622.1134277-1-dan.j.williams@intel.com> <20250430024622.1134277-3-dan.j.williams@intel.com> <0bdb1876-0cb3-4632-910b-2dc191902e3e@app.fastmail.com> <6812c6cda0575_1d6a294d7@dwillia2-xfh.jf.intel.com.notmuch> Subject: Re: [PATCH v5] x86/devmem: Drop /dev/mem access for confidential guests Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, May 1, 2025, at 10:12, Arnd Bergmann wrote: > On Thu, May 1, 2025, at 02:56, Dan Williams wrote: >> Arnd Bergmann wrote: >>> On Wed, Apr 30, 2025, at 04:46, Dan Williams wrote: > > The other bit of the puzzle is that memremap() on x86 silently > falls back to ioremap() for non-RAM pages. This was originally > added in 2008 commit e045fb2a988a ("x86: PAT avoid aliasing in > /dev/mem read/write"). I'm not sure what happened exactly, but > I suspect that the low 1MB was already mapped at the time > through a cached mapping, while the PCI MMIO hole was perhaps > not mapped. On x86-32, the 32-bit PCI BAR area should not > be included here (since it's above high_memory), but the 16MB > hold may be. Following up myself after thinking about it some more: if we remove both the <1MB special case and the memremap() hack on x86-64 but leave both for x86-32, that would also avoid the cases that break CC guests, right and make x86-64 behave exactly like the other architectures, right? If there is software that still relies on those hacks, it's probably very old, and more likely to be on 32-bit systems. There are many references to /dev/mem in Debian codesearch [1], but it's usually related to pre-PCIe graphics (svgalib, XFree86, uvesafb/v86), or it's memory-only accesses that rely on !CONFIG_STRICT_DEVMEM to read kernel structures. Arnd [1] https://codesearch.debian.net/search?q=%2Fdev%2Fmem&literal=1&perpkg=1