Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ctHes-0007MH-2p for mharc-grub-devel@gnu.org; Wed, 29 Mar 2017 13:45:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctHem-0007JB-SY for grub-devel@gnu.org; Wed, 29 Mar 2017 13:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctHej-0003T5-Kt for grub-devel@gnu.org; Wed, 29 Mar 2017 13:45:16 -0400 Received: from nm7-vm3.bullet.mail.gq1.yahoo.com ([98.136.218.210]:51937) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctHej-0003SL-4j for grub-devel@gnu.org; Wed, 29 Mar 2017 13:45:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s2048; t=1490809511; bh=lyZ8lwiiu5GFXlPcr7gJBAtILt2oUgFQKPg5r6XvoZs=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=q4pMIpfDpzoRHqjMt8SVPf63433Y3BloJxPHoElwFNs8yfEXn7Hj0wTBYCd097gNrrH6mMRD+6pKi+CnEHRD5eR0FS0q/OwB3nnM7OMvYlqTNa6R99fzOLZwJpf+pOfi+PIBws0ofYu/FKWB8dEw+IWXvBazzdA0XcrDDK/VDOmOh3Fo4EweKK0tiKMJ25nMiSLbCScaYDS2ABe8gHan9Dye1/gPL4H5/pN2eiahIvY8oRVLCTqdDmhOkEzip9iBhBMWYonlsctZC4PEnMN13xY/Oo+5rhVtGMKLpztX6tVh/TVwwTSfyAwC7dxdDNuBputGYgOXumUUP+tSvmEC/g== Received: from [98.137.12.174] by nm7.bullet.mail.gq1.yahoo.com with NNFMP; 29 Mar 2017 17:45:11 -0000 Received: from [98.137.12.240] by tm13.bullet.mail.gq1.yahoo.com with NNFMP; 29 Mar 2017 17:45:11 -0000 Received: from [127.0.0.1] by omp1048.mail.gq1.yahoo.com with NNFMP; 29 Mar 2017 17:45:11 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 138767.22520.bm@omp1048.mail.gq1.yahoo.com X-YMail-OSG: shOGgm4VM1mkMVtORNsHFzPKYG62ziqiryToHifMVLfaoy6BgEGHN_P8uDwvfSR 3ccasWQy3OmsXNfBKdgrlYBTJOoN0yM5yxxQRDg2W.nVHr4N8rSJ306bNp8N7MHjl0VRckLLNyKM Z8q.zwnfi0tHYairWDzjTtZVYw6sLu95yArbo0.dZdsDhBmMJrgh4g2igMGhedA1CEdynLWpMg4O jQ8.yZIMGvYown5NU4p_KBoPJXzMhl24gbm6bEPyRkIZvXRdK95Xnn_N8oIRCZvjoNYf1oTx4yWS 1L_8t6694F.tE.NdU1FGfSLEA6H1GAfbOKKPUeRiiLqrSIIV99Xu_GQDn0MiF_t6xPqXKbzR_IwR BztqNxAyP0Ro1OhL23znLPAzFXeRtYmFJKPPV93gagRre4zfg0QUcA8CoYTjBB7GGD1a0sjDi0Ji I2r1rNsqhVRLC15p04vcwKKXh0fPO.nOcUkzw6DvdL9jRqEGPthZwcOU.m_DinhpMjVyR4uOpZtU WHjSGhkbdIffreZQl1yXZYuZFbiXpdck314Bwzsc_4fIdfEA- Received: from jws300027.mail.gq1.yahoo.com by sendmailws101b.mail.gq1.yahoo.com; Wed, 29 Mar 2017 17:45:10 +0000; 1490809510.680 Date: Wed, 29 Mar 2017 17:45:10 +0000 (UTC) From: Nando Eva Reply-To: Nando Eva To: "grub-devel@gnu.org" Message-ID: <1390664917.8322220.1490809510437@mail.yahoo.com> In-Reply-To: <967677258.4693596.1490623960099@mail.yahoo.com> References: <1736729449.4676062.1487865639993.ref@mail.yahoo.com> <1736729449.4676062.1487865639993@mail.yahoo.com> <229125734.2281203.1488194973248@mail.yahoo.com> <144480689.2460565.1488208393781@mail.yahoo.com> <1893359760.2685777.1488219706759@mail.yahoo.com> <967677258.4693596.1490623960099@mail.yahoo.com> Subject: Re: Loading DSDT table using 'acpi' or some memory write command? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_8322219_868332792.1490809510433" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 98.136.218.210 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: Wed, 29 Mar 2017 17:45:19 -0000 ------=_Part_8322219_868332792.1490809510433 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > How exactly do you find RSDP? On EFI RSDP should be retrieved from EFI > Configuration Table, which grub tries to update. Please give as much > details as possible. Good point. I can get the RSDP from tools like 'ru.efi' or even with 'r-w e= verything'. However, 'lsacpi' won't tell me the new RSDP address after doing a 'acpi ds= dt.aml'. Is there anyway of finding it out using the grub shell, or chainloading EFI= shell (or chainload grubx64.efi from EFI shell and exiting in case grub's = chainloading is restoring the ACPI tables)? > Again - what address are you updating? >=20 > We need to understand why it fails first. GRUB *does* attempt to > override RSDP if it finds it. =20 On Tuesday, 28 March 2017, 1:12, Nando Eva wrote: =20 OK, I found the cause if the problem: - the ACPI tables specified to the 'acpi' command are loaded to new address= es and a new RSDT and XSDT created with pointers to them. This can be confi= rmed by the 'lsacpi' command. - the RSDP isn't updated to point to the new RSDT and XSDT.=20 So when chainload the OS, the original RSDT and XSDT are referenced from th= e RSDP. I'm now manually doing the 'acpi [DSDT]' table load, then a 'lsacpi -2' to = find the new RSDT+XSDT addresses and updating the RSDP via two write_dword = memory writes (though not doing checksum correction). Can a pach be made for grub2 to correct this behaviour to be automated with= out such manual intervention?=20 Thank you,Nando=20 On Tuesday, 28 February 2017, 5:21, Nando Eva wro= te: =20 Vladimir 'phcoder' Serbinenko wrote: I reproduced the bug. I'm investigating >> Apparently finish_boot_services rewrites acpi tables. It's possible to w= orkaround this, possibly by using acpi table protocol. >> But it's certaine= ly not for 2.02 at this point. Thank you for investigating the issue. Earlier I did a test to check to see= if UEFI chainloading was altering ACPI tables. I did this by: 1. performing two grub2 "write_dword" console memory commands to enable ASP= M in the ACPI FADT (FACP on my system) table as per http://smackerelofopini= on.blogspot.com.au/2011/03/making-sense-of-pcie-aspm.html=20 2. then chainloaded from Grub2 to windows: chainloader /efi/Microsoft/Boot/= bootmgfw.efi The ASPM enabling change was there as found by using r-w everything and rep= orted by 'powercfg /energy', indicating the UEFI chainloading isn't, at lea= st for ACPI FADT (FACP), altering the in-memory table. As the DSDT table is much larger, I can't really write_dword it. Hence aski= ng for some other memory loading module. As another lead, I found the mentioned finish_boot_services routine in mm.c= , quoted below. Would you mind pointing out which code is rewriting the ACP= I tables? Thank you,Nando ---grub_err_t grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 grub_efi_uintn_t *map_key, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 grub_efi_uintn_t *efi_desc_size, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 grub_efi_uint32_t *efi_desc_version) { =C2=A0 grub_efi_boot_services_t *b; =C2=A0 grub_efi_status_t status; #if defined (__i386__) || defined (__x86_64__) =C2=A0 const grub_uint16_t apple[] =3D { 'A', 'p', 'p', 'l', 'e' }; =C2=A0 int is_apple; =C2=A0 is_apple =3D (grub_memcmp (grub_efi_system_table->firmware_vendor, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 apple= , sizeof (apple)) =3D=3D 0); #endif =C2=A0 while (1) =C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (grub_efi_get_memory_map (&finish_mmap_si= ze, finish_mmap_buf, &finish_key, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 &finish_desc_size, &finish_desc_version) < 0) =C2=A0=C2=A0=C2=A0 return grub_error (GRUB_ERR_IO, "couldn't retrieve memor= y map"); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (outbuf && *outbuf_size < finish_mmap_siz= e) =C2=A0=C2=A0=C2=A0 return grub_error (GRUB_ERR_IO, "memory map buffer is to= o small"); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 finish_mmap_buf =3D grub_malloc (finish_mmap= _size); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!finish_mmap_buf) =C2=A0=C2=A0=C2=A0 return grub_errno; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (grub_efi_get_memory_map (&finish_mmap_si= ze, finish_mmap_buf, &finish_key, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 &finish_desc_size, &finish_desc_version) <=3D 0) =C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0 =C2=A0 grub_free (finish_mmap_buf); =C2=A0=C2=A0=C2=A0 =C2=A0 return grub_error (GRUB_ERR_IO, "couldn't retriev= e memory map"); =C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 b =3D grub_efi_system_table->boot_services; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 status =3D efi_call_2 (b->exit_boot_services= , grub_efi_image_handle, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 finis= h_key); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (status =3D=3D GRUB_EFI_SUCCESS) =C2=A0=C2=A0=C2=A0 break; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (status !=3D GRUB_EFI_INVALID_PARAMETER) =C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0 =C2=A0 grub_free (finish_mmap_buf); =C2=A0=C2=A0=C2=A0 =C2=A0 return grub_error (GRUB_ERR_IO, "couldn't termina= te EFI services"); =C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 grub_free (finish_mmap_buf); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 grub_printf ("Trying to terminate EFI servic= es again\n"); =C2=A0=C2=A0=C2=A0 } =C2=A0 grub_efi_is_finished =3D 1; =C2=A0 if (outbuf_size) =C2=A0=C2=A0=C2=A0 *outbuf_size =3D finish_mmap_size; =C2=A0 if (outbuf) =C2=A0=C2=A0=C2=A0 grub_memcpy (outbuf, finish_mmap_buf, finish_mmap_size); =C2=A0 if (map_key) =C2=A0=C2=A0=C2=A0 *map_key =3D finish_key; =C2=A0 if (efi_desc_size) =C2=A0=C2=A0=C2=A0 *efi_desc_size =3D finish_desc_size; =C2=A0 if (efi_desc_version) =C2=A0=C2=A0=C2=A0 *efi_desc_version =3D finish_desc_version; #if defined (__i386__) || defined (__x86_64__) =C2=A0 if (is_apple) =C2=A0=C2=A0=C2=A0 stop_broadcom (); #endif =C2=A0 return GRUB_ERR_NONE; } Nando=20 On Tuesday, 28 February 2017, 2:13, Nando Eva wro= te: =20 Andrei Borzenkov wrote: >> That's more or less what grub tries to do. We cannot really overwrite >> ACPI tables because they may be located in read-only memory, but it >> attempts to create EBDA and place new RSDP there and update EBDA >> address as well as update RSDP pointer in EFI system table. I would >> suggest trying to load something else (like Linux) and check whether >> it sees new or old table. This user had 'acpi' also fail to replace the FACS ACPI table on Linux: https://bbs.archlinux.org/viewtopic.php?id=3D190258=20 The DSDT I require is for Win10. Win10 has a registry override method to re= place a DSDT but requires test signing mode to do it, along with some app r= estrictions/incompatibilities.=20 I require a pre-boot DSDT override method to overcome Win10 test signing mo= de AND have my required DSDT table loaded. Just need an in-memory DSDT subs= itution tool to do it. =20 I have been able to accomplish this using MBR boot because the tools exist.= For the more popular UEFI,I have yet to find a load-file-into-memory-locat= ion tool to make it possible. Only things are the multiboot file encapsulat= ion, hexedit and write_dword. All not the right fit.=20 Any chance the grub-devel team can help out here with either a load-file-to= -memory-location module/tool (where I need to find the address) or specific= ally one that does a in-memory DSDT override by overwriting the existing ta= ble? Of course, ppl with read-only memory can't use it just like I imagine = would be the case with the current 'acpi' method.=20 Thank you, Nando =20 =20 =20 ------=_Part_8322219_868332792.1490809510433 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
> How exactly do you find RSDP? On EFI RSDP s=
hould be retrieved from EFI
> Configuration Table, which grub tries to update. Please give as much
> details as possible.

