Commit Graph

189 Commits

Author SHA1 Message Date
Richard Hughes
6e34a90a12 trivial: Add FuProgress to fu_context_load_hwinfo()
TIL: fu_bios_settings_setup() takes over 50ms (10%!) at startup.
2023-01-30 14:47:44 +00:00
Richard Hughes
c1ffebae48 Remove unused API for setting backend tags
It turns out we do not want to know the current phase of the device, and we can
achieve the same thing tagging the GUsbDevice manually and clearing the events
at exactly the correct time.
2023-01-30 13:32:48 +00:00
Richard Hughes
047b093904 Copy some flags from the proxy to the logical device 2023-01-30 12:00:04 +00:00
Richard Hughes
575871f505 Add fu_device_remove_backend_tag() for future use 2023-01-24 14:54:23 +00:00
Richard Hughes
fd08eaefee trivial: Fix bitwise operators in last commit 2023-01-22 08:29:20 +00:00
Richard Hughes
2b0f92506b Refactor the hwids functionality
This refactors the code as it was getting very confusing; before FuSmbios was
reading both SMBIOS and the kernel-provided DT -- and various things were
injecting overrides in three different place. To properly support FDT remove
one layer of indirection.

This also lets us use the compatible strings to enable plugins specifying the
flag _REQUIRE_HWID -- which means we only load the plugin if it's got a chance
of working. e.g.

    [aspeed,ast2500]
2023-01-18 07:04:44 +00:00
Richard Hughes
cf4f34572b Add fu_context_get_fdt() to get the Flat Device Tree
This is needed because multiple plugins will soon be consuming the system FDT,
and we don't want to either parse this multiple times, or duplicate the loading
logic.
2023-01-11 16:25:26 +00:00
Josh Soref
67deecde31
Lots of spelling fixes
Fixes:

* activate
* active
* additional
* and
* approaches
* attestation
* bootloader
* calculate
* capability
* children
* close
* compatible
* continuous
* convenience
* critical
* data
* delivery
* disabled
* disambiguate
* documented
* elapse
* emergency
* erasable
* expectations
* filesystem
* from
* haptic
* ignorable
* images
* infinity
* information
* information
* inhibited
* insufficient
* interrupt
* into
* limited
* management
* manifest
* maximum
* memory
* metadata
* mismatch
* model
* nonexistent
* not
* objects
* offset
* omissions
* ota
* past
* perform
* peripherals
* predictable
* product
* quarterly
* quirk
* quirks
* recognize
* release
* requests
* revocation
* sanitized
* sector
* status
* the
* the update
* timeout
* transfer
* transfers
* typically
* unspecified
* upgrade
* which
* will
* wireless
2022-12-29 13:57:31 +00:00
Richard Hughes
069fa56f1a Add fu_archive_firmware_get_image_fnmatch() for future use
It's useful to get images from archives by a specific filename extension.
2022-12-17 07:44:27 +00:00
Richard Hughes
4ef8854618 trivial: Add convenience API for future use 2022-12-13 20:38:49 +00:00
Richard Hughes
a157e3d19d Add fu_version_from_uint24() for future usage 2022-12-11 20:25:52 +00:00
Richard Hughes
e8eaca0051 Save the ONLY_QUIRK instance IDs to fix incorporation of i2c
The baseclass is calling fu_device_build_instance_id_quirk() and when we
incorporate the device we were only copying the 'proper' instance IDs and not
the ones used for quirk matching -- which we need to match the devices that use
keys containing MODALIAS for the Plugin key to be set.
2022-10-25 15:39:30 +01:00
Richard Hughes
6894f67dc5 Do not use GKeyFile to parse quirk files
There are two reasons for this. First is that GKeyFile is quite inefficient,
using a large amount of heap memory when loading. Given we don't actually use
the merge and replace functionality of GKeyFile and we only need line-by-line
access we can parse this ourselves and reduce the peak RSS considerably.

This also accidentally fixes another bug. Moving from multiple quirk files to
a single builtin.quirk meant that multiple subsystem plugins were deduped --
which isn't really what we wanted. For example, this now works:

    [MEI]
    Plugin = one
    [MEI]
    Plugin = two
