From owner-dev-commits-src-main@freebsd.org Thu Aug 12 07:24:20 2021 Return-Path: <owner-dev-commits-src-main@freebsd.org> Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9A7F8665719; Thu, 12 Aug 2021 07:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GldVD3m69z3sZ8; Thu, 12 Aug 2021 07:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6A45B1EADC; Thu, 12 Aug 2021 07:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17C7OKKj043737; Thu, 12 Aug 2021 07:24:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C7OK0X043736; Thu, 12 Aug 2021 07:24:20 GMT (envelope-from git) Date: Thu, 12 Aug 2021 07:24:20 GMT Message-Id: <202108120724.17C7OK0X043736@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Roger Pau Monn=C3=A9?= <royger@FreeBSD.org> Subject: git: 5e4279a8f35a - main - loader: fix multiboot loading on UEFI MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5e4279a8f35aa4b46debf728d3f743d64f15aaf8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository <dev-commits-src-main.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/dev-commits-src-main>, <mailto:dev-commits-src-main-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/dev-commits-src-main/> List-Post: <mailto:dev-commits-src-main@freebsd.org> List-Help: <mailto:dev-commits-src-main-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main>, <mailto:dev-commits-src-main-request@freebsd.org?subject=subscribe> X-List-Received-Date: Thu, 12 Aug 2021 07:24:20 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=5e4279a8f35aa4b46debf728d3f743d64f15aaf8 commit 5e4279a8f35aa4b46debf728d3f743d64f15aaf8 Author: Roger Pau Monné <royger@FreeBSD.org> AuthorDate: 2021-08-11 14:55:10 +0000 Commit: Roger Pau Monné <royger@FreeBSD.org> CommitDate: 2021-08-12 07:18:33 +0000 loader: fix multiboot loading on UEFI The Xen kernel has no symbol tables, so calling lookup_symbol against it triggers the following Divide by Zero fault: Loading Xen kernel... /boot/xen data=0x2809c8+0x149638 | !!!! X64 Exception Type - 00(#DE - Divide Error) CPU Apic ID - 00000000 !!!! Fix lookup_symbol to prevent the #DE fault from happening if the symbol table is not loaded and also fix loadfile_raw to mark multiboot kernels as relocatable, since the only multiboot kernel supported is Xen and was already unconditionally booted as relocatable. Fixes: f75caed644a5 ('amd64 UEFI loader: stop copying staging area to 2M physical') Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D31507 --- stand/common/load_elf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index 9ae91036dbb4..c163b50c9737 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -447,7 +447,7 @@ __elfN(loadfile_raw)(char *filename, uint64_t dest, *result = (struct preloaded_file *)fp; err = 0; #ifdef __amd64__ - fp->f_kernphys_relocatable = is_kernphys_relocatable(&ef); + fp->f_kernphys_relocatable = multiboot || is_kernphys_relocatable(&ef); #endif goto out; @@ -1253,6 +1253,11 @@ __elfN(lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym *symp, char *strp; unsigned long hash; + if (ef->nbuckets == 0) { + printf(__elfN(bad_symtable)); + return ENOENT; + } + hash = elf_hash(name); COPYOUT(&ef->buckets[hash % ef->nbuckets], &symnum, sizeof(symnum));