Good point. I can get the RSDP from tools like 'ru.efi' or even with 'r= -w everything'.
However, 'lsacpi' won't tell me the new RSDP address aft= er doing a 'acpi dsdt.aml'.

Is there anyway of finding it out using = the grub shell, or chainloading EFI shell (or chainload grubx64.efi from EF= I shell and exiting in case grub's chainloading is restoring the ACPI table= s)?

> Again - what address are you updating? >=20 > We need to understand why it fails first. GRUB *does* attempt to > override RSDP if it finds it.


On Tuesday, 28 March 2017, 1:12,= Nando Eva <nando4eva@ymail.com> wrote:


<= span id=3D"yiv4714573600yui_3_16_0_1_1490623332187_6123">OK, I found the ca= use if the problem:
- the ACPI tables specified to the 'acpi' command are loaded to new addresses and a new = RSDT and XSDT created with pointers to them. This can be confirmed by the '= lsacpi' command.

- the RSDP isn't updated to point to th= e new RSDT and XSDT.

So when chai= nload the OS, the original RSDT and XSDT are referenced from the RSDP.

I'm = now manually doing the 'acpi [DSDT]' table load, then a 'lsacpi -2' to find= the new RSDT+XSDT addresses and updating the RSDP via two write_dword memo= ry writes (though not doing checksum correction).

Can a pach be made for g= rub2 to correct this behaviour to be automated without such manual interven= tion?
Thank you,
Nando


On Tuesday, 28 February 2017, = 5:21, Nando Eva <nando4eva@ymail.com> wrote:


Vladimir 'phcoder' Serbinenko wrot= e:

I reproduced the bug. I'm investigating
>> Apparently finish_boot_services rewrites acpi tables. It's possible to workaround=20 this, possibly by using acpi table protocol. >> But it's certainely n= ot for 2.02 at this point.

Thank you for investigating the is= sue. Earlier I did a test to check to see if UEFI chainloading was altering= ACPI tables. I did this by:

1. performing two grub2 "write_dword" console memory commands to enable = ASPM in the ACPI FADT (FACP on my system) table as per http://smackerelofopinion.blogspot.com.au/2011/0= 3/making-sense-of-pcie-aspm.html

2. then chainloaded from Grub2 to windows: chainloader /efi/Microsoft/B= oot/bootmgfw.efi

T= he ASPM enabling change was there as found by using r-w everything and report= ed by=20 'powercfg /energy', indicating the UEFI chainloading isn't, at least for ACPI FADT (FACP), altering the in-memory table.

As the DSDT table is much larg= er, I can't really write_dword it. Hence asking for some other memory loadi= ng module.
<= br clear=3D"none">
As another lead, I found the mentioned finish_boot_servi= ces routine in mm.c, quoted below. Would you mind pointing out which code i= s rewriting the ACPI tables?

Thank you,
Nando
=
---
grub_err_t
grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_= size, void *outbuf,
            &n= bsp;      grub_efi_uintn_t *map_key,
   = ;               = ; grub_efi_uintn_t *efi_desc_size,
         =           grub_efi_uint32_t *efi_de= sc_version)
{
  grub_efi_boot_services_t *b;
  grub_efi_status_t status;<= br id=3D"yiv4714573600yui_3_16_0_1_1488217462159_60835" clear=3D"none">
#if def= ined (__i386__) || defined (__x86_64__)
  const grub_uint16_t apple[] =3D = { 'A', 'p', 'p', 'l', 'e' };
  int is_apple;

  is_apple =3D (grub_memcmp (gr= ub_efi_system_table->firmware_vendor,
        =        apple, sizeof (apple)) =3D=3D 0);
#endif

  while= (1)
    {
      if (grub_efi_get_memory_ma= p (&finish_mmap_size, finish_mmap_buf, &finish_key,
    =                &= finish_desc_size, &finish_desc_version) < 0)
    return g= rub_error (GRUB_ERR_IO, "couldn't retrieve memory map");

    &= nbsp; if (outbuf && *outbuf_size < finish_mmap_size)
  &nb= sp; return grub_error (GRUB_ERR_IO, "memory map buffer is too small");

 &nb= sp;    finish_mmap_buf =3D grub_malloc (finish_mmap_size); = ;     if (!finish_mmap_buf)
    return grub_= errno;

=       if (grub_efi_get_memory_map (&finish_mma= p_size, finish_mmap_buf, &finish_key,
       =            &finish_desc_size, = &finish_desc_version) <=3D 0)
    {
     = grub_free (finish_mmap_buf);
      return grub_error (GRUB= _ERR_IO, "couldn't retrieve memory map");
    }

    = ;  b =3D grub_efi_system_table->boot_services;
    =   status =3D efi_call_2 (b->exit_boot_services, grub_efi_image_hand= le,
=                finis= h_key);
      if (status =3D=3D GRUB_EFI_SUCCESS)
 &n= bsp;  break;

      if (status !=3D GRUB_EFI_INVALID_= PARAMETER)
    {
      grub_free (finish_mmap_bu= f);
=       return grub_error (GRUB_ERR_IO, "couldn't termina= te EFI services");
    }

      grub_free (fini= sh_mmap_buf);
      grub_printf ("Trying to terminate = EFI services again\n");
    }
  grub_efi_is_finished =3D 1;
  = if (outbuf_size)
    *outbuf_size =3D finish_mmap_size;
  if (o= utbuf)
    grub_memcpy (outbuf, finish_mmap_buf, finish_mmap_siz= e);
=   if (map_key)
    *map_key =3D finish_key;
  if (efi_desc= _size)
    *efi_desc_size =3D finish_desc_size;
  if (efi_desc_= version)
    *efi_desc_version =3D finish_desc_version;

#if defined (__= i386__) || defined (__x86_64__)
  if (is_apple)
    stop_broadc= om ();
#endif

  return GRUB_ERR_NONE;
}


