Received: from list by lists.gnu.org with archive (Exim 4.71) id 1dmiwZ-0004Gq-5i for mharc-grub-devel@gnu.org; Tue, 29 Aug 2017 12:00:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmiwW-0004E5-QO for grub-devel@gnu.org; Tue, 29 Aug 2017 12:00:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmiwQ-0007l6-VX for grub-devel@gnu.org; Tue, 29 Aug 2017 12:00:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:60430 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmiwQ-0007ju-Ov for grub-devel@gnu.org; Tue, 29 Aug 2017 12:00:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3A623AEA3; Tue, 29 Aug 2017 16:00:36 +0000 (UTC) From: Alexander Graf To: grub-devel@gnu.org Cc: elliott@hpe.com, mchang@suse.com, Daniel Kiper , phcoder@gmail.com Subject: [PATCH v3 1/2] efi: Move grub_reboot() into kernel Date: Tue, 29 Aug 2017 18:00:34 +0200 Message-Id: <20170829160035.11987-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170829160035.11987-1-agraf@suse.de> References: <20170829160035.11987-1-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 195.135.220.15 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Aug 2017 16:00:46 -0000 The reboot function calls machine_fini() and then reboots the system. Currently it lives in lib/ which means it gets compiled into the reboot module which lives on the heap. In a following patch, I want to free the heap on machine_fini() though, so we would free the memory that the code is running in. That obviously breaks with smarter UEFI implementations. So this patch moves it into the core. That way we ensure that all code running after machine_fini() in the UEFI case is running from memory that got allocated (and gets deallocated) by the UEFI core. Signed-off-by: Alexander Graf --- grub-core/Makefile.core.def | 9 +++++---- include/grub/misc.h | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index a65c27f7f..d01654b12 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -235,6 +235,11 @@ kernel = { arm64_efi = kern/arm64/efi/init.c; arm64_efi = kern/efi/fdt.c; + ia64_efi = lib/efi/reboot.c; + x86_64_efi = lib/efi/reboot.c; + arm_efi = lib/efi/reboot.c; + arm64_efi = lib/efi/reboot.c; + i386_pc = kern/i386/pc/init.c; i386_pc = kern/i386/pc/mmap.c; i386_pc = term/i386/pc/console.c; @@ -872,10 +877,6 @@ module = { name = reboot; i386 = lib/i386/reboot.c; i386 = lib/i386/reboot_trampoline.S; - ia64_efi = lib/efi/reboot.c; - x86_64_efi = lib/efi/reboot.c; - arm_efi = lib/efi/reboot.c; - arm64_efi = lib/efi/reboot.c; powerpc_ieee1275 = lib/ieee1275/reboot.c; sparc64_ieee1275 = lib/ieee1275/reboot.c; mips_arc = lib/mips/arc/reboot.c; diff --git a/include/grub/misc.h b/include/grub/misc.h index 2a9f87cc2..372f009e8 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -396,7 +396,8 @@ grub_abs (int x) } /* Reboot the machine. */ -#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) +#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) || \ + defined (GRUB_MACHINE_EFI) void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn)); #else void grub_reboot (void) __attribute__ ((noreturn)); -- 2.12.3