From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2DA0C52D7C for ; Thu, 15 Aug 2024 12:17:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BD076B00BE; Thu, 15 Aug 2024 08:17:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 246FF6B00CC; Thu, 15 Aug 2024 08:17:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E6406B00CF; Thu, 15 Aug 2024 08:17:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DF1A36B00BE for ; Thu, 15 Aug 2024 08:17:17 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6465F12152E for ; Thu, 15 Aug 2024 12:17:17 +0000 (UTC) X-FDA: 82454379714.03.A24BA8B Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf24.hostedemail.com (Postfix) with ESMTP id 780D4180011 for ; Thu, 15 Aug 2024 12:17:15 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=QseeLamu; dkim=pass header.d=linutronix.de header.s=2020e header.b=5UM9eemT; spf=pass (imf24.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723724199; a=rsa-sha256; cv=none; b=F6gR7YFFm9F3nVRBwSxi8w/TK98Wk/0xmF6tRx1t45QdnopQACUbcI8Xbiyg6Dvb/hTxZc WLG337OTG1Yo6Ir9jOzFQXc2rt2iUI2CM3OXKFmjKt7rjaL34RuJY9td9YjkIPn+n4xCP9 HdDC9rtUpvzLcrCp4aQrWoHawY8574w= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=QseeLamu; dkim=pass header.d=linutronix.de header.s=2020e header.b=5UM9eemT; spf=pass (imf24.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723724199; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:dkim-signature; bh=rRigOJOO3qhALtqJE6dw15axLsE6DCGme8lKMcQne9I=; b=rpmeTOX4/K3yIQt+uULpzFrCLkXp80zC3OKSXHKxSMwczJtKEkJxb49HXg4OV+UN/VytGA LWpu/b3FgWatIRQt84FKmXM7kC2IooSF2GSTSmCUBzJNnGUvhbrCJ51U/p35kuuZIjLqPJ G7eynG0UTdDfxLAZ3OydbrmcM1kIjvQ= From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1723724232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=rRigOJOO3qhALtqJE6dw15axLsE6DCGme8lKMcQne9I=; b=QseeLamu+Ve6G/d3HbW7okSVN98YQ2FNSrDeLd1E3GlVr8M63wB4CHCPs+NxPhKct4C4zc CHaKE6hfu/PQgUQ7Ky438ULIYOeaTZ5rJiC7fP+lkSt2vM7RhtimWvUlgFtQnRpTKz3g7F /S6aqMaio9VKU83MuH7FRTg1R+rmJk2KdX7KeiVQZgvBI/hAQZHuWqMeWy91SNpTyVOEhf 5QeoV7TQ6iQdmAfmWEayfH6mm6fbKLoIQyLw+CO4Cc3mSsO5ZLdeLyHdWQKY5Es26Tu5Rl +0fyU8dO9pPvNQ94ID/rjVgjWKCD9HDr6Iyr2rD5h6iK4cT+is8orsJTOMvALg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1723724232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=rRigOJOO3qhALtqJE6dw15axLsE6DCGme8lKMcQne9I=; b=5UM9eemTh6QW2duf1BOI6wBtqOvSeGaa8dJXAMrsOWaSKxHE9KNZkfxuix/5OayqMO8ppG Hy5eX/jx/Yc48mDA== To: Mary Strodl , linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org, linux-mm@kvack.org, lee@kernel.org, andi.shyti@kernel.org, linux-i2c@vger.kernel.org, s.hauer@pengutronix.de, christian.gmeiner@gmail.com, Mary Strodl Subject: Re: [PATCH v4 1/2] x86: Add basic support for the Congatec CGEB BIOS interface In-Reply-To: <20240814184731.1310988-2-mstrodl@csh.rit.edu> Date: Thu, 15 Aug 2024 14:17:12 +0200 Message-ID: <87sev6m14n.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Stat-Signature: nk6mxts4ueyxhki5mzjhk3ysxijrnm85 X-Rspamd-Queue-Id: 780D4180011 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1723724235-904032 X-HE-Meta: U2FsdGVkX1/1pez2loj12oIu/V4oWlQyukLE1muFWp9hxGUYn9L6NMnodIWollOEAJ4+dNCJnU/Dzf/lOcNnQ6ox/ky/iWel7VSq8eT/D4VADoQnmUpWO0wE4rKMpzLcCVgJUtx2jJg2ZqS7F2YswlOlJP7880qkWTJNEBVGiuk3u6vwRaD8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ender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Mary! On Wed, Aug 14 2024 at 14:47, Mary Strodl wrote: So this caught the attention of my mail filter because the subsystem prefix is 'x86:' while it obviously should be 'mfd:' > The Congatec CGEB is a BIOS interface found on some Congatec x86 > modules. It provides access to on board peripherals like I2C busses > and watchdogs. This driver contains the basic support for accessing > the CGEB interface and registers the child devices. > > Signed-off-by: Sascha Hauer > Signed-off-by: Christian Gmeiner > Signed-off-by: Mary Strodl This Signed-off-by chain is invalid. See Documentation/process/ Aisde of that. How is any of this supposed to work. What is the user mode helper doing and why does this need this netlink indirection? And looking at that reference implementation on github makes me just shudder: board.mem_fd = open("/dev/mem", O_RDONLY); and then it allocates anon memory: board->code = mmap(NULL, msg->code.length, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); which it hands back to the kernel so the kernel can copy stuff into it followed by some other command: mprotect(board->code, msg->code.length, PROT_EXEC | PROT_READ | PROT_WRITE) Seriously? RWX mappings? So this copies a code blob out of the BIOS region into user space and lets user space use this blob to interact with the BIOS extension, right? So an i2c transfer does a full round trip: i2c::xfer -> cgeb -> netlink -> user helper -> execute random code -> user helper -> netlink -> cgeb -> ... right? Has anyone tried to analyze what this BIOS provided code blob is actually doing? All it does is to poke at a range of IOPORTS with in*(), out*() and that poking mechanism depends on the generation of that CGEB implementation. Congatec even provides the GPL2 licenced source for this pokery as a kernel driver. Three generations of interfaces and for each the poking is about 200 lines of unreadable, malformated gunk, which can be probably condensed to 100 lines of readable kernel code for each generation. Add a bunch of helpers which set up the various transfers for the subdevices and you can spare all this horrible nonsense with user mode helper, executing random BIOS provided gunk, netlink and completely ill defined data structures. Thanks, tglx