From owner-freebsd-current@freebsd.org Tue Feb 26 02:58:32 2019 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8701715039FA for ; Tue, 26 Feb 2019 02:58:32 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 15A5692E4A for ; Tue, 26 Feb 2019 02:58:32 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 97F4D17B6C for ; Tue, 26 Feb 2019 02:58:31 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lf1-f46.google.com with SMTP id q12so8528553lfm.0 for ; Mon, 25 Feb 2019 18:58:31 -0800 (PST) X-Gm-Message-State: AHQUAuYUJkiCMl8j6zUP787YgJyueyH7DCB8DGdPkc0Mshc/vOXos9Db CkbpgdTMNjrt5XlqjctbETMOjE9UONZ7wzGJRJA= X-Google-Smtp-Source: AHgI3IaOzbUQNjblGBm4nJbHzlo3+rMsKCEqqqOeP4/WkdXGyhwJ4/lB7CWNj+NYvFFeg1g0A8XTYOPgTEvekPC7TNE= X-Received: by 2002:a19:c50c:: with SMTP id w12mr12214459lfe.53.1551149910132; Mon, 25 Feb 2019 18:58:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kyle Evans Date: Mon, 25 Feb 2019 20:58:18 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: i386 EFI booting is broken (ExitBootServices called in two places) To: Rebecca Cran Cc: FreeBSD Current Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 15A5692E4A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:96.47.64.0/20, country:US] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Feb 2019 02:58:32 -0000 On Mon, Feb 25, 2019 at 8:18 PM Rebecca Cran wrote: > > I've been working on some EFI changes, and in the process found that > i386 booting is broken. On real hardware - my MinnowBoard Turbot - the > loader hangs when calling ExitBootServices, while in a VM I get a panic > saying "exec returned". > > The problem appears to be that ExitBootServices is called twice: > elf32_exec in arch/i386/efimd.c calls bi_load which calls > bi_load_efi_data in bootinfo.c - which calls ExitBootServices the first > time. Then elf32_exec keeps going, and after printing "Start @ 0x....." > calls ldr_enter which tries to call ExitBootServices again - this time > with a mapkey whose value is zero since it never attempts to fetch the > memory map. I'm guessing that subsequently causes the exec to fail. > efimd.c should be garbage collected and the ldr_enter called removed. r328169 removed the copy of bootinfo that demonstrated the expected ordering: bi_load returned ldr_bootinfo(), then elf32_exec finished it off with ldr_enter. These details are captured in MI bootinfo bits nowadays and none of this is of use in the current world.