2022-10-12 15:12:56 +01:00
Richard Hughes
112e26e33d Make the CoSWID parser more full-featured 2022-10-07 16:25:31 +01:00
Richard Hughes
1bd8b5d211 trivial: Speed up the build by about 9%
Only build libfwupdplugin source files once; we were only using one
non-exported symbol and so move that to the exported map so we can just link
the library in the self tests.
2022-09-29 12:42:50 +01:00
Mario Limonciello
d5585728a2 trivial: don't refer to plugindir in the build system anymore 2022-09-28 15:12:10 -05:00
Richard Hughes
c73a55faa1 Remove a potential foot-gun when saving config values
If a specific plugin calls fu_plugin_set_secure_config_value() and then
fu_plugin_set_config_value() then we'll save the file with the world-readable
permissions.

Set a plugin flag to say that 'this plugin is storing sensitive details' which
allows us to use the same entrypoint and also fix up any files at startup that
do not have the correct permissions.
2022-09-22 14:47:12 +01:00
Richard Hughes
ea676855f2 Never save the Redfish passwords to a file readable by users
When the redfish plugin automatically creates an OPERATOR user account on the
BMC we save the autogenerated password to /etc/fwupd/redfish.conf, ensuring it
is chmod'ed to 0660 before writing the file with g_key_file_save_to_file().

Under the covers, g_key_file_save_to_file() calls g_file_set_contents() with
the keyfile string data.
I was under the impression that G_FILE_CREATE_REPLACE_DESTINATION was being
used to copy permissions, but alas not.

GLib instead calls g_file_set_contents_full() with the mode hardcoded to 0666,
which undoes the previous chmod().

Use g_file_set_contents_full() with the correct mode for newer GLib versions,
and provide a fallback with the same semantics for older versions.
2022-09-22 14:46:44 +01:00
Richard Hughes
139188a5b0 Allow adding backend tags to devices
This allows the backend to identify the specific device for a specific phase.

For instance, there might be a pre-update runtime, a bootloader and a
post-update runtime and allowing tags to be saved to the backend object allows
us to identify each version of the same physical device.

This takes us one step closer to emulating a complete byte-perfect end-to-end
update without actual hardware installed.
2022-09-14 16:54:55 +01:00
Richard Hughes
16b463334e Export the generic Intel Thunderbolt firmware format
This is being used for other products, e.g. USB4 docks.

If non-Intel firmware is being used (e.g. ASMedia) then the explicit
calls to `fu_intel_thunderbolt_nvm_new()` can be changed to something
like `fu_firmware_new_from_gtypes()` with all the formats listed.
2022-08-30 14:20:14 +01:00
Mario Limonciello
b7b0ce533d trivial: Unify ambiguity between bios-attrs and bios-settings
These are currently used interchangeably since there was indecisiveness
which to use as the feature was being developed.

As outward facing it will be named with "settings", change all uses
in the code to match this.
2022-08-24 07:20:01 -05:00
Mario Limonciello
7ddbe5e0b3 trivial: don't let people try to turn off UEFI secure boot
The firmware from both Dell and Lenovo actually blocks this, but the
error message is pretty confusing.

```
$ sudo fwupdtool set-bios-setting SecureBoot Disable
17:39:40:0249 FuBiosAttrs          KERNEL BUG: thinklmi doesn't export a 'type' attribute
Loading…                 [-                                      ]
failed to write 7 bytes to 17: Invalid argument
```
2022-08-10 11:09:31 -05:00
Mario Limonciello
7660222240 Add a unique identifier to all BIOSAttr objects
This identifier can be used by plugins or the daemon to disambiguate
behavior between two different drivers.

Set it up so that plugins don't NEED to use it, but optionally can
find attributes by either name or ID
2022-07-29 11:31:50 -05:00
Mario Limonciello
5ded4f44fe Add support for reading and writing firmware attributes
This support is comprehensive:
 * Client library support
 * Daemon support
 * plugin support
 * Client tool support (with new commands)
2022-07-28 17:30:57 -05:00
Richard Hughes
221238b4c0 trivial: Allow each device to specify a different acquiesce delay
Different device classes may need different values, and these may need
modifying by quirks. Also use 50ms to flush out any pending events.
2022-07-21 15:27:04 +01:00
Richard Hughes
0c51630991 Check firmware magic in a more standard way
Some parsers are ignoring the magic when using _FLAG_IGNORE_CHECKSUM
(which is wrong; fuzzers have no problem with enforcing a static prefix)
and other either disregard the offset or check the magic in an unsafe
way. Also, use FWUPD_ERROR_INVALID_FILE consistently for magic failure.

