From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cuF2E-0008Cr-NL for mharc-grub-devel@gnu.org; Sat, 01 Apr 2017 05:09:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuF2B-0008Cl-QT for grub-devel@gnu.org; Sat, 01 Apr 2017 05:09:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuF28-0003QH-F1 for grub-devel@gnu.org; Sat, 01 Apr 2017 05:09:23 -0400 Received: from mail-lf0-x22c.google.com ([2a00:1450:4010:c07::22c]:34532) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuF28-0003OT-0k for grub-devel@gnu.org; Sat, 01 Apr 2017 05:09:20 -0400 Received: by mail-lf0-x22c.google.com with SMTP id z15so53425994lfd.1 for ; Sat, 01 Apr 2017 02:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to; bh=C2J7/FEq4UH70qrG+QLVhZKrqMFadkyHoVHTmkDhpWE=; b=ojUm/msR1Ilk996kKkAsb5v8e7Qvmf9doqfIQG/bpnS+XuF9h39Pp+W8llNqjTtvEe b4xvRIZxYtk5TmvZ1dYJbkwB1I4UrHsOGc2bqDTvtzKXChCb/etfArQL5npTxCo/+/t8 jklCyMLCg5y3qJGhdo+tsnD26IhaQuytEUTa98guVh861SDgpal92IaiNYzr9RcU3n6W yzSHvP7YQ70Z/PY5U6/YnP3fCHqfIXoMVhyHazpxiReYmLwiCh2SCf07B/g/q3Cc/tFa gffwsPt0k8KCoBB1ZSaHBdeLcJ3ldJ/BSpYJVUbWNE/p1VVe+t0UivafU/BW4WdRifct +uDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=C2J7/FEq4UH70qrG+QLVhZKrqMFadkyHoVHTmkDhpWE=; b=nMHZQPnAA7cuuo5uVtXOTjIyFrfsoSK1go30zRjxqhggOZvon8x2RzwdVa9sVr5r/v uM7HnzccXCi/SV+DlpQ4piyTpgIf03JyMtVsTNx4N+sOMkBADyDomi4KjfFJOLok+8Dk Px7J6MltzJJ8ZqR4fxbI5cyTnsPq4l2kH9INCt+CJ5oMjaEcCwHDcDJMuviX3hRFj1cm XV8M62BMXvAta1+NCYOXjNANuZeUs531dFPSdRdcHVKGObP0cLHvQT8xiWd5cqqSqN1z BgQYTQXADRqU+huDnwSzf9u5AIdnLfXjFevLNFGoWNc0oNrytRmM0gMZQfWz4W8RasLq opqA== X-Gm-Message-State: AFeK/H0H5QbO0YqspHC7Ax9Gx8Ciu2u2h+9EDAF2XAGNmsDNaUayCeyKr6ozYV+xttn5GA== X-Received: by 10.25.193.70 with SMTP id r67mr2298595lff.66.1491037758293; Sat, 01 Apr 2017 02:09:18 -0700 (PDT) Received: from [192.168.1.6] (ppp109-252-90-38.pppoe.spdop.ru. [109.252.90.38]) by smtp.gmail.com with ESMTPSA id f72sm1409894lfk.2.2017.04.01.02.09.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 02:09:17 -0700 (PDT) Subject: Re: Loading DSDT table using 'acpi' or some memory write command? To: The development of GNU GRUB 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> <1390664917.8322220.1490809510437@mail.yahoo.com> From: Andrei Borzenkov Message-ID: Date: Sat, 1 Apr 2017 12:09:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1390664917.8322220.1490809510437@mail.yahoo.com> Content-Type: multipart/mixed; boundary="------------C4C944BEC0AD47163A6B3058" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22c 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: Sat, 01 Apr 2017 09:09:26 -0000 This is a multi-part message in MIME format. --------------C4C944BEC0AD47163A6B3058 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 29.03.2017 20:45, Nando Eva пишет: >> 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 everything'. > However, 'lsacpi' won't tell me the new RSDP address after 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 EFI shell and exiting in case grub's chainloading is restoring the ACPI tables)? > Please test attached patch. It adds printing of table addresses as well as "lsacpi --scan" option that forces fetching RSDP from firmware. It looks like on EFI our call to InstallConfigurationTable does not work; after "acpi ..." "lsacpi --scan" still displays old RSDP and tables (although grub itself would use new one). I also have rather weird issue that after "acpi dsdt.aml" I lose partitions (only hard disk itself is visible). This is on real hardware (Dell Latitude E5450). --------------C4C944BEC0AD47163A6B3058 Content-Type: text/x-patch; name="lsapi.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="lsapi.patch" From: Andrei Borzenkov Subject: [PATCH] lsacpi: print table address and allow bypassing stored p= ointers 1. Print memory address for each table, similat to what Linux kernel does= =2E 2. Add "--scan" option to ignore stored RSDP address (after acpi command)= and use normal platform-specific way to search for it. This provides for better debugging results of replacing tables with acpi.= --- grub-core/commands/acpi.c | 34 ++++++++------ grub-core/commands/acpihalt.c | 4 +- grub-core/commands/lsacpi.c | 86 ++++++++++++++++++++++++++++++= ------ grub-core/efiemu/i386/pc/cfgtables.c | 4 +- grub-core/loader/multiboot_mbi2.c | 6 +-- include/grub/acpi.h | 12 ++++- 6 files changed, 109 insertions(+), 37 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index b5c2f27..4163a78 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -100,22 +100,28 @@ static grub_size_t dsdt_size =3D 0; static grub_uint32_t facs_addr =3D 0; =20 struct grub_acpi_rsdp_v20 * -grub_acpi_get_rsdpv2 (void) +grub_acpi_get_rsdpv2 (int scan) { - if (rsdpv2_new) - return rsdpv2_new; - if (rsdpv1_new) - return 0; + if (!scan) + { + if (rsdpv2_new) + return rsdpv2_new; + if (rsdpv1_new) + return 0; + } return grub_machine_acpi_get_rsdpv2 (); } =20 struct grub_acpi_rsdp_v10 * -grub_acpi_get_rsdpv1 (void) +grub_acpi_get_rsdpv1 (int scan) { - if (rsdpv1_new) - return rsdpv1_new; - if (rsdpv2_new) - return 0; + if (!scan) + { + if (rsdpv1_new) + return rsdpv1_new; + if (rsdpv2_new) + return 0; + } return grub_machine_acpi_get_rsdpv1 (); } =20 @@ -198,8 +204,8 @@ grub_acpi_create_ebda (void) *((grub_uint16_t *) targetebda) =3D ebda_kb_len + 1; target =3D targetebda; =20 - v1 =3D grub_acpi_get_rsdpv1 (); - v2 =3D grub_acpi_get_rsdpv2 (); + v1 =3D grub_acpi_get_rsdpv1 (0); + v2 =3D grub_acpi_get_rsdpv2 (0); if (v2 && v2->length > 40) v2 =3D 0; =20 @@ -762,9 +768,9 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int = argc, char **args) struct grub_efi_guid acpi20 =3D GRUB_EFI_ACPI_20_TABLE_GUID; =20 grub_efi_system_table->boot_services->install_configuration_table - (&acpi20, grub_acpi_get_rsdpv2 ()); + (&acpi20, grub_acpi_get_rsdpv2 (0)); grub_efi_system_table->boot_services->install_configuration_table - (&acpi, grub_acpi_get_rsdpv1 ()); + (&acpi, grub_acpi_get_rsdpv1 (0)); } #endif =20 diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.= c index 9cc7f18..d7c51e1 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -395,11 +395,11 @@ grub_acpi_halt (void) grub_uint32_t port =3D 0; int sleep_type =3D -1; =20 - rsdp2 =3D grub_acpi_get_rsdpv2 (); + rsdp2 =3D grub_acpi_get_rsdpv2 (0); if (rsdp2) rsdp1 =3D &(rsdp2->rsdpv1); else - rsdp1 =3D grub_acpi_get_rsdpv1 (); + rsdp1 =3D grub_acpi_get_rsdpv1 (0); grub_dprintf ("acpi", "rsdp1=3D%p\n", rsdp1); if (!rsdp1) return; diff --git a/grub-core/commands/lsacpi.c b/grub-core/commands/lsacpi.c index 0824914..34c1220 100644 --- a/grub-core/commands/lsacpi.c +++ b/grub-core/commands/lsacpi.c @@ -43,6 +43,7 @@ print_strn (grub_uint8_t *str, grub_size_t len) static void disp_acpi_table (struct grub_acpi_table_header *t) { + grub_printf ("%p: ", t); print_field (t->signature); grub_printf ("%4" PRIuGRUB_UINT32_T "B rev=3D%u chksum=3D0x%02x (%s) O= EM=3D", t->length, t->revision, t->checksum, grub_byte_checksum (t, t->length) =3D=3D 0 ? "valid" : "invalid"= ); @@ -59,7 +60,6 @@ disp_madt_table (struct grub_acpi_madt *t) struct grub_acpi_madt_entry_header *d; grub_uint32_t len; =20 - disp_acpi_table (&t->hdr); grub_printf ("Local APIC=3D%08" PRIxGRUB_UINT32_T " Flags=3D%08" PRIxGRUB_UINT32_T "\n", t->lapic_addr, t->flags); @@ -174,6 +174,61 @@ disp_madt_table (struct grub_acpi_madt *t) } =20 static void +disp_facs_header (struct grub_acpi_facs_header *t) +{ + grub_printf ("%p: ", t); + print_field (t->signature); + grub_printf ("%4" PRIuGRUB_UINT32_T "B", t->length); + grub_printf ("\n"); +} + +static void +disp_fadt_table (struct grub_acpi_fadt *t) +{ + struct grub_acpi_facs_header *facs =3D NULL; + struct grub_acpi_table_header *dsdt =3D NULL; + + if (t->hdr.revision >=3D 3) + { + if (t->facs_xaddr) + { + if (t->facs_addr) + grub_printf (" Ignoring FACS 0x08%" PRIxGRUB_UINT32_T "\n", t->fac= s_addr); + +#if GRUB_CPU_SIZEOF_VOID_P =3D=3D 4 + if (t->facs_xaddr >=3D (1ULL << 32)) + grub_printf (" Unreachable FACS 0x%016" PRIxGRUB_UINT64_T "\n", t-= >facs_xaddr); + else +#endif + facs =3D (struct grub_acpi_facs_header *) (grub_addr_t) t->dsdt_xad= dr; + } + + if (t->dsdt_xaddr) + { + if (t->dsdt_addr) + grub_printf (" Ignoring DSDT 0x08%" PRIxGRUB_UINT32_T "\n", t->dsd= t_addr); + +#if GRUB_CPU_SIZEOF_VOID_P =3D=3D 4 + if (t->dsdt_xaddr >=3D (1ULL << 32)) + grub_printf (" Unreachable DSDT 0x%016" PRIxGRUB_UINT64_T "\n", t-= >dsdt_xaddr); + else +#endif + dsdt =3D (struct grub_acpi_table_header *) (grub_addr_t) t->dsdt_xa= ddr; + } + } + else + { + facs =3D (struct grub_acpi_facs_header *) (grub_addr_t) t->facs_ad= dr; + dsdt =3D (struct grub_acpi_table_header *) (grub_addr_t) t->dsdt_a= ddr; + } + + if (facs) + disp_facs_header (facs); + if (dsdt) + disp_acpi_table (dsdt); +} + +static void disp_acpi_xsdt_table (struct grub_acpi_table_header *t) { grub_uint32_t len; @@ -187,7 +242,7 @@ disp_acpi_xsdt_table (struct grub_acpi_table_header *= t) #if GRUB_CPU_SIZEOF_VOID_P =3D=3D 4 if (*desc >=3D (1ULL << 32)) { - grub_printf ("Unreachable table\n"); + grub_printf (" Unreachable table 0x%016" PRIxGRUB_UINT64_T "\n", *de= sc); continue; } #endif @@ -196,11 +251,13 @@ disp_acpi_xsdt_table (struct grub_acpi_table_header= *t) if (t =3D=3D NULL) continue; =20 + disp_acpi_table (t); if (grub_memcmp (t->signature, GRUB_ACPI_MADT_SIGNATURE, sizeof (t->signature)) =3D=3D 0) disp_madt_table ((struct grub_acpi_madt *) t); - else - disp_acpi_table (t); + else if (grub_memcmp (t->signature, GRUB_ACPI_FADT_SIGNATURE, + sizeof (t->signature)) =3D=3D 0) + disp_fadt_table ((struct grub_acpi_fadt *) t); } } =20 @@ -220,11 +277,13 @@ disp_acpi_rsdt_table (struct grub_acpi_table_header= *t) if (t =3D=3D NULL) continue; =20 + disp_acpi_table (t); if (grub_memcmp (t->signature, GRUB_ACPI_MADT_SIGNATURE, sizeof (t->signature)) =3D=3D 0) disp_madt_table ((struct grub_acpi_madt *) t); - else - disp_acpi_table (t); + else if (grub_memcmp (t->signature, GRUB_ACPI_FADT_SIGNATURE, + sizeof (t->signature)) =3D=3D 0) + disp_fadt_table ((struct grub_acpi_fadt *) t); } } =20 @@ -235,15 +294,13 @@ disp_acpi_rsdpv1 (struct grub_acpi_rsdp_v10 *rsdp) grub_printf ("chksum:%02x (%s), OEM-ID: ", rsdp->checksum, grub_byte_c= hecksum (rsdp, sizeof (*rsdp)) =3D=3D 0 ? "valid" : "invalid"); print_field (rsdp->oemid); grub_printf ("rev=3D%d\n", rsdp->revision); - grub_printf ("RSDT=3D%08" PRIxGRUB_UINT32_T "\n", rsdp->rsdt_addr); } =20 static void disp_acpi_rsdpv2 (struct grub_acpi_rsdp_v20 *rsdp) { disp_acpi_rsdpv1 (&rsdp->rsdpv1); - grub_printf ("len=3D%d chksum=3D%02x (%s) XSDT=3D%016" PRIxGRUB_UINT64= _T "\n", rsdp->length, rsdp->checksum, grub_byte_checksum (rsdp, rsdp->le= ngth) =3D=3D 0 ? "valid" : "invalid", - rsdp->xsdt_addr); + grub_printf ("len=3D%d chksum=3D%02x (%s)\n", rsdp->length, rsdp->chec= ksum, grub_byte_checksum (rsdp, rsdp->length) =3D=3D 0 ? "valid" : "inval= id"); if (rsdp->length !=3D sizeof (*rsdp)) grub_printf (" length mismatch %d !=3D %d\n", rsdp->length, (int) sizeof (*rsdp)); @@ -254,6 +311,7 @@ disp_acpi_rsdpv2 (struct grub_acpi_rsdp_v20 *rsdp) static const struct grub_arg_option options[] =3D { {"v1", '1', 0, N_("Show version 1 tables only."), 0, ARG_TYPE_NONE}, {"v2", '2', 0, N_("Show version 2 and version 3 tables only."), 0, ARG= _TYPE_NONE}, + {"scan", 0, 0, N_("Ignore cached RSDP pointers and rescan."), 0, ARG_T= YPE_NONE}, {0, 0, 0, 0, 0, 0} }; =20 @@ -264,12 +322,12 @@ grub_cmd_lsacpi (struct grub_extcmd_context *ctxt, { if (!ctxt->state[1].set) { - struct grub_acpi_rsdp_v10 *rsdp1 =3D grub_acpi_get_rsdpv1 (); + struct grub_acpi_rsdp_v10 *rsdp1 =3D grub_acpi_get_rsdpv1 (ctxt->s= tate[2].set); if (!rsdp1) grub_printf ("No RSDPv1\n"); else { - grub_printf ("RSDPv1 signature:"); + grub_printf ("%p: RSDPv1 signature:", rsdp1); disp_acpi_rsdpv1 (rsdp1); disp_acpi_rsdt_table ((void *) (grub_addr_t) rsdp1->rsdt_addr); } @@ -277,7 +335,7 @@ grub_cmd_lsacpi (struct grub_extcmd_context *ctxt, =20 if (!ctxt->state[0].set) { - struct grub_acpi_rsdp_v20 *rsdp2 =3D grub_acpi_get_rsdpv2 (); + struct grub_acpi_rsdp_v20 *rsdp2 =3D grub_acpi_get_rsdpv2 (ctxt->s= tate[2].set); if (!rsdp2) grub_printf ("No RSDPv2\n"); else @@ -288,7 +346,7 @@ grub_cmd_lsacpi (struct grub_extcmd_context *ctxt, else #endif { - grub_printf ("RSDPv2 signature:"); + grub_printf ("%p: RSDPv2 signature:", rsdp2); disp_acpi_rsdpv2 (rsdp2); disp_acpi_xsdt_table ((void *) (grub_addr_t) rsdp2->xsdt_addr); grub_printf ("\n"); @@ -302,7 +360,7 @@ static grub_extcmd_t cmd; =20 GRUB_MOD_INIT(lsapi) { - cmd =3D grub_register_extcmd ("lsacpi", grub_cmd_lsacpi, 0, "[-1|-2]",= + cmd =3D grub_register_extcmd ("lsacpi", grub_cmd_lsacpi, 0, "[-1|-2] [= --scan]", N_("Show ACPI information."), options); } =20 diff --git a/grub-core/efiemu/i386/pc/cfgtables.c b/grub-core/efiemu/i386= /pc/cfgtables.c index 492c07c..99a9228 100644 --- a/grub-core/efiemu/i386/pc/cfgtables.c +++ b/grub-core/efiemu/i386/pc/cfgtables.c @@ -43,14 +43,14 @@ grub_machine_efiemu_init_tables (void) if (err) return err; =20 - table =3D grub_acpi_get_rsdpv1 (); + table =3D grub_acpi_get_rsdpv1 (0); if (table) { err =3D grub_efiemu_register_configuration_table (acpi, 0, 0, tabl= e); if (err) return err; } - table =3D grub_acpi_get_rsdpv2 (); + table =3D grub_acpi_get_rsdpv2 (0); if (table) { err =3D grub_efiemu_register_configuration_table (acpi20, 0, 0, ta= ble); diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multibo= ot_mbi2.c index b0679a9..640a8de 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -391,7 +391,7 @@ static grub_size_t acpiv2_size (void) { #if GRUB_MACHINE_HAS_ACPI - struct grub_acpi_rsdp_v20 *p =3D grub_acpi_get_rsdpv2 (); + struct grub_acpi_rsdp_v20 *p =3D grub_acpi_get_rsdpv2 (0); =20 if (!p) return 0; @@ -938,7 +938,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) { struct multiboot_tag_old_acpi *tag =3D (struct multiboot_tag_old_acp= i *) ptrorig; - struct grub_acpi_rsdp_v10 *a =3D grub_acpi_get_rsdpv1 (); + struct grub_acpi_rsdp_v10 *a =3D grub_acpi_get_rsdpv1 (0); if (a) { tag->type =3D MULTIBOOT_TAG_TYPE_ACPI_OLD; @@ -952,7 +952,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) { struct multiboot_tag_new_acpi *tag =3D (struct multiboot_tag_new_acp= i *) ptrorig; - struct grub_acpi_rsdp_v20 *a =3D grub_acpi_get_rsdpv2 (); + struct grub_acpi_rsdp_v20 *a =3D grub_acpi_get_rsdpv2 (0); if (a) { tag->type =3D MULTIBOOT_TAG_TYPE_ACPI_NEW; diff --git a/include/grub/acpi.h b/include/grub/acpi.h index 66148f6..f00e1d6 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -60,6 +60,14 @@ struct grub_acpi_table_header grub_uint32_t creator_rev; } GRUB_PACKED; =20 +#define GRUB_ACPI_FACS_SIGNATURE "FACS" + +struct grub_acpi_facs_header +{ + grub_uint8_t signature[4]; + grub_uint32_t length; +} GRUB_PACKED; + #define GRUB_ACPI_FADT_SIGNATURE "FACP" =20 struct grub_acpi_fadt @@ -180,8 +188,8 @@ enum }; =20 #ifndef GRUB_DSDT_TEST -struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (void); -struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (void); +struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (int scan); +struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (int scan); struct grub_acpi_rsdp_v10 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv1) (vo= id); struct grub_acpi_rsdp_v20 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv2) (vo= id); grub_uint8_t EXPORT_FUNC(grub_byte_checksum) (void *base, grub_size_t si= ze); --=20 tg: (17cb997..) u/lsacpi/print-table-address (depends on: u/lsacpi/printf= -pointer-align) --------------C4C944BEC0AD47163A6B3058--