From patchwork Thu Nov 10 13:09:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeniy Baskov X-Patchwork-Id: 18123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp137867wru; Thu, 10 Nov 2022 05:10:20 -0800 (PST) X-Google-Smtp-Source: AMsMyM50PI8/xjHaiKyDvqEBibJyjuOnfqYNbptD68g+/zO3M1yl4M5deRSTshhXPjaLv3rYJtjt X-Received: by 2002:a17:90a:f2cb:b0:213:9afa:d13a with SMTP id gt11-20020a17090af2cb00b002139afad13amr65256900pjb.180.1668085819706; Thu, 10 Nov 2022 05:10:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668085819; cv=none; d=google.com; s=arc-20160816; b=Ysjm6Zx1GUrdJ+GrsxaR5SrEcVwpt7rqsC4GQ0b974VHe90Y8ww2rgxlci77VSm2TQ q01TNcW/KAqm3QMrjl6todS2Qk1qGMOLbwrH6bpbJBYLNYNO26zysKucIzvzteB1pluq yUH7TsesKHlupaO0S++VI1vYiUnOc+NfiZg7/wakNUZmObVjmZCthdtSEfcGLOYy6XjE Y3+e1U/R334AZ3fVqPHXk7exmz0RV1ONiufsqNNSyJGstmipyxEI0W+9Gc46i7eh+A3F YEr+E2G8bxk1ZyXNrHRjB4Bbpul/AQkHCMD/4+e7LFF5vCQTjV1hFfaWjlLY220QGuaK V4cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=8C0m+nikY+hKoEP6Ez5Q8u9vl0RUFjErqLyUvRmpH6Q=; b=MSuZtuDqiLzyJsR7ydA6lLnqBk6EPHrAR9LXEV5SKEEcFO3X9GFgXQYObaDozZnsHj 9oMW6O5qJQ0c/Thxi2O1bXFyOYlWaSkY52JAoyPXFS5vNIDd4PqZPG1gqc6AXmvuqyrt MOeHfVkK6jkrsy7zq4/RAuUsXVHhHqB6dF+yUlmqKoDI/DOBtGOlu+BhDRgAOg1zmP85 V/pLgXGdSCE8ZnlIjRlv1a0WMgyrHXizDnlBLMsV280ORRqsWT5Rm/ASZCet+HR4PLRS YXSGlYMkYSBuxQwBp6bym+WXLzz9vvjVV/m06g6875EyfsgNBWM01pDcNW4FYgWhO7+p jLpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=ZYwUalCb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l125-20020a632583000000b0046fbe60adc5si21262092pgl.510.2022.11.10.05.10.00; Thu, 10 Nov 2022 05:10:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=ZYwUalCb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbiKJNJv (ORCPT + 99 others); Thu, 10 Nov 2022 08:09:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230238AbiKJNJj (ORCPT ); Thu, 10 Nov 2022 08:09:39 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0264C12A89 for ; Thu, 10 Nov 2022 05:09:37 -0800 (PST) Received: from localhost.localdomain (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPSA id 1B85D40737BB; Thu, 10 Nov 2022 13:09:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 1B85D40737BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1668085776; bh=8C0m+nikY+hKoEP6Ez5Q8u9vl0RUFjErqLyUvRmpH6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZYwUalCb2nXd9lnjaqKwRXntRhcitVOzWlSmiJzHB5wCOn6y7U4B/c9YUkVuH7zxT BpA2vKgZurcsqZQK1gvVBNh/lFmv3JdwFnD+BtfGm7IU5kiAVH2pswTXc2ROiOl6u6 3EthC7c8acYuGdY1iKyQrGrl1vAfutJ2lPdA2QkE= From: Evgeniy Baskov To: Borislav Petkov Cc: Evgeniy Baskov , Dave Hansen , Ingo Molnar , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, Alexey Khoroshilov Subject: [PATCH v8 4/5] x86/boot: Use cmdline_prapare() in compressed kernel Date: Thu, 10 Nov 2022 16:09:32 +0300 Message-Id: <290b33437bc94c32fce2e13c0599eab5e1cc3132.1668082601.git.baskov@ispras.ru> X-Mailer: git-send-email 2.37.4 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749114756171095968?= X-GMAIL-MSGID: =?utf-8?q?1749114756171095968?= CONFIG_CMDLINE_BOOL and CONFIG_CMDLINE_OVERRIDE were ignored during options lookup in compressed kernel, including earlyprintk option, so it was impossible to get earlyprintk messages from that stage of boot process via command line provided at compile time. Being able to enable earlyprintk via compile-time option might be desirable for booting on systems with broken UEFI command line arguments via EFISTUB. Use a common helper function to handle CONFIG_CMDLINE_* in compressed kernel. Place command_line_init explicitly in '.data' section since it is used before '.bss' section is zeroed and it is expected to be equal to zero. Signed-off-by: Evgeniy Baskov --- arch/x86/boot/compressed/cmdline.c | 24 ++++++++++++++++++++++-- arch/x86/boot/compressed/misc.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c index f1add5d85da9..53ad259ee441 100644 --- a/arch/x86/boot/compressed/cmdline.c +++ b/arch/x86/boot/compressed/cmdline.c @@ -12,6 +12,15 @@ static inline char rdfs8(addr_t addr) return *((char *)(fs + addr)); } #include "../cmdline.c" + +static char command_line[COMMAND_LINE_SIZE] __section(".data"); +static bool command_line_init __section(".data"); + +/* + * This always returns runtime command line and does not account for built-in + * command line, so this should not be used for cmdline parsing. + * Use get_cmdline() instead. + */ unsigned long get_cmd_line_ptr(void) { unsigned long cmd_line_ptr = boot_params->hdr.cmd_line_ptr; @@ -20,11 +29,22 @@ unsigned long get_cmd_line_ptr(void) return cmd_line_ptr; } + +static inline unsigned long get_cmdline(void) +{ + if (!command_line_init) { + cmdline_prepare(command_line, (char *)get_cmd_line_ptr()); + command_line_init = 1; + } + + return (unsigned long)command_line; +} + int cmdline_find_option(const char *option, char *buffer, int bufsize) { - return __cmdline_find_option(get_cmd_line_ptr(), option, buffer, bufsize); + return __cmdline_find_option(get_cmdline(), option, buffer, bufsize); } int cmdline_find_option_bool(const char *option) { - return __cmdline_find_option_bool(get_cmd_line_ptr(), option); + return __cmdline_find_option_bool(get_cmdline(), option); } diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 62208ec04ca4..5bf1357c054c 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "tdx.h"