Implement ACPI table overriding via initramfs
This code generalizes the early_cpio parts of the early microcode implementation.
Then the acpi table overriding parts are added in the last patch.
Successfully tested.
Please consider to apply if people agree with the code.
Thanks,
Thomas
[PATCH 1/3] dracut: Generlize microcode early cpio usage [PATCH 2/3] dracut: Do not create early_cpio if no suitable [PATCH 3/3] dracut: Implement ACPI table overriding
PATCH 1/3 dracut: Generlize microcode early cpio usage
ACPI early table override also may need to place files into an early cpio. Reflect this in variable and file names.
This change is renaming only and does not introduce any real change.
--- dracut.sh | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
dracut.sh +9 -8
@@ -696,9 +696,9 @@ readonly initdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)" } if [[ $early_microcode = yes ]]; then - readonly microcode_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_microcode.XXXXXX)" - [ -d "$microcode_dir" ] || { - printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_microcode.XXXXXX failed." >&2 + readonly early_cpio_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_cpio.XXXXXX)" + [ -d "$early_cpio_dir" ] || { + printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_cpio.XXXXXX failed." >&2 exit 1 } fi
@@ -707,7 +707,7 @@ trap ' ret=$?; [[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$"; [[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; }; - [[ $keep ]] && echo "Not removing $microcode_dir." >&2 || { [[ $microcode_dir ]] && rm -Rf -- "$microcode_dir"; }; + [[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; }; [[ $_dlogdir ]] && rm -Rf -- "$_dlogdir"; exit $ret; ' EXIT
@@ -1301,7 +1301,7 @@ if [[ $early_microcode = yes ]]; then dinfo "*** Generating early-microcode cpio image ***" ucode_dir=(amd-ucode intel-ucode) ucode_dest=(AuthenticAMD.bin GenuineIntel.bin) - _dest_dir="$microcode_dir/d/kernel/x86/microcode" + _dest_dir="$early_cpio_dir/d/kernel/x86/microcode" _dest_idx="0 1" mkdir -p $_dest_dir if [[ $hostonly ]]; then
@@ -1321,14 +1321,15 @@ if [[ $early_microcode = yes ]]; then fi done done - (cd "$microcode_dir/d"; find . -print0 | cpio --null -o -H newc --quiet >../ucode.cpio) + create_early_cpio="yes" fi rm -f -- "$outfile" dinfo "*** Creating image file ***" -if [[ $early_microcode = yes ]]; then +if [[ $create_early_cpio = yes ]]; then # The microcode blob is _before_ the initramfs blob, not after - mv $microcode_dir/ucode.cpio $outfile.$$ + (cd "$early_cpio_dir/d"; find . -print0 | cpio --null -o -H newc --quiet >../early.cpio) + mv $early_cpio_dir/early.cpio $outfile.$$ fi if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null -R 0:0 -H newc -o --quiet| \ $compress >> "$outfile.$$"; ); then
Signature · 1 line
1.7.6.1
A message that is not in the archive (sent off-list or not yet received): 1380042177-66221-1-git-send-email-trenn-l3A5Bk7waGM@public.gmane.org
PATCH 2/3 dracut: Do not create early_cpio if no suitable microcode exist in hostonly case
Intel microcodes only exist for very specific family/model/stepping CPUs. If no microcode gets added, there is no need to create an empty (only directories) cpio later that gets glued to the initrd.
This also fixes:
*** Constructing GenuineIntel.bin ****
cat: /lib/firmware/intel-ucode/06-3c-03: No such file or directory
in hostonly mode if there is no suitable microcode for the CPU.
--- dracut.sh | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
dracut.sh +4 -1
@@ -1316,12 +1316,15 @@ if [[ $early_microcode = yes ]]; then dinfo "*** Constructing ${ucode_dest[$idx]} ****" if [[ $hostonly ]]; then _src=$(get_ucode_file) + if ! [[ -r $_fwdir/$_fw/$_src ]];then + break; + fi fi cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]} + create_early_cpio="yes" fi done done - create_early_cpio="yes" fi rm -f -- "$outfile"
Signature · 1 line
1.7.6.1
PATCH 3/3 dracut: Implement ACPI table overriding
In reply to a message not in the archiveAn example config file for this feature could be:
/etc/dracut.conf.d/03-acpi-override.conf
with this content:
acpi_override="yes"
acpi_table_dir="/etc/dracut.conf.d/acpi_tables"
Then all files ending with *.aml will be put into the early cpio (kernel/firmware/acpi) and will be used to replace the BIOS provided tables if the kernel supports this feature.
--- dracut.sh | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
dracut.sh +11 -0
@@ -1327,6 +1327,17 @@ if [[ $early_microcode = yes ]]; then done fi +if [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; then + dinfo "*** Packaging ACPI tables to override BIOS provided ones ***" + _dest_dir="$early_cpio_dir/d/kernel/firmware/acpi" + mkdir -p $_dest_dir + for table in $acpi_table_dir/*.aml; do + dinfo " Adding ACPI table: $table" + cp $table $_dest_dir + create_early_cpio="yes" + done +fi + rm -f -- "$outfile" dinfo "*** Creating image file ***" if [[ $create_early_cpio = yes ]]; then
Signature · 1 line
1.7.6.1
Quoted 7 lines · Thomas Renninger
This code generalizes the
early_cpioparts of the early microcode implementation.
Then the acpi table overriding parts are added in the last patch.Successfully tested.
Please consider to apply if people agree with the code.
They look good to me (aka Reviewed-by..). Thought I would say you should also add a patch to document this in the manual and the docs.
Quoted 12 lines
Thanks,
Thomas
[PATCH 1/3] dracut: Generlize microcode early cpio usage [PATCH 2/3] dracut: Do not create
early_cpioif no suitable [PATCH 3/3] dracut: Implement ACPI table overriding
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Thomas Renninger
This code generalizes the
early_cpioparts of the early microcode implementation.
Then the acpi table overriding parts are added in the last patch.Successfully tested.
Please consider to apply if people agree with the code.
Quoted 8 lines
Thanks,
Thomas
[PATCH 1/3] dracut: Generlize microcode early cpio usage [PATCH 2/3] dracut: Do not create
early_cpioif no suitable [PATCH 3/3] dracut: Implement ACPI table overriding
pushed! Thanks!