TFTP issue with large block sizes

2016-09-07 Thread Sakar Arora
Hi

The tftp block size is hardcoded in grub source code to 1024 bytes. I made some 
changes to alter block size via grub environment variable to increase tftp 
download speed.
But I am facing reliability issues with large block sizes that lead to IP 
packet fragmentation, though the download speed does increase proportionately 
with block size.

Downloading kernel Image.gz via linux command fails at times with "timeout 
reading ./Image.gz" error message. Has anybody else tried playing with the tftp 
block size?
What are your observations?

This is on grub master branch. Boot firmware is UEFI on aarch64.

Thanks
Sakar

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


[PATCH v2 3/4] x86/efi: Retrieve and assign Apple device properties

2016-09-07 Thread Lukas Wunner
Apple's EFI drivers supply device properties which are needed to support
Macs optimally. They contain vital information which cannot be obtained
any other way (e.g. Thunderbolt Device ROM). They're also used to convey
the current device state so that OS drivers can pick up where EFI
drivers left (e.g. GPU mode setting).

There's an EFI driver dubbed "AAPL,PathProperties" which implements a
per-device key/value store. Other EFI drivers populate it using a custom
protocol. The macOS bootloader /usr/standalone/i386/boot.efi retrieves
the properties with the same protocol. The module AppleACPIPlatform.kext
subsequently merges them into the I/O Kit registry (see ioreg(8)) where
they can be queried by other kernel extensions and user space.

This commit extends the efistub to retrieve the device properties before
ExitBootServices is called. It assigns them to devices in an fs_initcall
so that they can be queried with the API in .

Note that the device properties will only be available if the kernel is
booted with the efistub. Distros should adjust their installers to
always use the efistub on Macs. grub with the "linux" directive will not
work unless the functionality of this commit is duplicated in grub.
(The "linuxefi" directive should work but is not included upstream as of
this writing.)

The custom protocol has GUID 91BD12FE-F6C3-44FB-A5B7-5122AB303AE0 and
looks like this:

typedef struct {
unsigned long version; /* 0x1 */
efi_status_t (*get) (
IN  struct apple_properties_protocol *this,
IN  struct efi_dev_path *device,
IN  efi_char16_t *property_name,
OUT void *buffer,
IN OUT  u32 *buffer_len);
/* EFI_SUCCESS, EFI_NOT_FOUND, EFI_BUFFER_TOO_SMALL */
efi_status_t (*set) (
IN  struct apple_properties_protocol *this,
IN  struct efi_dev_path *device,
IN  efi_char16_t *property_name,
IN  void *property_value,
IN  u32 property_value_len);
/* allocates copies of property name and value */
/* EFI_SUCCESS, EFI_OUT_OF_RESOURCES */
efi_status_t (*del) (
IN  struct apple_properties_protocol *this,
IN  struct efi_dev_path *device,
IN  efi_char16_t *property_name);
/* EFI_SUCCESS, EFI_NOT_FOUND */
efi_status_t (*get_all) (
IN  struct apple_properties_protocol *this,
OUT void *buffer,
IN OUT  u32 *buffer_len);
/* EFI_SUCCESS, EFI_BUFFER_TOO_SMALL */
} apple_properties_protocol;

Thanks to @osxreverser for this blog post which was helpful in reverse
engineering Apple's EFI drivers and bootloader:
https://reverse.put.as/2016/06/25/apple-efi-firmware-passwords-and-the-scbo-myth/

If someone at Apple is reading this, please note there's a memory leak
in your implementation of the del() function as the property struct is
freed but the name and value allocations are not.

Neither the macOS bootloader nor Apple's EFI drivers check the protocol
version, but we do to avoid breakage if it's ever changed. It's been the
same since at least OS X 10.6 (2009).

The get_all() function conveniently fills a buffer with all properties
in marshalled form which can be passed to the kernel as a setup_data
payload. The number of device properties is dynamic and can change
between a first invocation of get_all() (to determine the buffer size)
and a second invocation (to retrieve the actual buffer), hence the
peculiar loop which does not finish until the buffer size settles.
The macOS bootloader does the same.

The setup_data payload is later on unmarshalled in an fs_initcall. The
idea is that most buses instantiate devices in "subsys" initcall level
and drivers are usually bound to these devices in "device" initcall
level, so we assign the properties in-between, i.e. in "fs" initcall
level.

This assumes that devices to which properties pertain are instantiated
from a "subsys" initcall or earlier. That should always be the case
since on macOS, AppleACPIPlatformExpert::matchEFIDevicePath() only
supports ACPI and PCI nodes and we've fully scanned those buses during
"subsys" initcall level.

The second assumption is that properties are only needed from a "device"
initcall or later. Seems reasonable to me, but should this ever not work
out, an alternative approach would be to store the property sets e.g. in
a btree early during boot. Then whenever device_add() is called, an EFI
Device Path would have to be constructed for the newly added device,
and looked up in the btree. That way, the property set could be assigned
to the device immediately on instantiation. And this would also work for
devices instantiated in a deferred fashion. It seems like this approach
would be more complicated and require more code. That doesn't 

[PATCH v2 0/4] Apple device properties

2016-09-07 Thread Lukas Wunner
Retrieve device properties from EFI on Macs before ExitBootServices is
called and assign them to devices (patch [3/4]). The devices that
properties pertain to are encoded as EFI Device Paths, so add a parser
for these (patch [2/4]). As a first use case, amend the Thunderbolt driver
to take advantage of the Device ROM supplied by EFI (patch [4/4]).

Patch [1/4] is already queued in Rafael J. Wysocki's tree for 4.9 and is
included here only because patch [2/4] wouldn't compile without it.

The series also depends on these two patches which are already queued
in Matt's tree for 4.9:

- x86/efi: Optimize away setup_gop32/64 if unused
  https://patchwork.kernel.org/patch/9315763/

- x86/efi: Allow invocation of arbitrary boot services
  https://patchwork.kernel.org/patch/9293371/


Changes since v1:

- Previously there were two separate patches for retrieving properties
  and assigning them to devices. These are now squashed together in
  patch [3/4]. (Requested by Matt Fleming.)

- The version of the EFI properties protocol as well as the properties
  payload is now checked.

- Applied a bit of polish all over.


Link to v1:
https://lkml.org/lkml/2016/7/27/218

Browseable on GitHub:
https://github.com/l1k/linux/commits/apple_properties_v2

Thanks,

Lukas


Lukas Wunner (4):
  ACPI / bus: Make acpi_get_first_physical_node() public
  efi: Add device path parser
  x86/efi: Retrieve and assign Apple device properties
  thunderbolt: Use Device ROM retrieved from EFI

 Documentation/kernel-parameters.txt |   5 +
 arch/x86/boot/compressed/eboot.c|  63 +
 arch/x86/include/uapi/asm/bootparam.h   |   1 +
 drivers/acpi/internal.h |   1 -
 drivers/firmware/efi/Kconfig|  18 +++
 drivers/firmware/efi/Makefile   |   2 +
 drivers/firmware/efi/apple-properties.c | 230 
 drivers/firmware/efi/dev-path-parser.c  | 186 ++
 drivers/thunderbolt/Kconfig |   1 +
 drivers/thunderbolt/eeprom.c|  42 ++
 drivers/thunderbolt/switch.c|   2 +-
 include/linux/acpi.h|   7 +
 include/linux/efi.h |  38 ++
 13 files changed, 594 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/efi/apple-properties.c
 create mode 100644 drivers/firmware/efi/dev-path-parser.c

-- 
2.9.3


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