forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/powerpc/net/bpf_jit32.h
....@@ -1,14 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * bpf_jit32.h: BPF JIT compiler for PPC
34 *
45 * Copyright 2011 Matt Evans <matt@ozlabs.org>, IBM Corporation
56 *
67 * Split from bpf_jit.h
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * as published by the Free Software Foundation; version 2
11
- * of the License.
128 */
139 #ifndef _BPF_JIT32_H
1410 #define _BPF_JIT32_H
....@@ -76,21 +72,21 @@
7672 DECLARE_LOAD_FUNC(sk_load_byte);
7773 DECLARE_LOAD_FUNC(sk_load_byte_msh);
7874
79
-#define PPC_LBZ_OFFS(r, base, i) do { if ((i) < 32768) PPC_LBZ(r, base, i); \
80
- else { PPC_ADDIS(r, base, IMM_HA(i)); \
81
- PPC_LBZ(r, r, IMM_L(i)); } } while(0)
75
+#define PPC_LBZ_OFFS(r, base, i) do { if ((i) < 32768) EMIT(PPC_RAW_LBZ(r, base, i)); \
76
+ else { EMIT(PPC_RAW_ADDIS(r, base, IMM_HA(i))); \
77
+ EMIT(PPC_RAW_LBZ(r, r, IMM_L(i))); } } while(0)
8278
83
-#define PPC_LD_OFFS(r, base, i) do { if ((i) < 32768) PPC_LD(r, base, i); \
84
- else { PPC_ADDIS(r, base, IMM_HA(i)); \
85
- PPC_LD(r, r, IMM_L(i)); } } while(0)
79
+#define PPC_LD_OFFS(r, base, i) do { if ((i) < 32768) EMIT(PPC_RAW_LD(r, base, i)); \
80
+ else { EMIT(PPC_RAW_ADDIS(r, base, IMM_HA(i))); \
81
+ EMIT(PPC_RAW_LD(r, r, IMM_L(i))); } } while(0)
8682
87
-#define PPC_LWZ_OFFS(r, base, i) do { if ((i) < 32768) PPC_LWZ(r, base, i); \
88
- else { PPC_ADDIS(r, base, IMM_HA(i)); \
89
- PPC_LWZ(r, r, IMM_L(i)); } } while(0)
83
+#define PPC_LWZ_OFFS(r, base, i) do { if ((i) < 32768) EMIT(PPC_RAW_LWZ(r, base, i)); \
84
+ else { EMIT(PPC_RAW_ADDIS(r, base, IMM_HA(i))); \
85
+ EMIT(PPC_RAW_LWZ(r, r, IMM_L(i))); } } while(0)
9086
91
-#define PPC_LHZ_OFFS(r, base, i) do { if ((i) < 32768) PPC_LHZ(r, base, i); \
92
- else { PPC_ADDIS(r, base, IMM_HA(i)); \
93
- PPC_LHZ(r, r, IMM_L(i)); } } while(0)
87
+#define PPC_LHZ_OFFS(r, base, i) do { if ((i) < 32768) EMIT(PPC_RAW_LHZ(r, base, i)); \
88
+ else { EMIT(PPC_RAW_ADDIS(r, base, IMM_HA(i))); \
89
+ EMIT(PPC_RAW_LHZ(r, r, IMM_L(i))); } } while(0)
9490
9591 #ifdef CONFIG_PPC64
9692 #define PPC_LL_OFFS(r, base, i) do { PPC_LD_OFFS(r, base, i); } while(0)
....@@ -101,31 +97,30 @@
10197 #ifdef CONFIG_SMP
10298 #ifdef CONFIG_PPC64
10399 #define PPC_BPF_LOAD_CPU(r) \
104
- do { BUILD_BUG_ON(FIELD_SIZEOF(struct paca_struct, paca_index) != 2); \
100
+ do { BUILD_BUG_ON(sizeof_field(struct paca_struct, paca_index) != 2); \
105101 PPC_LHZ_OFFS(r, 13, offsetof(struct paca_struct, paca_index)); \
106102 } while (0)
107103 #else
108104 #define PPC_BPF_LOAD_CPU(r) \
109
- do { BUILD_BUG_ON(FIELD_SIZEOF(struct thread_info, cpu) != 4); \
110
- PPC_LHZ_OFFS(r, (1 & ~(THREAD_SIZE - 1)), \
111
- offsetof(struct thread_info, cpu)); \
105
+ do { BUILD_BUG_ON(sizeof_field(struct task_struct, cpu) != 4); \
106
+ PPC_LHZ_OFFS(r, 2, offsetof(struct task_struct, cpu)); \
112107 } while(0)
113108 #endif
114109 #else
115
-#define PPC_BPF_LOAD_CPU(r) do { PPC_LI(r, 0); } while(0)
110
+#define PPC_BPF_LOAD_CPU(r) do { EMIT(PPC_RAW_LI(r, 0)); } while(0)
116111 #endif
117112
118113 #define PPC_LHBRX_OFFS(r, base, i) \
119
- do { PPC_LI32(r, i); PPC_LHBRX(r, r, base); } while(0)
114
+ do { PPC_LI32(r, i); EMIT(PPC_RAW_LHBRX(r, r, base)); } while(0)
120115 #ifdef __LITTLE_ENDIAN__
121116 #define PPC_NTOHS_OFFS(r, base, i) PPC_LHBRX_OFFS(r, base, i)
122117 #else
123118 #define PPC_NTOHS_OFFS(r, base, i) PPC_LHZ_OFFS(r, base, i)
124119 #endif
125120
126
-#define PPC_BPF_LL(r, base, i) do { PPC_LWZ(r, base, i); } while(0)
127
-#define PPC_BPF_STL(r, base, i) do { PPC_STW(r, base, i); } while(0)
128
-#define PPC_BPF_STLU(r, base, i) do { PPC_STWU(r, base, i); } while(0)
121
+#define PPC_BPF_LL(r, base, i) do { EMIT(PPC_RAW_LWZ(r, base, i)); } while(0)
122
+#define PPC_BPF_STL(r, base, i) do { EMIT(PPC_RAW_STW(r, base, i)); } while(0)
123
+#define PPC_BPF_STLU(r, base, i) do { EMIT(PPC_RAW_STWU(r, base, i)); } while(0)
129124
130125 #define SEEN_DATAREF 0x10000 /* might call external helpers */
131126 #define SEEN_XREG 0x20000 /* X reg is used */