From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZLyO-0007yN-Dn for mharc-grub-devel@gnu.org; Tue, 08 Sep 2015 12:42:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLyL-0007xt-79 for grub-devel@gnu.org; Tue, 08 Sep 2015 12:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZLyF-0004Iq-Ai for grub-devel@gnu.org; Tue, 08 Sep 2015 12:42:17 -0400 Received: from mail-pa0-x232.google.com ([2607:f8b0:400e:c03::232]:36199) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLyF-0004IH-1z for grub-devel@gnu.org; Tue, 08 Sep 2015 12:42:11 -0400 Received: by padhk3 with SMTP id hk3so43555731pad.3 for ; Tue, 08 Sep 2015 09:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=Q5cb5rn+rb6qb3r3BOahMRiZDsz19t/lR6AlCgcFPUM=; b=tlz48EyriMMRt+CP4MmIDrF/6ZKKboik7FIflY5spRMVozg7bUaU1Rq/aeJaUADfsc MCEYiWbhhB2YnNcUA487T14+hp0ggJ+Qcj55s1ma6T1FETjeoNAi/aXmq1x7KXkY0Hnu BsZBNVGBPwuOQALEPXS1q/LzJ7g3/PBmlpGR0+NnZnpRA3C/ElEJzE/J89Ud4Mu2gXL9 KunFGcwFr+R37Io0zvgtLRPqCaold9ritxlSg1Q8SiXy1zIp42rKjVXNBXAwxT5zqAsu IGBEhJOCD1RBOZSH07QF3iaYVpf0KB3GSESgi799sA/Ro1emkpdGXm7aJzNLGTxhQoHc 7R+g== X-Received: by 10.66.144.200 with SMTP id so8mr49917699pab.63.1441730530508; Tue, 08 Sep 2015 09:42:10 -0700 (PDT) Received: from [192.168.10.113] ([207.198.105.23]) by smtp.gmail.com with ESMTPSA id i9sm3976489pbq.84.2015.09.08.09.42.09 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Sep 2015 09:42:09 -0700 (PDT) Subject: Re: [PATCH] Remove unconditional disablement of the watchdog To: The development of GNU GRUB References: <20150901145133.GK47665@juniper.net> From: =?UTF-8?Q?Vladimir_'=cf=86-coder/phcoder'_Serbinenko?= Message-ID: <55EF0FE0.4060207@gmail.com> Date: Tue, 8 Sep 2015 09:42:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150901145133.GK47665@juniper.net> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ai1oEO2J38uM1U5ba2xsUB5WoV3Fo7G9U" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::232 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 16:42:18 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Ai1oEO2J38uM1U5ba2xsUB5WoV3Fo7G9U Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01.09.2015 07:51, Arthur Mesh wrote: > Starting with d9a0c9413e81d3c0affc6383693bdd28dc863a5c, GRUB unconditio= nally > disables watchdog on EFI platforms. This opens up a window (starting at= GRUB's > grub_efi_init(), until OS re-enables it) when EFI system operates w/o w= atchdog. > If an EFI system gets stuck in that window, the chipset will never rese= t the > system. >=20 > Remove the unconditional disablement of the watchdog, and create a comm= and line > interface to enable/disable watchdog: >=20 This patch will break any current config on systems with watchdog. You need to ensure that: a) watchdog timeout is plenty to load config file even on very slow netboot systems. b) disable watchdog if the config didn't opt-in to have the watchdog. > efi-watchdog (enable|disable) > --- > docs/grub.texi | 8 ++++++ > grub-core/kern/efi/init.c | 60 +++++++++++++++++++++++++++++++++++++= +++++--- > 2 files changed, 65 insertions(+), 3 deletions(-) >=20 > diff --git a/docs/grub.texi b/docs/grub.texi > index b9f41a7..4cfd50c 100644 > --- a/docs/grub.texi > +++ b/docs/grub.texi > @@ -3784,6 +3784,7 @@ you forget a command, you can run the command @co= mmand{help} > * distrust:: Remove a pubkey from trusted keys > * drivemap:: Map a drive to another > * echo:: Display a line of text > +* efi-watchdog:: Manipulate EFI watchdog > * eval:: Evaluate agruments as GRUB commands > * export:: Export an environment variable > * false:: Do nothing, unsuccessfully > @@ -4192,6 +4193,13 @@ When interpreting backslash escapes, backslash f= ollowed by any other > character will print that character. > @end deffn > =20 > +@node efi-watchdog > +@subsection efi-watchdog > + > +@deffn Command efi-watchdog enable|disable > +Enable or disable the system's watchdog timer. Only available in EFI t= argeted > +GRUB. > +@end deffn > =20 > @node eval > @subsection eval > diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c > index e9c85de..f8a79eb 100644 > --- a/grub-core/kern/efi/init.c > +++ b/grub-core/kern/efi/init.c > @@ -25,9 +25,62 @@ > #include > #include > #include > +#include > +#include > =20 > grub_addr_t grub_modbase; > =20 > +static grub_command_t cmd_list; > + > +static grub_err_t > +grub_cmd_efi_watchdog (grub_command_t cmd __attribute__ ((unused)), > + int argc, char **args) > +{ > + long input; > + grub_efi_status_t status; > + grub_efi_uintn_t timeout; > + > + if (argc < 1) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + N_("efi-watchdog (enable|disable) ")); > + > + if (grub_strcasecmp (args[0], "enable") =3D=3D 0) { > + > + if (argc !=3D 2) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + N_("efi-watchdog enable ")); > + > + input =3D grub_strtol (args[1], 0, 0); > + > + if (input >=3D 0) { > + timeout =3D input; > + } else { > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + N_(" must be non-negative")); > + } > + > + } else if (grub_strcasecmp (args[0], "disable") =3D=3D 0) { > + > + if (argc !=3D 1) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + N_("efi-watchdog disable")); > + timeout =3D 0; > + > + } else { > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + N_("efi-watchdog (enable|disable) ")); > + } > + > + status =3D efi_call_4 (grub_efi_system_table->boot_services->set_w= atchdog_timer, > + timeout, 0, sizeof(L"GRUB"), L"GRUB"); > + > + if (status !=3D GRUB_EFI_SUCCESS) > + return grub_error (GRUB_ERR_BUG, > + N_("EFI SetWatchdogTimer() bug")); > + else > + return GRUB_ERR_NONE; > +} > + > void > grub_efi_init (void) > { > @@ -39,10 +92,10 @@ grub_efi_init (void) > /* Initialize the memory management system. */ > grub_efi_mm_init (); > =20 > - efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer= , > - 0, 0, 0, NULL); > - > grub_efidisk_init (); > + > + cmd_list =3D grub_register_command ("efi-watchdog", grub_cmd_efi_wat= chdog, 0, > + N_("Enable/Disable system's watchdog timer.")); > } > =20 > void (*grub_efi_net_config) (grub_efi_handle_t hnd,=20 > @@ -77,4 +130,5 @@ grub_efi_fini (void) > { > grub_efidisk_fini (); > grub_console_fini (); > + grub_unregister_command (cmd_list); > } >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >=20 --Ai1oEO2J38uM1U5ba2xsUB5WoV3Fo7G9U Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iF4EAREKAAYFAlXvD+AACgkQmBXlbbo5nOs4QgD8CoFRaVFZ84zmqyN8aEBzXtup KBuGk1PyNNgyYVfK0ncA/20qapd1aqyjSdBO73VPiv7lRB7rUFkZ2cTikDU5C/s1 =oX+5 -----END PGP SIGNATURE----- --Ai1oEO2J38uM1U5ba2xsUB5WoV3Fo7G9U--