diff mbox series

[kvm-unit-tests,RFC,03/16] x86 UEFI: Move setjmp.h out of desc.h

Message ID 20210818000905.1111226-4-zixuanwang@google.com (mailing list archive)
State New, archived
Headers show
Series x86_64 UEFI and AMD SEV/SEV-ES support | expand

Commit Message

Zixuan Wang Aug. 18, 2021, 12:08 a.m. UTC
Previous desc.h includes setjmp.h, and this causes duplicate definition
when compiling with UEFI header efi.h. This is because setjmp() function
is defined both in KVM-Unit-Tests and UEFI. When including both desc.h
and efi.h, the setjmp() is found in both headers and causes this error.

The easy solution is to move setjmp.h from desc.h to desc.c, so
including desc.h does not bring in setjmp.h, so that we can include
both desc.h and efi.h in lib/x86/setup.c.

This commit also includes setjmp.h in x86/vmx.c, because this test case
previously assumed setjmp.h is included by desc.h and did not include
setjmp.h explicitly.

This commit does not change any test case behavior.

Signed-off-by: Zixuan Wang <zixuanwang@google.com>
---
 lib/x86/desc.c | 4 ++++
 lib/x86/desc.h | 5 -----
 x86/vmx.c      | 1 +
 3 files changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/lib/x86/desc.c b/lib/x86/desc.c
index e7378c1..eb4d2bc 100644
--- a/lib/x86/desc.c
+++ b/lib/x86/desc.c
@@ -3,6 +3,10 @@ 
 #include "processor.h"
 #include <setjmp.h>
 
+void __set_exception_jmpbuf(jmp_buf *addr);
+#define set_exception_jmpbuf(jmpbuf) \
+	(setjmp(jmpbuf) ? : (__set_exception_jmpbuf(&(jmpbuf)), 0))
+
 #ifndef __x86_64__
 __attribute__((regparm(1)))
 #endif
diff --git a/lib/x86/desc.h b/lib/x86/desc.h
index a6ffb38..9fda20d 100644
--- a/lib/x86/desc.h
+++ b/lib/x86/desc.h
@@ -1,8 +1,6 @@ 
 #ifndef _X86_DESC_H_
 #define _X86_DESC_H_
 
-#include <setjmp.h>
-
 void setup_idt(void);
 void setup_alt_stack(void);
 
@@ -226,9 +224,6 @@  void unhandled_exception(struct ex_regs *regs, bool cpu);
 
 bool test_for_exception(unsigned int ex, void (*trigger_func)(void *data),
 			void *data);
-void __set_exception_jmpbuf(jmp_buf *addr);
-#define set_exception_jmpbuf(jmpbuf) \
-	(setjmp(jmpbuf) ? : (__set_exception_jmpbuf(&(jmpbuf)), 0))
 
 static inline void *get_idt_addr(idt_entry_t *entry)
 {
diff --git a/x86/vmx.c b/x86/vmx.c
index f0b853a..4469b31 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -38,6 +38,7 @@ 
 #include "msr.h"
 #include "smp.h"
 #include "apic.h"
+#include "setjmp.h"
 
 u64 *bsp_vmxon_region;
 struct vmcs *vmcs_root;