Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1461757/?format=api
{ "id": 1461757, "url": "http://patchwork.ozlabs.org/api/patches/1461757/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/13fb0995a91bdbce71812794d28cb29070daf51e.1617375802.git.christophe.leroy@csgroup.eu/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/", "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/", "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}" }, "msgid": "<13fb0995a91bdbce71812794d28cb29070daf51e.1617375802.git.christophe.leroy@csgroup.eu>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/13fb0995a91bdbce71812794d28cb29070daf51e.1617375802.git.christophe.leroy@csgroup.eu/", "date": "2021-04-02T15:18:05", "name": "[v4,04/20] drivers: firmware: efi: use cmdline building function", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "72073797dd484d01838d1e4c3f45241076785f19", "submitter": { "id": 79086, "url": "http://patchwork.ozlabs.org/api/people/79086/?format=api", "name": "Christophe Leroy", "email": "christophe.leroy@csgroup.eu" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/13fb0995a91bdbce71812794d28cb29070daf51e.1617375802.git.christophe.leroy@csgroup.eu/mbox/", "series": [ { "id": 237158, "url": "http://patchwork.ozlabs.org/api/series/237158/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=237158", "date": "2021-04-02T15:18:03", "name": "Implement GENERIC_CMDLINE", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/237158/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1461757/comments/", "check": "success", "checks": "http://patchwork.ozlabs.org/api/patches/1461757/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Authentication-Results": [ "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org;\n receiver=<UNKNOWN>)", "lists.ozlabs.org; spf=pass (sender SPF authorized)\n smtp.mailfrom=csgroup.eu (client-ip=93.17.236.30; helo=pegase1.c-s.fr;\n envelope-from=christophe.leroy@csgroup.eu; receiver=<UNKNOWN>)" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4FBkHJ5kcpz9sf9\n\tfor <patchwork-incoming@ozlabs.org>; Sat, 3 Apr 2021 02:19:24 +1100 (AEDT)", "from boromir.ozlabs.org (localhost [IPv6:::1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4FBkHJ52GPz3cb5\n\tfor <patchwork-incoming@ozlabs.org>; Sat, 3 Apr 2021 02:19:24 +1100 (AEDT)", "from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by lists.ozlabs.org (Postfix) with ESMTPS id 4FBkFv03qzz3brZ\n for <linuxppc-dev@lists.ozlabs.org>; Sat, 3 Apr 2021 02:18:08 +1100 (AEDT)", "from localhost (mailhub1-int [192.168.12.234])\n by localhost (Postfix) with ESMTP id 4FBkFm3NsKz9v2m3;\n Fri, 2 Apr 2021 17:18:04 +0200 (CEST)", "from pegase1.c-s.fr ([192.168.12.234])\n by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024)\n with ESMTP id UqB_0D8kMq5r; Fri, 2 Apr 2021 17:18:04 +0200 (CEST)", "from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192])\n by pegase1.c-s.fr (Postfix) with ESMTP id 4FBkFm1vXmz9v2ls;\n Fri, 2 Apr 2021 17:18:04 +0200 (CEST)", "from localhost (localhost [127.0.0.1])\n by messagerie.si.c-s.fr (Postfix) with ESMTP id 2AD948BB7B;\n Fri, 2 Apr 2021 17:18:06 +0200 (CEST)", "from messagerie.si.c-s.fr ([127.0.0.1])\n by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023)\n with ESMTP id Da56GN4Eog_p; Fri, 2 Apr 2021 17:18:06 +0200 (CEST)", "from po16121vm.idsi0.si.c-s.fr (unknown [192.168.4.90])\n by messagerie.si.c-s.fr (Postfix) with ESMTP id ABC668BB79;\n Fri, 2 Apr 2021 17:18:05 +0200 (CEST)", "by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0)\n id 86AF467989; Fri, 2 Apr 2021 15:18:05 +0000 (UTC)" ], "X-Virus-Scanned": [ "Debian amavisd-new at c-s.fr", "amavisd-new at c-s.fr" ], "Message-Id": "\n <13fb0995a91bdbce71812794d28cb29070daf51e.1617375802.git.christophe.leroy@csgroup.eu>", "In-Reply-To": "<cover.1617375802.git.christophe.leroy@csgroup.eu>", "References": "<cover.1617375802.git.christophe.leroy@csgroup.eu>", "From": "Christophe Leroy <christophe.leroy@csgroup.eu>", "Subject": "[PATCH v4 04/20] drivers: firmware: efi: use cmdline building\n function", "To": "will@kernel.org, danielwa@cisco.com, robh@kernel.org,\n daniel@gimpelevich.san-francisco.ca.us, arnd@kernel.org,\n akpm@linux-foundation.org", "Date": "Fri, 2 Apr 2021 15:18:05 +0000 (UTC)", "X-BeenThere": "linuxppc-dev@lists.ozlabs.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Linux on PowerPC Developers Mail List <linuxppc-dev.lists.ozlabs.org>", "List-Unsubscribe": "<https://lists.ozlabs.org/options/linuxppc-dev>,\n <mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://lists.ozlabs.org/pipermail/linuxppc-dev/>", "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>", "List-Help": "<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>", "List-Subscribe": "<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n <mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>", "Cc": "linux-arch@vger.kernel.org, devicetree@vger.kernel.org,\n microblaze <monstr@monstr.eu>, linux-xtensa@linux-xtensa.org,\n linux-sh@vger.kernel.org, linux-hexagon@vger.kernel.org, x86@kernel.org,\n linux-kernel@vger.kernel.org, nios2 <ley.foon.tan@intel.com>,\n linux-mips@vger.kernel.org, linux-mm@kvack.org,\n openrisc@lists.librecores.org,\n sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org,\n linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org", "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org", "Sender": "\"Linuxppc-dev\"\n <linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>" }, "content": "Use cmdline building function in EFI.\n\nEFI cannot use pr_err() and doesn't have a .init.data section,\nso use the __cmdline_build() internal function and provides\nboth a source and a destination.\n\nRemove the handling of too long command lines as it is handled\nby the generic CMDLINE.\n\nSigned-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>\n---\nv4: New\n---\n .../firmware/efi/libstub/efi-stub-helper.c | 35 ++++++++++---------\n drivers/firmware/efi/libstub/efi-stub.c | 23 +++---------\n drivers/firmware/efi/libstub/efistub.h | 2 +-\n drivers/firmware/efi/libstub/x86-stub.c | 18 +++-------\n 4 files changed, 29 insertions(+), 49 deletions(-)", "diff": "diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c\nindex aa8da0a49829..9f60d471d650 100644\n--- a/drivers/firmware/efi/libstub/efi-stub-helper.c\n+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c\n@@ -13,6 +13,7 @@\n #include <linux/efi.h>\n #include <linux/kernel.h>\n #include <linux/printk.h> /* For CONSOLE_LOGLEVEL_* */\n+#include <linux/cmdline.h>\n #include <asm/efi.h>\n #include <asm/setup.h>\n \n@@ -339,13 +340,13 @@ void efi_apply_loadoptions_quirk(const void **load_options, int *load_options_si\n * Size of memory allocated return in *cmd_line_len.\n * Returns NULL on error.\n */\n-char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len)\n+char *efi_convert_cmdline(efi_loaded_image_t *image)\n {\n \tconst u16 *s2;\n-\tunsigned long cmdline_addr = 0;\n+\tunsigned long cmdline_addr = 0, options_addr = 0;\n \tint options_chars = efi_table_attr(image, load_options_size);\n \tconst u16 *options = efi_table_attr(image, load_options);\n-\tint options_bytes = 0, safe_options_bytes = 0; /* UTF-8 bytes */\n+\tint options_bytes = 0; /* UTF-8 bytes */\n \tbool in_quote = false;\n \tefi_status_t status;\n \n@@ -354,16 +355,12 @@ char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len)\n \n \tif (options) {\n \t\ts2 = options;\n-\t\twhile (options_bytes < COMMAND_LINE_SIZE && options_chars--) {\n+\t\twhile (options_chars--) {\n \t\t\tu16 c = *s2++;\n \n \t\t\tif (c < 0x80) {\n \t\t\t\tif (c == L'\\0' || c == L'\\n')\n \t\t\t\t\tbreak;\n-\t\t\t\tif (c == L'\"')\n-\t\t\t\t\tin_quote = !in_quote;\n-\t\t\t\telse if (!in_quote && isspace((char)c))\n-\t\t\t\t\tsafe_options_bytes = options_bytes;\n \n \t\t\t\toptions_bytes++;\n \t\t\t\tcontinue;\n@@ -395,24 +392,30 @@ char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len)\n \t\t\t\t}\n \t\t\t}\n \t\t}\n-\t\tif (options_bytes >= COMMAND_LINE_SIZE) {\n-\t\t\toptions_bytes = safe_options_bytes;\n-\t\t\tefi_err(\"Command line is too long: truncated to %d bytes\\n\",\n-\t\t\t\toptions_bytes);\n-\t\t}\n \t}\n \n \toptions_bytes++;\t/* NUL termination */\n \n \tstatus = efi_bs_call(allocate_pool, EFI_LOADER_DATA, options_bytes,\n-\t\t\t (void **)&cmdline_addr);\n+\t\t\t (void **)&options_addr);\n \tif (status != EFI_SUCCESS)\n \t\treturn NULL;\n \n-\tsnprintf((char *)cmdline_addr, options_bytes, \"%.*ls\",\n+\tsnprintf((char *)options_addr, options_bytes, \"%.*ls\",\n \t\t options_bytes - 1, options);\n \n-\t*cmd_line_len = options_bytes;\n+\tstatus = efi_bs_call(allocate_pool, EFI_LOADER_DATA, COMMAND_LINE_SIZE,\n+\t\t\t (void **)&cmdline_addr);\n+\tif (status != EFI_SUCCESS) {\n+\t\tefi_bs_call(free_pool, (void *)options_addr);\n+\t\treturn NULL;\n+\t}\n+\n+\tif (!__cmdline_build((char *)cmdline_addr, (char *)options_addr))\n+\t\tefi_err(\"Command line is too long\\n\");\n+\n+\tefi_bs_call(free_pool, (void *)cmdline_addr);\n+\n \treturn (char *)cmdline_addr;\n }\n \ndiff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c\nindex 26e69788f27a..b79ee76f2e95 100644\n--- a/drivers/firmware/efi/libstub/efi-stub.c\n+++ b/drivers/firmware/efi/libstub/efi-stub.c\n@@ -127,7 +127,6 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,\n \tunsigned long fdt_addr = 0; /* Original DTB */\n \tunsigned long fdt_size = 0;\n \tchar *cmdline_ptr = NULL;\n-\tint cmdline_size = 0;\n \tefi_guid_t loaded_image_proto = LOADED_IMAGE_PROTOCOL_GUID;\n \tunsigned long reserve_addr = 0;\n \tunsigned long reserve_size = 0;\n@@ -165,29 +164,17 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,\n \t * protocol. We are going to copy the command line into the\n \t * device tree, so this can be allocated anywhere.\n \t */\n-\tcmdline_ptr = efi_convert_cmdline(image, &cmdline_size);\n+\tcmdline_ptr = efi_convert_cmdline(image);\n \tif (!cmdline_ptr) {\n \t\tefi_err(\"getting command line via LOADED_IMAGE_PROTOCOL\\n\");\n \t\tstatus = EFI_OUT_OF_RESOURCES;\n \t\tgoto fail;\n \t}\n \n-\tif (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||\n-\t IS_ENABLED(CONFIG_CMDLINE_FORCE) ||\n-\t cmdline_size == 0) {\n-\t\tstatus = efi_parse_options(CONFIG_CMDLINE);\n-\t\tif (status != EFI_SUCCESS) {\n-\t\t\tefi_err(\"Failed to parse options\\n\");\n-\t\t\tgoto fail_free_cmdline;\n-\t\t}\n-\t}\n-\n-\tif (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0) {\n-\t\tstatus = efi_parse_options(cmdline_ptr);\n-\t\tif (status != EFI_SUCCESS) {\n-\t\t\tefi_err(\"Failed to parse options\\n\");\n-\t\t\tgoto fail_free_cmdline;\n-\t\t}\n+\tstatus = efi_parse_options(cmdline_ptr);\n+\tif (status != EFI_SUCCESS) {\n+\t\tefi_err(\"Failed to parse options\\n\");\n+\t\tgoto fail_free_cmdline;\n \t}\n \n \tefi_info(\"Booting Linux Kernel...\\n\");\ndiff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h\nindex cde0a2ef507d..2f872c48b20b 100644\n--- a/drivers/firmware/efi/libstub/efistub.h\n+++ b/drivers/firmware/efi/libstub/efistub.h\n@@ -780,7 +780,7 @@ void efi_free(unsigned long size, unsigned long addr);\n \n void efi_apply_loadoptions_quirk(const void **load_options, int *load_options_size);\n \n-char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len);\n+char *efi_convert_cmdline(efi_loaded_image_t *image);\n \n efi_status_t efi_get_memory_map(struct efi_boot_memmap *map);\n \ndiff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c\nindex 28659276b6ba..0f6a33149ef7 100644\n--- a/drivers/firmware/efi/libstub/x86-stub.c\n+++ b/drivers/firmware/efi/libstub/x86-stub.c\n@@ -359,7 +359,6 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,\n \tstruct setup_header *hdr;\n \tvoid *image_base;\n \tefi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID;\n-\tint options_size = 0;\n \tefi_status_t status;\n \tchar *cmdline_ptr;\n \n@@ -404,7 +403,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,\n \thdr->type_of_loader = 0x21;\n \n \t/* Convert unicode cmdline to ascii */\n-\tcmdline_ptr = efi_convert_cmdline(image, &options_size);\n+\tcmdline_ptr = efi_convert_cmdline(image);\n \tif (!cmdline_ptr)\n \t\tgoto fail;\n \n@@ -674,6 +673,8 @@ unsigned long efi_main(efi_handle_t handle,\n \tunsigned long buffer_start, buffer_end;\n \tstruct setup_header *hdr = &boot_params->hdr;\n \tefi_status_t status;\n+\tunsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |\n+\t\t\t\t ((u64)boot_params->ext_cmd_line_ptr << 32));\n \n \tefi_system_table = sys_table_arg;\n \n@@ -735,22 +736,11 @@ unsigned long efi_main(efi_handle_t handle,\n \t\timage_offset = 0;\n \t}\n \n-#ifdef CONFIG_CMDLINE_BOOL\n-\tstatus = efi_parse_options(CONFIG_CMDLINE);\n+\tstatus = efi_parse_options((char *)cmdline_paddr);\n \tif (status != EFI_SUCCESS) {\n \t\tefi_err(\"Failed to parse options\\n\");\n \t\tgoto fail;\n \t}\n-#endif\n-\tif (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {\n-\t\tunsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |\n-\t\t\t\t\t ((u64)boot_params->ext_cmd_line_ptr << 32));\n-\t\tstatus = efi_parse_options((char *)cmdline_paddr);\n-\t\tif (status != EFI_SUCCESS) {\n-\t\t\tefi_err(\"Failed to parse options\\n\");\n-\t\t\tgoto fail;\n-\t\t}\n-\t}\n \n \t/*\n \t * At this point, an initrd may already have been loaded by the\n", "prefixes": [ "v4", "04/20" ] }