From patchwork Tue Mar 11 03:31:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Simonelli X-Patchwork-Id: 874346 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8BCC1EA7DE; Tue, 11 Mar 2025 03:31:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741663908; cv=none; b=Aucl36LTSHqEY1Fl7xPh5LShtHlbXuOKtp5zqZiovuqfbLkpr2Az8qtsqqhcHd99r95XShw3QqsATTT519MTiMXxp63aOU7vE/wPLkLURVAym/3uGrE+9ckq3piV1awU4mtAbC2aRR5x+tP9D+TiEwMkShWf9lDsKxZlbSCoxpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741663908; c=relaxed/simple; bh=gRv7CV35Y+wxD8+twcYg9frzBTRq/XFnU65egWn7k6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+8ulKgIfzho4oGEqVV86HTi9PiFvza/4fHfYN7D/FjQUMMAD+Di6PeAorW3Cx8z+kgQvRjK4Qa/3KezH3rlbAZ7ejWLVtMGsUPGGOI1dTGm+LmwLOOKyP1eCdRz4/Zov6iVIovBRN9HiFuUjbzyqJdIxklo9tRX1PnJl80S9R0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mk5/APvl; arc=none smtp.client-ip=209.85.222.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mk5/APvl" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7c089b2e239so448279285a.0; Mon, 10 Mar 2025 20:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741663905; x=1742268705; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lcg5+dUnqHObtyvwEawYvLNi2iYwLJnPZJ0YScHoNmg=; b=mk5/APvlGv9pWw0JnzoXlCTmbPJKOn2jSB71JNgpuyI1wCMpUsiLtDxKyQTHrQ0vaf +hAQTI/AYUznjZUAzooR58DyaLn351ly62l8qIvPgiCSS6wEMoobHxmJ5x3AWKZJY6eW IkUdum7pxSpctmhCbGuOX5S5oVD9eNOa39OmCkyu9hNA/ATWFy0t7uT1L1oIK/8RStTE Pq7QCdzFCV8x+Ako9PFCsqfaFNB0D/DFJqhBkxcg5t3gEmC3aDDniOSO3b9sf/P9duer wl2z+PjFRTQrmVkVcarYFHYx7X6yL28GHlrAbMc2eh4UG9FODR0PepdttLJoIArljI+2 qUkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741663905; x=1742268705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lcg5+dUnqHObtyvwEawYvLNi2iYwLJnPZJ0YScHoNmg=; b=xQvQQGQLXy32/aySED1myCkOa8D6Kv3HjdCQyMGQK0oKwrylqL7RUGvHgaCF0UYwmL rk7FA2JAHtlheUuzMME11q3EAFXcl587/eZesv30g+70jiGuan9BisO48p5/RqbZg/4b B8kQOTDgAsEmAMhu37QLf7gilQs8ClowmUYiXc2tF3CmZaOgeV9Qbx4lGCY+XpsAdyQK Af6hZcpr9JNfA6aVSnfcHzy26z9II3oaz1UhAnDBkdim0jkYr/tVduBnrGRKtO73yZWP 1hPueK2rqVbcX5tmhs2VYfVLQ7S6HmTVQio7WhncWjQrtqfAadDHOUXxLAwdT20uqiv6 nWpQ== X-Forwarded-Encrypted: i=1; AJvYcCWLFQ7ZKGYgFTXG0wTFT3UotvyKY4GSvAWvb66uChT7K86qVFG4vONO5lLCg50H559XJDqBzIZyQjbsdo4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2y1DHHbahqpY7ixMgnqkNGOycHdkGER1Q1vnCx5iKo3u5t2DL 1v5SrP04a+/AS3Z+iTz7HAKlvuU0SAPssglRiPSGuO4s015d86wmFpfPm/eL X-Gm-Gg: ASbGnct+i76MFjaQ8eLjJlIAcM7sZaF9whguAfyeSqpyeoLt84avUGkvT6x0DyXpsfV JxiBQVOP6FG4j0SZLp4trQwst6ka6SC9H1Ju6cepyZgXUjLauYrjpcS0jAhwpy8Z+K4qaxo2bZl sZdL6vCSnV60DYropT8WH1E4iu8y1T+qBnwrMZ88pSAPpJAppZqTdF+htT7Kn7H7CDpWFGC0kZ+ GVf1MG9igtU0DcEMQo0eKdpvb65FLfKvE30BlO0/LlN9xmV/XxpBSAV+wgQs6YxpxAIV17bwBNq UQRb3v3+sZPUaDwMDzetbTtND2QSUH7DW0ABJvIKyxHIacqxCD/VEGAidCsWWAOM69a8QEUmDc0 vxkmmTBQ= X-Google-Smtp-Source: AGHT+IGDuWOGj9LjvCtGYcIQ2LrciEoR/Kq2YNbvqL+OAo+OzyfUQf89uUjw/59JlAdVVmhzK7MqJw== X-Received: by 2002:a05:620a:3d11:b0:7c0:b490:2c26 with SMTP id af79cd13be357-7c55eed3cbbmr223480685a.12.1741663904895; Mon, 10 Mar 2025 20:31:44 -0700 (PDT) Received: from nerdopolis2.mynetworksettings.com ([2600:4040:5e66:a800:aa39:bd07:6207:ac0d]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c54c204e36sm342772385a.40.2025.03.10.20.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 20:31:43 -0700 (PDT) From: adamsimonelli@gmail.com To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , Greg Kroah-Hartman , Andy Shevchenko , Steven Rostedt , John Ogness , Sergey Senozhatsky , Petr Mladek Cc: Adam Simonelli Subject: [PATCH v8 1/4] ttynull: Always initialize console index to -1 Date: Mon, 10 Mar 2025 23:31:30 -0400 Message-ID: <20250311033133.1859963-2-adamsimonelli@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250311033133.1859963-1-adamsimonelli@gmail.com> References: <20250311033133.1859963-1-adamsimonelli@gmail.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Adam Simonelli This allows ttynull to be considered in console selection. Suggested-by: Petr Mladek Signed-off-by: Adam Simonelli --- drivers/tty/ttynull.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/ttynull.c b/drivers/tty/ttynull.c index 6b2f7208b564..d8b51edde628 100644 --- a/drivers/tty/ttynull.c +++ b/drivers/tty/ttynull.c @@ -57,6 +57,7 @@ static struct tty_driver *ttynull_device(struct console *c, int *index) static struct console ttynull_console = { .name = "ttynull", .device = ttynull_device, + .index = -1, }; static int __init ttynull_init(void) From patchwork Tue Mar 11 03:31:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Simonelli X-Patchwork-Id: 872785 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A97B81EB198; Tue, 11 Mar 2025 03:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741663911; cv=none; b=CI/0CHuo6OlLFzojRW973o9UycetULPsOfKBJU5G8pOndNSNH/LTz7FfVe35qslmH31cGfC3sWlZIIH7rAV4zyI755HgCB/KXtQ5kJ44zjQPI+LU2pEeuOt8/NCXJIdUBxG4nvKOQBucpJc9K6+PtH4pGzdxtf55r+n+gTjQZIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741663911; c=relaxed/simple; bh=Nxd57m3NJdibA2oX+FRYFHVGk89RBSkaja9sGdB3cBE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tZw24XpYmffE4YuriGbBTSx+Ii+RYK/lmC8bQDrAdV+5iKLmUOhKp7jG5RqlzL0sW+sD4KidepqvsitsYfNyKXJS8GH9mBEU3MoED4uPv/xhzQDioYv2VGn0jWSELQuqNdF/uFDwqD8qMXeFuBF2Nyq3NBtK3khCRHZq69oLGFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xw8vmyXH; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xw8vmyXH" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7c54f67db99so137750585a.1; Mon, 10 Mar 2025 20:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741663908; x=1742268708; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4oSwziDsvKFTJXuiRqL1YfUkGA94TmfsRfg9TxsllkI=; b=Xw8vmyXH29pMarbEsKji0obUWnCW7G5fYfACCiGuvV+FD5LthRTNY8m/n8GRfyatjQ gKqdApAUCRkhhQhp4wmcTqQPAID32xzN1kr0pMiM8EiPKXc0ZnD8LJM3IgxRspERH5/y P5T8web+ynJBXMRCWkRnZS6HjY/mNvBhRTc9jSdDUHj52zCJiEUseKO6jNjMpQn2mktY NI5u+7xF1oFmikXIG3V4jBHR+Df8hQB34DcmUbnoW0nmakyTvMnHZ+iwoNpKzpJGqM5I jOuYDR+E2iLEDR70cLaKsdHUrzC4MzqNHli3r+r2ED7N92iXA4teMZPUB9ZpWJVjUn30 WZPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741663908; x=1742268708; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4oSwziDsvKFTJXuiRqL1YfUkGA94TmfsRfg9TxsllkI=; b=VCZC4ejHL32EboM9r3vwcILXHxx/uV2M+tKwE285oGq5J5N3GziDqGBBm/gyFzu57S gPIeMC9AwMlHi/yIxRMwrF8YIxO7z+rEw72/AOX9BdzbmZ3pW5vrKQv3jxLaXXxFf594 LLk7edWUDFccVghGX8f+VZJ1IdIFWGtQL02oHaVoJgSlL3jdm3UfVovMkCkpCeYmQeQY 6HLwN308tFv6TUSqZJ8VcPNtDbVZGBXA+dkf+u8yIxt7KKGaqnxczsgF7IMiB+F/2+J0 dX5cYzEtYJUIDxM3NU0fak/9OJeOGU6uTYULzFpF/l51/RsTmMR+mZGESsObe/M6ugBm 0xIQ== X-Forwarded-Encrypted: i=1; AJvYcCVWf+9/enr3NjvOwc1bCd+m+XRUuHSTHYaWBKUkenHlVAx7Mo9ZCV4vOPkszZlP3YBsKWIa+XEb3HSf8Ww=@vger.kernel.org X-Gm-Message-State: AOJu0YwSUH6Iu245u7z5JUwOoEC5z/Cn0eqcTQEnvBPiqtYWeHIdCGD+ 61b9hhiW30e1YKrBJMDVYfsJ0DN0HH3imfiv1E7UxFXlIIXGsF0gTuWd9ACa X-Gm-Gg: ASbGncuMFVlZKLzxTklSzkj76cgbGO2Xqvooyev4qk/SHmxhIQa+BgMCHnvfkhqcgtz 1WQ2KMJRBWkJ8pfh7OhK7z566o6E6Ub7ExwmcFQLI0mgTKSRFFSqJiCWFLhJc9rqeRIaSE8s4RG u3PbZ/3P5/VZT4851LEsWHfX72Jymu/7up53yjn7TadR84uWXHgbHA5vsaTI1/b5/Q1gqSYq7MZ yxRI3ZQyCborBrp85geNXOlDT2/XK8IFNvfxHt+BZ/z8u3BIaQJsz3L9VlxsRflaxL42/t4abC6 hf+99sHgYRnTEQIgGlnU49YsEWVb3C6K9Xopfo961YWUzZWjsMxdGKSUJC6QA6Oh/oBpcRTIFki kRr8C02Q= X-Google-Smtp-Source: AGHT+IFFcOoLxYbcFoq2EKXWhDHAIqJd9bXV7vm6uNhfgjef7g8cAwQoCjN0z6xXPQSPleRrcAuGig== X-Received: by 2002:a05:620a:688b:b0:7c5:3da4:5bcb with SMTP id af79cd13be357-7c55eecfd37mr344036885a.10.1741663908257; Mon, 10 Mar 2025 20:31:48 -0700 (PDT) Received: from nerdopolis2.mynetworksettings.com ([2600:4040:5e66:a800:aa39:bd07:6207:ac0d]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c54c204e36sm342772385a.40.2025.03.10.20.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 20:31:47 -0700 (PDT) From: adamsimonelli@gmail.com To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , Greg Kroah-Hartman , Andy Shevchenko , Steven Rostedt , John Ogness , Sergey Senozhatsky , Petr Mladek Cc: Adam Simonelli Subject: [PATCH v8 2/4] ttynull: Add an option to allow ttynull to be used as a console device Date: Mon, 10 Mar 2025 23:31:31 -0400 Message-ID: <20250311033133.1859963-3-adamsimonelli@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250311033133.1859963-1-adamsimonelli@gmail.com> References: <20250311033133.1859963-1-adamsimonelli@gmail.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Adam Simonelli The new config option, CONFIG_NULL_TTY_DEFAULT_CONSOLE will allow ttynull to be initialized by console_initcall() and selected as a possible console device. Signed-off-by: Adam Simonelli --- drivers/tty/Kconfig | 15 ++++++++++++++- drivers/tty/ttynull.c | 13 +++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig index 63a494d36a1f..edf557c73586 100644 --- a/drivers/tty/Kconfig +++ b/drivers/tty/Kconfig @@ -383,7 +383,20 @@ config NULL_TTY available or desired. In order to use this driver, you should redirect the console to this - TTY, or boot the kernel with console=ttynull. + TTY, boot the kernel with console=ttynull, or enable + NULL_TTY_DEFAULT_CONSOLE. + + If unsure, say N. + +config NULL_TTY_DEFAULT_CONSOLE + bool "Support for console on ttynull" + depends on NULL_TTY=y && !VT_CONSOLE + help + Say Y here if you want the NULL TTY to be used as a /dev/console + device. + + This is similar to VT_CONSOLE, but without the dependency on VT. + It uses the ttynull driver as the system console. If unsure, say N. diff --git a/drivers/tty/ttynull.c b/drivers/tty/ttynull.c index d8b51edde628..67aad3e6f538 100644 --- a/drivers/tty/ttynull.c +++ b/drivers/tty/ttynull.c @@ -96,6 +96,19 @@ static int __init ttynull_init(void) return 0; } +#ifdef CONFIG_NULL_TTY_DEFAULT_CONSOLE +static int __init ttynull_register(void) +{ + if (console_set_on_cmdline) + return 0; + + add_preferred_console("ttynull", 0, NULL); + + return 0; +} +console_initcall(ttynull_register); +#endif + static void __exit ttynull_exit(void) { unregister_console(&ttynull_console); From patchwork Tue Mar 11 03:31:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Simonelli X-Patchwork-Id: 874345 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 680491EB5FA; Tue, 11 Mar 2025 03:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741663914; cv=none; b=cRvBO5MRewofE3ursSZghtUBGRiA1SrCXzlOUm5qUSB0fEvusWoPekuVYYoEHqbq6y0YsHEz5UYo7DgR4P4j3JXYpg+NGpa1DN+IFsml8ueOcofzxZWnWQKSjriCTNmDFv/rYHIPGj51iUgPW5n/P1j4BFaRIe8CF2HNy6Y116Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741663914; c=relaxed/simple; bh=/Ur3QigqVe6BvuF6KFEyubm6FemNS7SrI3khZNNAKGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RW2gp6GdkIduCClZ1bRhFRIsQk6Z9y3nj4gMPfYuZ1C5hX0mWKbUlp2RjhxKUq81hiF3dIAkunVuiJSpyH+XboGX6EKQyJXPo5NatnW7f7gBCx8ZR8uKgOV7EKUz4Nc5wD3z3h2UPwAbGJ4E7Em/rFP7YSGM1PBU/ACuU2QvhBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B8KVN98o; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B8KVN98o" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7c559b3eb0bso74089085a.1; Mon, 10 Mar 2025 20:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741663911; x=1742268711; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kA1OV3LCyCYIYiWIgM4V5RUECOenxGpsaM/3MlbJANQ=; b=B8KVN98olYm12ONIEbcAS8Ylw0IW/xtf136y7Ne99tX27sEMstvVqjmIS7MK5RX//O G72fyFQi0tMfZJhaXA8eeWhfi2NONPOp5guBZOAiyjazL1gG5ZtPz8AbrQyQMzODM1MQ WXyoeBgbUBbibl1FzwGpKtmMFlkDjZmHj2kafoR0+YxDe0N2avaN9ZmrUm+p1qo0ygWO rnalC51CJKmvxmMES61tQ7+yP5f4/oSrW6k8fidn9tuuqmSb2STEQb7KguxNSyXF1ii+ 9omyV9+rqxCoHoS+pXxOsoFhFT5GiMYMBfWMUd0uTNiNvpz42+4+5ObwMEvT9uep56Xx iVhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741663911; x=1742268711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kA1OV3LCyCYIYiWIgM4V5RUECOenxGpsaM/3MlbJANQ=; b=pTS63o7GA98gelKbU8JG9oFfxjGcE5JugCoqomu1MHDNCjm5uuaZv7avzoVT8nv8Rz sxzOz5GKcqvb2dxOU4VscrTnldeIPHFvKOwS+Byw9deNOAisku0TGPz/qDrk5Hq0kr3i gZE2HKLZflSlPA9f5yc24sl6Iiz3g0n+UBLrZl36nOwDmgjH9y1Waa73ntZeE8XW/tAU bKx5k9Q5y+m/raru61YCuZwFDDIaKGBuiiJR5MA02383ZURGRLmROjuHi0Sl8TV3om0w VHwNI69bGrbt/CSfG4tcQrStXU7vTOxEgl3X67NQXqGp7uh/QaN2TfUKxWYqZu8QgJcl LAAg== X-Forwarded-Encrypted: i=1; AJvYcCWD7DSPRve+Ny59fgnhcj5L044hXkXzm3rg9mxIPL2NTwt5AJAOSa+d7EQ+5mDdwjYEtlgqyDYgZq1c81Y=@vger.kernel.org X-Gm-Message-State: AOJu0YwDp0yjZEmwod1nlG3XZ8YSYQHDl7EVWoEXR6Tqur5n1b7UBK0l PQMfyUrWsDCa49R/DuBNhIy+JA+mdwwO3MPsSAN8qvl9XLo7bzIFTzf+opBF X-Gm-Gg: ASbGnctp2ZB4ZUT7vvBfgNgJRhvftm5uETkGt60ntLDtCQTIIRpIzOcmeoTUFeonnv6 Y+kOjPZlOVtep+pw5aEgRZgAFDtoN/XVWn2eRp5AlHgy1SP/bcsFb8ckEzi0U7zh5bMeLDgMmcC tqwXbq86hLYvl6tN/dKwV6lQ7Q3FDY4dc4KOQ58XWrxKZ6XU01PDEQ32oGBo8XQaNGaZciTblKJ yrO9L9hZE/rF0uGBs92RMgTMxYesXVX7mNqj5N1zdEEQLiH2mUeeSeXKGgim9yfC33+0UqnebkJ /4PfB8YZ113d6zAPS5COE7Yv7FsQqjO2SyyUFo6+z/pEuE5IcNdcQNmmJv0gQDT/K7uQ6s1BgyL EkMF7bGg= X-Google-Smtp-Source: AGHT+IGO6oLV5do8yYss44bnT2N4WL9FloUnYXlt04KMsjlUR+qtL3oT0lT3VEA5R53JbKPYtkk2Mw== X-Received: by 2002:a05:620a:8004:b0:7c5:467f:d131 with SMTP id af79cd13be357-7c5467fd2d5mr1746411185a.36.1741663911012; Mon, 10 Mar 2025 20:31:51 -0700 (PDT) Received: from nerdopolis2.mynetworksettings.com ([2600:4040:5e66:a800:aa39:bd07:6207:ac0d]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c54c204e36sm342772385a.40.2025.03.10.20.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 20:31:49 -0700 (PDT) From: adamsimonelli@gmail.com To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , Greg Kroah-Hartman , Andy Shevchenko , Steven Rostedt , John Ogness , Sergey Senozhatsky , Petr Mladek Cc: Adam Simonelli Subject: [PATCH v8 3/4] tty: Change order of ttynull to be linked sooner if enabled as a console. Date: Mon, 10 Mar 2025 23:31:32 -0400 Message-ID: <20250311033133.1859963-4-adamsimonelli@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250311033133.1859963-1-adamsimonelli@gmail.com> References: <20250311033133.1859963-1-adamsimonelli@gmail.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Adam Simonelli If CONFIG_NULL_TTY_DEFAULT_CONSOLE is enabled, and CONFIG_VT is disabled, ttynull will become the default primary console device, based on the link order. ttynull will be the only console device usually with this option enabled. Some architectures do call add_preferred_console() which may add another console though. Many distributions ship with CONFIG_VT enabled. On tested desktop hardware if CONFIG_VT is disabled, the default console device falls back to /dev/ttyS0 instead of /dev/tty. This could cause issues in user space, and hardware problems: 1. The user space issues include the case where /dev/ttyS0 is disconnected, and the TCGETS ioctl, which some user space libraries use as a probe to determine if a file is a tty, is called on /dev/console and fails. Programs that call isatty() on /dev/console and get an incorrect false value may skip expected logging to /dev/console. 2. The hardware issues include the case if a user has a science instrument or other device connected to the /dev/ttyS0 port, and they were to upgrade to a kernel that is disabling the CONFIG_VT option, kernel logs will then be sent to the device connected to /dev/ttyS0 unless they edit their kernel command line manually. The new CONFIG_NULL_TTY_CONSOLE option will give users and distribution maintainers an option to avoid this. Disabling CONFIG_VT and enabling CONFIG_NULL_TTY_CONSOLE will ensure the default kernel console behavior is not dependant on hardware configuration by default, and avoid unexpected new behavior on devices connected to the /dev/ttyS0 serial port. Signed-off-by: Adam Simonelli --- drivers/tty/Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile index 07aca5184a55..7d0414dc31ed 100644 --- a/drivers/tty/Makefile +++ b/drivers/tty/Makefile @@ -11,6 +11,12 @@ obj-$(CONFIG_N_HDLC) += n_hdlc.o obj-$(CONFIG_N_GSM) += n_gsm.o obj-y += vt/ + +# If ttynull is configured to be a console by default, ensure that it is linked +# earlier before a real one is selected. +obj-$(CONFIG_NULL_TTY_DEFAULT_CONSOLE) \ + += ttynull.o + obj-$(CONFIG_HVC_DRIVER) += hvc/ obj-y += serial/ obj-$(CONFIG_SERIAL_DEV_BUS) += serdev/ @@ -20,7 +26,13 @@ obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o obj-$(CONFIG_MOXA_INTELLIO) += moxa.o obj-$(CONFIG_MOXA_SMARTIO) += mxser.o obj-$(CONFIG_NOZOMI) += nozomi.o + +# If ttynull is enabled, but not as a boot console, it is linked and used later +# after the real ones. +ifneq ($(CONFIG_NULL_TTY_DEFAULT_CONSOLE),y) obj-$(CONFIG_NULL_TTY) += ttynull.o +endif + obj-$(CONFIG_SYNCLINK_GT) += synclink_gt.o obj-$(CONFIG_PPC_EPAPR_HV_BYTECHAN) += ehv_bytechan.o obj-$(CONFIG_GOLDFISH_TTY) += goldfish.o From patchwork Tue Mar 11 03:31:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Simonelli X-Patchwork-Id: 872784 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9F4B1EDA03; Tue, 11 Mar 2025 03:31:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741663918; cv=none; b=Uosz5CH0tgHogUEQ7MvskRMf+CH6NNffMneo+dateZScTYRFm/O/nicGyZ3u1jTIJ6sD/+Uoli4O8ShxvVMBrzSpK/SAGYd8fp9lEO/6/NDm1AuNqcY2VvylKQvDyWa1mDBZhTIVA5e7jEyVuGdGw0qHNwQ5LWd02X3fZ09bniE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741663918; c=relaxed/simple; bh=/TKgmRcpR6FwG+QP75QeweLLHLthLmIsWG6RxmlgQmg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hyml4lORjsW45ZiFaZJyzusoH7NtPzTpJ0HHmWxDICMnvrICDVNP693l5uz824y7X1uGGBdMcoWAZtyGL3keHaBexLeT0eSR/3FJeivbly6XPnyJiYyPMulkIJBsmwGA7Rci0sUhnFdAxF9ssZS9DDqA0okmnTN8PIbracB7LoE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RkeYEAl+; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RkeYEAl+" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7c04df48a5bso438173285a.2; Mon, 10 Mar 2025 20:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741663914; x=1742268714; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tEOdYvwBabq4hLr7eGLZh7Wd260T/gAnmabJNmIq24s=; b=RkeYEAl+wC0znmtUydZvF81b6zA6maDdvgFxVzfKhsn9iaMF58l7nCicf6jKzGOLka Jnu6/DaSbKdSivnU3uwSCatjdXnemjZ/T41cECe997e/f+gPF9UgyE4qdgZgGH5UJpjF fNVR0M4KurScNPX5cpYe2XsQv8ymXF0nYcacNhLo8q1RsVSzqBu1JehBXlqzUB4XkLJN +8Lky4/O2aO3vEbXRceSQNQaqQdiHvaOznSXBqvFl9Yle2IEXq9/VY3Ws5Z0HQ6zvZxC bTlHZX3kjW4GYZhVA1XjQlkwTBcESSLyar6NdRjj+Sg9E3TQlmAPdahwD14K3eQvlVko XAxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741663914; x=1742268714; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tEOdYvwBabq4hLr7eGLZh7Wd260T/gAnmabJNmIq24s=; b=mz2SXg3UdcpWWomO/Isg7fx8EUDSD528c29fvd/eAW69YCMMYCrzX28nI2GyIgqfeK 3CNKu4Gcm9yyoN+iejPGQU2UqadvrMkj30SkYUDEISCV9YHSUZ57p5xkVQEsFagNuGy5 RfjN43sHR1iQhH8eHte97KDhxxcbdCbX8gmDgIc+uuTAhBql7Ei27hUxudCnbq/Vp2in 4drVqOc/sigmyYkOs6mqQ8ZmYteB4Hreinc3pRx/0RHD9Zh187vI8JTr21FwR5gfc1/K 2DdfkNpaa7/G3LykjoQbu8Ca/Sf9xvb7fe7oJlLvZS0s+G9+bt1j0RQ6iT0m3s3mtc9p PMbQ== X-Forwarded-Encrypted: i=1; AJvYcCV+ybUS/JLyu0Ed5QSX/fNzwEkWs3hRAGDT9WpQOlRBHffjEaEJoVP1NrForzOLY5z0GcNFu8cVi9WAKwk=@vger.kernel.org X-Gm-Message-State: AOJu0YyOp3T92kgchvxuDvgmXY/0gO45r7NbKHXH4CTvz9ybiwJW5Uwl 3y0NnY7ctQMXXY+XM59CQkOy/CCIi0RyuvvwzSv/Cdjafk3kTXqzqsiBlcdR X-Gm-Gg: ASbGncscR44+c0S3TCpDJNIluRPzd/6YuEHGqTeY50QhMagwOcWd4p16qPhD4WQF6Hw lF/Ozj9lrllFIyc9JP6In2nX+5HHJAuinvcKp7Bn4+b6JIbXseMW4EPqdQgQfj6CATLO+oksHwK GrUBBrDBhfJpcKJSjJQXClNu52+sRWpYsVAMwe7uEyLa0RCvrdUiBWF0ziF2umr6tPdzlbuwahF +LEWZeAFFpE5XzMokKlbrB1dAAt8sh0oIDeTQq7dYH1J9rJ4KGvIgMTJDC1NBdAH433afwukq8A 9giMwY45WgKxIKkP+B7BzxL2ll0GDIYPOMPrsBxrOto8uCGPkHf44hg2ADTVyWBNAYnIQ/m8uqG irhiJJPpA5k3AFWxBOA== X-Google-Smtp-Source: AGHT+IHIAyzXVA/iU++8gfxQ63RCGP5YFcZSH8DC2qBAqSfVfKP1LwdcEzYiabOBoLCtcoyEq3huvg== X-Received: by 2002:a05:620a:6407:b0:7c5:565a:2177 with SMTP id af79cd13be357-7c5565a2b71mr687815285a.33.1741663913931; Mon, 10 Mar 2025 20:31:53 -0700 (PDT) Received: from nerdopolis2.mynetworksettings.com ([2600:4040:5e66:a800:aa39:bd07:6207:ac0d]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c54c204e36sm342772385a.40.2025.03.10.20.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 20:31:52 -0700 (PDT) From: adamsimonelli@gmail.com To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , Greg Kroah-Hartman , Andy Shevchenko , Steven Rostedt , John Ogness , Sergey Senozhatsky , Petr Mladek Cc: Adam Simonelli Subject: [PATCH v8 4/4] Documentation/serial-console: Document CONFIG_NULL_TTY_DEFAULT_CONSOLE. Date: Mon, 10 Mar 2025 23:31:33 -0400 Message-ID: <20250311033133.1859963-5-adamsimonelli@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250311033133.1859963-1-adamsimonelli@gmail.com> References: <20250311033133.1859963-1-adamsimonelli@gmail.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Adam Simonelli When the kernel is compiled with CONFIG_NULL_TTY_DEFAULT_CONSOLE and no console= options are selected, it defaults to using the ttynull device. Reviewed-by: Petr Mladek --- Documentation/admin-guide/serial-console.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/serial-console.rst b/Documentation/admin-guide/serial-console.rst index a3dfc2c66e01..1609e7479249 100644 --- a/Documentation/admin-guide/serial-console.rst +++ b/Documentation/admin-guide/serial-console.rst @@ -78,7 +78,9 @@ If no console device is specified, the first device found capable of acting as a system console will be used. At this time, the system first looks for a VGA card and then for a serial port. So if you don't have a VGA card in your system the first serial port will automatically -become the console. +become the console, unless the kernel is configured with the +CONFIG_NULL_TTY_DEFAULT_CONSOLE option, then it will default to using the +ttynull device. You will need to create a new device to use ``/dev/console``. The official ``/dev/console`` is now character device 5,1.