Import Upstream version 2.3.1

This commit is contained in:
openKylinBot 2022-05-14 00:25:25 +08:00
commit 76aace8615
31 changed files with 23500 additions and 0 deletions

6
AUTHORS Normal file
View File

@ -0,0 +1,6 @@
Main author:
* Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Based on previous work by:
* Simon Trimmer
* Tigran Aivazian

30
CONTRIBUTING Normal file
View File

@ -0,0 +1,30 @@
Contributing to iucode_tool development
---------------------------------------
Contributions in the form of patches or merge requests, and bug/issue
reports (especially when they are detailed) are welcome.
Please report issues and bugs (with or without proposed patches) and
request new features through the gitlab interface:
https://gitlab.com/iucode-tool/iucode-tool/issues
Merge requests (aka pull requests) should be made through the gitlab web
interface. Note that I am perfectly happy to also take patches over
email or as attachments to issue reports.
Reporting security issues:
iucode_tool is not particularly security-sensitive, but if you need to
contact me about a security issue that should not be made public before
a fix is widely deployed, you have two options:
1. Contact me through GnuPG encrypted email (key fingerprint/key id
0xC467A717507BBAFED3C160920BD9E81139CB4807).
2. Alternatively, please contact the Debian security team[1]. They will
forward the issue to me, and they can independently coordinate with
vendor-sec and the other Linux distros as required.
[1] https://www.debian.org/security/faq#contact

339
COPYING Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

677
ChangeLog Normal file
View File

