aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2025-11-28 13:29:28 +0100
committerAlexander Potapenko <glider@google.com>2025-11-28 13:15:13 +0000
commit01c07bfe113aa2369bbff34c8f845108a2273e1f (patch)
treee03a9e26dd5faffc8def529849fb6eb06c8536d3
parentd1b870e1003b52891d2196c1e2ee42fe905010ba (diff)
executor: apply optnone to guest_handle_nested_vmentry_intel()
Florent Revest reported ThinLTO builds failing with the following error: <inline asm>:2:1: error: symbol 'after_vmentry_label' is already defined after_vmentry_label: ^ error: cannot compile inline asm , which turned out to be caused by the compiler not respecting `noinline`. Adding __attribute__((optnone)) (or optimize("O0") on GCC) fixes the issue.
-rw-r--r--executor/common_kvm_amd64_syzos.h5
-rw-r--r--executor/common_kvm_syzos.h11
2 files changed, 14 insertions, 2 deletions
diff --git a/executor/common_kvm_amd64_syzos.h b/executor/common_kvm_amd64_syzos.h
index baabbef7e..df1f63ad5 100644
--- a/executor/common_kvm_amd64_syzos.h
+++ b/executor/common_kvm_amd64_syzos.h
@@ -1151,7 +1151,10 @@ guest_handle_nested_load_code(struct api_call_nested_load_code* cmd, uint64 cpu_
}
}
-GUEST_CODE static noinline void
+// Clang's LTO may ignore noinline and attempt to inline this function into both callers,
+// which results in duplicate declaration of after_vmentry_label.
+// Applying __optnone should prevent this behavior.
+GUEST_CODE static noinline __optnone void
guest_handle_nested_vmentry_intel(uint64 vm_id, uint64 cpu_id, bool is_launch)
{
uint64 vmx_error_code = 0;
diff --git a/executor/common_kvm_syzos.h b/executor/common_kvm_syzos.h
index 5fe513ab1..923284efe 100644
--- a/executor/common_kvm_syzos.h
+++ b/executor/common_kvm_syzos.h
@@ -35,10 +35,19 @@
#define __addrspace_guest
#endif
+// Disable optimizations for a particular function.
+#if defined(__clang__)
+#define __optnone __attribute__((optnone))
+#elif defined(__GNUC__)
+#define __optnone __attribute__((optimize("O0")))
+#else
+#define __optnone
+#endif
+
// Host will map the code in this section into the guest address space.
#define GUEST_CODE __attribute__((section("guest"))) __no_stack_protector __addrspace_guest
// Start/end of the guest section.
extern char *__start_guest, *__stop_guest;
-#endif // EXECUTOR_COMMON_KVM_SYZOS_H \ No newline at end of file
+#endif // EXECUTOR_COMMON_KVM_SYZOS_H