]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[prefix] Remove userptr_t from command line image construction
authorMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2025 22:54:01 +0000 (23:54 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2025 23:30:34 +0000 (00:30 +0100)
Simplify cmdline_init() by assuming that the externally provided
command line is directly accessible via pointer dereferences.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/core/runtime.c

index 2d2a1067457b40682bbc0420ddb462ff8bb9e342..1fdf80497416fcc46b953ae0acb0b25f47c85059 100644 (file)
@@ -114,9 +114,7 @@ static void cmdline_strip ( char *cmdline, const char *cruft ) {
  * @ret rc             Return status code
  */
 static int cmdline_init ( void ) {
-       userptr_t cmdline_user;
        char *cmdline;
-       size_t len;
        int rc;
 
        /* Do nothing if no command line was specified */
@@ -124,19 +122,15 @@ static int cmdline_init ( void ) {
                DBGC ( colour, "RUNTIME found no command line\n" );
                return 0;
        }
-       cmdline_user = phys_to_virt ( cmdline_phys );
-       len = ( strlen ( cmdline_user ) + 1 /* NUL */ );
 
        /* Allocate and copy command line */
-       cmdline_copy = malloc ( len );
+       cmdline_copy = strdup ( phys_to_virt ( cmdline_phys ) );
        if ( ! cmdline_copy ) {
-               DBGC ( colour, "RUNTIME could not allocate %zd bytes for "
-                      "command line\n", len );
+               DBGC ( colour, "RUNTIME could not allocate command line\n" );
                rc = -ENOMEM;
                goto err_alloc_cmdline_copy;
        }
        cmdline = cmdline_copy;
-       copy_from_user ( cmdline, cmdline_user, 0, len );
        DBGC ( colour, "RUNTIME found command line \"%s\" at %08x\n",
               cmdline, cmdline_phys );
 
@@ -151,7 +145,7 @@ static int cmdline_init ( void ) {
        DBGC ( colour, "RUNTIME using command line \"%s\"\n", cmdline );
 
        /* Prepare and register image */
-       cmdline_image.data = virt_to_user ( cmdline );
+       cmdline_image.data = cmdline;
        cmdline_image.len = strlen ( cmdline );
        if ( cmdline_image.len ) {
                if ( ( rc = register_image ( &cmdline_image ) ) != 0 ) {