Add a vfunc, and move all the clever code into one place.
2022-07-14 14:48:15 +01:00
Richard Hughes
7a224007f2 Add support for Flat Image Tree aka FIT firmware 2022-07-08 14:05:20 +01:00
Richard Hughes
f3755ef708 Add support for Flattened Devicetree aka FDT firmware 2022-07-08 14:05:20 +01:00
Richard Hughes
57a1270bad Add fu_firmware_get_parent() for future use
Some firmware stacks images hierarchically, and it's useful to be able
to get the parent when unrolling them out into a linear format.
2022-07-05 16:47:18 +01:00
Richard Hughes
e6fee15d3c
Skip uSWID self tests when compiled without cbor support (#4800)
Fixes https://github.com/fwupd/fwupd/issues/4791
2022-07-05 10:20:46 +00:00
Richard Hughes
de31992522 trivial: Fix a tiny memory leak in the self tests 2022-07-01 13:57:18 +01:00
Richard Hughes
91cb4e7274 trivial: Relax some timings a little to fix running valgrind 2022-07-01 13:57:18 +01:00
Richard Hughes
726d20e498 Ensure more firmware formats can round-trip to and from XML
This greatly improves the coverage stats too.
2022-07-01 13:57:18 +01:00
Richard Hughes
96b423e04f Add support for IFWI Intel Flash Program Tool (aka FPT) firmware 2022-06-28 10:09:58 +01:00
Richard Hughes
0a7eb03704 Add a linear firmware wrapper
This allows us to parse any concatenated firmware format where the
image size is stored in the image.
2022-06-28 10:09:58 +01:00
Richard Hughes
08c7172168 Add support for parsing OptionROM firmware 2022-06-28 10:09:58 +01:00
Richard Hughes
f1542c3f9f Add support for IFWI Intel Code Partition (aka CPD) firmware 2022-06-28 10:09:58 +01:00
Richard Hughes
cf9ebdb703 Add startup profiling functionality
Using `sudo FWUPD_PROFILE=10 ./src/fwupd --verbose` will print a
dump of startup times onto the console so that we can debug which
plugin is slowing down system startup. For example:

    ../src/fu-engine.c:5409:plugins-coldplug [108.55ms]:
        ../plugins/amt/fu-plugin-amt.c:437:amt [27.14ms]:
            :create-context [12.66ms]
            :get-version [8.44ms]
            :add-device [3.95ms]
2022-06-14 22:08:02 +01:00
Richard Hughes
30aab6f564 Copy the instance ID strings when incorporating
Also, add a test.
2022-06-14 21:01:57 +01:00
Richard Hughes
d4d0ba0faf Unexport fu_common_cab_build_silo()
There's no reason this needs to be in the shared library.
2022-06-14 14:36:52 -05:00
Richard Hughes
3eaa907534 Remove the now unnecessary fu_smbios_to_string() 2022-06-14 14:36:52 -05:00
Richard Hughes
fc2da47b69 Remove fu_strtoull_full() 2022-06-14 14:36:52 -05:00
Richard Hughes
4105768a01 Remove the 'common' prefix when parsing version numbers 2022-06-14 14:36:52 -05:00
Richard Hughes
3e0a4dc1c3 Be smarter and include less header files per source file 2022-06-14 14:36:52 -05:00
Richard Hughes
7f86ffab6f Split out the dump helpers to a new source file 2022-06-14 14:36:52 -05:00
Richard Hughes
72ca59653e Unexport fu_common_uri_get_scheme()
We don't want plugins to be using this.
2022-06-14 14:36:52 -05:00
Richard Hughes
2c5e4ff3ab Unexport fu_common_firmware_builder()
We don't want plugins to be using this.
2022-06-14 14:36:52 -05:00
Richard Hughes
3f77af3cd4 Split out the kernel helpers to a new source file 2022-06-14 14:36:52 -05:00
Richard Hughes
fd9b9db5b3 Unexport fu_common_instance_id_strsafe()
We want plugins to use the instance ID builder instead now.
2022-06-14 14:36:52 -05:00
Richard Hughes
25dccf09f7 Unexport fu_common_spawn_sync()
This isn't something we want plugins to use.
2022-06-14 14:36:52 -05:00