@ -0,0 +1,677 @@
2018-02-05, iucode_tool v2.3.1
* iucode_tool: fix filter by revision parser on ILP32
2018-01-28, iucode_tool v2.3
* iucode_tool(8): document changes to ucode filtering
* iucode_tool: support selecting by ucode revision
Add a third (and optional) parameter to microcode selection filters, to
select microcodes by revision. The revision can be prefixed by the
operators eq: (equal to), lt: (less than), or gt: (greater than).
The revision numbering is signed, but in order to be more user friendly,
since we display revisions as unsigned values in hex, we accept the
range -INT32_MAX to +UINT32_MAX, and convert it to int32_t.
* iucode_tool: add function to parse signed 32-bit integers
Add parse_s32e(), based on parse_u32(). It will be used to parse
microcode revisions in the command line, so it has an extension
that accepts something like 0xfffffffe as an alias for -2.
* iucode_tool: optimize detection of base10 numeric names
* iucode_tool: better handle offline/non-continuous topology
* iucode_tool(8): document changes to --scan-system
* iucode_tool: select scan-system strategy change at runtime
Instead of selecting the scan-system strategy at compile time, enhance the
long-version of the --scan-system option to take an optional argument, and
select the strategy. Available strategies are: 0 (auto), 1 (fast), and 2
(exact). Fast uses just the cpuid instruction and activates all steppings.
Exact will query all processors using the kernel cpuid driver. Auto (the
default) is currently the same as fast. The short option -S is equivalent
to --scan-system=auto. This way, we don't break backwards command line
behavior, and something like "iucode_tool -Sl" will still work. In
--scan-system=exact mode, when a /dev/cpu/#/cpuid scan fails, it will use
the result from the cpuid instruction and also add every other stepping for
any signatures found before the failure.
* gitignore: rearrange, and ignore backup and vim swap files
* iucode_tool: move scan_system_processor() one layer down
* iucode_tool: do not scan-system while parsing
Instead of processing -s and -S/--scan-system while parsing, queue all
filters so that we can call scan_system_processors() later. This was the
only complex operation that was being carried out while parsing the command
line. This change ensures that global options such as -q and -v, that are
not supposed to be sensitive to their position in the command line, will
work as expected.
* iucode_tool: add two command-line parser helpers
* intel_microcode.h: document intel_ucode_status_t sources
* update copyright dates to 2018
2017-08-28, iucode_tool v2.2
* README: update for mixed dat and bin Intel releases
* configure: fix handling of --without-foo/--disable-bar
* intel_microcode: fast-track intel_ucode_compare(a, a)
* iucode_tool: fix microcode count when selecting extended signatures
* iucode_tool: rename and document some xx_xtsdeduplist* functions
* configure: support libargp as an alternative to glibc argp
* intel_microcode: do not request inlining for is_zero_checksum()
* iucode_tool: use fprintf(stdout) instead of printf()
* intel_microcode: declare intel_ucode_errstr() as const
* iucode_tool: ensure printf %x args are unsigned
* README: add an example of microcode with multiple sigs
* configure: add --enable-extend-flags to change default build flags
Add a way to not completely override the C/CPP/LDFLAGS configure.ac
would like to set.
* configure: default build to hardened -O3 PIE with lots of warnings
Override the autoconf default CFLAGS, CPPFLAGS and LDFLAGS for a more
optimized, hardened build by default. Also, print the value of these
variables in configure output. The standard methods to override the
default CFLAGS, CPPFLAGS and LDFLAGS in configure still work, and will
bypass the new defaults. Linux distros that override these on every build
should not see any changes. Should the compiler not be detected as
gcc-compatible, no change to CFLAGS/CPPFLAGS/LDFLAGS will be made. Note
that clang is explicitly supported, and works just fine. The build will
default to a baseline of "-O3 -g" and will attempt to selectively enable
several warning options, and several hardening options. configure will
attempt to detect the set of compiler and linker driver flags that would
work. Caveats: autoconf 2.69 and automake 1.13 or later are now
required.
* configure: whitespace fixes and minor cosmetic fixes
2017-02-15, iucode_tool v2.1.2
* iucode_tool: compare payloads of similar (not just duplicate) MCUs
Within the same signature, if two microcodes have the same revision,
and can be installed on the same processor, their payload contents
ought to be the same. However, we would only compare the payloads of
microcodes with the exactly same processor flags mask, which is not
enough. Fix it. Note: this issue not present in Intel-issued
microcode seen in the field.
* iucode_tool: skip small files as if empty in the -tr loader
Make the recovery loader behave the same for empty files and files
that are too small to contain any microcode: report that there were no
microcodes found in the file, and skip the file.
* intel-microcode: validade xx_intel_ucode_check_uc() parameters
* iucode_tool: silence a harmless -Wmissing-field-initializers warning
2017-01-11, iucode_tool v2.1.1
* intel_microcode, iucode_tool: enhance microcode scan API
* intel_microcode: harden intel_ucode_scan_for_microcode()
* intel_microcode, iucode_tool: no more magic 1024 constants
* intel_microcode: forbid unknown buffer sizes in
intel_ucode_check_microcode()
* intel_microcode, iucode_tool: track buffer sizes when iterating
* intel_microcode: fix heap buffer overflow on -tr loader
(CVE-2017-0357)
When the last microcode region ends at exactly the end of the data
file, intel_ucode_scan_for_microcode() would read data past the end of
the memory buffer. This is usually harmless. Unfortunately, should
there be a valid microcode exactly after the memory buffer,
iucode_tool will misbehave *badly*. It is extremely unlikely that the
harmful misbehavior could be triggered by accident -- at least when
iucode_tool is linked to glibc -- due to glibc's memory allocator
implementation details. Also, it is not believed to be possible for
this bug to trigger in a harmful manner when only one datafile is
being processed. However, it might be possible for an attacker to
trigger the issue using a number of specially crafted data files, and
it might also require tricking the user into using a specially crafted
command line. Should the worst happen, iucode_tool may be convinced
to corrupt its heap, and possibly the libc's heap control data
structures, which could result in code execution, depending on the
libc's internals. The harmless version of this bug is trivially
triggered by using the -tr (recovery) loader on any file that ends
with a valid microcode, such as any file that only contains valid
microcode. This issue was detected by gcc's address sanitizer.
* update copyright dates to 2017
* spelling fixes to comments, messages and docs
2016-11-10, iucode_tool v2.1
* iucode_tool: alternative bug workaround for the early initramfs
Implement a less hackish workaround to ensure the microcode file data
will be aligned to a 16-byte boundary from the start of the early
initramfs: instead of extending the microcode data filename with NULs,
add a suitably sized empty directory entry to the initramfs cpio
archive right before it (an empty file entry, or a hardlink entry
would also have worked). We control the size of this "padding" entry
by the length of its name, without any embedded NULs hacks. The
increase in cpio metadata size caused by an extra cpio member header
entry is always going to be absorbed by the padding at the end of the
cpio archive at a 512 byte or 1024 byte block size: the file size of
the resulting early initramfs is not changed. For --mini-earlyfs
mode, which is tailored to what the kernel cares about and minimal
size, we use the older workaround which results in a smaller archive
at a 16-byte block size.
* iucode_tool: cosmetic error path cleanup for write_cpio_header()
* iucode_tool(8): document --mini-earlyfw and --normal-earlyfw
* iucode_tool: add command line option to minimize early initramfs size
A minimized early initramfs has a block size of 16 bytes, and doesn't
contain parent directories.
* iucode_tool: prepare for early-initramfs size minimization
Enhance the low-level cpio header/trailer output functions to take
runtime parameters instead of compile-time constants for: cpio block
size and whether to include parent directories. While at it, constify
parameters on the changed functions where possible.
* iucode_tool: xx_write_cpio_hdrentry can assume dword-alignment
* iucode_tool: generate reproducible early initramfs
Instead of embedding the current time in the early initramfs, use the
latest date found among the microcodes that are going to be included
in that initramfs. While at it, fix an year 2038 issue which would
result in a corrupted initramfs cpio archive. The microcode ordering
inside the initramfs was already stabilized by iucode_tool release
v2.0. This change is a contribution to the Reproducible Builds effort
captained by the Debian project.
* Add new CONTRIBUTING text file:
Add a CONTRIBUTING text file with some details about how to submit bug
reports, report security issues, and request new features.
* Makefile.am: ship CONTRIBUTING in the tarball
* intel_microcode: add intel_ucode_getdate_bcd() function
* intel_microcode: move is_valid_bcd() earlier in the file
* README: remove feeds as means to get latest microcode
Intel is not updating every processor model's download feeds with the
latest microcode package anymore. Do not suggest using them to locate
the latest microcode data pack anymore.
* configure, iucode_tool: define bug report address
* intel_microcode: constify and restyle prototypes
* iucode_tool: constify function parameters
2016-09-12, iucode_tool v2.0
* README: update for pf_mask change in output
* ChangeLog: fix typos
* iucode_tool(8): reduce usage of pf_mask in manpage
* iucode_tool(8): document iucode-tool microcode ids
* iucode_tool: don't str_append_ucode_id() on every microcode
* iucode_tool: ensure IUCODE_MAX_MCU_FILE_SIZE is sane
* iucode_tool: limit verbosity level to 5
* iucode_tool: reorder malloc calls in load_intel_microcode_dat()
* iucode_tool: increase first microcode data size guess to 2MiB
* iucode_tool: fix -h help text for --scan-system
* iucode_tool: limit cpio member size to 4GiB
* iucode_tool(8): update for new -s/-S interaction
Update manpage now that --scan-system can be overridden by -s !<sig>
* iucode_tool: allow override of --scan-system results
Process --scan-system in-line with -s, so that a later -s !<sig> can
override signature filters added by --scan-system. To reproduce the
earlier behavior, have --scan-system as the last option.
* iucode_tool: complain of large sigs and masks for -s option
Detect and report as an error (instead of silently truncating to
32-bits) CPU signatures and processor flags masks in the command line
when they are too large.
* iucode_tool: retry on EINTR during writes
Instead of aborting with an "interrupted system call" error during
writes, retry the operation. This is already done for reads.
* iucode_tool, intel_microcode: fix config.h include order
The autoconf config header must be included before any C library
headers, or it won't have the desired effects.
This change activates large file support on 32-bit targets.
* iucode_tool: support very large output files on 32bit
* iucode_tool: use LFS-safe typecast for 32-bit
* iucode_tool: add exception threshold to disable .dat fast parser
If the fast-path parser fails too many times to handle the .dat file
being processed, disable it for the remaining of that file.
* iucode_tool: add fast-path to .dat loader
Add a limited parser to the .dat loader, and use it as a fast path.
This fast-path parser is capable of dealing with all currently
released Intel .dat files ~40% faster than the better (strtoul-based)
slow path. The fast-path defers to the slow path anything it cannot
handle.
* iucode_tool: use fgets_unlocked to parse .dat files
* iucode_tool: detect large values in .dat files
Detect as invalid any values that won't fit in 32 bits when parsing
Intel .dat files, instead of silently truncating them to 32 bits.
Note that these files would eventually fail to load for other reasons,
such as invalid checksums.
* iucode_tool: add helper to parse uint32_t values
* iucode_tool: detect invalid NULs in .dat format loader
Detect and reject files with embedded NULs when attempting to load
using the text .dat format, since any NULs will cause everything after
them in the same line to be discarded (due to the use of fgets() to
parse the file). This effectively means every line must end with a
newline ('\n') EOL marker, except for the last one in the data file.
* intel_microcode: use the same type for internal microcode sizes
* intel_microcode: don't drop const qualifiers from pointers
* iucode_tool: use unsigned types for cpio header writing
* iucode_tool: fix cosmetic issues in scan_and_pack_microcodes
* intel_microcode: silence harmless sign-conversion
* intel_microcode: remove undesired sign conversions
* iucode_tool: avoid implicit promotion to signed in is_in_date_range()
* iucode_tool: use defensive coding in load_intel_microcode_bin
* iucode_tool: ensure fileno(stdin) did not fail
Fixes: Coverity CID 163302 (false positive, failure requires broken
libc/kernel)
* iucode_tool: avoid signed bit constants
* iucode_tool: (cosmetic comment fixes) it is errno, not errno()
* iucode_tool: avoid conversions for constant line buffer size
* iucode-tool: flush output files to permanent storage
Use fdatasync() to flush output files to permanent storage before
close(). For --write-named-to, --write-all-named-to, and
--write-firmware, also fsync() the parent directory after all files
have been written. These changes cause a severe performance
degradation, but without them we cannot detect write errors on close,
and that can end up corrupting a file important for system boot since
the write error would be undetectable to a shell script.
* configure.ac: default to dist-xz and enable warnings
Enable automake warnings, and switch the "make dist" target to xz
compression, as that's what is being used for the signed release
tarballs.
* configure.ac: update autotools minimum versions
Update the minimum autoconf version to 2.69, and automake to 1.11.
Older versions are not supported, and might or might not work.
This is only relevant when not using the pre-built configure script
shipped in the iucode_tool distribution tarballs.
* iucode_tool: use print_warn() when we do not write to a file
When there is nothing to output to a file, we don't touch it (i.e. we
do not overwrite it with an empty result). Use print_warn() to report
that to the user as a warning, instead of print_msg().
* iucode_tool: fix minor issue on warning message
* iucode_tool: widen bundle id output to three digits
* iucode_tool: change pf mask to pf_mask on output
* iucode_tool: indent selected microcode output
Indent the selected microcode output (for --list) so that it matches
the output of --list-all.
* iucode_tool: change first column of --list output to gid/id
Change the output format of --list output to use the gid/id notation
(the same used by --list-all and also by any error messages and by
most verbose debug or status messages) to identify the selected
microcodes. This is vastly more useful than a monotonically
increasing number that is not usable anywhere else.
* iucode_tool: demote debug output about bundle assignment
Now that we will output bundle assignment messages for --list (and not
just --list-all), demote status/debug output about bundle assignment,
so that it matches the same verbosity level of other messages from the
same function. While at it, change the status message to better match
what it means.
* iucode_tool: output bundle assignment for --list-* when not quiet
Output the bundle assignment headers already used for --list-all also
for --list. Suppress that output for both --list-all and --list when
in quiet mode.
* iucode_tool(8): document new sorting order
Microcode sorting order is now stabilized by a secondary key (pf_mask)
* iucode_tool: refactor and improve uclist_merge_signature()
Refactor uclist_merge_signature() into something much easier to
understand. The refactored code sorts the uclist by cpuid (ascending
order) and pf_mask (descending order), which stabilizes the sorting
order. The pf_masks are sorted in descending order to ensure it will
find supersets first as it walks the list. Downgrade mode is (still)
limited by not being able to change pf_masks, so partially
"superseded" (in the downgrade mode sense) entries will be left over
in the selected microcode list when unavoidable.
2016-06-04, iucode_tool v1.6.1
* iucode_tool: append microcode bundles to linked list in O(1)
* iucode_tool: stop allocating twice the required memory for a bundle
* iucode_tool: don't close input files twice
load_intel_microcode() would cause fds to be closed twice. iucode_tool
is not multi-threaded and isn't otherwise affected by this bug, but
unfortunately there is a free() call between the first and second
close(). When running iucode_tool under some sort of malloc
instrumentation insane enough to open file descriptors on free()
inside the instrumented process' context, or indirectly linked to a
multi-threaded glibc module/plugin that could do the same, bad things
could happen.
* iucode_tool(8): minor fix to a comment
* iucode_tool(8): update Linux notes for up to v4.6
* iucode_tool: constify argp parser information
2016-05-14, iucode_tool v1.6
* iucode_tool: fix failsafe for --enable-cpuid-device
Further fixes for --scan-system when iucode_tool is compiled with the
non-default configure/build-time option --enable-cpuid-device mode.
Do not disable the failsafe mode when either /dev/cpu/*/cpuid cannot be
opened, or an unexpected error happens during the cpuid scan. Note that
we still consider the scan result valid when there are offline nodes.
Also, adjust the error and status/debug messages so that proper feedback
(through a warning) is given to the user when the scan fails.
* iucode_tool: report out-of-memory error during cpuid scan
* iucode_tool(8): document warning when downgrade mode fails
* iucode_tool: warn of shadowed microcode in downgrade mode
Warn when downgrading is impossible due to pf_mask shadowing: this
happens when a pf_mask set loaded earlier has a higher microcode
revision than a pf_mask subset loaded later for the same signature.
* iucode_tool: introduce print_warn()
Note: this changes the single "WARNING" in iucode_tool to "warning"
* iucode_tool: don't snprintf just to printf something
* iucode_tool: silence gcc warnings in -flto mode
* iucode_tool: use pfm for pf_mask in structures
* iucode_tool: fix another downgrade+loose date filter corner case
Fix a corner case for the second pass of the loose date filter in
downgrade mode: while late-merging an earlier microcode (in load order)
whose pf_mask is either the same as, or a superset of, a later microcode
(in load order) but with a same-or-higher revision, it would erroneously
remove the later microcode (i.e. act as if download mode was not
active).
2016-04-30, iucode_tool v1.5.2
* README: update technical details and correct two mistakes
Mixed-stepping configurations are possible, and there was an off-by-one
error in the platform flags mask table.
* iucode_tool(8): fix manpage text for --scan-system
Fix the iucode_tool(8) manpage text to not imply we will scan every
processor in the system, as that depends on configure (compile-time)
options, and it isn't the default behavior since version 1.2.
* iucode_tool: don't assume single signature for multi-socket
When not scanning every processor using the kernel cpuid device, add all
possible steppings for the signature of the running processor.
2016-02-13, iucode_tool v1.5.1
* update copyright dates to 2016
* iucode_tool: drop incorrect use of likely() in uclist_merge_signature()
* iucode_tool(8): document downgrade mode limitations
* iucode_tool: fix unimportant memory leaks for valgrind
Fix two memory leaks at the program exit path for valgrind builds. This
ensures "valgrind --leak-check=full --show-leak-kinds=all" output has no
known false positives. For non-valgrind builds, we simply don't bother to
free any heap memory in the exit path, as it would be just a waste of CPU
cycles.
* iucode_tool: look harder for superseded entries
When we replace an entry that has the same pf_mask, it is necessary to
look for entries that became obsolete. In non-downgrade mode, we might
have skipped a few revisions, and might have merged microcode that is a
proper subset, but has an intermediary revision between ours and the
one we're replacing. In downgrade mode, the revision doesn't matter so
it is even easier to have proper subset entries around that became
obsolete.
* iucode_tool: discard late outdated merge for loose date filter
When in downgrade mode, during the second pass of the loose date
filter, we would merge microcode that is a proper subset (and has the
same revision) of already merged microcode. This is harmless, but it
would waste space in the output. It is unlikely that this bug would
ever happen with real microcode updates.
* iucode_tool: fix downgrade mode when loose date-filtering
Downgrade mode was broken for the loose mode of date filtering. Due to
this bug, a microcode selected by the loose date filter might be
preferred over one that was loaded later.
* iucode_tool: fix infinite loop bug on non-disjoint pf_masks
In the specific case where two microcodes for the same CPU signature
had non-disjoint pf_masks, and neither pf_mask was contained in the
other, the code would loop forever when it attempted to add the second
microcode to the list of selected microcodes. Fortunately, Intel never
published a public microcode update that could trigger this codepath.
This issue exists in every released version of iucode_tool to date.
* iucode_tool: cosmetic changes to load_intel_microcode()
* iucode_tool: make uclist_add_signature() slightly faster
Change uclist_add_signature() to stop looking for duplicates at the
first match. This is slightly faster when processing several files
with many duplicates, but it changes same-sig same-revision internal
ordering from earliest first to latest first. This change to the
sorting order only change the order in which do_write_named() will
create the per-microcode data files. Also, trigger microcode opaque
data comparison on the pointer to the duplicate being non-NULL, instead
of testing for res == EEXIST. Note that this is not fixing an existing
bug, the old code was correct.
* iucode_tool: cosmetic fixes for uclist_add_signature()
2015-10-16, iucode_tool v1.5
* New --write-all-named-to option:
+ iucode_tool(8): document the new --write-all-named-to option.
+ iucode_tool: add a --write-all-named-to option, which works like
--write-named-to, but instead of operating on selected microcode, it
operates on every revision of every microcode. Exact duplicates are
skipped, keyed on INTEL_UCLE_DUPSIG. This avoids the need to always
enable --overwrite mode. This is the only way to write out every
revision of a microcode.
+ iucode_tool: add a new flag, INTEL_UCLE_DUPSIG, and use it to track
duplicate signatures when they are added to all_microcodes. Only the
first copy of that exact microcode (signature+pfm+revision) will not
have INTEL_UCLE_DUPSIG set, in *load* order, regardless of downgrade
mode.
* intel_microcode.c: remove lots of unlikely() use, as the premise that
it is most often called on valid microcode is no longer valid due to
the recovery loader.
* iucode_tool(8): fix parameter of --write-named-to. The manpage text
was incorrectly naming the parameter of the option --write-named-to to
be a file. It is a directory, as documented for the short version of
the same option (-W).
* iucode_tool(8): add two examples for the recovery loader (-tr): how to
use it to load microcode from an early initramfs, and also how to use
it to update an Arch-linux style separate early initramfs.
* Changelog: correct the indentation of older Changelog entries.
* Changelog: switch back to a "raw" changelog style. Writing user-level
documentation is a much better use of time than simplifying Changelogs.
2015-10-03, iucode_tool v1.4
* Implement a microcode recover mode (-tr) for the binary loader,
which searches for valid microcode(s) inside a generic (binary)
data file of unknown format
+ Do not store an empty microcode bundle for further processing,
even if the low-level loader didn't return an error status (this
is for future-proofing, currently all of them return errors)
+ Report unaligned microcode as an internal error in the iterator
functions as well as in intel_ucode_check_microcode(), but add
a private function to allow for microcode checking without
alignment restrictions
+ Add intel_ucode_scan_for_microcode() to search for valid micro-
code(s) inside a memory buffer, regardless of alignment
+ Factor out microcode checksumming into is_zero_checksum(), and
change it to avoid unaligned dword reads. This avoids a long
time gcc -O3 loop vectorizing optimization issue which is still
present in gcc 5.2.1
* Notify the user when we fail to find any microcode in a data file
when the low-level loader returns ENOENT, and continue processing
in that case
* Report empty data files using ENOENT instead of EINVAL in the
low-level loader functions. This is can happen to non-empty files
in the -tr and -td loaders, as well as when reading an empty file
from stdin, FIFO, pipe, character device, etc.
* In -vv mode, print a message before reading a file, and also when
skipping empty files or reading a directory
* Fix spelling of default-firmware-dir option in configure,
thanks to Timo Gurr for the report and fix
* Minor cosmetic fixes:
+ Typo fix: replace "interator" with "iterator" everywhere
+ Add comment about not closing a fd in fix_fds() should it
be copied elsewhere, fix by Imran Zaman
+ Add comment that one must not close(fd) after fdopendir(fd)
succeeded. Both human programmers and static checkers get
confused over this one and mistake it for leak
* Replace "deselect" with "unselect" in the manpage text
2015-05-24, iucode_tool v1.3
* Reopen stdin/stdout/stderr file descriptors using /dev/null if any
of them are closed at program start. Before this change, it was
not safe to call iucode_tool with stdout and/or stderr closed
* Ignore multiple attempts to read microcode data from stdin, as all
data will have been read by the first attempt
* Enforce a maximum of UINT_MAX data files. The number of microcodes
per data file is also limited to UINT_MAX (actually, less than that
due to other limits). Use "unsigned int" instead of "unsigned long
int" for variables related to these (such as microcode group id and
microcode id)
* Document in the manpage the arbitrary maximum limit of 1GiB worth of
binary data per microcode data file. The other limits are too large
to bother documenting
* Microcode data file loader fixes and enhancements:
+ Detect and report stream IO errors while reading .dat files
+ Detect and report IO errors from fdstat() at the beginning
of the binary microcode loader
+ Print the line number when reporting .dat parsing errors
+ Allow comments after valid data for .dat files, previously they
had to be on a line of their own
+ Rework the .dat parser to make it less convoluted, and optimize it
for the exact .dat file layout Intel has been using in the last 15
years
* Minor build fixes
+ Silence unused parameter warning on --disable-cpuid-device build
+ Silence unused function warning on --disable-valgrind-build build
+ configure.ac: minor updates: add AC_COPYRIGHT; move AC_PREREQ
before AC_INIT; remove commented-out AM_MAINTAINER_MODE
* Reorder fields to pack some structs on 64 bits
* Reorder some struct fields for better cache locality
2015-03-29, iucode_tool v1.2.1
* Update README and NEWS to mention the new project home
location at GitLab, due to gitorious.org's planned shutdown
at the end of 2015-05
* Manpage fixes and enhancements:
+ Minor typography/groff fixes
+ Format long examples into multi-line format
+ Add examples for --scan-system, -s and --write-earlyfw
+ Minor changes to the other examples
+ Document iucode_tool use of stdout and stderr
+ Document that iucode_tool ignores the loader version microcode
metadata field entirely
+ Document the use of the "0x" and "0" prefixes to denote hexadecimal
and octal bases for the signature and pf_mask parameters of the -s
option
* Flush stdout before writing to stderr. We want stdout/stderr output
to be correctly interleaved when buffering is in effect due to stdout
redirection
* Flush stdout right after do_process_microcodes() is called, so that
iucode_tool will output the result of --list and --list-all at that
point in time
* Minor argp parser fixes
+ Don't include EOL in argp_error() strings
+ Surround incorrect parameters with single quotes in parser error
messages
* Report internal errors (EINVAL) from uclist_add_signature() as
such. While at it, cosmetic fix the same error message for
uclist_merge_signature()
2015-02-14, iucode_tool v1.2
* Documentation updates:
+ README: correct the /lib/firmware example to not remove execute
permissions from the /lib/firmware/intel-ucode directory, and
enhance the text to make it clear those are examples of fixing the
permissions and may need to be adjusted
+ README: enhance the README text and update it to the post-Haswell
microcode update reality. Also, add a table of pf flags and
masks, to make the text easier to understand and stop using tabs
for the layout
+ iucode_tool(8): update Linux notes to match reality as of kernel
3.18. Also reword and improve the overall text
* iucode_tool: use the cpuid instruction (via gcc's cpuid.h) directly
to implement --scan-system. This assumes there is only one
signature per x86/x86-64 system, which is a safe assumption at this
time. One can have processors with distinct pf flags and the same
signature in a x86/x86-64 multi-processor system, so --scan-system
will match any pf_mask. When compile-time configured with
--enable-cpuid-device (disabled by default), iucode-tool will use
the cpuid instruction directly and also scan every processor using
the kernel cpuid device. This fixes an scalability issue in systems
with many processors
2014-10-28, iucode_tool v1.1.1
* Fix issues found by the Coverity static checker:
+ CID 72165: An off-by-one error caused an out-of-bounds write to a
buffer while loading large microcode data files in ASCII format
(will not be triggered by the data files currently issued by Intel)
+ CID 72163: The code could attempt to close an already closed file
descriptor in certain conditions when processing directories
+ CID 72161: Stop memory leak in error path when loading microcode
data files
+ CID 72159, 72164, 72166, 72167, 72168, 72169: Cosmetic issues
that could not cause problems at runtime.
2014-09-09, iucode_tool v1.1
* Don't output duplicates for microcodes with extended signatures
to the same file or to the kernel
* When writing an early initramfs, pad its trailer with zeros to
the next 1024-byte boundary. This is done so that the next
initramfs segment will be better aligned, just in case. The
entire cpio metadata overhead is now exactly 1024 bytes
* Manpage style fixes: use iucode_tool consistently, groff formatting
* Refuse to load ridiculously large data files (limit set to 1GiB)
2014-08-12, iucode_tool v1.0.3
* Add a work-around for a Linux kernel bug on the early initramfs
microcode update support. The work-around appends non-standard NUL
padding to the file name inside the cpio archive, so as to have the
the microcode data 16-byte-aligned to the start of the file
* Document file alignment requirements for the early initramfs
archive.
* Properly check microcode metadata date to be valid packed BCD in
strict mode
* Do not assume a non-zero microcode Total Size field to be valid, it
is valid only when the Data Size field is non-zero. Fortunately,
Intel always set reserved fields to zero on released microcode, so
this bug was never (and is unlikely to ever be) triggered
* Fix several cosmetic and minor code issues
* minor corrections, enhancements and style fixes to the manpage
2014-05-10, iucode_tool v1.0.2
* Mention iucode-tool's new home at gitorious in documentation.
* Warn user when --scan-system fails due to errors such as a lack
of permission to access the cpuid devices
* Use the libc optimized memcmp() to compare microcode
* Minor manpage updates
* --strict-checks now verifies that the microcode update date
is not utterly insane
2013-12-14, iucode_tool v1.0.1
* Fix several cosmetic code issues
* Manpage updates
+ Make it clear that the output order of microcodes is not stabilized
+ Make it clear that iucode_tool always break links when writing a
data file, and that it doesn't replace files atomically, so they
can get corrupted/lost if iucode-tool is interrupted while writing.
+ Reword several notes for better readability
* Use openat() when loading from a directory
* Use openat() when creating files in a directory
2013-05-25, iucode_tool v1.0
* Add verbose title to manpage iucode_tool(8)
* Add support to write an early initramfs archive for Linux v3.9.
This early initramfs archive will need to be prepended to the
regular initramfs to allow the kernel to load the microcode
update
2013-03-28, iucode_tool v0.9
* Document missing -W, --write-named option in iucode_tool(8)
manpage
* Print the number of unique signatures in verbose mode
* Add loose date-based filtering (--loose-date-filtering option),
which is useful when trying to select microcode for very old
processors
* Skip empty files and directories instead of aborting with an
error
* Add an option to default to an empty selection (-s!)
* Ensure that microcodes with the same metadata have the same
opaque data (payload) when in --strict-checks mode (default)
* Update copyright notices and manpage date
2012-08-26, iucode_tool v0.8.3
* Fix regression introduced in 0.8.2 that caused all microcodes
to be selected by --scan-system on a box with unsupported
processors (e.g. non-Intel)
* Update README: Intel has some microcode update information in
some public processor specification update documents
2012-07-28, iucode_tool v0.8.2
* Update documentation and manpages for the new microcode
update interface in Linux v3.6.
* Fail safe when --scan-system cannot access the cpuid driver:
instead of not selecting anything, still select all microcodes
if no other microcode selection option was used.
* Move NEWS to ChangeLog
2012-07-24, iucode_tool v0.8.1
* Updates to the iucode_tool(8) manpage, disclosing the
need for the cpuid driver for iucode_tool --scan-system,
and more details about the sysfs microcode reload
interface.
* Output an error message if --scan-system could not find
any cpuid nodes in sysfs.
2012-06-07, iucode_tool v0.8
* First release to the general public. Please refer to
the README file for the irrelevant details, and to the
manpage for the relevant details.

237
INSTALL Normal file
View File

@ -0,0 +1,237 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
6. Often, you can also type `make uninstall' to remove the installed
files again.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

10
Makefile.am Normal file
View File

@ -0,0 +1,10 @@
##
## Toplevel Makefile.am for iucode_tool
##
sbin_PROGRAMS = iucode_tool
man_MANS = iucode_tool.8
iucode_tool_SOURCES = intel_microcode.h intel_microcode.c iucode_tool.c
EXTRA_DIST = autogen.sh CONTRIBUTING

853
Makefile.in Normal file
View File

@ -0,0 +1,853 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
sbin_PROGRAMS = iucode_tool$(EXEEXT)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_append_link_flags.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_check_link_flag.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = iucode_tool_config.h
CONFIG_CLEAN_FILES = iucode_tool.8
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"
PROGRAMS = $(sbin_PROGRAMS)
am_iucode_tool_OBJECTS = intel_microcode.$(OBJEXT) \
iucode_tool.$(OBJEXT)
iucode_tool_OBJECTS = $(am_iucode_tool_OBJECTS)
iucode_tool_LDADD = $(LDADD)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(iucode_tool_SOURCES)
DIST_SOURCES = $(iucode_tool_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
man8dir = $(mandir)/man8
NROFF = nroff
MANS = $(man_MANS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)iucode_tool_config.h.in
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
AM_RECURSIVE_TARGETS = cscope
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/iucode_tool.8.in \
$(srcdir)/iucode_tool_config.h.in AUTHORS COPYING ChangeLog \
INSTALL NEWS README TODO compile config.guess config.sub \
depcomp install-sh missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
GZIP_ENV = --best
DIST_ARCHIVES = $(distdir).tar.xz
DIST_TARGETS = dist-xz
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPUID_DEVICE_BASE = @CPUID_DEVICE_BASE@
CPUID_DEVICE_PARENT = @CPUID_DEVICE_PARENT@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MICROCODE_DEVICE_DEFAULT = @MICROCODE_DEVICE_DEFAULT@
MICROCODE_DIR_DEFAULT = @MICROCODE_DIR_DEFAULT@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
man_MANS = iucode_tool.8
iucode_tool_SOURCES = intel_microcode.h intel_microcode.c iucode_tool.c
EXTRA_DIST = autogen.sh CONTRIBUTING
all: iucode_tool_config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
iucode_tool_config.h: stamp-h1
@test -f $@ || rm -f stamp-h1
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
stamp-h1: $(srcdir)/iucode_tool_config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status iucode_tool_config.h
$(srcdir)/iucode_tool_config.h.in: $(am__configure_deps)
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f iucode_tool_config.h stamp-h1
iucode_tool.8: $(top_builddir)/config.status $(srcdir)/iucode_tool.8.in
cd $(top_builddir) && $(SHELL) ./config.status $@
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
} \
; done
uninstall-sbinPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(sbindir)" && rm -f $$files
clean-sbinPROGRAMS:
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
iucode_tool$(EXEEXT): $(iucode_tool_OBJECTS) $(iucode_tool_DEPENDENCIES) $(EXTRA_iucode_tool_DEPENDENCIES)
@rm -f iucode_tool$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(iucode_tool_OBJECTS) $(iucode_tool_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intel_microcode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iucode_tool.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
install-man8: $(man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(man_MANS)'; \
test -n "$(man8dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.8[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \
done; }
uninstall-man8:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man8dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.8[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__post_remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build/sub \
&& ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(MANS) iucode_tool_config.h
installdirs:
for dir in "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-man
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-sbinPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man: install-man8
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-man uninstall-sbinPROGRAMS
uninstall-man: uninstall-man8
.MAKE: all install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \
clean-cscope clean-generic clean-sbinPROGRAMS cscope \
cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
distcheck distclean distclean-compile distclean-generic \
distclean-hdr distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-man8 install-pdf install-pdf-am install-ps \
install-ps-am install-sbinPROGRAMS install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-man uninstall-man8 \
uninstall-sbinPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

141
NEWS Normal file
View File

@ -0,0 +1,141 @@
v2.3:
* Processor signature scan strategies can now be selected at
runtime, using a new optional argument of the --scan-system
option. It is possible to disable the "exact" scan strategy
(which uses the kernel cpuid device) at build time to reduce the
impact on executable size.
* Microcode updates for a specific signature can now be optionally
selected based on their revision, not just processor flags mask.
v2.2:
* build infrastructure changes: autoconf 2.69 or later, and
automake 1.13 or later are now required. The configure script
will attempt to auto-detect and enable several warning and
hardening options by default if CFLAGS/LDFLAGS are *unset*, or if
given the new --enable-extend-flags option. "-O3" optimization
mode will be used by default. The usual ways to override *FLAGS
are respected by configure and the Makefile.
v2.1.1:
* Fix CVE-2017-0357: iucode_tool: heap buffer overflow on -tr loader
v2.1:
* The early initramfs cpio archives created by iucode_tool are now
deterministic. Instead of the current system time, the date of
the latest microcode included in the early initramfs will be used.
* There is a new option to minimize the size of the early initramfs:
--mini-earlyfw. This option causes iucode_tool to create a non-
standard cpio archive which is typically 736 bytes smaller.
WARNING: the microcode data file might not be visible to the
regular initramfs when this mode is used.
* iucode-tool will now create valid early initramfs archives past
year 2038.
v2.0:
* This new major version has several non-backwards-compatible
changes. Scripts that scrape iucode_tool's stdout/stderr messages
might have to be updated, and the behavior for -s and -S options
changed.
* The microcode listing output format used by --list and
--list-all changed: the processor flags mask field is now
labeled "pf_mask" instead of "pf mask", and the first field
(bundle id/microcode id) is wider for --list-all, and completely
changed for --list (refer to next entry).
* The output for the --list option now uses the same microcode
numbering used in --list-all and error messages, and also the
same indentation as --list-all. For this reason, --list will
output the bundle assignment list to stdout when not in --quiet
mode, the same way --list-all does.
* The --scan-system/-S option can now only be specified once, and
it may be overridden by -s !<signature> options that come
*after* it in command line ordering. To emulate the previous
behavior, always specify --scan-system just once, and as the
last option (i.e. after any -s options).
* Error and warning messages, as well as some verbose (and debug)
messages were updated, and some of them were demoted to higher
verbosity levels.
* Other relevant changes since v1.6.1:
* Microcodes are now sorted by signature (ascending) and processor
flags mask (descending). Before, microcodes with the same
signature but different processor flags mask had unspecified
ordering.
* The .dat format loader was optimized to run a lot faster on
files that match the Intel layout exactly, and improved its
error detection.
* iucode_tool now flushes output data files to permanent storage
using fdatasync() before closing them, to better detect write
errors. This causes a performance hit, but it is much safer.
* Fix large file support (LFS) on 32-bit builds.
* Abort with an error when attempting to write more than 4GiB to a
cpio (early initramfs) archive, due to a limitation of that cpio
file format.
v1.6.1:
* Memory usage was greatly reduced when processing large microcode
bundles.
v1.6:
* Fix --scan-system to properly support mixed-stepping systems
(broken since v1.2, partially fixed in v1.5.2).
v1.5:
* There is a new option to write out microcodes, capable of writing
out every revision of every microcode: --write-all-named-to. All
other write out options will only output a single revision of a
microcode. Refer to the manpage for details.
v1.4:
* There is a new file type loader: -tr (recover microcode in
binary format), which searches for valid microcodes in Intel
binary format anywhere inside a binary file.
For standard, undamaged microcode data files, the default
binary loader (-tb) should be used instead: it is faster, and
it will properly complain of data file corruption. Refer to
the manpage for details.
v1.3:
* The .dat file loader was fixed to properly report IO errors, and
enhanced to report the number of the line that caused a syntax
error, as well as to accept comments at the end of a line.
Before, comments had to be on a line of their own. Note that
the .dat file loader assumes all comments start with / and span
to the end of line.
* It is now safe to call iucode_tool with stdin, stdout or stderr
closed: /dev/null will be used, instead.
v1.2.1:
* Due to gitorious.org planned shutdown at the end of 2015-05,
iucode-tool has a new home at gitlab:
https://gitlab.com/iucode-tool
The old home at Debian Alioth will remain as a backup location:
http://anonscm.debian.org/gitweb/?p=users/hmh/intel-microcode.git
v1.2:
* Scalability improvement for --scan-system: by compile-time
default, use the cpuid instruction directly on the running
processor, and assume all other cores have the same
signature. The code now depends on gcc's cpuid.h header.
v1.1:
* Working support for extended signature tables
v1.0.2:
* iucode-tool has a new home at gitorious:
https://gitorious.org/iucode-tool
The old home at Debian Alioth will remain as a backup location:
http://anonscm.debian.org/gitweb/?p=users/hmh/intel-microcode.git
v1.0:
* Added --write-earlyfw, useful to support microcode
updates during very early boot (kernel support added in
Linux v3.9)
* iucode_tool has implemented the most important features
it currently needs, bump the major version number to 1.
v0.9:
* Added -s! and --lose-date-filtering options, described in
the iucode_tool(8) manpage.

331
README Normal file
View File

@ -0,0 +1,331 @@
iucode_tool - Intel® 64 and IA-32 processor microcode tool
Version 2.3.1
Frebruary 5th, 2018
https://gitlab.com/iucode-tool
Intel® 64 and IA-32 system processors (x86_64 and i686 system processors)
are capable of field-upgrading their control program (microcode). These
microcode updates correct processor errata, and are often important for
safe, correct system operation.
While most of the microcode updates fix problems that either happen rarely
or are related to less commonly used features, there are enough updates
fixing issues that would cause system lockup, memory corruption, and
unpredictable system behavior, to warrant taking it seriously.
Microcode updates are ephemeral: they will be lost after a system processor
hard reset or when the processor is powered off. They must be reapplied at
every boot and after the system wakes up from suspend to RAM or to disk.
Updating the system processor microcode is the responsibility of the system
firmware (BIOS or EFI). However, not all vendors will release timely
updates for their firmware when Intel releases updated microcode, and most
users don't update their system firmware in a timely fashion (or at all)
anyway.
The end result is that, unless some other method of distributing microcode
updates is in place, the processor in many systems will be running with
outdated microcode, increasing the chances of incorrect system operation.
Intel has made available to the general public a microcode update data file
(microcode bundle), which the operating system can use to install microcode
updates independently from any system firmware updates. Currently, the
same data file (microcode bundle) is used to distribute microcode updates
for all Intel i686 and X86_64 processor models.
Updating the system processor microcode:
The Intel-distributed microcode bundle contains microcode update data for
several processor models. Older microcode releases used a text format
which is unsuitable to be used directly by the Linux kernel: it must be
converted by an utility like iucode_tool before Linux can use it. Newer
releases have the same microcode update content both in the legacy text
format, and in binary format.
Updating the processor microcode is a process that can be done at any time
(even with the system at full load), and as many times as required. It is
strongly recommended that microcode updates be applied during early system
boot, though:
* Microcode updates should be applied as soon as possible to
shorten the time window where the errata fixed by the update
could still trigger;
* Some microcode updates can only be applied safely before the
operating system enables more advanced processor functionality,
otherwise that functionality must be disabled by the kernel
(Atom PSE erratum);
* Some microcode updates disable (faulty) functionality or make
other "visible" changes to the processor, and must be applied
before either the kernel or applications start using that
functionality (e.g. Haswell Intel TSX erratum).
Therefore, one should always apply microcode updates through firmware
(BIOS/EFI) updates when possible. Failing that, one should use the "early
initramfs" and "early microcode update driver" support in Linux v3.9 and
later. As a last option, one can use the "late microcode update" driver,
but this one might run too late to be of any help (and it cannot safely
apply microcode updates such as the Intel Haswell TSX fix).
To apply a microcode update using the early microcode kernel driver:
1. Arrange for iucode_tool --write-earlyfw to generate the early
initramfs image from microcode data files. You probably want
to also use --scan-system to reduce the size of the generated
early initramfs image;
2. Either prepend the earlyfw image generated by iucode_tool to
the initramfs, or, if your bootloader can handle it, arrange
for it to load the early initramfs and the standard initramfs
images in sequence;
3. Boot the system using a suitable Linux v3.9 or later kernel,
compiled with kconfig options CONFIG_MICROCODE_EARLY=y and
CONFIG_MICROCODE_INTEL_EARLY=y.
4. Ensure the late microcode update driver (microcode module) is
either loaded or compiled in (CONFIG_MICROCODE=y), as it will
be needed if the microcode needs to be reapplied to a processor,
e.g. due to a suspend/resume or hibernate/resume cycle, or due
to CPU hotplug.
This is usually handled by the Linux distro when you install microcode
update support packages. Check your distro's documentation for details.
To apply a microcode update for an Intel system processor after the Linux
kernel boots, using the late microcode update driver (warning: this can
render the system unusable if it applies a microcode update that disables
processor features):
***** WARNING ***** the method below is unsafe ***** WARNING *****
1. Place the binary microcode in /lib/firmware/ with the correct
file name (iucode_tool -K can do this automatically for Intel
microcode);
2. Trigger a microcode refresh action, either by the initial load
of the kernel "microcode" module, or if it is already loaded,
by running the shell commands:
(Linux v3.6 and later)
echo 1 > /sys/devices/system/cpu/microcode/reload
(Linux v3.5 and earlier)
for i in /sys/devices/system/cpu/cpu[0-9]*/microcode/reload ; do
echo 1 2>/dev/null > "$i" || true
done
***** WARNING ***** the method above is unsafe ***** WARNING *****
Downloading the microcode update data file from Intel:
A new version of the microcode update data bundle can be downloaded
directly from Intel, by navigating to the support section looking for
downloads for your processor. One could also search the Intel Download
Center for "microcode linux":
https://downloadcenter.intel.com/SearchResult.aspx?keyword=microcode+linux
To manually install the downloaded microcode data, unpack the archive you
got from Intel and copy the microcode-*.dat file from the archive to where
your distro expects it, e.g. /usr/share/misc/intel-microcode.dat
If your distro uses /lib/firmware to update microcode, you should instead
use "iucode_tool -K" to convert the downloaded microcode bundle to binary
firmware files.
You should make sure the microcode data is owned by root, and that it can
only be written to by root (e.g. mode 0644) for security reasons:
(example, adjust as needed for your Linux distro):
chown root:root /usr/share/misc/intel-microcode.dat
chmod 0644 /usr/share/misc/intel-microcode.dat
(example, if using /lib/firmware):
chown -R root:root /lib/firmware/intel-ucode
find /lib/firmware/intel-ucode -type d -exec chmod 0755 {} \;
find /lib/firmware/intel-ucode -type f -exec chmod 0644 {} \;
You might have to regenerate the initramfs image to get the updated
microcode files into the initramfs. The proper way to do this is
distro-specific.
If your distro has no use for the .dat file after you installed updated
binary files to /lib/firmware, you can remove it to save some space.
About the Intel-supplied microcode updates file:
Unfortunately, as of November 2014, Intel still does not usually publish
any information about changes to the intel-microcode.dat distribution to
the general public. Such information may be available through restricted
developer and partner channels, though. Very rarely, a specification
update might carry some information about the errata fixed by the latest
microcode revision.
Intel removes microcode from their public distribution regularly. One can
theorize that removals of microcode updates for very old processors that
were distributed over a reasonable number of microcode data file releases
were done to reduce bundle file growth. Unfortunately, such removals could
cause unnecessary regressions on very old, but still operational hardware,
so distros used on older hardware might want to still ship them.
On recent processors, Intel microcode release management can be puzzling:
Intel has often removed from the distribution microcode for recent
processors, as well as microcode that it had recently issued updates for.
Microcode version downgrades have also been observed.
We can only hope that Intel will start publishing microcode update
changelog information to the general public in the future. This would
certainly make it easier for distros to schedule microcode updates for
their stable branches.
Technical details (optional reading)
Intel Microcode signatures:
Intel system processor microcode is identified by the processor signature
(a 32-bit number) and by three bits called "processor flags". The
Microcode is often, but not always, the same among several processors that
differ only on their processor flags, and have the same processor
signature.
These signatures are useful when one wants to look for entries referring to
a specific processor in documentation, or request that iucode_tool create
microcode binary bundles for a specific set of processors. Otherwise, you
can just ignore them as they are handled automatically by iucode_tool and
by the kernel microcode driver.
If you want to know the signature of the processors in your system, run
"iucode_tool --scan-system". It is possible for a multiprocessor system
to contain processors with different signatures (known as mixed stepping
configurations), although this is usually not an ideal configuration.
The processor signature is returned in the EAX register from leaf 1 of the
CPUID instruction. It contains an encoded format of the CPU stepping,
model, family and type, and a few undefined (reserved) bits that are zero
on all current Intel processors.
Listing what is inside a microcode bundle:
The microcode signatures for each microcode available in a microcode bundle
can be listed by iucode_tool:
iucode_tool -L /usr/share/misc/intel-microcode.dat
microcode bundle 1: /usr/share/misc/intel-microcode.dat
001/001: sig 0x00000683, pf_mask 0x01, 2001-02-06, rev 0x0013, size 2048
001/002: sig 0x00000f4a, pf_mask 0x5c, 2005-12-14, rev 0x0004, size 2048
001/003: sig 0x00000653, pf_mask 0x04, 1999-05-20, rev 0x000b, size 2048
...
The first and third microcode updates are for very specific processor
models (a single combination of processor flags, each, as they only have
one bit set in the pf_mask field). The second microcode update applies to
several processors that share the same family, model and stepping, but have
different processor flags (more than one bit set in the pf_mask field). The
processor flags and pf_mask field are explained below.
iucode_tool -L s000406A8_m00000001_r0000081F.fw
microcode bundle 1: s000406A8_m00000001_r0000081F.fw
001/001: sig 0x000406a8, pf_mask 0x01, 2014-08-12, rev 0x081f, size 38912
sig 0x000406a8, pf_mask 0x01, 2014-08-12, rev 0x081f
sig 0x000406a9, pf_mask 0x01, 2014-08-12, rev 0x081f
This is a microcode update with multiple signatures. At least one of the
signatures will typically be a duplicate. iucode_tool will act on each
signature (list, select, etc) as if they were independent, but when writing
out the microcode, all of its signatures will be included. It will not
output more than a single copy of the microcode to the same output file.
Microcode revisions:
Microcode revisions are signed 32-bit integers. Negative revisions are
used by Intel during microcode and chip development, and will not be found
on public microcode updates: you'd usually find such microcode only in
UEFI/BIOS images, to support Engineering Sample processors.
Revision 0 is used by the system processor to signal that it is running the
factory-provided microcode (i.e. no microcode updates were installed). No
Intel processor to date (since the Pentium Pro) is supposed to run with
factory (revision 0) microcode: a lot of functionality will be either
extremely buggy or missing entirely.
iucode_tool will list negative revisions as a large unsigned number.
However, it will prefer positive revisions over negative revisions when
selecting microcode.
microcode bundle 1: coreboot/s00040650_m00000072_rFFFF000A.fw
01/001: sig 0x00040650, pf_mask 0x72, 2012-11-09, rev 0xffff000a, size 22528
The release dates are useful to track how old a microcode update is, but
are otherwise ignored by the kernel driver: Intel documentation clearly
states that only the revision number should be used to decide which
microcode update is more recent.
Microcode processor flags mask (pf_mask):
Some Intel processor variants may share the same processor signature, and
yet require different microcode. These processors can be told apart by
checking their "processor flags" (bits 52, 51 and 50 of MSR 17h,
IA32_PLATFORM_ID).
processor flags processor flags mask
000b (0) 00000001b (01h)
001b (1) 00000010b (02h)
010b (2) 00000100b (04h)
011b (3) 00001000b (08h)
100b (4) 00010000b (10h)
101b (5) 00100000b (20h)
110b (6) 01000000b (40h)
111b (7) 10000000b (80h)
The microcode data file has a field called "processor flags mask", or
"pf_mask" for short, where a bit is set if the microcode can be applied to
a processor with that set of processor flags. E.g. if bit 6 is set, that
microcode can be applied to a processor with the appropriate signature and
the processor flags combination 110 (in binary).
A microcode update identified by a processor flags mask of 42 (hexadecimal)
would apply to two types of processors: those with processor flags
combination 001 (binary), and also those with processor flags combination
110 (binary).
The definition of what a processor flag combination means varies with the
processor model.
Some very old processors lack processor flags support. In that case,
microcode updates will have an empty processor flag mask (all bits clear).
When the "microcode" kernel driver is loaded, the processor flags
combination for each online processor in a system will be available through
sysfs. These sysfs nodes follow the pattern:
/sys/devices/system/cpu/cpu*/microcode/processor_flags
NOTE: iucode_tool prefixes hexadecimal values with "0x".
Further reading:
The Intel 64 and IA-32 Architectures Software Developer's Manual, Volume
3A: System Programming Guide, Part 1 (order number 253668), section 9.11.
* Note: Intel is a registered trademark of Intel Corporation.

