Re: [PATCH] tsc: Change default tsc calibration method to EFI on EFI systems

2017-09-12 Thread Paul Menzel
Dear David,


Am Mittwoch, den 06.09.2017, 13:20 -0700 schrieb David E. Box:
> On efi systems, make efi based tsc calibration the default, followed by
> the pmtimer before using the pit. This prevents Grub boot failure on
> newer x86 systems that power gate the pit.

Could you please be specific, what “newer x86 systems” are? Also, what
is the “GRUB boot failure”? A hang?

What about older EFI x86 systems? Is there a chance, that they hang
now?

> Signed-off-by: David E. Box 
> ---
>  grub-core/kern/i386/tsc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
> index 2e85289d8..de4057ddb 100644
> --- a/grub-core/kern/i386/tsc.c
> +++ b/grub-core/kern/i386/tsc.c
> @@ -68,7 +68,7 @@ grub_tsc_init (void)
>  #ifdef GRUB_MACHINE_XEN
>(void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
>  #elif defined (GRUB_MACHINE_EFI)
> -  (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer 
> () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
> +  (void) (grub_tsc_calibrate_from_efi () || grub_tsc_calibrate_from_pmtimer 
> () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
>  #elif defined (GRUB_MACHINE_COREBOOT)
>(void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit 
> () || calibrate_tsc_hardcode());
>  #else


Thanks,

Paul

signature.asc
Description: This is a digitally signed message part
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: What GPL requirements are implied by publishing an ISO with GRUB binaries ?

2017-09-12 Thread Thomas Schmitt
Hi,

Tom Davies wrote:
> This might not be the best place to ask about legal issues for edge-case
> scenarios.

At least it would be the place to discuss what should be written in the docs.

The problem is quite specific to grub-mkrescue or people who equip computers
with GRUB and then pass them on to other people.
If i had general questions about GPL, then i would ask fellow GNU maintainers
in general.

My own GNU sub project would not invite the question because it does not
need to spread software in order to do its job. It spreads ISOs instead.


An illustration of the special constraints with GRUB equipped media is
this statement which is obviously intended for a person or organisation which
permanently offers GPL'ed software:

> https://www.gnu.org/licenses/gpl-faq.html#SourceAndBinaryOnDifferentSites

"you must take care to make sure that the source remains available for as
 long as you distribute the object code."

If i take this literally, then i can hand a GRUB equipped DVD to a friend,
offer for the durance of the handover to provide the sources, and would then
be free of further obligations.
(I do not have to ask Richard Stallman about his opinion to that theory.
 The answer is easy to guess.)


As said, the normal way to fulfill GPL, if you do not modify the original code
but only distribute binaries, is to simply tell the public source from where
you got it and to show due dilligence with verifying that this source still
exists as long as you offer the binary.

The problem is how to properly point to GRUB sources when redistributing
GRUB binaries on bootable media. Especially when there is no official GRUB
release to which one could point. (E.g. caused by the long release gap which
ended not very long ago.)


> Note that the licence is not intended to make things difficult!

The FSF will not contradict if i state that ease of use is not the first
priority of GPL, but that it is rather about rigidly ensuring the Four
Essential Freedoms (https://www.gnu.org/philosophy/free-sw.en.html).

Just look at the situation with GPLv2-only (without "+") and LGPLv3.
( https://www.gnu.org/licenses/license-list.en.html#GPLv2 )
The official answer is: Urge the license givers of the GPLv2-only software
to expand their license to GPLv2+, or else do not combine it with LGPLv3.
No grandfather clause is offered by LGPLv3 for GPLv2-only despite the fact
that LGPLv3 is compatible with many non-free licenses.


> https://www.gnu.org/licenses/gpl-howto.html

Urm. The headline is "How to use GNU licenses for your own software".
Not the situation i am asking about.

It gives advise for the normal situation, though:

  "(Optionally) make the program display a startup notice."

If the version id in the notice was significant enough to find the source
version in GRUB's git, then there would be no problem with fulfilling GPL
for binaries from unmodified source code.


Have a nice day :)

Thomas


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] Fix grub-mkconfig detecting .sig files as system images

2017-09-12 Thread Jordan Glover
This patch solves https://savannah.gnu.org/bugs/index.php?52002

--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -188,6 +188,7 @@
   *.dpkg-*) return 1 ;; # debian dpkg
   *.rpmsave|*.rpmnew) return 1 ;;
   README*|*/README*)  return 1 ;; # documentation
