disable efi watchdog

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

disable efi watchdog

Jonathan Gray-11
The UEFI specification states a watchdog should be armed for 5 minutes.
Stop this from resetting a system when in efiboot.

Index: amd64/stand/efiboot/efiboot.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/efiboot.c,v
retrieving revision 1.28
diff -u -p -r1.28 efiboot.c
--- amd64/stand/efiboot/efiboot.c 25 Nov 2017 19:02:07 -0000 1.28
+++ amd64/stand/efiboot/efiboot.c 11 Feb 2018 05:25:11 -0000
@@ -81,6 +81,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
  RS = ST->RuntimeServices;
  IH = image;
 
+ /* disable reset by watchdog after 5 minutes */
+ EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
+
  efi_video_init();
  efi_heap_init();
 
Index: armv7/stand/efiboot/efiboot.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/stand/efiboot/efiboot.c,v
retrieving revision 1.19
diff -u -p -r1.19 efiboot.c
--- armv7/stand/efiboot/efiboot.c 21 Aug 2017 20:05:32 -0000 1.19
+++ armv7/stand/efiboot/efiboot.c 11 Feb 2018 05:25:11 -0000
@@ -71,6 +71,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
  BS = ST->BootServices;
  IH = image;
 
+ /* disable reset by watchdog after 5 minutes */
+ EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
+
  status = EFI_CALL(BS->HandleProtocol, image, &imgp_guid,
     (void **)&imgp);
  if (status == EFI_SUCCESS)
Index: arm64/stand/efiboot/efiboot.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/stand/efiboot/efiboot.c,v
retrieving revision 1.15
diff -u -p -r1.15 efiboot.c
--- arm64/stand/efiboot/efiboot.c 6 Feb 2018 20:35:21 -0000 1.15
+++ arm64/stand/efiboot/efiboot.c 11 Feb 2018 05:25:12 -0000
@@ -74,6 +74,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
  BS = ST->BootServices;
  IH = image;
 
+ /* disable reset by watchdog after 5 minutes */
+ EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
+
  status = EFI_CALL(BS->HandleProtocol, image, &imgp_guid,
     (void **)&imgp);
  if (status == EFI_SUCCESS)

Reply | Threaded
Open this post in threaded view
|

Re: disable efi watchdog

Jonathan Gray-11
On Sun, Feb 11, 2018 at 04:38:18PM +1100, Jonathan Gray wrote:
> The UEFI specification states a watchdog should be armed for 5 minutes.
> Stop this from resetting a system when in efiboot.

Anyone?  It is annoying to have the system reset itself when trying
to do something in boot or purposefully leaving it at the prompt.

>
> Index: amd64/stand/efiboot/efiboot.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/efiboot.c,v
> retrieving revision 1.28
> diff -u -p -r1.28 efiboot.c
> --- amd64/stand/efiboot/efiboot.c 25 Nov 2017 19:02:07 -0000 1.28
> +++ amd64/stand/efiboot/efiboot.c 11 Feb 2018 05:25:11 -0000
> @@ -81,6 +81,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
>   RS = ST->RuntimeServices;
>   IH = image;
>  
> + /* disable reset by watchdog after 5 minutes */
> + EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
> +
>   efi_video_init();
>   efi_heap_init();
>  
> Index: armv7/stand/efiboot/efiboot.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/armv7/stand/efiboot/efiboot.c,v
> retrieving revision 1.19
> diff -u -p -r1.19 efiboot.c
> --- armv7/stand/efiboot/efiboot.c 21 Aug 2017 20:05:32 -0000 1.19
> +++ armv7/stand/efiboot/efiboot.c 11 Feb 2018 05:25:11 -0000
> @@ -71,6 +71,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
>   BS = ST->BootServices;
>   IH = image;
>  
> + /* disable reset by watchdog after 5 minutes */
> + EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
> +
>   status = EFI_CALL(BS->HandleProtocol, image, &imgp_guid,
>      (void **)&imgp);
>   if (status == EFI_SUCCESS)
> Index: arm64/stand/efiboot/efiboot.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/arm64/stand/efiboot/efiboot.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 efiboot.c
> --- arm64/stand/efiboot/efiboot.c 6 Feb 2018 20:35:21 -0000 1.15
> +++ arm64/stand/efiboot/efiboot.c 11 Feb 2018 05:25:12 -0000
> @@ -74,6 +74,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
>   BS = ST->BootServices;
>   IH = image;
>  
> + /* disable reset by watchdog after 5 minutes */
> + EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
> +
>   status = EFI_CALL(BS->HandleProtocol, image, &imgp_guid,
>      (void **)&imgp);
>   if (status == EFI_SUCCESS)
>

Reply | Threaded
Open this post in threaded view
|

Re: disable efi watchdog

