From owner-svn-src-stable@freebsd.org Thu Feb 11 17:57:44 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4229DAA4B8A; Thu, 11 Feb 2016 17:57:44 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED1E0DC4; Thu, 11 Feb 2016 17:57:43 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1BHvgkM056312; Thu, 11 Feb 2016 17:57:42 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1BHvgdd056311; Thu, 11 Feb 2016 17:57:42 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201602111757.u1BHvgdd056311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Thu, 11 Feb 2016 17:57:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r295539 - stable/10/sys/boot/efi/boot1 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2016 17:57:44 -0000 Author: smh Date: Thu Feb 11 17:57:42 2016 New Revision: 295539 URL: https://svnweb.freebsd.org/changeset/base/295539 Log: MFC r294768: Process /boot/config and /boot.config during EFI boot Approved by: re (marius) Sponsored by: Multiplay Modified: stable/10/sys/boot/efi/boot1/boot1.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/efi/boot1/boot1.c ============================================================================== --- stable/10/sys/boot/efi/boot1/boot1.c Thu Feb 11 17:56:09 2016 (r295538) +++ stable/10/sys/boot/efi/boot1/boot1.c Thu Feb 11 17:57:42 2016 (r295539) @@ -91,13 +91,41 @@ Free(void *buf, const char *file __unuse void try_load(const boot_module_t *mod) { - size_t bufsize; + size_t bufsize, cmdsize; void *buf; + char *cmd; dev_info_t *dev; EFI_HANDLE loaderhandle; EFI_LOADED_IMAGE *loaded_image; EFI_STATUS status; + /* + * Read in and parse the command line from /boot.config or /boot/config, + * if present. We'll pass it the next stage via a simple ASCII + * string. loader.efi has a hack for ASCII strings, so we'll use that to + * keep the size down here. We only try to read the alternate file if + * we get EFI_NOT_FOUND because all other errors mean that the boot_module + * had troubles with the filesystem. We could return early, but we'll let + * loading the actual kernel sort all that out. Since these files are + * optional, we don't report errors in trying to read them. + */ + cmd = NULL; + cmdsize = 0; + status = mod->load(PATH_DOTCONFIG, &dev, &buf, &bufsize); + if (status == EFI_NOT_FOUND) + status = mod->load(PATH_CONFIG, &dev, &buf, &bufsize); + if (status == EFI_SUCCESS) { + cmdsize = bufsize + 1; + cmd = malloc(cmdsize); + if (cmd == NULL) { + free(buf); + return; + } + memcpy(cmd, buf, bufsize); + cmd[bufsize] = '\0'; + free(buf); + } + status = mod->load(PATH_LOADER_EFI, &dev, &buf, &bufsize); if (status == EFI_NOT_FOUND) return; @@ -115,6 +143,9 @@ try_load(const boot_module_t *mod) return; } + if (cmd != NULL) + printf(" command args: %s\n", cmd); + if ((status = bs->HandleProtocol(loaderhandle, &LoadedImageGUID, (VOID**)&loaded_image)) != EFI_SUCCESS) { printf("Failed to query LoadedImage provided by %s (%lu)\n", @@ -123,11 +154,16 @@ try_load(const boot_module_t *mod) } loaded_image->DeviceHandle = dev->devhandle; + loaded_image->LoadOptionsSize = cmdsize; + loaded_image->LoadOptions = cmd; if ((status = bs->StartImage(loaderhandle, NULL, NULL)) != EFI_SUCCESS) { printf("Failed to start image provided by %s (%lu)\n", mod->name, EFI_ERROR_CODE(status)); + free(cmd); + loaded_image->LoadOptionsSize = 0; + loaded_image->LoadOptions = NULL; return; } }