+  *.sig) return 1 ;; # signatures
 esac
   else
 return 1--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -188,6 +188,7 @@
   *.dpkg-*) return 1 ;; # debian dpkg
   *.rpmsave|*.rpmnew) return 1 ;;
   README*|*/README*)  return 1 ;; # documentation
+  *.sig) return 1 ;; # signatures
 esac
   else
 return 1
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] tsc: Change default tsc calibration method to EFI on EFI systems

2017-09-12 Thread David E. Box
Hi Paul,

On Tue, 2017-09-12 at 09:10 +0200, Paul Menzel wrote:
> Dear David,
> 
> 
> Am Mittwoch, den 06.09.2017, 13:20 -0700 schrieb David E. Box:
> > On efi systems, make efi based tsc calibration the default,
> > followed by
> > the pmtimer before using the pit. This prevents Grub boot failure
> > on
> > newer x86 systems that power gate the pit.
> 
> Could you please be specific, what “newer x86 systems” are? Also,
> what
> is the “GRUB boot failure”? A hang?

Intel SoC's supporting the S0ix feature require the 8254 to be power
gated. This feature as been around as early as the Cherry Trail line.
In order to support this some firmware configurations clock gate the
8254 by default. This causes grub to hang on these systems when they
attempt to use it to calibrate the tsc.

See section 18.9.2.4 in https://www.intel.com/content/www/us/en/process
ors/atom/atom-z8000-datasheet-vol-1.html

> 
> What about older EFI x86 systems? Is there a chance, that they hang
> now?support this some firmware configurations clock gate the 8254 by
> default. This causes grub to hang on t

Can't say for sure. I have no reason to suspect so. Such a system would
have to have no (or broken) support for the EFI_STALL boot service
command, which has been around since EFI 1.0.

> 
> > Signed-off-by: David E. Box 
> > ---
> >  grub-core/kern/i386/tsc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
> > index 2e85289d8..de4057ddb 100644
> > --- a/grub-core/kern/i386/tsc.c
> > +++ b/grub-core/kern/i386/tsc.c
> > @@ -68,7 +68,7 @@ grub_tsc_init (void)
> >  #ifdef GRUB_MACHINE_XEN
> >(void) (grub_tsc_calibrate_from_xen () ||
> > calibrate_tsc_hardcode());
> >  #elif defined (GRUB_MACHINE_EFI)
> > -  (void) (grub_tsc_calibrate_from_pit () ||
> > grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi()
> > || calibrate_tsc_hardcode());
> > +  (void) (grub_tsc_calibrate_from_efi () ||
> > grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit
> > () || calibrate_tsc_hardcode());
> >  #elif defined (GRUB_MACHINE_COREBOOT)
> >(void) (grub_tsc_calibrate_from_pmtimer () ||
> > grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
> >  #else
> 
> 
> Thanks,
> 
> Paul

Dave

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] tsc: Change default tsc calibration method to EFI on EFI systems

2017-09-12 Thread Vladimir 'phcoder' Serbinenko
On Wed, Sep 6, 2017, 22:21 David E. Box  wrote:

> On efi systems, make efi based tsc calibration the default, followed by
> the pmtimer before using the pit. This prevents Grub boot failure on
> newer x86 systems that power gate the pit.
>
Why does put code fail? I think it was changed to detect gated pit.
Also I'd prefer to use pmtimer first as we had problems with event and time
routines on some Macs. Any reason not to use pmtimer first?