Mark Kettenis
> Date: Thu, 1 Mar 2018 16:38:50 +1100
> From: Jonathan Gray <[hidden email]>
>
> On Sun, Feb 11, 2018 at 04:38:18PM +1100, Jonathan Gray wrote:
> > The UEFI specification states a watchdog should be armed for 5 minutes.
> > Stop this from resetting a system when in efiboot.
>
> Anyone?  It is annoying to have the system reset itself when trying
> to do something in boot or purposefully leaving it at the prompt.

I've never actually run into this.  But assuming you've tested this
with both U-Boot and a real UEFI implementation, I'm ok with this.

It'd be interesting to be able to re-arm the watchdog before loading a
kernel and disable it again once the kernel has booted.  But it
doesn't look like it would be possible to do that.

> > Index: amd64/stand/efiboot/efiboot.c
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/efiboot.c,v
> > retrieving revision 1.28
> > diff -u -p -r1.28 efiboot.c
> > --- amd64/stand/efiboot/efiboot.c 25 Nov 2017 19:02:07 -0000 1.28
> > +++ amd64/stand/efiboot/efiboot.c 11 Feb 2018 05:25:11 -0000
> > @@ -81,6 +81,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
> >   RS = ST->RuntimeServices;
> >   IH = image;
> >  
> > + /* disable reset by watchdog after 5 minutes */
> > + EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
> > +
> >   efi_video_init();
> >   efi_heap_init();
> >  
> > Index: armv7/stand/efiboot/efiboot.c
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/armv7/stand/efiboot/efiboot.c,v
> > retrieving revision 1.19
> > diff -u -p -r1.19 efiboot.c
> > --- armv7/stand/efiboot/efiboot.c 21 Aug 2017 20:05:32 -0000 1.19
> > +++ armv7/stand/efiboot/efiboot.c 11 Feb 2018 05:25:11 -0000
> > @@ -71,6 +71,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
> >   BS = ST->BootServices;
> >   IH = image;
> >  
> > + /* disable reset by watchdog after 5 minutes */
> > + EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
> > +
> >   status = EFI_CALL(BS->HandleProtocol, image, &imgp_guid,
> >      (void **)&imgp);
> >   if (status == EFI_SUCCESS)
> > Index: arm64/stand/efiboot/efiboot.c
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/arm64/stand/efiboot/efiboot.c,v
> > retrieving revision 1.15
> > diff -u -p -r1.15 efiboot.c
> > --- arm64/stand/efiboot/efiboot.c 6 Feb 2018 20:35:21 -0000 1.15
> > +++ arm64/stand/efiboot/efiboot.c 11 Feb 2018 05:25:12 -0000
> > @@ -74,6 +74,9 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
> >   BS = ST->BootServices;
> >   IH = image;
> >  
> > + /* disable reset by watchdog after 5 minutes */
> > + EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
> > +
> >   status = EFI_CALL(BS->HandleProtocol, image, &imgp_guid,
> >      (void **)&imgp);
> >   if (status == EFI_SUCCESS)
> >
>
>

Reply | Threaded
Open this post in threaded view
|

Re: disable efi watchdog

Jonathan Gray-11
On Thu, Mar 01, 2018 at 11:15:19AM +0100, Mark Kettenis wrote:

> > Date: Thu, 1 Mar 2018 16:38:50 +1100
> > From: Jonathan Gray <[hidden email]>
> >
> > On Sun, Feb 11, 2018 at 04:38:18PM +1100, Jonathan Gray wrote:
> > > The UEFI specification states a watchdog should be armed for 5 minutes.
> > > Stop this from resetting a system when in efiboot.
> >
> > Anyone?  It is annoying to have the system reset itself when trying
> > to do something in boot or purposefully leaving it at the prompt.
>
> I've never actually run into this.  But assuming you've tested this
> with both U-Boot and a real UEFI implementation, I'm ok with this.

Yes, on a lenovo ideapad that previously reset itself when I was hand
transcribing 'machine memory' output and on armv7/arm64 U-Boot.

>
> It'd be interesting to be able to re-arm the watchdog before loading a
> kernel and disable it again once the kernel has booted.  But it
> doesn't look like it would be possible to do that.

In U-Boot since 2018.01.

commit b3d6090042d4de265c930358aec4d9b96bf3748a
Author: Heinrich Schuchardt <[hidden email]>
Date:   Wed Oct 18 18:13:04 2017 +0200

    efi_loader: implement SetWatchdogTimer
   
    The watchdog is initialized with a 5 minute timeout period.
    It can be reset by SetWatchdogTimer.
    It is stopped by ExitBoottimeServices.
   
    Signed-off-by: Heinrich Schuchardt <[hidden email]>
    Signed-off-by: Alexander Graf <[hidden email]>

 cmd/bootefi.c                 |  1 +
 include/efi_loader.h          |  4 ++
 lib/efi_loader/Makefile       |  2 +-
 lib/efi_loader/efi_boottime.c | 17 ++-------
 lib/efi_loader/efi_watchdog.c | 89 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 15 deletions(-)