mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 12:25:46 +08:00
[BOLT] Skip functions with unsupported Linux kernel features (#86345)
Do not overwrite functions with alternative and paravirtual instructions until a proper update support is implemented.
This commit is contained in:
@@ -252,11 +252,17 @@ class LinuxKernelRewriter final : public MetadataRewriter {
|
||||
|
||||
/// Paravirtual instruction patch sites.
|
||||
Error readParaInstructions();
|
||||
Error rewriteParaInstructions();
|
||||
|
||||
Error readBugTable();
|
||||
|
||||
/// Read alternative instruction info from .altinstructions.
|
||||
/// Do no process functions containing instruction annotated with
|
||||
/// \p Annotation.
|
||||
void skipFunctionsWithAnnotation(StringRef Annotation) const;
|
||||
|
||||
/// Handle alternative instruction info from .altinstructions.
|
||||
Error readAltInstructions();
|
||||
Error rewriteAltInstructions();
|
||||
|
||||
/// Read .pci_fixup
|
||||
Error readPCIFixupTable();
|
||||
@@ -318,6 +324,12 @@ public:
|
||||
if (Error E = rewriteExceptionTable())
|
||||
return E;
|
||||
|
||||
if (Error E = rewriteAltInstructions())
|
||||
return E;
|
||||
|
||||
if (Error E = rewriteParaInstructions())
|
||||
return E;
|
||||
|
||||
if (Error E = rewriteORCTables())
|
||||
return E;
|
||||
|
||||
@@ -1126,6 +1138,31 @@ Error LinuxKernelRewriter::readParaInstructions() {
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
void LinuxKernelRewriter::skipFunctionsWithAnnotation(
|
||||
StringRef Annotation) const {
|
||||
for (BinaryFunction &BF : llvm::make_second_range(BC.getBinaryFunctions())) {
|
||||
if (!BC.shouldEmit(BF))
|
||||
continue;
|
||||
for (const BinaryBasicBlock &BB : BF) {
|
||||
const bool HasAnnotation = llvm::any_of(BB, [&](const MCInst &Inst) {
|
||||
return BC.MIB->hasAnnotation(Inst, Annotation);
|
||||
});
|
||||
if (HasAnnotation) {
|
||||
BF.setSimple(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Error LinuxKernelRewriter::rewriteParaInstructions() {
|
||||
// Disable output of functions with paravirtual instructions before the
|
||||
// rewrite support is complete.
|
||||
skipFunctionsWithAnnotation("ParaSite");
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
/// Process __bug_table section.
|
||||
/// This section contains information useful for kernel debugging.
|
||||
/// Each entry in the section is a struct bug_entry that contains a pointer to
|
||||
@@ -1305,6 +1342,14 @@ Error LinuxKernelRewriter::readAltInstructions() {
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error LinuxKernelRewriter::rewriteAltInstructions() {
|
||||
// Disable output of functions with alt instructions before the rewrite
|
||||
// support is complete.
|
||||
skipFunctionsWithAnnotation("AltInst");
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
/// When the Linux kernel needs to handle an error associated with a given PCI
|
||||
/// device, it uses a table stored in .pci_fixup section to locate a fixup code
|
||||
/// specific to the vendor and the problematic device. The section contains a
|
||||
|
||||
Reference in New Issue
Block a user