>
> Signed-off-by: David E. Box 
> ---
>  grub-core/kern/i386/tsc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
> index 2e85289d8..de4057ddb 100644
> --- a/grub-core/kern/i386/tsc.c
> +++ b/grub-core/kern/i386/tsc.c
> @@ -68,7 +68,7 @@ grub_tsc_init (void)
>  #ifdef GRUB_MACHINE_XEN
>(void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
>  #elif defined (GRUB_MACHINE_EFI)
> -  (void) (grub_tsc_calibrate_from_pit () ||
> grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() ||
> calibrate_tsc_hardcode());
> +  (void) (grub_tsc_calibrate_from_efi () ||
> grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () ||
> calibrate_tsc_hardcode());
>  #elif defined (GRUB_MACHINE_COREBOOT)
>(void) (grub_tsc_calibrate_from_pmtimer () ||
> grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
>  #else
> --
> 2.13.5
>
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH 1/4] i386/x86_64: make linux header definitions arch-specific

2017-09-12 Thread Daniel Kiper
Hi Leif,

Sorry for late reply but I am traveling. I should be
more responsive starting from next week.

On Tue, Sep 05, 2017 at 09:41:11PM +0100, Leif Lindholm wrote:
> Rename GRUB_LINUX_MAGIC_SIGNATURE -> GRUB_LINUX_I386_MAGIC_SIGNATURE
> and linux_kernel_header -> linux_i386_kernel_header.

I think that this begs for 2 separate patches.

> Also change the include guard on grub/i386/linux.h to prevent clashes
> when including multiple linux.h headers (like in commands/file.c).

Third patch.

> Signed-off-by: Leif Lindholm 
> ---
>
> OK, so one question here: in order to follow existing style, I have kept
> to the existing linux_ format. Is that the appropriate prefix, or should
> this be grub_linux_ like I originally used in the ARM series?

I prefer linux_.

> Regardless, I intend to align the ARM patches to whatever format ends up
> being used for this patch.

Please do.

Daniel

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH 2/4] arm64/efi: move EFI_PAGE definitions to efi/memory.h

2017-09-12 Thread Daniel Kiper
On Tue, Sep 05, 2017 at 09:41:12PM +0100, Leif Lindholm wrote:
> The EFI page definitions and macros are generic and should not be confined
> to arm64 headers - so move to efi/memory.h.

I am OK with this.

> Also add EFI_PAGE_SIZE macro.

However, this should be added in 3rd patch.

> Update loader sources to reflect new header location.
>
> Signed-off-by: Leif Lindholm 
> ---
>  grub-core/loader/arm64/linux.c| 1 +
>  grub-core/loader/arm64/xen_boot.c | 1 +
>  grub-core/loader/efi/fdt.c| 1 +
>  include/grub/efi/fdtload.h| 3 ---
>  include/grub/efi/memory.h | 7 +++
>  5 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
> index 746edd104..ca01a2349 100644
> --- a/grub-core/loader/arm64/linux.c
> +++ b/grub-core/loader/arm64/linux.c
> @@ -28,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/grub-core/loader/arm64/xen_boot.c 
> b/grub-core/loader/arm64/xen_boot.c
> index c95d6c5a8..67ada136b 100644
> --- a/grub-core/loader/arm64/xen_boot.c
> +++ b/grub-core/loader/arm64/xen_boot.c
> @@ -30,6 +30,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include/* required by struct xen_hypervisor_header */
>  #include 
>  #include 
> diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
> index 17212c38d..c0c6800f7 100644
> --- a/grub-core/loader/efi/fdt.c
> +++ b/grub-core/loader/efi/fdt.c
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  static void *loaded_fdt;
>  static void *fdt;
> diff --git a/include/grub/efi/fdtload.h b/include/grub/efi/fdtload.h
> index 7b9ddba91..713c9424d 100644
> --- a/include/grub/efi/fdtload.h
> +++ b/include/grub/efi/fdtload.h
> @@ -29,7 +29,4 @@ grub_fdt_unload (void);
>  grub_err_t
>  grub_fdt_install (void);
>
> -#define GRUB_EFI_PAGE_SHIFT  12
> -#define GRUB_EFI_BYTES_TO_PAGES(bytes)   (((bytes) + 0xfff) >> 
> GRUB_EFI_PAGE_SHIFT)
> -
>  #endif
> diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h
> index 20526b146..08fe62277 100644
> --- a/include/grub/efi/memory.h
> +++ b/include/grub/efi/memory.h
> @@ -22,6 +22,13 @@
>  #include 
>  #include 
>
> +/* The term "page" in UEFI refers only to a 4 KiB-aligned 4 KiB size region 
> of
> +   memory. It is not concerned with underlying translation management 
> concepts,
> +   but only used as the granule for memory allocations. */
> +#define GRUB_EFI_PAGE_SHIFT 12
> +#define GRUB_EFI_PAGE_SIZE  (1 << GRUB_EFI_PAGE_SHIFT)
> +#define GRUB_EFI_BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >> 
> GRUB_EFI_PAGE_SHIFT)

