All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>
Subject: [PATCH v2 10/12] x86/pv: Move x86/trace.c to x86/pv/trace.c
Date: Mon, 20 Sep 2021 18:25:27 +0100	[thread overview]
Message-ID: <20210920172529.24932-11-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20210920172529.24932-1-andrew.cooper3@citrix.com>

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%)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 202d4d27823d..82dd4e18bd36 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -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
diff --git a/xen/arch/x86/pv/Makefile b/xen/arch/x86/pv/Makefile
index 75b01b0062d8..6cda354cc41f 100644
--- a/xen/arch/x86/pv/Makefile
+++ b/xen/arch/x86/pv/Makefile
@@ -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
diff --git a/xen/arch/x86/pv/emul-inv-op.c b/xen/arch/x86/pv/emul-inv-op.c
index b15f302bcaad..2c07eed9a092 100644
--- a/xen/arch/x86/pv/emul-inv-op.c
+++ b/xen/arch/x86/pv/emul-inv-op.c
@@ -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"
 
diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
index 11467a1e3a90..d0df5bc616c0 100644
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -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>
diff --git a/xen/arch/x86/pv/ro-page-fault.c b/xen/arch/x86/pv/ro-page-fault.c
index 335aa8dc5dc0..ac5b66870c8c 100644
--- a/xen/arch/x86/pv/ro-page-fault.c
+++ b/xen/arch/x86/pv/ro-page-fault.c
@@ -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"
diff --git a/xen/arch/x86/trace.c b/xen/arch/x86/pv/trace.c
similarity index 95%
rename from xen/arch/x86/trace.c
rename to xen/arch/x86/pv/trace.c
index 4a953c5b2f1e..550c22765bae 100644
--- a/xen/arch/x86/trace.c
+++ b/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
diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c
index 7439b76df88d..764773c02104 100644
--- a/xen/arch/x86/pv/traps.c
+++ b/xen/arch/x86/pv/traps.c
@@ -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>
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 4a0e498b4c21..0cc1ee95cb5b 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -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;
     }
diff --git a/xen/include/asm-x86/trace.h b/xen/include/asm-x86/pv/trace.h
similarity index 92%
copy from xen/include/asm-x86/trace.h
copy to xen/include/asm-x86/pv/trace.h
index e65b5de6eec4..c616206eeb15 100644
--- a/xen/include/asm-x86/trace.h
+++ b/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 */
diff --git a/xen/include/asm-x86/trace.h b/xen/include/asm-x86/trace.h
index e65b5de6eec4..edef1bb099d4 100644
--- a/xen/include/asm-x86/trace.h
+++ b/xen/include/asm-x86/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__ */
-- 
2.11.0



  parent reply	other threads:[~2021-09-20 17:34 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 17:25 [PATCH v2 00/12] xen/trace: Fix leakage of uninitialised stack into the tracebuffer Andrew Cooper
2021-09-20 17:25 ` [PATCH v2 01/12] xen/trace: Don't over-read trace objects Andrew Cooper
2021-09-21  6:53   ` Jan Beulich
2021-09-21 17:51     ` Andrew Cooper
2021-09-22  7:01       ` Jan Beulich
2021-09-22 12:58         ` Andrew Cooper
2021-09-22 13:32           ` Jan Beulich
2021-09-24 14:35           ` Dario Faggioli
2021-09-24 14:51   ` Dario Faggioli
2021-09-27  7:51     ` Jan Beulich
2021-09-30  8:07       ` Dario Faggioli
2021-12-03 16:29         ` Andrew Cooper
2021-09-20 17:25 ` [PATCH v2 02/12] xen/memory: Remove tail padding from TRC_MEM_* records Andrew Cooper
2021-09-24 16:50   ` Dario Faggioli
2021-09-20 17:25 ` [PATCH v2 03/12] xen/credit2: Remove tail padding from TRC_CSCHED2_* records Andrew Cooper
2021-09-24 16:54   ` Dario Faggioli
2021-09-20 17:25 ` [PATCH v2 04/12] x86/hvm: Reduce stack usage from HVMTRACE_ND() Andrew Cooper
2021-09-21 11:00   ` Jan Beulich
2021-09-21 15:38     ` Andrew Cooper
2021-09-21 15:40       ` Jan Beulich
2021-09-20 17:25 ` [PATCH v2 05/12] x86/hvm: Remove duplicate calls caused by tracing Andrew Cooper
2021-09-21 12:18   ` Jan Beulich
2021-09-21 18:04     ` Andrew Cooper
2021-09-20 17:25 ` [PATCH v2 06/12] xen/credit2: Clean up trace handling Andrew Cooper
2021-09-24 16:55   ` Dario Faggioli
2021-09-20 17:25 ` [PATCH v2 07/12] xen/rt: " Andrew Cooper
2021-09-24 16:56   ` Dario Faggioli
2021-09-20 17:25 ` [PATCH v2 08/12] xen/sched: " Andrew Cooper
2021-09-24 16:57   ` Dario Faggioli
2021-09-20 17:25 ` [PATCH v2 09/12] xen/trace: Minor code cleanup Andrew Cooper
2021-09-21 11:03   ` Jan Beulich
2021-09-24 15:16     ` Dario Faggioli
2021-09-20 17:25 ` Andrew Cooper [this message]
2021-09-21 15:58   ` [PATCH v2 10/12] x86/pv: Move x86/trace.c to x86/pv/trace.c Jan Beulich
2021-09-20 17:25 ` [PATCH v2 11/12] xen/arch: Drop asm-*/trace.h Andrew Cooper
2021-09-21 16:01   ` Jan Beulich
2021-10-12 12:31   ` Julien Grall
2021-09-20 17:25 ` [PATCH v2 12/12] x86/trace: Clean up trace handling Andrew Cooper
2021-09-21 16:08   ` Jan Beulich
2021-09-21 18:34     ` Andrew Cooper
2021-09-20 19:29 ` [PATCH v2.1 13/12] xen/trace: Introduce new API Andrew Cooper
2021-09-24 13:21   ` Jan Beulich
2021-09-20 19:32 ` [PATCH v2.1 14/12] xen: Switch to new TRACE() API Andrew Cooper
2021-09-24 13:34   ` Jan Beulich
2021-09-24 15:30   ` Dario Faggioli
2021-09-20 19:33 ` [PATCH v2.1 15/12] xen/trace: Drop old trace macros Andrew Cooper
2021-09-24 13:31   ` Jan Beulich
2021-09-20 19:40 ` [PATCH v2.1 16/12] xen/trace: Restrict CONFIG_TRACEBUFFER to x86 PV Andrew Cooper
2021-09-21  1:10   ` Julien Grall
2021-09-21 20:08 ` [PATCH v2.1 RFC 17/12] xen/trace: Drop cycles parameter Andrew Cooper
2021-09-22  7:03   ` Jan Beulich
2021-09-22  9:38     ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210920172529.24932-11-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.