19
TODO Normal file
View File

@ -0,0 +1,19 @@
* Extended status codes, so that we can tell the user
exactly why we don't want to load a "supposed microcode",
e.g. "extended table checksum is incorrect".
* Compressor support (gzip, others) without the need for
stdin tricks (gzip -dc file.bin.gz | iucode_tool -k -).
VERY useful for .dat files, less so for .bin files.
* Microcode selection:
* select microcodes which were already installed in -K dir
* select/unselect by signature+pfmask+revision
* change code to actually be able to select and merge in
a lossless way, would simplify things a lot.
* error handling
- return status when we skip a ucode? when we skip a file?
* --overwrite: removes symlinks. Maybe it would be better to fail?

1158
aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

6
autogen.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
#
# Commands required to prepare tree for building after
# a clean checkout
autoreconf -i

347
compile Executable file
View File

@ -0,0 +1,347 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

1463
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1848
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

8369
configure vendored Executable file

File diff suppressed because it is too large Load Diff

334
configure.ac Normal file
View File

@ -0,0 +1,334 @@
dnl Process this file with autoconf 2.69+ to produce a configure script.
dnl
dnl Copyright (c) 2010-2018 Henrique de Moraes Holschuh
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
AC_PREREQ([2.69])
AC_INIT([iucode_tool], [2.3.1],
[https://gitlab.com/iucode-tool/iucode-tool/issues],
[iucode-tool],
[https://gitlab.com/iucode-tool/iucode-tool/wikis/home])
AC_COPYRIGHT([Copyright (c) 2010-2018 Henrique de Moraes Holschuh])
AC_CONFIG_SRCDIR([iucode_tool.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.13 gnu no-dist-gzip dist-xz -Wall])
AC_CONFIG_HEADERS([iucode_tool_config.h])
AC_CONFIG_MACRO_DIR([m4])
dnl Work around the lack of a way to set preferred *FLAGS
AC_ARG_ENABLE([extend-flags],
[AC_HELP_STRING([--enable-extend-flags],
[force configure to extend already-defined C/CPP/LDFLAGS])],
[
AC_MSG_NOTICE([will extend C/CPP/LDFLAGS])
enable_cflags_setting=yes
enable_cppflags_setting=yes
enable_ldflags_setting=yes
enable_extend_flags=yes
],
[
AC_MSG_CHECKING([whether configure.ac should try to override CFLAGS])
if test "x${CFLAGS+set}" = xset; then
enable_cflags_setting=no
else
enable_cflags_setting=yes
fi
AC_MSG_RESULT($enable_cflags_setting)
dnl AC_MSG_CHECKING([whether configure.ac should try to override CPPFLAGS])
dnl if test "x${CPPFLAGS+set}" = xset; then
dnl enable_cppflags_setting=no
dnl else
dnl enable_cppflags_setting=yes
dnl fi
dnl AC_MSG_RESULT($enable_cppflags_setting)
AC_MSG_CHECKING([whether configure.ac should try to override LDFLAGS])
if test "x${LDFLAGS+set}" = xset; then
enable_ldflags_setting=no
else
enable_ldflags_setting=yes
fi
AC_MSG_RESULT($enable_ldflags_setting)
])
dnl Before we get to the C compiler...
AC_USE_SYSTEM_EXTENSIONS
dnl Checks for programs
AC_PROG_CC
dnl Checks for headers
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h unistd.h time.h cpuid.h])
dnl Other important checks
AC_C_BIGENDIAN([AC_ERROR([This program does not work on big-endian systems])])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT32_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([memset strcasecmp strdup strerror strrchr strtoul strtoull timegm])
# Allow GNU Argp as a standalone lib, as an alternative to glibc
AC_SEARCH_LIBS([argp_parse], [argp], [],
[AC_ERROR([An implementation of GNU Argp was not found, please install libargp])])
dnl important system extensions
AC_SYS_LARGEFILE
AC_CHECK_FUNCS([flockfile fgets_unlocked])
dnl -----------------
dnl Configure options
dnl -----------------
AC_ARG_WITH([default-kernel-device],
[AS_HELP_STRING([--with-default-kernel-device=PATH],
[default microcode device (/dev/cpu/microcode)])],
[AS_IF([test "x$withval" = "x" || test "x$withval" = "xno"],
[AC_ERROR([--without-kernel-device build unsupported])],
[MICROCODE_DEVICE_DEFAULT="$withval"])],
[MICROCODE_DEVICE_DEFAULT="/dev/cpu/microcode"])
AC_DEFINE_UNQUOTED(MICROCODE_DEVICE_DEFAULT, "$MICROCODE_DEVICE_DEFAULT",
[Path to kernel microcode device])
AC_SUBST(MICROCODE_DEVICE_DEFAULT)
AC_ARG_WITH([default-firmware-dir],
[AS_HELP_STRING([--with-default-firmware-dir=PATH],
[default firmware loader directory (/lib/firmware/intel-ucode)])],
[AS_IF([test "x$withval" = "x" || test "x$withval" = "xno"],
[AC_ERROR([--without-default-firmware-dir build unsupported])],
[MICROCODE_DIR_DEFAULT="$withval"])],
[MICROCODE_DIR_DEFAULT="/lib/firmware/intel-ucode"])
AC_DEFINE_UNQUOTED(MICROCODE_DIR_DEFAULT, "$MICROCODE_DIR_DEFAULT",
[Path to the kernel microcode firmware directory])
AC_SUBST(MICROCODE_DIR_DEFAULT)
AC_ARG_WITH([cpuid-device-parent],
[AS_HELP_STRING([--with-cpuid-device-parent=PATH],
[per-cpu devices parent directory (/dev/cpu)])],
[AS_IF([test "x$withval" = "x" || test "x$withval" = "xno"],
[AC_ERROR([use --disable-cpuid-device instead of --without-cpuid-device-parent])],
[CPUID_DEVICE_PARENT="$withval"])],
[CPUID_DEVICE_PARENT="/dev/cpu"])
AC_DEFINE_UNQUOTED(CPUID_DEVICE_PARENT, "$CPUID_DEVICE_PARENT",
[path to the per-cpu tree of cpuid devices])
AC_SUBST(CPUID_DEVICE_PARENT)
AC_ARG_WITH([cpuid-device-base],
[AS_HELP_STRING([--with-cpuid-device-base=PATH_FORMAT],
[per-cpu cpuid device format string, relative to CPUID_DEVICE_PARENT (%s/cpuid)])],
[AS_IF([test "x$withval" = "x" || test "x$withval" = "xno"],
[AC_ERROR([use --disable-cpuid-device instead of --without-cpuid-device-base])],
[CPUID_DEVICE_BASE="$withval"])],
[CPUID_DEVICE_BASE="%s/cpuid"])
AC_DEFINE_UNQUOTED(CPUID_DEVICE_BASE, "$CPUID_DEVICE_BASE",
[snprintf format string for the per-cpu cpuid device path, relative to CPUID_DEVICE_NAME])
AC_SUBST(CPUID_DEVICE_BASE)
AC_ARG_ENABLE([cpuid-device],
[AS_HELP_STRING([--disable-cpuid-device],
[disable support for the Linux cpuid device (cripples --scan-system=exact)])])
AS_IF([test "x${enable_cpuid_device}" != "xno"],
[AC_DEFINE(USE_CPUID_DEVICE, [], [Support scanning every core using Linux cpuid device])])
AC_ARG_ENABLE([valgrind-build],
[AS_HELP_STRING([--enable-valgrind-build],
[build for valgrind testing])],
[AS_IF([test "x$enableval" != "xno"],
[AC_DEFINE(VALGRIND_BUILD, [], [Valgrind-friendly build])])
])
dnl -------------------------------------------
dnl Override hardcoded *FLAGS for GCC and Clang
dnl If this breaks your platform, file a bug
dnl -------------------------------------------
dnl Do it after most of the autoconf crap, as they tend to screw
dnl up when you have anything more complex than -O2 -g for CFLAGS.
dnl We could do most of these overrides through AM_*FLAGS, but
dnl that's a pain for distros and users to override (as in it breaks
dnl 'make CFLAGS="-O0"') and only to be used for stuff that is
dnl absolutely essential to the build.
dnl if test "${GCC}${enable_cppflags_setting}" = "yesyes" ; then
dnl CPPFLAGS="<whatever>"
dnl fi
if test "x${GCC}${enable_cflags_setting}" = "xyesyes" ; then
dnl in "extend mode", we will get either user-supplied,
dnl or the autoconf-default CFLAGS
if test "x${enable_extend_flags}" != "xyes"; then
CFLAGS="-O3 -g"
fi
dnl We need to detect -Wunknown-warning without the use of -Werror.
dnl -Werror would be unsafe, as it might eventually trigger on the
dnl test source code.
dnl
dnl clang needs "-Werror=unknown-warning-option".
dnl gcc exits with an error when trying to enable unknown warnings.
AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],
[CFLAGSERRUW="-Werror=unknown-warning-option"],
[],
[],
[AC_LANG_SOURCE([[
int
main(void)
{
;
return 0;
}
]])])
dnl gcc and clang warnings the code is not supposed to trigger...
AX_APPEND_COMPILE_FLAGS(
[-Wall -Wextra -Wformat=2 -Werror=format-security dnl
-Wformat-signedness -Wformat-overflow=2 -Wformat-truncation=2 dnl
-Wtrampolines -Wcast-align -Wsign-conversion -Wnull-dereference dnl
-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations dnl
-Wredundant-decls -Wstrict-overflow -Winit-self -Wshadow dnl
-Wrestrict -Wpointer-arith -Wlogical-op -Wbad-function-cast dnl
-Wwrite-strings -Wduplicated-branches -Wduplicated-cond dnl
-Walloca -Wvla -Walloc-zero -Walloc-size-larger-than=1073741824],
[],
[${CFLAGSERRUW}],
[AC_LANG_SOURCE([[
int
main(void)
{
;
return 0;
}
]])])
dnl Do not move _FORTIFY_SOURCE to CPPFLAGS, otherwise bad things
dnl happen when the user does 'make CFLAGS="-O0 -g"'. Debian/Ubuntu
dnl have fixes for this, but others don't. We keep it in CFLAGS
dnl where it will get overriden along with -O3/-O2.
AC_MSG_CHECKING([whether _FORTIFY_SOURCE is already enabled])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
int
main(void) {
#ifndef _FORTIFY_SOURCE
return 0;
#else
#error _FORTIFY_SOURCE already defined
#endif
}
]])],
[
AC_MSG_RESULT([no])
dnl gcc manual says to avoid -Wp,-D like the plague and use
dnl -D/-U directly.
AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2], [], [],
[AC_LANG_SOURCE([[
int
main(int argc, char *argv[])
{
char arr[64], *dst = arr, *src = argv[0];
if (argc && src) { while (*src) { *dst++ = *src++; } }
return 0;
}
]])])
],
[
AC_MSG_RESULT([yes])
])
AX_APPEND_COMPILE_FLAGS([-fstack-protector-strong -Wstack-protector],
[],
[],
[AC_LANG_SOURCE([[
int
main(int argc, char *argv[])
{
char arr[64], *dst = arr, *src = argv[0];
if (argc && src) { while (*src) { *dst++ = *src++; } }
return 0;
}
]])])
fi
if test "x${GCC}${enable_ldflags_setting}" = "xyesyes" ; then
AX_APPEND_LINK_FLAGS([-Wl,-z,relro -Wl,-z,now], [], [],
[AC_LANG_SOURCE([[
int
main(int argc, char *argv[])
{
char arr[64], *dst = arr, *src = argv[0];
if (argc && src) { while (*src) { *dst++ = *src++; } }
return 0;
}
]])])
fi
if test "x${GCC}${enable_ldflags_setting}${enable_cflags_setting}" = "xyesyesyes" ; then
AC_MSG_NOTICE([checking for Position Independent Executables (PIE) support])
OCFLAGS="${CFLAGS}"
AX_CHECK_COMPILE_FLAG([-fPIE],
[
CFLAGS="${CFLAGS} -fPIE"
AX_CHECK_LINK_FLAG([-fPIE -pie],
[LDFLAGS="${LDFLAGS} -fPIE -pie"
AC_MSG_NOTICE([PIE generation enabled])],
[CFLAGS="${OCFLAGS}"
AC_MSG_NOTICE([PIE generation not supported by linker])],
[],
[AC_LANG_SOURCE([[
int
main(void)
{
;
return 0;
}
]])])
],
[AC_MSG_NOTICE([PIE generation not supported by compiler])],
[],
[AC_LANG_SOURCE([[
int
main(void)
{
;
return 0;
}
]])])
fi
dnl --------------------------
dnl autoconf output generation
dnl --------------------------
AC_MSG_NOTICE([project-wide base CPPFLAGS: $CPPFLAGS])
AC_MSG_NOTICE([project-wide base CFLAGS: $CFLAGS])
AC_MSG_NOTICE([project-wide base LDFLAGS: $LDFLAGS])
AC_CONFIG_FILES([Makefile iucode_tool.8])
AC_OUTPUT