If you add GRUB_EFI_PAGE_SIZE why not change GRUB_EFI_BYTES_TO_PAGES() macro to

#define GRUB_EFI_BYTES_TO_PAGES(bytes) ALIGN_UP (bytes, GRUB_EFI_PAGE_SIZE)?

Of course in separate patch.

Daniel

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH 3/4] efi: add central copy of grub_efi_find_mmap_size

2017-09-12 Thread Daniel Kiper
On Tue, Sep 05, 2017 at 09:41:13PM +0100, Leif Lindholm wrote:
> There are several implementations of this function in the tree.
> Add a central version in grub-core/efi/mm.c.
>
> Taken from grub-core/loader/i386/linux.c, changing some hard-coded constants
> to use macros from efi/memory.h.

I am OK with the idea but...

> Signed-off-by: Leif Lindholm 
> ---
>  grub-core/kern/efi/mm.c | 47 +++
>  include/grub/efi/efi.h  |  1 +
>  2 files changed, 48 insertions(+)
>
> diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> index ac2a4c556..8795aa1e0 100644
> --- a/grub-core/kern/efi/mm.c
> +++ b/grub-core/kern/efi/mm.c
> @@ -218,6 +218,53 @@ grub_efi_finish_boot_services (grub_efi_uintn_t 
> *outbuf_size, void *outbuf,
>return GRUB_ERR_NONE;
>  }
>
> +/* To obtain the UEFI memory map, we must pass a buffer of sufficient size
> +   to hold the entire map. This function returns a sane start value for
> +   buffer size.  */
> +grub_efi_uintn_t
> +grub_efi_find_mmap_size (void)
> +{
> +  static grub_efi_uintn_t mmap_size = 0;
> +
> +  if (mmap_size != 0)
> +return mmap_size;

What will happen if memory will be fragmented further after this call
and number of memory map entries increases above mmap_size?

> +  mmap_size = 1 * GRUB_EFI_PAGE_SIZE;
> +  while (1)
> +{
> +  int ret;
> +  grub_efi_memory_descriptor_t *mmap;
> +  grub_efi_uintn_t desc_size;
> +  grub_efi_uintn_t cur_mmap_size = mmap_size;
> +
> +  mmap = grub_malloc (cur_mmap_size);
> +  if (! mmap)
> + return 0;
> +
> +  ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size, 0);
> +  grub_free (mmap);
> +
> +  if (ret < 0)
> + {
> +   grub_error (GRUB_ERR_IO, "cannot get memory map");
> +   return 0;
> + }
> +  else if (ret > 0)
> + break;
> +
> +  if (mmap_size < cur_mmap_size)
> + mmap_size = cur_mmap_size;
> +  mmap_size += GRUB_EFI_PAGE_SIZE;
> +}
> +
> +  /* Increase the size a bit for safety, because GRUB allocates more on
> + later, and EFI itself may allocate more.  */
> +  mmap_size += 3 * GRUB_EFI_PAGE_SIZE;
> +
> +  mmap_size = ALIGN_UP (mmap_size, GRUB_EFI_PAGE_SIZE);

I prefer if you do something like that:

map_size = 0;

if (grub_efi_get_memory_map (&map_size, NULL, NULL, &desc_size, 0) < 0)
{
  grub_error (GRUB_ERR_IO, "cannot get EFI memory map size");
  return 0;
}

return ALIGN_UP (map_size + GRUB_EFI_PAGE_SIZE, GRUB_EFI_PAGE_SIZE);

Daniel

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH 4/4] loader: drop local implementations of find_efi_mmap_size

2017-09-12 Thread Daniel Kiper
On Tue, Sep 05, 2017 at 09:41:14PM +0100, Leif Lindholm wrote:
> Now we have a grub_efi_find_mmap_size, replace near-identical implementations
> in i386/linux and mbi2 loaders with calls to that one.

Please do it in separate patches. And I think that
grub-core/commands/efi/lsefimmap.c:grub_cmd_lsefimmap()
begs for similar change too. In general please look for

grub_efi_get_memory_map (&map_size, NULL, NULL, &desc_size, 0)

calls or something like that.

Daniel

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel