aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mm
diff options
context:
space:
mode:
authorDavid Daney <ddaney@caviumnetworks.com>2010-12-27 21:18:29 -0500
committerRalf Baechle <ralf@linux-mips.org>2011-01-18 13:30:24 -0500
commit8d662c8d34a05e8e47deaa9e22fe770dc557c2d3 (patch)
tree96f8ee1bcbda6aded36a9f551f4df8179e33782c /arch/mips/mm
parent2c8c53e28f178577dfdf3a69731b998b7e3df8ae (diff)
MIPS: Use WARN() in uasm for better diagnostics.
On the off chance that uasm ever warns about overflow, there is no way to know what the offending instruction is. Change the printks to WARNs, so we can get a nice stack trace. It has the added benefit of being much more noticeable than the short single line warning message, so is less likely to be ignored. Signed-off-by: David Daney <ddaney@caviumnetworks.com> To: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/1905/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/mm')
-rw-r--r--arch/mips/mm/uasm.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
index 357916de0fab..5fa185151fc8 100644
--- a/arch/mips/mm/uasm.c
+++ b/arch/mips/mm/uasm.c
@@ -156,91 +156,83 @@ static struct insn insn_table[] __uasminitdata = {
156 156
157static inline __uasminit u32 build_rs(u32 arg) 157static inline __uasminit u32 build_rs(u32 arg)
158{ 158{
159 if (arg & ~RS_MASK) 159 WARN(arg & ~RS_MASK, KERN_WARNING "Micro-assembler field overflow\n");
160 printk(KERN_WARNING "Micro-assembler field overflow\n");
161 160
162 return (arg & RS_MASK) << RS_SH; 161 return (arg & RS_MASK) << RS_SH;
163} 162}
164 163
165static inline __uasminit u32 build_rt(u32 arg) 164static inline __uasminit u32 build_rt(u32 arg)
166{ 165{
167 if (arg & ~RT_MASK) 166 WARN(arg & ~RT_MASK, KERN_WARNING "Micro-assembler field overflow\n");
168 printk(KERN_WARNING "Micro-assembler field overflow\n");
169 167
170 return (arg & RT_MASK) << RT_SH; 168 return (arg & RT_MASK) << RT_SH;
171} 169}
172 170
173static inline __uasminit u32 build_rd(u32 arg) 171static inline __uasminit u32 build_rd(u32 arg)
174{ 172{
175 if (arg & ~RD_MASK) 173 WARN(arg & ~RD_MASK, KERN_WARNING "Micro-assembler field overflow\n");
176 printk(KERN_WARNING "Micro-assembler field overflow\n");
177 174
178 return (arg & RD_MASK) << RD_SH; 175 return (arg & RD_MASK) << RD_SH;
179} 176}
180 177
181static inline __uasminit u32 build_re(u32 arg) 178static inline __uasminit u32 build_re(u32 arg)
182{ 179{
183 if (arg & ~RE_MASK) 180 WARN(arg & ~RE_MASK, KERN_WARNING "Micro-assembler field overflow\n");
184 printk(KERN_WARNING "Micro-assembler field overflow\n");
185 181
186 return (arg & RE_MASK) << RE_SH; 182 return (arg & RE_MASK) << RE_SH;
187} 183}
188 184
189static inline __uasminit u32 build_simm(s32 arg) 185static inline __uasminit u32 build_simm(s32 arg)
190{ 186{
191 if (arg > 0x7fff || arg < -0x8000) 187 WARN(arg > 0x7fff || arg < -0x8000,
192 printk(KERN_WARNING "Micro-assembler field overflow\n"); 188 KERN_WARNING "Micro-assembler field overflow\n");
193 189
194 return arg & 0xffff; 190 return arg & 0xffff;
195} 191}
196 192
197static inline __uasminit u32 build_uimm(u32 arg) 193static inline __uasminit u32 build_uimm(u32 arg)
198{ 194{
199 if (arg & ~IMM_MASK) 195 WARN(arg & ~IMM_MASK, KERN_WARNING "Micro-assembler field overflow\n");
200 printk(KERN_WARNING "Micro-assembler field overflow\n");
201 196
202 return arg & IMM_MASK; 197 return arg & IMM_MASK;
203} 198}
204 199
205static inline __uasminit u32 build_bimm(s32 arg) 200static inline __uasminit u32 build_bimm(s32 arg)
206{ 201{
207 if (arg > 0x1ffff || arg < -0x20000) 202 WARN(arg > 0x1ffff || arg < -0x20000,
208 printk(KERN_WARNING "Micro-assembler field overflow\n"); 203 KERN_WARNING "Micro-assembler field overflow\n");
209 204
210 if (arg & 0x3) 205 WARN(arg & 0x3, KERN_WARNING "Invalid micro-assembler branch target\n");
211 printk(KERN_WARNING "Invalid micro-assembler branch target\n");
212 206
213 return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff); 207 return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff);
214} 208}
215 209
216static inline __uasminit u32 build_jimm(u32 arg) 210static inline __uasminit u32 build_jimm(u32 arg)
217{ 211{
218 if (arg & ~((JIMM_MASK) << 2)) 212 WARN(arg & ~(JIMM_MASK << 2),
219 printk(KERN_WARNING "Micro-assembler field overflow\n"); 213 KERN_WARNING "Micro-assembler field overflow\n");
220 214
221 return (arg >> 2) & JIMM_MASK; 215 return (arg >> 2) & JIMM_MASK;
222} 216}
223 217
224static inline __uasminit u32 build_scimm(u32 arg) 218static inline __uasminit u32 build_scimm(u32 arg)
225{ 219{
226 if (arg & ~SCIMM_MASK) 220 WARN(arg & ~SCIMM_MASK,
227 printk(KERN_WARNING "Micro-assembler field overflow\n"); 221 KERN_WARNING "Micro-assembler field overflow\n");
228 222
229 return (arg & SCIMM_MASK) << SCIMM_SH; 223 return (arg & SCIMM_MASK) << SCIMM_SH;
230} 224}
231 225
232static inline __uasminit u32 build_func(u32 arg) 226static inline __uasminit u32 build_func(u32 arg)
233{ 227{
234 if (arg & ~FUNC_MASK) 228 WARN(arg & ~FUNC_MASK, KERN_WARNING "Micro-assembler field overflow\n");
235 printk(KERN_WARNING "Micro-assembler field overflow\n");
236 229
237 return arg & FUNC_MASK; 230 return arg & FUNC_MASK;
238} 231}
239 232
240static inline __uasminit u32 build_set(u32 arg) 233static inline __uasminit u32 build_set(u32 arg)
241{ 234{
242 if (arg & ~SET_MASK) 235 WARN(arg & ~SET_MASK, KERN_WARNING "Micro-assembler field overflow\n");
243 printk(KERN_WARNING "Micro-assembler field overflow\n");
244 236
245 return arg & SET_MASK; 237 return arg & SET_MASK;
246} 238}