791
depcomp Executable file
View File

@ -0,0 +1,791 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

508
install-sh Executable file
View File

@ -0,0 +1,508 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2014-09-12.12; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# $RANDOM is not portable (e.g. dash); use it when possible to
# lower collision chance
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
# As "mkdir -p" follows symlinks and we work in /tmp possibly; so
# create the $tmpdir first (and fail if unsuccessful) to make sure
# that nobody tries to guess the $tmpdir name.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

743
intel_microcode.c Normal file
View File

@ -0,0 +1,743 @@
/*
* Intel CPU Microcode data manipulation
*
* Copyright (c) 2000-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
* 2006 Shaohua Li <shaohua.li@intel.com>
* 2010-2018 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
*
* Based on Linux kernel Intel Microcode driver v2.6.36-rc3 (1.14)
* Based on Linux microcode.ctl version 1.17
*
* Reference: Section 9.11 of Volume 3a, IA-32 Intel Architecture
* Software Developer's Manual
* Order Number 253668 or free download from:
* http://developer.intel.com/design/pentium4/manuals/253668.htm
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "intel_microcode.h"
#include <stdint.h>
#include <sys/types.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
/*
* For micro-optimization on the hotter paths
*/
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
/* pointer alignment test */
#define IS_PTR_ALIGNED(p, a) (!!(((uintptr_t)p & ((uintptr_t)(a)-1)) == 0))
/*
* Microcode update file data structures
*/
/*
* Microcode bundle layout, version 1:
*
* sequence of one or more intel_ucode_v1_get_totalsize() bytes:
* struct intel_ucode_v1_hdr (48 bytes)
* uint32_t data[] (intel_ucode_v1_get_datasize() bytes)
* struct intel_ucode_v1_extsig_table (optional, size varies)
*
* The total size will always be a multiple of 1024 bytes and is
* composed of all three of the above structures.
*/
struct intel_ucode_v1_hdr { /* 48 bytes */
uint32_t hdrver; /* must be 0x1 */
int32_t rev; /* yes, it IS signed */
uint32_t date; /* packed BCD, MMDDYYYY */
uint32_t sig;
uint32_t cksum;
uint32_t ldrver;
uint32_t pf_mask;
uint32_t datasize; /* 0 means 2000 */
uint32_t totalsize; /* 0 means 2048 */
uint32_t reserved[3];
} __attribute__((packed));
/* microcode format is extended from prescott processors */
struct intel_ucode_v1_extsig {
uint32_t sig;
uint32_t pf_mask;
uint32_t cksum;
} __attribute__((packed));
struct intel_ucode_v1_extsig_table {
uint32_t count; /* number of entries in sigs[] */
uint32_t cksum;
uint32_t reserved[3];
struct intel_ucode_v1_extsig sigs[];
} __attribute__((packed));
#define INTEL_UC_V1_DEF_DATASIZE (2000)
#define INTEL_UC_V1_HEADER_SIZE (sizeof(struct intel_ucode_v1_hdr))
#define INTEL_UC_V1_DEF_TOTALSIZE (INTEL_UC_V1_DEF_DATASIZE + \
INTEL_UC_V1_HEADER_SIZE)
#define INTEL_UC_V1_EXTHDR_SIZE (sizeof(struct intel_ucode_v1_extsig_table))
#define INTEL_UC_V1_EXTSIG_SIZE (sizeof(struct intel_ucode_v1_extsig))
#define intel_uc_v1_exttable_size(et) \
((et)->count * INTEL_UC_V1_EXTSIG_SIZE + INTEL_UC_V1_EXTHDR_SIZE)
/**
* is_valid_bcd() - validate 8-digit packed BCD
* @data: 32-bit integer with the 8-digit packet BCD number
*
* Check validity of an 8-digit packed BCD (ensure all digits are
* between 0 and 9).
*
* Returns zero if invalid, and non-zero otherwise.
*/
static inline int is_valid_bcd(const uint32_t data)
{
/* use arcane bit magic to test lower 7 digits just for fun,
* try to figure it out when you're feeling bored. */
return (data < 0xA0000000U) &&
((((data + 0x06666666U) ^ data) & 0x11111110U) == 0);
}
/**
* intel_ucode_v1_get_totalsize() - get total size of a microcode entry
*
* @hdr: pointer to the start of the microcode entry (header)
*
* Returns the total size of a single microcode entry. The microcode
* data file is composed of one or more microcode entries, stored
* back-to-back.
*
* The total size includes the header, microcode data, and the optional
* extended signature table.
*/
static inline uint32_t intel_ucode_v1_get_totalsize(const struct intel_ucode_v1_hdr * const hdr)
{
/* totalsize is valid only if datasize != 0, IA SDM 9.11.1, page 9-28 */
if (hdr->datasize != 0)
return hdr->totalsize;
else
return INTEL_UC_V1_DEF_TOTALSIZE;
}
/**
* intel_ucode_v1_get_datasize() - get microcode data size of a microcode entry
*
* @hdr: pointer to the start of the microcode entry (header)
*
* Returns the size of the opaque data field of a single microcode entry.
*/
static inline uint32_t intel_ucode_v1_get_datasize(const struct intel_ucode_v1_hdr * const hdr)
{
if (hdr->datasize != 0)
return hdr->datasize;
else
return INTEL_UC_V1_DEF_DATASIZE;
}
/**
* intel_ucode_getmetadata() - extract metadata from microcode
* @uc: microcode
* @metadata: pointer to struct intel_ucode_metadata to be filled with
*
* Fills @metadata with metadata from microcode @uc. @uc must already have
* been validated.
*/
intel_ucode_status_t intel_ucode_getmetadata(const void * const uc,
struct intel_ucode_metadata * const metadata)
{
const struct intel_ucode_v1_hdr * const hdr = uc;
if (unlikely(!hdr || !metadata))
return INTEL_UCODE_BAD_PARAMETERS;
if (unlikely(hdr->hdrver != 1))
return INTEL_UCODE_UNKNOWN_FORMAT;
metadata->date_year = hdr->date & 0xffffU;
metadata->date_day = hdr->date >> 16 & 0xffU;
metadata->date_month = hdr->date >> 24 & 0xffU;
metadata->revision = hdr->rev;
metadata->extsig_count = 0;
if (hdr->datasize) {
metadata->size = hdr->totalsize;
if (unlikely(hdr->totalsize > INTEL_UC_V1_HEADER_SIZE + hdr->datasize)) {
const struct intel_ucode_v1_extsig_table * const ext_header =
(const void *)((const uint8_t *)uc + INTEL_UC_V1_HEADER_SIZE + hdr->datasize);
metadata->extsig_count = ext_header->count;
}
} else {
metadata->size = INTEL_UC_V1_DEF_TOTALSIZE;
}
return INTEL_UCODE_NOERROR;
}
/**
* intel_ucode_getdate_bcd() - extract microcode date
* @uc: microcode
*
* Returns the microcode date, in packed BCD (YYYYMMDD) format.
* The date is not normalized, but it will be valid packed BCD.
*
* Call this function only on microcode entries that have been
* verified to be well-formed by intel_ucode_check_microcode().
*
* Returns zero in case of error.
*/
uint32_t intel_ucode_getdate_bcd(const void * const uc)
{
const struct intel_ucode_v1_hdr * const hdr = uc;
if (unlikely(!hdr || hdr->hdrver != 1))
return 0;
if (unlikely(!is_valid_bcd(hdr->date)))
return 0;
/* v1 ucode date field is in MMDDYYYY format */
return ((hdr->date & 0xffffU) << 16) |
((hdr->date >> 16) & 0xffffU);
}
/**
* intel_ucode_compare() - compares two microcodes
*
* @uc1, @uc2: pointer to start of microcode entries to compare
*
* Checks if the two microcode entries are compatible, i.e. they
* differ at most on their pf masks. Compatible microcode entries can
* be merged into a single entry by ORing their pf masks.
*
* Extended signature tables are not supported. If any of the
* microcode entries has one, the function will return a mismatch.
*
* Call this function only on microcode entries that have been
* verified to be well-formed by intel_ucode_check_microcode().
*
* Returns:
* -EINVAL: parameter problem
* -EBADF: two copies of the same microcode, with different opaque data
* 0: the two microcodes are incompatible
* 1: the two microcodes are compatible
* 2: the two microcodes are identical
*/
int intel_ucode_compare(const void * const uc1, const void * const uc2)
{
const struct intel_ucode_v1_hdr * const hdr1 = uc1;
const struct intel_ucode_v1_hdr * const hdr2 = uc2;
unsigned long int ts1, ts2, ds1, ds2;
if (unlikely(!uc1 || !uc2))
return -EINVAL;
if (unlikely((hdr1->hdrver != 1) || (hdr2->hdrver != 1)))
return -EINVAL;
if (unlikely(uc1 == uc2))
return 2;
ts1 = intel_ucode_v1_get_totalsize(hdr1);
ts2 = intel_ucode_v1_get_totalsize(hdr2);
if (ts1 != ts2)
return 0;
ds1 = intel_ucode_v1_get_datasize(hdr1);
ds2 = intel_ucode_v1_get_datasize(hdr2);
if (ds1 != ds2)
return 0;
if (ds1 + INTEL_UC_V1_HEADER_SIZE < ts1)
return 0; /* uc1,2 have extended header */
if (hdr1->sig != hdr2->sig || hdr1->rev != hdr2->rev)
return 0;
if (memcmp((const uint8_t *)uc1 + INTEL_UC_V1_HEADER_SIZE,
(const uint8_t *)uc2 + INTEL_UC_V1_HEADER_SIZE, ds1))
return (hdr1->pf_mask & hdr2->pf_mask)? -EBADF: 0;
/*
* we *really* don't want different microcodes with the same
* rev number and signature, but we don't care if they're the
* same but have different dates.
*/
return (hdr1->date == hdr2->date &&
hdr1->pf_mask == hdr2->pf_mask)? 2 : 1;
}
/**
* intel_ucode_errstr - converts intel_ucode_status_t to string
*
* @status: intel_ucode_status_t value to convert
*
* Returns a human-readable string explaining a intel_ucode_status_t
* status code. The string is static allocated, NULL-terminated,
* and in English.
*/
const char * intel_ucode_errstr(const intel_ucode_status_t status)
{
/* warning: this is an __attribute__((const)) function! */
switch (status) {
case INTEL_UCODE_INVALID_DATA:
return "invalid microcode data";
case INTEL_UCODE_UNKNOWN_FORMAT:
return "unknown microcode format";
case INTEL_UCODE_BAD_EXTENDED_TABLE:
return "bad extended signature table";
case INTEL_UCODE_BAD_EXTENDED_TABLE_CHECKSUM:
return "incorrect extended signature table checksum";
case INTEL_UCODE_BAD_CHECKSUM:
return "incorrect microcode checksum";
case INTEL_UCODE_BAD_EXTENDED_SIG_CHECKSUM:
return "incorrect extended signature checksum";
case INTEL_UCODE_COUNTEROVERFLOW:
return "too many microcodes or signatures to handle";
case INTEL_UCODE_CALLBACK_ERROR:
return "callback returned failure status";
case INTEL_UCODE_NOERROR:
return "success";
case INTEL_UCODE_BAD_PARAMETERS:
return "internal error: bad parameters passed to function";
default:
return "internal error: invalid intel_ucode_status_t status";
}
}
static int is_zero_checksum(const uint8_t *data, uint32_t dwords)
{
uint32_t s = 0;
/*
* Test using -tr loader on a valid microcode data file with one to
* three bytes of zeros prepended (to offset the valid microcode
* data out of alignment).
*/
if (IS_PTR_ALIGNED(data, sizeof(uint32_t))) {
/*
* gcc might generate vectorized code that cannot handle
* unaligned pointer dereferences when given this pattern:
*/
const uint32_t *p = (const uint32_t *)data;
while (dwords--)
s += *(p++);
} else {
/*
* Avoid unaligned accesses. gcc seems to always vectorize
* this properly into code that can handle unaligned data.
* When not vectorized, generates slow code.
*
* Note:
* s += (((uint16_t *)data)[0] | (((uint16_t *)data)[1] << 16));
*
* also works when vectorized by gcc, and generates faster
* and better code than doing it one byte at a time like
* below. However, when working around compiler issues, it
* often pays off to go all the way...
*/
while (dwords--) {
s += ((unsigned int)data[0] |
((unsigned int)data[1] << 8) |
((unsigned int)data[2] << 16) |
((unsigned int)data[3] << 24));
data += 4;
}
}
return (s == 0);
}
/*
* xx_intel_ucode_check_uc()
*
* refer to intel_ucode_check_microcode() for details.
*
* @uc does not have to be aligned.
*
* We depend on the fact that x86/x86-64 is fine with misaligned data
* access, as long as you keep away from aligned vector instructions and
* other "specials".
*/
static intel_ucode_status_t xx_intel_ucode_check_uc(const void * const uc,
const size_t maxlen,
const int strict)
{
unsigned long int total_size, data_size, ext_table_size;
const struct intel_ucode_v1_hdr * const uc_header = uc;
unsigned int i;
if (unlikely(!uc || (strict && !IS_PTR_ALIGNED(uc, sizeof(uint32_t)))))
return INTEL_UCODE_BAD_PARAMETERS;
if (unlikely(maxlen < INTEL_UC_MINSIZE))
return INTEL_UCODE_INVALID_DATA;
if (unlikely(uc_header->hdrver != 1))
return INTEL_UCODE_UNKNOWN_FORMAT;
/* Header version 1 format */
total_size = intel_ucode_v1_get_totalsize(uc_header);
data_size = intel_ucode_v1_get_datasize(uc_header);
if (data_size > total_size || data_size < INTEL_UC_V1_HEADER_SIZE)
return INTEL_UCODE_INVALID_DATA;
if (data_size + INTEL_UC_V1_HEADER_SIZE > total_size)
return INTEL_UCODE_INVALID_DATA;
if (data_size % sizeof(uint32_t))
return INTEL_UCODE_INVALID_DATA;
if (total_size % sizeof(uint32_t))
return INTEL_UCODE_INVALID_DATA;
if (strict && total_size % 1024)
return INTEL_UCODE_INVALID_DATA;
if (total_size > maxlen)
return INTEL_UCODE_INVALID_DATA;
/* Calculate the checksum. We exclude the extended table as it
* also has to have a zero checksum, in order to get better
* coverage */
if (!is_zero_checksum(uc, (INTEL_UC_V1_HEADER_SIZE + data_size) / sizeof(uint32_t)))
return INTEL_UCODE_BAD_CHECKSUM; /* invalid checksum */
/* we can now assume that this is very likely to be microcode */
ext_table_size = total_size - (INTEL_UC_V1_HEADER_SIZE + data_size);
if (unlikely(ext_table_size)) {
const struct intel_ucode_v1_extsig_table *ext_header;
const struct intel_ucode_v1_extsig *ext_sig;
uint32_t ext_sigcount;
if (ext_table_size < INTEL_UC_V1_EXTHDR_SIZE)
return INTEL_UCODE_BAD_EXTENDED_TABLE; /* exttable size too small */
if ((ext_table_size - INTEL_UC_V1_EXTHDR_SIZE) % INTEL_UC_V1_EXTSIG_SIZE)
return INTEL_UCODE_BAD_EXTENDED_TABLE; /* bad exttable size */
ext_header = (const void *)((const uint8_t *)uc + INTEL_UC_V1_HEADER_SIZE + data_size);
if (ext_table_size != intel_uc_v1_exttable_size(ext_header))
return INTEL_UCODE_BAD_EXTENDED_TABLE; /* bad exttable size */
/* extended table checksum */
if (!is_zero_checksum((const uint8_t *)ext_header, ext_table_size / sizeof(uint32_t)))
return INTEL_UCODE_BAD_EXTENDED_TABLE_CHECKSUM; /* invalid checksum */
ext_sigcount = ext_header->count;
/* check checksum of each extended signature */
ext_sig = (const void *)((const uint8_t *)ext_header + INTEL_UC_V1_EXTHDR_SIZE);
i = ext_sigcount;
while (i--) {
uint32_t sum = (ext_sig->sig + ext_sig->pf_mask + ext_sig->cksum) -
(uc_header->sig + uc_header->pf_mask + uc_header->cksum);
if (sum)
return INTEL_UCODE_BAD_EXTENDED_SIG_CHECKSUM; /* invalid checksum */
ext_sig++;
}
}
/* misc sanity checks */
if (unlikely(!uc_header->date)) /* missing date, breaks filtering */
return INTEL_UCODE_INVALID_DATA;
if (unlikely(strict && !uc_header->rev)) /* illegal revision */
return INTEL_UCODE_INVALID_DATA;
if (unlikely(strict && (
!is_valid_bcd(uc_header->date) || (uc_header->date & 0xffffU) < 0x1995U ||
!(uc_header->date >> 16 & 0xffU) || (uc_header->date >> 16 & 0xffU) > 0x31U ||
!(uc_header->date >> 24 & 0xffU) || (uc_header->date >> 24 & 0xffU) > 0x12U )))
return INTEL_UCODE_INVALID_DATA;
return INTEL_UCODE_NOERROR;
}
/**
* intel_ucode_check_microcode() - perform sanity checks on a microcode entry
*
* @uc: pointer to the beginning of a microcode entry
* @strict: if non-zero, perform more strict checking
* @maxlen: memory buffer size (limit microcode entry to maxlen bytes)
*
* This function checks the well-formedness and sanity of a microcode entry.
* All other functions in the library expect to receive sane and well-formed
* microcode headers and full microcode entries, so this function MUST be
* used beforehand.
*
* @uc must be correctly aligned to a 4-byte boundary.
*
* In strict mode, secondary checks such as size constraints are applied
* which will help weed off almost-correct data. This DID flag some weird
* microcode for signature 0x106c0, present in one of the microcode files
* distributed by urbanmyth.org in 2008 (apparently it was microcode for
* an engineering stepping of an Atom processor).
*
* Returns INTEL_UCODE_NOERROR if the microcode entry looks sane, or a
* different status code indicating a problem with the microcode entry.
*/
intel_ucode_status_t intel_ucode_check_microcode(const void * const uc,
const size_t maxlen,
const int strict)
{
if (unlikely(!uc || !IS_PTR_ALIGNED(uc, sizeof(uint32_t))))
return INTEL_UCODE_BAD_PARAMETERS;
return xx_intel_ucode_check_uc(uc, maxlen, strict);
}
/**
* intel_ucode_scan_for_microcode() - scan for valid microcode
*
* @bs: pointer to a pointer to the memory area to scan for valid
* microcode. Modified on return to point to the start of the
* area with valid microcode
* @be: Modified on return to point to the first byte past the end
* of the area with valid microcode
* @blen: Modified on return to be the size of the microcode area
* @alen: size of the memory area to search. Modified on return
* to account for the bytes that have been already searched
* (i.e. @bs delta plus @blen).
*
* This function searches for the first well-formed microcode entry in the
* memory area starting at @bs, with a length of @alen. Then, it validates
* all microcodes in that memory area that are stored back-to-back (up to
* INT_MAX microcodes), and updates @bs to point to the start of the first
* microcode. It sets @be to point to the byte after the last microcode
* and @blen to the size of the microcode block, and updates @alen to
* account for all data already read from the memory area.
*
* Returns the number of microcodes found (can be zero), or a
* negative error number:
*
* -EINVAL: Invalid function parameters
* -EFAULT: Internal error (counter/pointer under/overflow)
*
* It searches for valid microcode using intel_ucode_check_microcode()
* in non-strict mode.
*
* There are no alignment requirements on @bs or on the start position of
* the first microcode inside the memory area. @bs and @be are pointers
* to a byte-aligned memory area (i.e. char* / uint8_t*).
*
* The resulting microcode area, if one is found, MIGHT BE UNALIGNED, IN
* WHICH CASE IT MUST BE COPIED/MOVED TO A 4-BYTE ALIGNED BUFFER BEFORE USE.
*/
int intel_ucode_scan_for_microcode(const void ** const bs, const void ** const be,
size_t * const blen, size_t * const alen)
{
intel_ucode_status_t r = INTEL_UCODE_INVALID_DATA;
const uint8_t *p, *q;
size_t bl, al, cnt_max;
int uc_cnt;
if (!bs || !be || !blen || !alen)
return -EINVAL;
al = *alen;
cnt_max = al;
p = *bs;
/* NOTE: update only at success exit path */
*blen = 0;
*be = p;
/* find first microcode */
while (al >= INTEL_UC_MINSIZE) {
q = memchr(p, 0x01, al); /* search for a v1 header, which starts with 0x01 */
if (!q) {
/* not found */
*be = *(const uint8_t **)bs + *alen;
*alen = 0;
return 0;
}
/* successful memchr() ensures q >= p, and (q-p) < al */
al -= (size_t)(q - p);
if (unlikely(!al || al > cnt_max))
goto paranoia_out;
p = q;
r = xx_intel_ucode_check_uc(p, al, 0);
if (r == INTEL_UCODE_NOERROR)
break;
p++;
al--;
}
if (r != INTEL_UCODE_NOERROR)
return 0;
*bs = p;
/* find size of the continuous area */
bl = 0;
uc_cnt = 0;
cnt_max = al;
do {
const struct intel_ucode_v1_hdr * const uch = (const void *)p;
const unsigned long int total_size = intel_ucode_v1_get_totalsize(uch);
p += total_size;
bl += total_size;
al -= total_size;
uc_cnt++;
if (unlikely(al > cnt_max || bl > cnt_max))
goto paranoia_out;
r = xx_intel_ucode_check_uc(p, al, 0);
} while (uc_cnt < INT_MAX && r == INTEL_UCODE_NOERROR);
*be = p;
*blen = bl;
*alen = al;
return uc_cnt;
paranoia_out:
/* Hardening against programming errors that could cause counter
* under/overflow or buffer overflow */
*bs = *be;
return -EFAULT;
}
/**
* intel_ucode_foreach_signature() - run callback for every signature
*
* @uc: pointer to the microcode entry
* @action: callback of type intel_ucode_sig_callback
* @userdata: opaque pointer passed to callback
*
* Call the @action callback for each signature in the microcode entry,
* including any optional extended signatures.
*
* Do NOT run this function on microcode that was not verified to be
* correct by intel_ucode_check_microcode().
*
* @uc must be correctly aligned to a 4-byte boundary.
*/
intel_ucode_status_t intel_ucode_foreach_signature(const void * const uc,
intel_ucode_sig_callback * const action,
void * const userdata)
{
const struct intel_ucode_v1_hdr * const uc_header = uc;
const void *uc_data;
unsigned int total_size, data_size, ext_table_size;
if (!action || !uc || !IS_PTR_ALIGNED(uc, sizeof(uint32_t)))
return INTEL_UCODE_BAD_PARAMETERS;
if (uc_header->hdrver != 1)
return INTEL_UCODE_UNKNOWN_FORMAT;
/* Header version 1 format */
uc_data = (const uint8_t *)uc + INTEL_UC_V1_HEADER_SIZE;
total_size = intel_ucode_v1_get_totalsize(uc_header);
data_size = intel_ucode_v1_get_datasize(uc_header);
/* Process first signature (from header) */
if (action(userdata, 0,
uc_header->sig, uc_header->pf_mask,
uc_data, data_size, uc, total_size))
return INTEL_UCODE_CALLBACK_ERROR;
ext_table_size = total_size - (INTEL_UC_V1_HEADER_SIZE + data_size);
if (ext_table_size) {
const struct intel_ucode_v1_extsig_table *ext_header;
const struct intel_ucode_v1_extsig *ext_sig;
uint32_t ext_sigcount;
uint32_t i;
ext_header = (const void *)((const uint8_t *)uc + INTEL_UC_V1_HEADER_SIZE + data_size);
ext_sig = (const void *)((const uint8_t *)ext_header + INTEL_UC_V1_EXTHDR_SIZE);
ext_sigcount = ext_header->count;
for (i = 1; i <= ext_sigcount; i++) {
if (action(userdata, i,
ext_sig->sig, ext_sig->pf_mask,
uc_data, data_size, uc, total_size))
return INTEL_UCODE_CALLBACK_ERROR;
ext_sig++;
}
}
return INTEL_UCODE_NOERROR;
}
/**
* intel_ucode_foreach_microcode() - run callback for every microcode entry
*
* @uc_bundle: bundle of microcodes
* @uc_bundle_size: size of the microcode bundle in bytes
* @action: callback of type intel_ucode_mc_callback
* @userdata: opaque pointer passed to callback
*
* Call the @action callback for each microcode in the microcode entry.
*
* Note that it is very likely that the callback will HAVE to call
* intel_ucode_check_microcode() to check each microcode, and return
* non-zero should it be faulty, otherwise nasty things can happen.
*
* A version 1 microcode bundle is a series of microcode entries, one
* after the other, without any sort of padding.
*
* @uc_bundle must be correctly aligned to a 4-byte boundary.
*/
intel_ucode_status_t intel_ucode_foreach_microcode(
const void * const uc_bundle,
const size_t uc_bundle_size,
intel_ucode_uc_callback * const action,
void * const userdata)
{
const uint8_t *uc = uc_bundle;
size_t leftover = uc_bundle_size;
unsigned int uc_count;
if (!action || !uc || !IS_PTR_ALIGNED(uc, sizeof(uint32_t)))
return INTEL_UCODE_BAD_PARAMETERS;
/* try to guess bundle version */
if (uc_bundle_size < INTEL_UC_MINSIZE)
return INTEL_UCODE_INVALID_DATA;
if (((const struct intel_ucode_v1_hdr *)uc)->hdrver != 1)
return INTEL_UCODE_UNKNOWN_FORMAT;
/* bundle of version 0x1 microcodes */
uc_count = 0;
while (leftover) {
unsigned int uc_size;
if (leftover < INTEL_UC_V1_HEADER_SIZE)
return INTEL_UCODE_INVALID_DATA;
uc_count++;
if (!uc_count)
return INTEL_UCODE_COUNTEROVERFLOW;
uc_size = intel_ucode_v1_get_totalsize((const struct intel_ucode_v1_hdr *)uc);
if (uc_size % sizeof(uint32_t) || uc_size > leftover)
return INTEL_UCODE_INVALID_DATA;
if (action(userdata, uc_count, uc, leftover))
return INTEL_UCODE_CALLBACK_ERROR;
uc += uc_size;
leftover -= uc_size;
}
return INTEL_UCODE_NOERROR;
}

159
intel_microcode.h Normal file
View File

@ -0,0 +1,159 @@
/*
* Intel CPU Microcode data manipulation
*
* Copyright (c) 2000-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
* 2006 Shaohua Li <shaohua.li@intel.com>
* 2010-2018 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
*
* Based on Linux kernel Intel Microcode driver v2.6.36-rc3 (1.14)
* Based on Linux microcode.ctl version 1.17
*
* Reference: Section 9.11 of Volume 3a, IA-32 Intel Architecture
* Software Developer's Manual
* Order Number 253668 or free download from:
* http://developer.intel.com/design/pentium4/manuals/253668.htm
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef INTEL_MICROCODE_H
#define INTEL_MICROCODE_H
#include "iucode_tool_config.h"
#include <stdint.h>
#include <sys/types.h>
/* Minimum object size that could have a valid production microcode */
#define INTEL_UC_MINSIZE 1024
typedef enum { /* status result codes */
INTEL_UCODE_NOERROR = 0,
INTEL_UCODE_BAD_PARAMETERS,
INTEL_UCODE_INVALID_DATA,
INTEL_UCODE_UNKNOWN_FORMAT,
/* only returned by intel_ucode_check_microcode() */
INTEL_UCODE_BAD_EXTENDED_TABLE,
INTEL_UCODE_BAD_EXTENDED_TABLE_CHECKSUM,
INTEL_UCODE_BAD_EXTENDED_SIG_CHECKSUM,
INTEL_UCODE_BAD_CHECKSUM,
/* only returned by the foreach functions */
INTEL_UCODE_CALLBACK_ERROR,
INTEL_UCODE_COUNTEROVERFLOW,
} intel_ucode_status_t;
struct intel_ucode_metadata {
uint16_t date_year; /* 4-bit packed BCD format */
uint8_t date_day; /* 4-bit packed BCD format */
uint8_t date_month; /* 4-bit packed BCD format */
int32_t revision;
uint32_t size;
uint32_t extsig_count;
};
intel_ucode_status_t intel_ucode_getmetadata(const void * const uc,
struct intel_ucode_metadata * const metadata);
uint32_t intel_ucode_getdate_bcd(const void * const uc);
/**
* intel_ucode_sigmatch() - match signature against processor signature
*
* @s1: CPUID 0x01, EAX
* @s2: microcode signature/extended signature "sig" field
* @p1: 1 << (MSR IA32_PLATFORM_ID[52:50])
* @p2: microcode signature/extended signature "pf" mask
*
* Returns true if the microcode can be used in a given processor.
*
* The kernel driver exports through sysfs the processor flags already
* in the format expected by this macro.
*/
#define intel_ucode_sigmatch(s1, s2, p1, p2) \
(((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0))))
const char * intel_ucode_errstr(const intel_ucode_status_t status) __attribute__((const));
intel_ucode_status_t intel_ucode_check_microcode(const void * const uc,
const size_t maxlen,
const int strict);
int intel_ucode_compare(const void * const uc1, const void * const uc2);
int intel_ucode_scan_for_microcode(const void ** const bs,
const void ** const be,
size_t * const blen,
size_t * const alen);
/* Iterators */
/**
* intel_ucode_sig_callback() - callback function for the
* intel_ucode_foreach_microcode() function
*
* @userdata: pointer as passed to intel_ucode_foreach_microcode()
* @uc_count: one-based counter of microcode entries
* @uc: pointer to start of microcode entry
* @uc_max_size: maximum bound for microcode entry size
*
* @uc is a pointer to somewhere inside the original bundle passed to
* intel_ucode_foreach_microcode(), where a microcode entry starts.
* DO NOT MODIFY the memory area pointed by @uc.
*
* Note that it is very likely that the callback will HAVE to call
* intel_ucode_check_microcode(uc) to check the microcode entry, and
* return non-zero should it is faulty, otherwise nasty things can
* happen.
*
* If the callback returns a non-zero value, the foreach operation
* is aborted with a INTEL_UCODE_CALLBACK_ERROR error.
*/
typedef int (intel_ucode_uc_callback)(void * const userdata,
const unsigned int uc_count,
const void * const uc,
const size_t uc_max_size);
intel_ucode_status_t intel_ucode_foreach_microcode(
const void * const uc_bundle,
const size_t uc_bundle_size,
intel_ucode_uc_callback * const action,
void * const userdata);
/**
* intel_ucode_sig_callback() - callback function for the
* intel_ucode_foreach_signature() function
*
* @userdata: pointer as passed to intel_ucode_foreach_signature()
* @sig_count: zero-based counter of signatures on this microcode
* @cpuid: cpuid this microcode applies to
* @pf_mask: processor flags mask this microcode applies to
* @uc_data: microcode data
* @uc_data_size: microcode data size
* @uc: microcode entry (headers and data)
* @uc_size: microcode entry size
*
* DO NOT MODIFY THE MEMORY AREAS REFERENCED BY @uc_data and @uc.
*
* The callback can obtain data about the microcode through
* a call to intel_ucode_getmetadata(uc, metadata).
*
* If the callback returns a non-zero value, the foreach operation
* is aborted with a INTEL_UCODE_CALLBACK_ERROR error.
*/
typedef int (intel_ucode_sig_callback)(void * const userdata,
const unsigned int sig_count,
const uint32_t cpuid,
const uint32_t pf_mask,
const void * const uc_data,
const unsigned int uc_data_size,
const void * const uc,
const unsigned int uc_size);
intel_ucode_status_t intel_ucode_foreach_signature(const void * const uc,
intel_ucode_sig_callback * const action,
void * const userdata);
#endif /* INTEL_MICROCODE_H */