Nando


On Tuesday, 28 February 2017, 2:13, Nando Eva <= ;nando4eva@ymail.com> wrote:


<= div id=3D"yiv4714573600">
Andrei Borzenkov wrote:
>> That's more or less what grub tries to do. We cannot r= eally overwrite >> ACPI tables because they may be located in read-only memory, but i= t >> attempts to create EBDA and place new RSDP there and update EBDA >> address as well as update RSDP pointer in EFI system table. I woul= d >> suggest trying to load something else (like Linux) and check wheth= er >> it sees new or old table.

Thi= s user had 'acpi' also fail to replace the FACS ACPI table on Linux:
https://bbs.archlinux.org/viewtopic.php?id=3D1= 90258

The DSDT I require is for W= in10. Win10 has a registry override method to replace a DSDT but requires t= est signing mode to do it, along with some app restrictions/incompatibiliti= es.

I require a pre-boot DSDT overrid= e method to overcome Win10 test signing mode AND have my required DSDT tabl= e loaded. Just need an in-memory DSDT subsitution tool to do it.

I have been able to accomplish this using MBR = boot because the tools exist. For the more popular UEFI,I have yet to find = a load-file-into-memory-location tool to make it possible. Only things are = the multiboot file encapsulation, hexedit and write_dword. All not the righ= t fit.

Any chance the grub-devel team= can help out here with either a load-file-to-memory-location module/tool (= where I need to find the address) or specifically one that does a in-memory= DSDT override by overwriting the existing table? Of course, ppl with read-= only memory can't use it just like I imagine would be the case with the cur= rent 'acpi' method.


Thank you,Nando




<= /div>


------=_Part_8322219_868332792.1490809510433--