linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [REGRESSION] Failure to write the NVRAM variables starting from kernel 6.0 on T2 Macs
@ 2022-10-19 19:26 Aditya Garg
  2022-10-19 21:23 ` Ard Biesheuvel
  0 siblings, 1 reply; 6+ messages in thread
From: Aditya Garg @ 2022-10-19 19:26 UTC (permalink / raw)
  To: matthew.garrett, jk, ardb, linux-efi, linux-kernel; +Cc: Orlando Chamberlain

Starting from linux kernel 6.0, the ability to write to the NVRAM has been lost on T2 Macs.

This has been observed especially during installation of boot loaders like GRUB, causing errors as shown :-

Installing for x86_64-efi platform.
grub-install: warning: Cannot set EFI variable Boot0001.
grub-install: warning: efivarfs_set_variable: writing to fd 7 failed: Invalid argument.
grub-install: warning: _efi_set_variable_mode: ops->set_variable() failed: Invalid argument.
grub-install: error: failed to register the EFI boot entry: Invalid argument.

I couldn't find any relevant error in journalctl though, but I still am posting my journalctl just in case I missed any error.

https://gist.github.com/AdityaGarg8/da7a9a2c891f5b2f68f71dc0d0e77f9a

Regards
Aditya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [REGRESSION] Failure to write the NVRAM variables starting from kernel 6.0 on T2 Macs
  2022-10-19 19:26 [REGRESSION] Failure to write the NVRAM variables starting from kernel 6.0 on T2 Macs Aditya Garg
@ 2022-10-19 21:23 ` Ard Biesheuvel
  2022-10-20 10:54   ` Aditya Garg
  2022-10-26 21:18   ` Aditya Garg
  0 siblings, 2 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2022-10-19 21:23 UTC (permalink / raw)
  To: Aditya Garg
  Cc: matthew.garrett, jk, linux-efi, linux-kernel, Orlando Chamberlain

Hello Aditya

On Wed, 19 Oct 2022 at 21:26, Aditya Garg <gargaditya08@live.com> wrote:
>
> Starting from linux kernel 6.0, the ability to write to the NVRAM has been lost on T2 Macs.
>
> This has been observed especially during installation of boot loaders like GRUB, causing errors as shown :-
>
> Installing for x86_64-efi platform.
> grub-install: warning: Cannot set EFI variable Boot0001.
> grub-install: warning: efivarfs_set_variable: writing to fd 7 failed: Invalid argument.
> grub-install: warning: _efi_set_variable_mode: ops->set_variable() failed: Invalid argument.
> grub-install: error: failed to register the EFI boot entry: Invalid argument.
>

Thanks for the report. I did identify an issue in some refactoring
work of the efivars layer that went into 6.0

Can you please check whether the change below fixes the issue for you?

diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index dd74d2ad3184..35edba93cf14 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -209,7 +209,7 @@ efivar_set_variable_blocking(efi_char16_t *name,
efi_guid_t *vendor,
        if (data_size > 0) {
                status = check_var_size(attr, data_size +
                                              ucs2_strsize(name, 1024));
-               if (status != EFI_SUCCESS)
+               if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
                        return status;
        }
        return __efivars->ops->set_variable(name, vendor, attr,
data_size, data);
@@ -242,7 +242,7 @@ efi_status_t
efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor,
        if (data_size > 0) {
                status = check_var_size_nonblocking(attr, data_size +

ucs2_strsize(name, 1024));
-               if (status != EFI_SUCCESS)
+               if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
                        return status;
        }
        return setvar(name, vendor, attr, data_size, data);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [REGRESSION] Failure to write the NVRAM variables starting from kernel 6.0 on T2 Macs
  2022-10-19 21:23 ` Ard Biesheuvel
@ 2022-10-20 10:54   ` Aditya Garg
  2022-10-26 21:18   ` Aditya Garg
  1 sibling, 0 replies; 6+ messages in thread
From: Aditya Garg @ 2022-10-20 10:54 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: matthew.garrett, jk, linux-efi, linux-kernel, Orlando Chamberlain

Hi Ard

> On 20-Oct-2022, at 2:53 AM, Ard Biesheuvel <ardb@kernel.org> wrote:
> 
> Hello Aditya
> 
> Thanks for the report. I did identify an issue in some refactoring
> work of the efivars layer that went into 6.0
> 
> Can you please check whether the change below fixes the issue for you?

The patch given below fixes the issue for me.

> 
> diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
> index dd74d2ad3184..35edba93cf14 100644
> --- a/drivers/firmware/efi/vars.c
> +++ b/drivers/firmware/efi/vars.c
> @@ -209,7 +209,7 @@ efivar_set_variable_blocking(efi_char16_t *name,
> efi_guid_t *vendor,
>        if (data_size > 0) {
>                status = check_var_size(attr, data_size +
>                                              ucs2_strsize(name, 1024));
> -               if (status != EFI_SUCCESS)
> +               if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
>                        return status;
>        }
>        return __efivars->ops->set_variable(name, vendor, attr,
> data_size, data);
> @@ -242,7 +242,7 @@ efi_status_t
> efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor,
>        if (data_size > 0) {
>                status = check_var_size_nonblocking(attr, data_size +
> 
> ucs2_strsize(name, 1024));
> -               if (status != EFI_SUCCESS)
> +               if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
>                        return status;
>        }
>        return setvar(name, vendor, attr, data_size, data);

Thanks
Aditya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [REGRESSION] Failure to write the NVRAM variables starting from kernel 6.0 on T2 Macs
  2022-10-19 21:23 ` Ard Biesheuvel
  2022-10-20 10:54   ` Aditya Garg
@ 2022-10-26 21:18   ` Aditya Garg
  2022-10-26 21:20     ` Ard Biesheuvel
  1 sibling, 1 reply; 6+ messages in thread
From: Aditya Garg @ 2022-10-26 21:18 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: matthew.garrett, jk, linux-efi, linux-kernel, Orlando Chamberlain

Hi Ard

Just a friendly reminder to get updates on the patch you asked me to test, as it seems to fix my issue.

> Thanks for the report. I did identify an issue in some refactoring
> work of the efivars layer that went into 6.0
> 
> Can you please check whether the change below fixes the issue for you?
> 
> diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
> index dd74d2ad3184..35edba93cf14 100644
> --- a/drivers/firmware/efi/vars.c
> +++ b/drivers/firmware/efi/vars.c
> @@ -209,7 +209,7 @@ efivar_set_variable_blocking(efi_char16_t *name,
> efi_guid_t *vendor,
>        if (data_size > 0) {
>                status = check_var_size(attr, data_size +
>                                              ucs2_strsize(name, 1024));
> -               if (status != EFI_SUCCESS)
> +               if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
>                        return status;
>        }
>        return __efivars->ops->set_variable(name, vendor, attr,
> data_size, data);
> @@ -242,7 +242,7 @@ efi_status_t
> efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor,
>        if (data_size > 0) {
>                status = check_var_size_nonblocking(attr, data_size +
> 
> ucs2_strsize(name, 1024));
> -               if (status != EFI_SUCCESS)
> +               if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
>                        return status;
>        }
>        return setvar(name, vendor, attr, data_size, data);

Regards
Aditya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [REGRESSION] Failure to write the NVRAM variables starting from kernel 6.0 on T2 Macs
  2022-10-26 21:18   ` Aditya Garg
@ 2022-10-26 21:20     ` Ard Biesheuvel
  2022-10-27  4:33       ` Aditya Garg
  0 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2022-10-26 21:20 UTC (permalink / raw)
  To: Aditya Garg
  Cc: matthew.garrett, jk, linux-efi, linux-kernel, Orlando Chamberlain

On Wed, 26 Oct 2022 at 23:18, Aditya Garg <gargaditya08@live.com> wrote:
>
> Hi Ard
>
> Just a friendly reminder to get updates on the patch you asked me to test, as it seems to fix my issue.
>

This should be fixed now in v6.1-rc2


> > Thanks for the report. I did identify an issue in some refactoring
> > work of the efivars layer that went into 6.0
> >
> > Can you please check whether the change below fixes the issue for you?
> >
> > diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
> > index dd74d2ad3184..35edba93cf14 100644
> > --- a/drivers/firmware/efi/vars.c
> > +++ b/drivers/firmware/efi/vars.c
> > @@ -209,7 +209,7 @@ efivar_set_variable_blocking(efi_char16_t *name,
> > efi_guid_t *vendor,
> >        if (data_size > 0) {
> >                status = check_var_size(attr, data_size +
> >                                              ucs2_strsize(name, 1024));
> > -               if (status != EFI_SUCCESS)
> > +               if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
> >                        return status;
> >        }
> >        return __efivars->ops->set_variable(name, vendor, attr,
> > data_size, data);
> > @@ -242,7 +242,7 @@ efi_status_t
> > efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor,
> >        if (data_size > 0) {
> >                status = check_var_size_nonblocking(attr, data_size +
> >
> > ucs2_strsize(name, 1024));
> > -               if (status != EFI_SUCCESS)
> > +               if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
> >                        return status;
> >        }
> >        return setvar(name, vendor, attr, data_size, data);
>
> Regards
> Aditya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [REGRESSION] Failure to write the NVRAM variables starting from kernel 6.0 on T2 Macs
  2022-10-26 21:20     ` Ard Biesheuvel
@ 2022-10-27  4:33       ` Aditya Garg
  0 siblings, 0 replies; 6+ messages in thread
From: Aditya Garg @ 2022-10-27  4:33 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: matthew.garrett, jk, linux-efi, linux-kernel, Orlando Chamberlain

Hi Ard

> 
> This should be fixed now in v6.1-rc2

I tested 6.1-rc2 but the issue isn’t fixed yet.

I guess you had applied the patch in the link below to fix the issue right?

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/firmware/efi?h=v6.1-rc2&id=8a254d90a77580244ec57e82bca7eb65656cc167

Here is the build log of the kernel I compiled, just in case you need :-

https://github.com/t2linux/T2-Ubuntu-Kernel/actions/runs/3319113145/jobs/5483863180

Although if I apply the patch you sent me on 6.1-rc2, the issue gets fixed again.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-10-27  4:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 19:26 [REGRESSION] Failure to write the NVRAM variables starting from kernel 6.0 on T2 Macs Aditya Garg
2022-10-19 21:23 ` Ard Biesheuvel
2022-10-20 10:54   ` Aditya Garg
2022-10-26 21:18   ` Aditya Garg
2022-10-26 21:20     ` Ard Biesheuvel
2022-10-27  4:33       ` Aditya Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).