489
iucode_tool.8.in Normal file
View File

@ -0,0 +1,489 @@
.\" hey, Emacs: -*- nroff -*-
.\" Copyright (c) 2010-2018 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
.\"
.\" iucode_tool is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; see the file COPYING. If not, write to
.\" the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
.\"
.TH IUCODE_TOOL 8 "2018-01-28" "IUCODE_TOOL @VERSION@" "iucode_tool manual"
.\" Please update the above date whenever this man page is modified.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins (default)
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.\"
.\" disable a Debian-specific workaround for the misuse of - to mean \-
.char - \(hy
.\"
.SH NAME
iucode_tool \- Tool to manipulate Intel\*R IA-32/X86-64 microcode bundles
.SH SYNOPSIS
.B iucode_tool
.RI [ options ]
.RI "[[\-t" type "] " filename | dirname "] ..."
.SH DESCRIPTION
\fBiucode_tool\fP is an utility that can load Intel\*R processor microcode
data from files in both text and binary microcode bundle formats.
.PP
It can output a list of the microcodes in these files, merge them, upload
them to the kernel (to upgrade the microcode in the system processor cores)
or write some of them out to a file in binary format for later use.
.PP
\fBiucode_tool\fP will load all microcodes in the specified files and
directories to memory, in order to process them. Duplicated and outdated
microcodes will be discarded. It can read microcode data from standard
input (\fIstdin\fP), by specifying a file name of \(lq\-\(rq (minus sign).
.PP
Microcode data files are assumed to be in .dat text format if they have a .dat
suffix, and to be in binary format otherwise. Standard input (\fIstdin\fP) is
assumed to be in .dat text format. The \fI\-t\fP option can be used to change
the type of the files specified after it, including for \fIstdin\fP.
.PP
If a directory is specified, all files whose names do not begin with a
dot will be loaded, in unspecified order. Nested directories are skipped.
.PP
Empty files and directories are ignored, and will be skipped.
.PP
You can select which microcodes should be written out, listed or uploaded
to the kernel using the
.IR "\-S" ", " "\-s" ", " "\-\-date\-before" " and " "\-\-date\-after"
options. Should none of those options be specified, all microcodes will be
selected.
.PP
You can upload the selected microcodes to the kernel, write them out to
a file (in binary format), to a Linux early initramfs archive, to
per-processor-signature files in a directory, or to per-microcode files
in a directory using the
.IR "\-w" ", "
.IR "\-\-write\-earlyfw" ", "
.IR "\-k" ", "
.IR "\-K" ", and "
.IR "\-W" " options."
.PP
\fBiucode_tool\fP will identify microcodes in its output and error messages
using a \(lq\fIn/k\fP\(rq notation, where \(lq\fIn\fP\(rq is the bundle
number, and \(lq\fIk\fP\(rq is the microcode number within that bundle. The
output of the
.IR "\-\-list\-all" " option"
when processing multiple input files is the best example of how it works.
.PP
For more information about Intel processor microcodes, please read the
included documentation and the Intel manuals listed in the \fISEE ALSO\fP
section.
.SH OPTIONS
\fBiucode_tool\fP accepts the following options:
.TP
.BR \-q ", " \-\-quiet
Inhibit usual output.
.TP
.BR \-v ", " \-\-verbose
Print more information. Use more than once for added verbosity.
.TP
.BR \-h ", " \-? ", " \-\-help
List all available options and their meanings.
.TP
.B \-\-usage
Show summary of options.
.TP
.BR \-V ", " \-\-version
Show version of program.
.TP
.BI "\-t " type
.RI "Sets the file type of the following files. " type " can be:"
.RS
.IP \fBb\fP
binary format. This is the same format used by the kernel driver and the
BIOS/EFI, which is described in detail by the
.IR "Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A",
section 9.11.
.IP \fBd\fP
Intel microcode .dat text format. This is the format normally used
by Intel to distribute microcode data files.
.IP \fBr\fP
recover microcode in binary format. Search uncompressed generic binary
files for microcodes in Intel microcode binary format to recover. Note:
It can find microcode that will not pass strict checks, and thus cause
\fBiucode_tool\fP to exit if the \fI\-\-no\-strict\-checks\fP or
\fI\-\-ignore\-broken\fP options are not in effect.
.IP \fBa\fP
(default) \fBiucode_tool\fP will use the suffix of the file name to
select the file type: .dat text format for files that have a
.I .dat
suffix, and binary type otherwise. Note that for \fIstdin\fP, .dat
text format is assumed.
.RE
.TP
.B "\-\-downgrade"
When multiple versions of the microcode for a specific processor are
available from different files, keep the one from the file loaded last,
regardless of revision levels. Files are always loaded in the order
they were specified in the command line. This option has no effect
when just one file has been loaded.
.TP
.B "\-\-no\-downgrade"
When multiple versions of the microcode for a specific processor are
available from different files, keep the one with the highest revision
level. This is the default mode of operation.
.TP
.B "\-\-strict\-checks"
Perform strict checks on the microcode data. It will refuse to load
microcodes and microcode data files with unexpected size and metadata. It
will also refuse to load microcode entries that have the same metadata, but
different payload. This is the default mode of operation.
.TP
.B "\-\-no\-strict\-checks"
Perform less strict checks on the microcode data. Use only if you happen
to come across a microcode data file that has microcodes with weird sizes
or incorrect non-critical metadata (such as invalid dates), which you want
to retain. If you just want to skip those, use the \fI\-\-ignore\-broken\fP
option.
.TP
.B "\-\-ignore\-broken"
Skip broken microcode entries when loading a microcode data file, instead
of aborting program execution. If the microcode entry has an unsupported
format or had its header severely corrupted, all remaining data in the file
will have to be ignored. In that case, using a file type of \fIrecover
microcode in binary format\fP (\fI\-tr\fP option) is recommended, as it
can skip over badly mangled microcode data.
.TP
.B "\-\-no\-ignore\-broken"
Abort program execution if a broken microcode is found while loading a
microcode data file. This is the default mode of operation.
.TP
.BI "\-s ! | [!]" signature "[,[" pf_mask "][,[" lt: "|" eq: "|" gt: "]" revision "]]"
Select microcodes by the specified \fIsignature\fP, \fIprocessor flags mask\fP
(\fIpf_mask\fP), and \fIrevision\fP.
If the \fIprocessor flags mask\fP is specified, it will select only microcodes
that are suitable for at least one of the processor flag combinations present
in the mask.
If the \fIrevision\fP is specified, optionally prefixed by one of the
\(lq\fIeq:\fP\(rq, \(lq\fIlt:\fP\(rq or \(lq\fIgt:\fP\(rq operators, it will
select only microcodes that have that same \fIrevision\fP (if no operator, or
if the \(lq\fIeq:\fP\(rq operator is used), or microcodes that have a
\fIrevision\fP that is less than (\(lq\fIlt:\fP\(rq operator), or greater than
(\(lq\fIgt:\fP\(rq operator), the one specified.
Specify more than once to select more microcodes. This option can be combined
with the \fI\-\-scan\-system\fP option to select more microcodes. If
\fIsignature\fP is prefixed with a \(lq\fI!\fP\(rq (exclamation mark), it will
deselect microcodes instead. Ordering matters, with later \fI\-s\fP options
overriding earlier ones, including \fI\-\-scan\-system\fP.
When specifying \fIsignature\fP and \fIpf_mask\fP, hexadecimal numbers must be
prefixed with \(lq\fI0x\fP\(rq, and octal numbers with \(lq\fI0\fP\(rq.
Decimal numbers must not have leading zeros, otherwise they would be
interpreted as octal numbers.
The special notation \fI\-s!\fP (with no \fIsignature\fP parameter) instructs
\fBiucode_tool\fP to require explicit inclusion of microcode signatures (using
the non\-negated form of \fI\-s\fP, or using \fI\-\-scan\-system\fP).
.TP
.BR "\-S" ", " "\-\-scan\-system" "[=\fImode\fP]"
Select microcodes by scanning online processors on this system for their
signatures.
This option can be used only once, and it can be combined with the \fI\-s\fP
option to select more microcodes. The microcodes selected by
\fI\-\-scan\-system\fP can also be deselected by a later \fI\-s\ !signature\fP
option.
The optional \fImode\fP argument (accepted only by the long version of the
option) selects the strategy used to scan processors:
.RS
.IP "\fB0\fP or \fBauto\fP"
Currently the same as \fBfast\fP, but this might change in future versions if
Intel ever deploys multi-signature systems that go beyond mixed-stepping. This
is the default mode of operation, for backwards compatibility
with previous versions of \fBiucode_tool\fP.
.IP "\fB1\fP or \fBfast\fP"
Uses the cpuid instruction to detect the signature of the processor
\fBiucode_tool\fP is running on, and selects all steppings for that processor's
type, family and model. Supports mixed-stepping systems.
.IP "\fB2\fP or \fBexact\fP"
Uses kernel drivers to scan the signature of every online processor directly.
This mode supports multi-signature systems. This scan mode will be slow on
large systems with many processors, and likely requires special permissions
(such as running as the root user). Should the scan fail for any reason, as
a fail-safe measure, it will issue an warning and consider all possible
steppings for every signature it did manage to scan successfully.
.RE
.TP
\fB\-\-date\-before\fR=\fIYYYY\-MM\-DD\fR and \fB\-\-date\-after\fR=\fIYYYY\-MM\-DD\fR
Limit the selected microcodes by a date range. The date must be given in ISO
format, with four digits for the year and two digits for the month and day and
\(lq\fI\-\fP\(rq (minus sign) for the separator. Dates are not range-checked,
so you can use \fI\-\-date\-after=2000\-00\-00\fP to select all microcodes
dated since January 1st, 2000.
.TP
.B \-\-loose\-date\-filtering
When a date range is specified, all revisions of the microcode will be
considered for selection (ignoring just the date range, all other filters still
apply) should any of the microcode's revisions be within the date range.
.TP
.B \-\-strict\-date\-filtering
When a date range is specified, select only microcodes which are within the
date range. This is the default mode of operation.
.TP
.BR "\-l" ", " "\-\-list"
List selected microcode signatures to standard output (\fIstdout\fP).
.TP
.BR "\-L" ", " "\-\-list\-all"
List all microcode signatures while they're being processed to standard output
(\fIstdout\fP).
.TP
.BR "\-k" "[\fIdevice\fP], " "\-\-kernel" "[=\fIdevice\fP]"
Upload selected microcodes to the kernel. Optionally, the device path can be
specified (default:
.IR "@MICROCODE_DEVICE_DEFAULT@" "). This update method is deprecated:
it will be removed eventually from the kernel and from iucode_tool.
.TP
.BR "\-K" "[\fIdirectory\fP], " "\-\-write\-firmware" "[=\fIdirectory\fP]"
Write selected microcodes with the file names expected by the Linux kernel
firmware loader. Optionally, the destination directory can be specified
.RI "(default: " "@MICROCODE_DIR_DEFAULT@" ")."
.TP
.BR "\-w\fIfile\fP" ", " "\-\-write\-to" "=\fIfile\fP"
Write selected microcodes to a file in binary format.
.TP
.BR "\-\-write\-earlyfw" "=\fIfile\fP"
Write selected microcodes to an early initramfs archive, which should be
prepended to the regular initramfs to allow the kernel to update processor
microcode very early during system boot.
.TP
.BR "\-W\fIdirectory\fP" ", " "\-\-write\-named\-to" "=\fIdirectory\fP"
Write selected microcodes to the specified directory, one microcode per
file, in binary format. The file names reflect the microcode signature,
processor flags mask and revision.
.TP
.BR "\-\-write\-all\-named\-to" "=\fIdirectory\fP"
Write every microcode to the specified directory, one microcode per file,
in binary format. The file names reflect the microcode signature,
processor flags mask and revision. This is the only way to write out every
revision of the same microcode.
.TP
.B "\-\-overwrite"
Remove the destination file before writing, if it exists and is not a
directory. The destination file is not overwritten in-place. Hardlinks
will be severed, and any existing access permissions, ACLs and other
extended attributes of the old destination file will be lost.
.TP
.B "\-\-no\-overwrite"
Abort if the destination file already exists. This is the default mode of
operation. Do note that iucode_tool does not follow non-directory symlinks
when writing files.
.TP
.B "\-\-mini\-earlyfw"
Optimize the early initramfs cpio container for minimal size. It will
change the cpio block size to 16 bytes, and remove header entries for the
parent directories of the microcode data file. As a result, the microcode
data file will not be available to the regular initramfs, and tools might
complain about the non-standard cpio block size.
This will typically reduce the early initramfs size by 736 bytes.
.TP
.B "\-\-normal\-earlyfw"
Optimize the early initramfs size for tool compatibility. This is the
default mode of operation. The microcode data file will be available
inside the regular initramfs as well.
.SH NOTES
\fBiucode_tool\fP reads all data to memory before doing any processing. It
enforces a sanity limit of a maximum of 1GiB worth of binary microcode data
per microcode data file.
.PP
All informational and error messages are sent to standard error
(\fIstderr\fP), while user-requested output (such as output generated by
the list options) is sent to standard output (\fIstdout\fP).
.PP
\fBiucode_tool\fP creates files with permissions 0644 (rw\-r\-\-r\-\-),
modified by the current umask.
.PP
\fBiucode_tool\fP's selected microcode listing and microcode output files
are sorted first by \fIprocessor signature\fP (in ascending order), and
then by \fIprocessor flags mask\fP (in descending order).
.PP
When multiple revisions of a microcode are selected, the older ones will
be skipped. Only the newest selected revision of a microcode (or the
last one in load order when the \fI\-\-downgrade\fP option is active) will
be written to a file or uploaded to the kernel.
.PP
Intel microcode data files, both in binary and text formats, can be
concatenated to generate a bigger and still valid microcode data file.
.PP
\fBiucode_tool\fP does not follow symlinks when writing microcode data
files. It will either refuse to write the file and abort (default mode
of operation), or (when the \fI\-\-overwrite\fP option is active) it will
remove the target symlink or file (and therefore breaking hardlinks)
\fIbefore\fP writing the new file.
.PP
\fBiucode_tool\fP does follow directory symlinks to locate the directory
to write files into.
.SS Linux Notes
Before Linux v4.4, the microcode update driver was split in two parts: the
early microcode update driver (which gets microcode data from the
initramfs) and the late microcode update driver, which could be a module
and got microcode data from the firmware subsystem. The two drivers were
unified in Linux v4.4.
The microcode update driver needs to be present in the system at all times
to ensure microcode updates are reapplied on resume from suspend and CPU
hotplug. Do not unload the microcode module, unless you really know
better. Since Linux v4.4, the late microcode driver cannot be a module
anymore and will always be present in the system when enabled.
Updating microcode early is safer. It can only be done at boot and it
requires an initramfs, but it is strongly recommended: late microcode
updates (which read microcode data from /lib/firmware) cannot safely change
visible processor features.
Early microcode updates are available since Linux v3.9. They can safely
change visible processor features (such as the microcode updates that
disabled Intel TSX instructions on Intel Haswell cores do). They require
an uncompressed initramfs image with the microcode update data in
\fI/kernel/x86/microcode/GenuineIntel.bin\fP. This uncompressed initramfs
image must come before any compressed initramfs image(s), and it has an
special name: \fIearly initramfs\fP.
The microcode update data inside the early initramfs image must be aligned
to a 16-byte boundary due to a bug in several versions of the Linux kernel
early microcode update driver. This requires special steps when creating
the initramfs archive with the microcode data, and will be handled
automatically by the \fBiucode_tool\fP \fI\-\-write\-earlyfw\fP option.
Since Linux v4.2, it is also possible to build a kernel with the microcode
update data as built-in firmware, using the CONFIG_FIRMWARE_IN_KERNEL
facility. This feature is not yet mature as of Linux v4.2.8, v4.4.11,
v4.5.5 and v4.6, and might not work in every case.
The \fI/dev/cpu/microcode\fP update interface has been deprecated and
should not be used. It has one special requirement: each write syscall
must contain whole microcode(s). It can be accessed through
\fBiucode_tool\fP \fI\-\-kernel\fP.
Up to Linux v3.5, late microcode updates were required to be triggered
per-core, by writing the number 1 to
\fI/sys/devices/system/cpu/*/microcode/reload\fP for every cpu. Depending
on kernel version, you must either trigger it on every core to avoid a
dangerous situation where some cores are using outdated microcode, or the
kernel will accept the request only for the boot processor and use it to
trigger an update on all system processor cores.
Since Linux v3.6, the late microcode update driver has a new interface
that explicitly triggers an update for every core at once when the number
1 is written to \fI/sys/devices/system/cpu/microcode/reload\fP.
.SH EXAMPLES
.SS Updating files in \fI@MICROCODE_DIR_DEFAULT@\fP:
.HP
iucode_tool \-K@MICROCODE_DIR_DEFAULT@ \\
.br
@MICROCODE_DIR_DEFAULT@ \\
.br
/tmp/file\-with\-new\-microcodes.bin
.SS Processing several compressed files at once:
.HP
zcat intel\-microcode*.dat.gz | iucode_tool\ \-l\ \-
.HP
zcat intel\-microcode*.bin.gz | iucode_tool \-l\ \-tb\ \-
.SS Selecting microcodes and creating an early initramfs:
.HP
iucode_tool \-\-scan\-system \\
.br
\-\-write\-earlyfw=/tmp/early.cpio \\
.br
/lib/firmware/intel\-ucode
.HP
iucode_tool \-s\ 0x106a5 \-s\ 0x106a4 \-l /lib/firmware/intel\-ucode
.SS Using the recovery loader to load and to update microcode in an early initramfs:
.HP
iucode_tool \-L \-tr /boot/intel\-ucode.img
.HP
iucode_tool \-Ll \-S \-\-write\-earlyfw=/boot/intel\-ucode.img.new \\
.br
\-tr /boot/intel\-ucode.img \-tb /lib/firmware/intel\-ucode && \\
.br
mv /boot/intel\-ucode.img.new /boot/intel\-ucode.img
.SH BUGS
Microcode with negative revision numbers is not special-cased, and will not be
preferred over regular microcode.
.PP
The \fIdowngrade mode\fP should be used only for microcodes with the same
\fIprocessor flags mask\fP. It cannot handle the corner cases where
modifying a \fIprocessor flags mask\fP would be required to force the
kernel to load a lower revision of a microcode, and \fBiucode_tool\fP will
issue an warning when that happens. So far, this has not proved to be a
relevant limitation as changes to the \fIprocessor flags mask\fP of
post-launch, production microcode updates are very rare.
.PP
The \fIloader version\fP microcode metadata field is ignored by
\fBiucode_tool\fP. This shouldn't cause problems as long as the same signature
never needs more than a single type of loader.
.PP
Files are not replaced atomically: if \fBiucode_tool\fP is interrupted while
writing to a file, that file will be corrupted.
.SH "SEE ALSO"
\fBThe Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A:
System Programming Guide, Part 1\fP (order number 253668), section 9.11.
.\" .BR foo (1),
.\" .BR bar (1).
.SH AUTHOR
Henrique de Moraes Holschuh <hmh@hmh.eng.br>

3808
iucode_tool.c Normal file

File diff suppressed because it is too large Load Diff

231
iucode_tool_config.h.in Normal file
View File

@ -0,0 +1,231 @@
/* iucode_tool_config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* snprintf format string for the per-cpu cpuid device path, relative to
CPUID_DEVICE_NAME */
#undef CPUID_DEVICE_BASE
/* path to the per-cpu tree of cpuid devices */
#undef CPUID_DEVICE_PARENT
/* Define to 1 if you have the <cpuid.h> header file. */
#undef HAVE_CPUID_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fgets_unlocked' function. */
#undef HAVE_FGETS_UNLOCKED
/* Define to 1 if you have the `flockfile' function. */
#undef HAVE_FLOCKFILE
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#undef HAVE_REALLOC
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
#undef HAVE_STAT_EMPTY_STRING_BUG
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strrchr' function. */
#undef HAVE_STRRCHR
/* Define to 1 if you have the `strtoul' function. */
#undef HAVE_STRTOUL
/* Define to 1 if you have the `strtoull' function. */
#undef HAVE_STRTOULL
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the `timegm' function. */
#undef HAVE_TIMEGM
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
/* Path to kernel microcode device */
#undef MICROCODE_DEVICE_DEFAULT
/* Path to the kernel microcode firmware directory */
#undef MICROCODE_DIR_DEFAULT
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Support scanning every core using Linux cpuid device */
#undef USE_CPUID_DEVICE
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Valgrind-friendly build */
#undef VALGRIND_BUILD
/* Version number of package */
#undef VERSION
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to 1 if on MINIX. */
#undef _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT8_T
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef int32_t
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define to rpl_realloc if the replacement function should be used. */
#undef realloc
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* Define to `int' if <sys/types.h> does not define. */
#undef ssize_t
/* Define to the type of an unsigned integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef uint16_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef uint32_t
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
#undef uint8_t

View File

@ -0,0 +1,67 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. During the check the flag is always added to the
# current language's flags.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
# AX_APPEND_LINK_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 5
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
done
])dnl AX_APPEND_COMPILE_FLAGS

71
m4/ax_append_flag.m4 Normal file
View File

@ -0,0 +1,71 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
#
# DESCRIPTION
#
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
# added in between.
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
# FLAG.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 6
AC_DEFUN([AX_APPEND_FLAG],
[dnl
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
AS_VAR_SET_IF(FLAGS,[
AS_CASE([" AS_VAR_GET(FLAGS) "],
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
[
AS_VAR_APPEND(FLAGS,[" $1"])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
],
[
AS_VAR_SET(FLAGS,[$1])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
AS_VAR_POPDEF([FLAGS])dnl
])dnl AX_APPEND_FLAG

View File

@ -0,0 +1,65 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the linker works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
# used. During the check the flag is always added to the linker's flags.
#
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
# when the check is done. The check is thus made with the flags: "LDFLAGS
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 5
AC_DEFUN([AX_APPEND_LINK_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
done
])dnl AX_APPEND_LINK_FLAGS

View File

@ -0,0 +1,74 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 4
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

74
m4/ax_check_link_flag.m4 Normal file
View File

@ -0,0 +1,74 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the linker or gives an error.
# (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
# when the check is done. The check is thus made with the flags: "LDFLAGS
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_LINK_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 4
AC_DEFUN([AX_CHECK_LINK_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
ax_check_save_flags=$LDFLAGS
LDFLAGS="$LDFLAGS $4 $1"
AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
LDFLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_LINK_FLAGS

37
m4/ax_require_defined.m4 Normal file
View File

@ -0,0 +1,37 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_REQUIRE_DEFINED(MACRO)
#
# DESCRIPTION
#
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
# been defined and thus are available for use. This avoids random issues
# where a macro isn't expanded. Instead the configure script emits a
# non-fatal:
#
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
#
# It's like AC_REQUIRE except it doesn't expand the required macro.
#
# Here's an example:
#
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
#
# LICENSE
#
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 1
AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
])dnl AX_REQUIRE_DEFINED

215
missing Executable file
View File

@ -0,0 +1,215 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End: