Commit Graph

5517 Commits

Author SHA1 Message Date
Javier Martinez Canillas
f2327011a7 uefi-capsule: Include crt0 for arm and aarch64 that add a SBAT section
Due the lack of pei-aarch64 support in binutils, the gnu-efi crt0 harcodes
the PE32+ sections among other things. These crt0 aren't aware of the SBAT
section and so custom ones have to be used.

In the same vein as commit cfd1f2f42a ("uefi-capsule: Ensure SBAT metadata
is added correctly") included custom linker scripts, this change add a set
of crt0 for arm and aarch64 that hardcode a SBAT section in the PE headers.

These are the crt0 from gnu-efi plus the following fixes from Peter Jones:

* Include .sbat in section headers
* Fix some PE headers
* Calculate the VirtualSize of .sbat separately
* Put .rel* and .dyn* in .rodata
2021-04-07 13:46:58 +01:00
Javier Martinez Canillas
011db8e467 uefi-capsule: Sync linker scripts with latest used by shim
The linker scripts used in the project were copied from the shim project,
but there were a few fixes made after this original copy.

Until binutils have proper pei-aarch64 support, the linker scripts should
be kept in sync to make sure that the PE32+ binaries are built correctly.

The fixes included in this change are the following:

 * Include missing .text sections in PE/COFF binary (Chris Coulson)
 * Put .sbat after _edata (Peter Jones)
 * Fix some PE headers for arm and aarch64 (Peter Jones)
 * Include the aligned part in SizeOfRawData of sbat for arm and aarch64 (Gary Lin)
 * Swizzle some sections to make old sbsign happier for arm and aarch64 (Peter Jones)
 * Put .rel* and .dyn* in .rodata for arm and aarch64 (Peter Jones)
2021-04-07 13:46:58 +01:00
Richard Hughes
4d76d18d35 Set the system battery state and level on the FuContext shared state
This allows plugins to set the battery power state of the *machine* which means
we can automatically inhibit devices with FWUPD_DEVICE_FLAG_REQUIRE_AC set.

It also allows to set the BatteryThreshold to 25% for Lenovo hardware, and we
can override other vendors with further quirks as required.

Fixes https://github.com/fwupd/fwupd/issues/3084
2021-04-07 08:05:15 +01:00
Mario Limonciello
0f50a3186c Add a new internal flag for whether or not to inherit activation
The activation flag is stored into the history database, but not all
plugins will want to inherit it on coldplug the next time the daemon
is started.

For example the Dell Dock plugin will query this information from the
device and it will prevent getting into a bad state as a result.
Fixes: #3106
2021-04-06 14:09:12 -05:00
Mario Limonciello
395856afeb trivial: remove some unused variables
Caught by clang
2021-04-06 14:09:12 -05:00
Richard Hughes
776a0890fe srec: Make FuIhexFirmware derivable for possible future use
An ABI change, so probably not a good idea to backport.
2021-04-06 14:54:39 +01:00
Richard Hughes
7f7e4437fc ihex: Make FuIhexFirmware derivable for future use
An ABI change, so probably not a good idea to backport.
2021-04-06 14:54:39 +01:00
Dirk-Jan C. Binnema
79536a0265 dfu-tool: Avoid runtime warning (overriding error)
We were seeing:

,----
| (dfu-tool:1139827): GLib-WARNING **: 17:34:42.671: GError set over the top of a previous GError or uninitialized memory.
| This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
| The overwriting error message was: no device matches for 1234:abcd
`----

This is because we were attempting to overwrite libgusb's error with one
for fwupd, and glib rightfully complains. So let's prefix it instead.
2021-04-05 14:42:04 -05:00
Richard Hughes
edcca6d1d7 Do not show a GType failure when using fwupdtool
If only one plugin is enabled and there exists a device match for a GType that
has not been registered then the user sees a GType error about not being able
to create a device that wouldn't be created anyway.

By removing the error in the quirk parser we will catch actual errors in
fu_plugin_runner_backend_device_added() which actually does chcek for
FWUPD_PLUGIN_FLAG_DISABLED.

Fixes https://github.com/fwupd/fwupd/issues/3099
2021-04-02 21:52:55 +01:00
Norbert Kamiński
a863e6a84e fu-engine.c: Fix undeclared variable for *BSDs builds
Signed-off-by: Norbert Kamiński <norbert.kaminski@3mdeb.com>
2021-04-02 18:17:46 +01:00
Richard Hughes
f3c64adb6c intel-spi: Allow downloading the firmware image from the eSPI controller
Add the IFD regions as child devices and set the region access on the child
devices. Also add read-only SPI descriptor as an HSI attribute and require
FLOCKDN on Intel hardware.

Use the hidden PCI 00:1f.5 device to set the SPIBAR automatically and generate
the quirk file automatically to support more hardware.
2021-04-01 21:56:35 +01:00
Richard Hughes
b333e0045c Split out a shared system context
There is a lot of code in fwupd that just assigns a shared object type to
a FuPlugin, and then for each device on that plugin assigns that same shared
object to each FuDevice.

Rather than proxy several kinds of information stores over two different levels
of abstraction create a 'context' which contains the shared *system* state
between the daemon, the plugins and the daemon.

This will allow us to hold other per-machine state in the future, for instance
the system battery level or AC state.
2021-04-01 21:11:29 +01:00
Richard Hughes
0d4255b589 vli: Remove deprecated quirk prefixes 2021-04-01 18:40:14 +01:00
Daniel Campello
f82ce6ecb6 flashrom: Update plugin to support multiple devices
This change moves many of the logic at the plugin level to the device
level in order to support multiple devices updatable via libflashrom.
2021-04-01 16:40:09 +01:00
Richard Hughes
c6569eff67 Remvoe the unused fu_plugin_set_coldplug_delay() 2021-04-01 16:01:06 +01:00
Richard Hughes
4ae7b5e837 Remove the unused fu_plugin_recoldplug() 2021-04-01 16:01:06 +01:00
Richard Hughes
250f30ceb9 trivial: Remove more deprecated API because we can
We bumped soversion, so lets clean up the API.
2021-04-01 13:12:45 +01:00
Richard Hughes
5a27967fb9 Simplify asking the user about reviews
Although a 4-state question encodes all the possibilities entirely correctly,
it's not easy for end users to understand. Replace the 2x2 logic by two boolean
questions.

This also has the advantage that we only offer to make the upload automatic if
the initial upload actually succeeded.
2021-03-31 19:21:24 +01:00
Richard Hughes
a3b8515e51 trivial: Inhibit when the *device* power is below the threshold 2021-03-31 19:19:46 +01:00
Richard Hughes
74ac5ab86d trivial: Add fu_device_remove_flag() as a proper symbol
This allows us to automatically uninhibit() like we do in fu_device_add_flag().
2021-03-31 19:19:46 +01:00
Richard Hughes
b9ac0bc029 Add fu_device_inhibit() to mark the device as non-updatable
We already have two things managing the UPDATABLE_HIDDEN->UPDATABLE transition,
and we're about to add a third.

Add a 'stackable' inhibit-style API so we do not accidentally mark a device as
updatable when it should remain hidden.
2021-03-31 19:19:46 +01:00
Richard Hughes
62a8b0c288
Add fu_device_set_battery_threshold() (#3086)
This allows a device to set a custom 'check battery level is X%' value from
either the plugin or from a quirk.
2021-03-31 16:43:36 +01:00
Richard Hughes
18dcb6f511
wacom-raw: Fix an impossible to hit overflow (#3082)
Spotted by Coverity.
2021-03-31 16:30:59 +01:00
Mario Limonciello
541a71b140 trivial: ci: disable LTO for clang (fixes: #3089) 2021-03-31 10:28:27 -05:00
memily
c255034574
vli: Add VL822 device+share-spi-pd
Co-authored-by: Emily Miller <m_emily@berkeley.com>
2021-03-30 13:06:49 +01:00
Érico Nogueira
391647f55e Fix build on musl.
malloc_trim isn't a linux function, it's a GNU extension to malloc.  We
can check for it in meson.build, which avoids hardcoding platform
knowledge.
2021-03-29 18:58:56 +01:00
Richard Hughes
baf10157dd pixart-rf: Retry the SetReport after a successfull firmware update 2021-03-29 10:23:16 +01:00
Richard Hughes
836d9e9568 Offer the user to refresh after enabling
Some users are enabling updates-testing and then wondering why there are no more
firmware updates available. It appears after a 'fwupdmgr refresh' but that's
not obvious to end users who don't know about how this stuff is built.
2021-03-29 09:28:07 +01:00
Richard Hughes
dd61689073 Add fu_device_add_security_attrs() 2021-03-28 17:54:19 +01:00
Steve McIntyre
50348e1104 Tweak the SBAT output for a vendor string
The format is meant to be "<project>.<vendor>" with a period as a
separator.

Signed-off-by: Steve McIntyre <93sam@debian.org>
2021-03-26 15:21:15 +00:00
Ricardo Cañuelo
7f00967392 fu-tool: fix array access in fw_util_verify_update 2021-03-26 08:52:16 +01:00
Benson Leung
ef7262f19f trivial: cros-ec: Fix error string to use inlen
Looks like this error message was copy/pasted from above.
Since we're testing whether actual != inlen, the error message should
output inlen.
2021-03-25 15:12:54 -07:00
Benson Leung
3dba442c1f cros-ec: Fix call to fu_memdup_safe in fu_cros_ec_usb_device_do_xfer
outbuf == NULL is a valid condition in fu_cros_ec_usb_device_do_xfer. That's
how we use this function to specify a read with no outbound buffer, like the
reply at the end of sending a block.
Since 9b11af985f ("Add fu_memdup_safe()"), however, the call to fu_memdup_safe
always fails if outbuf, the dst, is NULL.

Fix this by moving this into the if (outbuf != NULL && outlen > 0)  block below.

Fixes: 9b11af985f ("Add fu_memdup_safe()")
fixes #3064
2021-03-25 21:27:48 +00:00
Richard Hughes
f08491f727 synaptics-cxaudio: Retry GetReport to fix an enumeration failure 2021-03-25 14:30:07 +00:00
Richard Hughes
2d3b8c8427 Add some more new category types for firmware to use 2021-03-24 10:29:09 +00:00
JimmyYu
af1e70ad92 pixart: Modify ota retransmit flow 2021-03-22 17:48:08 +01:00
Richard Hughes
4a1baae30a Do not timeout when bluez fails to start
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1933838
2021-03-22 10:04:28 +00:00
David Chiu
98328679ab synaptics-rmi: Force the hardware into IEP mode as required 2021-03-22 07:51:06 +00:00
David Chiu
02404b0797 synaptics-rmi: Fix regression when setting edpAuxStatusRequest 2021-03-22 07:51:06 +00:00
David Chiu
09ad3a7f93 synaptics-rmi: Allow failure when writing and erasing 2021-03-22 07:51:06 +00:00
David Chiu
f9a0b04389 synaptics-rmi: Validate the firmware signature correctly 2021-03-22 07:51:06 +00:00
David Chiu
b15f393494 synaptics-rmi: Reduce the idle wait time 2021-03-22 07:51:06 +00:00
Richard Hughes
2002bd5046 trivial: Fix a compile failure with new GLib versions
GLib now 'helpfully' includes type_traits in gmacros.h -- which now explodes
when compiling with a C++ compiler.
2021-03-21 20:18:34 +00:00
Richard Hughes
790cb8fea2 ihex: Dectect address overflow causing the fuzz process to take along time
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32302
2021-03-21 20:18:34 +00:00
Richard Hughes
c8423fd685 ihex: Do not allow zero-sized data sections 2021-03-21 20:18:34 +00:00
Richard Hughes
69016bda04 ihex: Do not allow data sections after EOF 2021-03-21 20:18:34 +00:00
Richard Hughes
d4ad7cef71 trivial: Print the ASCII data in FuFirmware->to_string() 2021-03-21 20:18:34 +00:00
Richard Hughes
ece778c83d intel-spi: Fix a typo spotted by Coverity 2021-03-20 17:33:18 +00:00
Richard Hughes
9c318a5a08 trivial: Fix 32 bit overflow in fu_common_get_memory_size()
Spotted by Coverity, thanks!
2021-03-20 17:32:56 +00:00
Richard Hughes
276baf12f9 trivial: Rename spi to intel-spi as it's all Intel specific
If we need to export the EFI symbols into libfwupdplugin for other plugins we
can do that when we need them.
2021-03-20 12:24:27 +00:00