@@ -61,7 +61,6 @@ obj-y += spec_ctrl.o
obj-y += srat.o
obj-y += string.o
obj-y += time.o
-obj-y += trace.o
obj-y += traps.o
obj-y += tsx.o
obj-y += usercopy.o
@@ -12,6 +12,7 @@ obj-y += misc-hypercalls.o
obj-y += mm.o
obj-y += ro-page-fault.o
obj-$(CONFIG_PV_SHIM) += shim.o
+obj-$(CONFIG_TRACEBUFFER) += trace.o
obj-y += traps.o
obj-bin-y += dom0_build.init.o
@@ -19,7 +19,7 @@
* along with this program; If not, see <http://www.gnu.org/licenses/>.
*/
-#include <xen/trace.h>
+#include <asm/pv/trace.h>
#include "emulate.h"
@@ -30,6 +30,7 @@
#include <asm/hypercall.h>
#include <asm/mc146818rtc.h>
#include <asm/pv/domain.h>
+#include <asm/pv/trace.h>
#include <asm/shared.h>
#include <xsm/xsm.h>
@@ -20,7 +20,7 @@
* along with this program; If not, see <http://www.gnu.org/licenses/>.
*/
-#include <xen/trace.h>
+#include <asm/pv/trace.h>
#include <asm/shadow.h>
#include "emulate.h"
similarity index 95%
rename from xen/arch/x86/trace.c
rename to xen/arch/x86/pv/trace.c
@@ -1,9 +1,6 @@
-#include <xen/init.h>
-#include <xen/kernel.h>
-#include <xen/lib.h>
-#include <xen/domain.h>
#include <xen/sched.h>
-#include <xen/trace.h>
+
+#include <asm/pv/trace.h>
void __trace_pv_trap(int trapnr, unsigned long eip,
int use_error_code, unsigned error_code)
@@ -21,7 +18,7 @@ void __trace_pv_trap(int trapnr, unsigned long eip,
d.trapnr = trapnr;
d.error_code = error_code;
d.use_error_code=!!use_error_code;
-
+
__trace_var(TRC_PV_TRAP, 1, sizeof(d), &d);
}
else
@@ -38,7 +35,7 @@ void __trace_pv_trap(int trapnr, unsigned long eip,
d.trapnr = trapnr;
d.error_code = error_code;
d.use_error_code=!!use_error_code;
-
+
event = TRC_PV_TRAP;
event |= TRC_64_FLAG;
__trace_var(event, 1, sizeof(d), &d);
@@ -58,7 +55,7 @@ void __trace_pv_page_fault(unsigned long addr, unsigned error_code)
d.eip = eip;
d.addr = addr;
d.error_code = error_code;
-
+
__trace_var(TRC_PV_PAGE_FAULT, 1, sizeof(d), &d);
}
else
@@ -22,10 +22,10 @@
#include <xen/event.h>
#include <xen/hypercall.h>
#include <xen/lib.h>
-#include <xen/trace.h>
#include <xen/softirq.h>
#include <asm/apic.h>
+#include <asm/pv/trace.h>
#include <asm/shared.h>
#include <asm/traps.h>
#include <irq_vectors.h>
@@ -82,6 +82,7 @@
#include <xsm/xsm.h>
#include <asm/mach-default/irq_vectors.h>
#include <asm/pv/traps.h>
+#include <asm/pv/trace.h>
#include <asm/pv/mm.h>
/*
@@ -1480,7 +1481,7 @@ static int fixup_page_fault(unsigned long addr, struct cpu_user_regs *regs)
{
int ret = paging_fault(addr, regs);
- if ( ret == EXCRET_fault_fixed )
+ if ( IS_ENABLED(CONFIG_PV) && ret == EXCRET_fault_fixed )
trace_trap_two_addr(TRC_PV_PAGING_FIXUP, regs->rip, addr);
return ret;
}
similarity index 92%
copy from xen/include/asm-x86/trace.h
copy to xen/include/asm-x86/pv/trace.h
@@ -1,5 +1,7 @@
-#ifndef __ASM_TRACE_H__
-#define __ASM_TRACE_H__
+#ifndef XEN_X86_PV_TRACE_H
+#define XEN_X86_PV_TRACE_H
+
+#include <xen/trace.h>
#include <asm/page.h>
@@ -43,4 +45,4 @@ static inline void trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
__trace_ptwr_emulation(addr, npte);
}
-#endif /* __ASM_TRACE_H__ */
+#endif /* XEN_X86_PV_TRACE_H */
@@ -1,46 +1,4 @@
#ifndef __ASM_TRACE_H__
#define __ASM_TRACE_H__
-#include <asm/page.h>
-
-void __trace_pv_trap(int trapnr, unsigned long eip,
- int use_error_code, unsigned error_code);
-static inline void trace_pv_trap(int trapnr, unsigned long eip,
- int use_error_code, unsigned error_code)
-{
- if ( unlikely(tb_init_done) )
- __trace_pv_trap(trapnr, eip, use_error_code, error_code);
-}
-
-void __trace_pv_page_fault(unsigned long addr, unsigned error_code);
-static inline void trace_pv_page_fault(unsigned long addr,
- unsigned error_code)
-{
- if ( unlikely(tb_init_done) )
- __trace_pv_page_fault(addr, error_code);
-}
-
-void __trace_trap_one_addr(unsigned event, unsigned long va);
-static inline void trace_trap_one_addr(unsigned event, unsigned long va)
-{
- if ( unlikely(tb_init_done) )
- __trace_trap_one_addr(event, va);
-}
-
-void __trace_trap_two_addr(unsigned event, unsigned long va1,
- unsigned long va2);
-static inline void trace_trap_two_addr(unsigned event, unsigned long va1,
- unsigned long va2)
-{
- if ( unlikely(tb_init_done) )
- __trace_trap_two_addr(event, va1, va2);
-}
-
-void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte);
-static inline void trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
-{
- if ( unlikely(tb_init_done) )
- __trace_ptwr_emulation(addr, npte);
-}
-
#endif /* __ASM_TRACE_H__ */
This entire file is pv-only, and not excluded from the build by CONFIG_TRACEBUFFER. Move it into the pv/ directory, build it conditionally, and drop unused includes. Also move the contents of asm/trace.h to asm/pv/trace.h to avoid the functions being declared across the entire hypervisor. One caller in fixup_page_fault() is effectively PV only, but is not subject to dead code elimination. Add an additional IS_ENABLED(CONFIG_PV) to keep the build happy. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Jan Beulich <JBeulich@suse.com> CC: Roger Pau Monné <roger.pau@citrix.com> CC: Wei Liu <wl@xen.org> v2: * New --- xen/arch/x86/Makefile | 1 - xen/arch/x86/pv/Makefile | 1 + xen/arch/x86/pv/emul-inv-op.c | 2 +- xen/arch/x86/pv/emul-priv-op.c | 1 + xen/arch/x86/pv/ro-page-fault.c | 2 +- xen/arch/x86/{ => pv}/trace.c | 13 +++++------ xen/arch/x86/pv/traps.c | 2 +- xen/arch/x86/traps.c | 3 ++- xen/include/asm-x86/{ => pv}/trace.h | 8 ++++--- xen/include/asm-x86/trace.h | 42 ------------------------------------ 10 files changed, 17 insertions(+), 58 deletions(-) rename xen/arch/x86/{ => pv}/trace.c (95%) copy xen/include/asm-x86/{ => pv}/trace.h (92%)