From nobody Sat Jun 19 20:55:08 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4E01B11D8A2A for ; Sat, 19 Jun 2021 20:55:08 +0000 (UTC) (envelope-from bugzilla-noreply@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 4G6p2h1VFvz4qrs for ; Sat, 19 Jun 2021 20:55:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 17F541CDF5 for ; Sat, 19 Jun 2021 20:55:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 15JKt7LD012961 for ; Sat, 19 Jun 2021 20:55:07 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 15JKt7ZK012960 for bugs@FreeBSD.org; Sat, 19 Jun 2021 20:55:07 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 256722] [PATCH] EFI boot: Fix boot freeze on some systems Date: Sat, 19 Jun 2021 20:55:08 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: dasebek@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D256722 Bug ID: 256722 Summary: [PATCH] EFI boot: Fix boot freeze on some systems Product: Base System Version: CURRENT Hardware: amd64 OS: Any Status: New Severity: Affects Many People Priority: --- Component: misc Assignee: bugs@FreeBSD.org Reporter: dasebek@gmail.com Created attachment 225941 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D225941&action= =3Dedit [PATCH] efi: loader: Fix a boot freeze on some amd64 systems This is a copy of a patch from Bug 209821. I am creating a new ticket for i= t so that it does not get lost. Users keep reporting that when booting in UEFI m= ode, the boot process freezes after displaying framebuffer information. This pat= ch fixes the problem for me and for some other people who tried it. After this patch gets mainlined, it will be easier to distinguish boot issues caused by this bug from those caused by something else. This patch fixes a bug that seems to be present on all supported FreeBSD versions. This patch addresses a problem that, immediately before the kernel is start= ed, the amd64_tramp function calls the efi_copy_finish function to copy the ker= nel image from a temporary staging area in the memory to the actual memory addr= ess where the kernel expects to be run from. The problem is that the boot loade= r, including the efi_copy_finish function, may have been loaded by the UEFI firmware somewhere in the range where the kernel is being copied to. The efi_copy_finish function may thus overwrite its own instructions by the ker= nel image, causing the system to freeze. This is not a problem for the amd64_tr= amp trampoline itself, which is first copied to a safe memory location before i= t is executed. My patch does the following: - Instead of calling the efi_copy_finish function, which may be located anywhere in the memory, the copy operation is done by the trampoline itself. This is the most important part of the patch. - Adds missing return value checks. - Before the kernel is copied from the staging area, a new efi_verify_destination_type function checks that the target memory area is = safe to use. If not, it only prints a warning message. (This is useful mainly for debugging purposes when a system freezes.) Because I changed the parameters of the trampoline function, I created a new amd64_tramp_inline function and kept the original amd64_tramp intact in ord= er not to break any other existing code. However, the amd64_tramp function does not seem to be used anywhere else in the existing code, so it could be modi= fied directly. The efi_copy_finish function is not needed anymore too. --=20 You are receiving this mail because: You are the assignee for the bug.=