Re: objtool crashes on clang output (drivers/hwmon/pmbus/adm1275.o)

From: Josh Poimboeuf
Date: Thu Jul 11 2019 - 19:20:57 EST


On Thu, Jul 11, 2019 at 11:04:35PM +0200, Jann Horn wrote:
> On Thu, Jul 11, 2019 at 11:00 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
> >
> > On Thu, Jul 11, 2019 at 7:26 PM Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
> > >
> > > On Thu, Jul 11, 2019 at 02:40:06PM +0200, Arnd Bergmann wrote:
> > > > During randconfig testing with clang-9, I came across an object file
> > > > that makes objtool segfault, see attachment. Let me know if you need
> > > > more information to
> > > > debug this.
> > > >
> > > > I also get a ton of objtool warnings building random configurations, but Nick
> > > > mentioned that there is still a bug related to asm-goto in the build I'm using
> > > > that may be the root cause. Once I have a fixed clang-9 build, I can have a look
> > > > at those as well.
> > >
> > > Seg fault fix:
> >
> > Thanks for the fix! testing it over night now, will let you know tomorrow
> > if problems remain.
> >
> > I wonder if this is also related to several warnings I get about switch
> > tables like:
> >
> > drivers/usb/misc/sisusbvga/sisusb.o: warning: objtool:
> > sisusb_write_mem_bulk()+0x588: can't find switch jump table
> >
> > drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_mem_input_v.o:
> > warning: objtool: dce_mem_input_v_program_pte_vm()+0x46e: can't find
> > switch jump table
> > drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_opp_csc_v.o:
> > warning: objtool: dce110_opp_v_set_csc_default()+0x714: can't find
> > switch jump table
> > drivers/gpu/drm/nouveau/nvkm/subdev/clk/nv50.o: warning: objtool:
> > nv50_clk_read()+0x15c: can't find switch jump table
> > drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.o: warning:
> > objtool: x_tune_dvbt2_demod_setting()+0x992: can't find switch jump
> > table
> > drivers/media/tuners/mt2063.o: warning: objtool:
> > MT2063_SetReceiverMode()+0x24d: can't find switch jump table
> > drivers/mmc/host/tifm_sd.o: warning: objtool: tifm_sd_exec()+0x7e:
> > can't find switch jump table
> > drivers/mtd/nand/raw/fsl_ifc_nand.o: warning: objtool:
> > fsl_ifc_nand_probe()+0x4c7: can't find switch jump table
> > drivers/net/can/at91_can.o: warning: objtool: at91_irq()+0x347: can't
> > find switch jump table
> > drivers/net/phy/phylink.o: warning: objtool:
> > phylink_mac_config()+0x2b5: can't find switch jump table
> > drivers/regulator/max8973-regulator.o: warning: objtool:
> > max8973_probe()+0x736: can't find switch jump table
> > drivers/regulator/tps80031-regulator.o: warning: objtool:
> > tps80031_regulator_probe()+0x143: can't find switch jump table
> > drivers/tty/cyclades.o: warning: objtool: cy_set_line_char()+0x86c:
> > can't find switch jump table
> > drivers/tty/serial/jsm/jsm_cls.o: warning: objtool: cls_param()+0x10b:
> > can't find switch jump table
> > drivers/tty/serial/jsm/jsm_neo.o: warning: objtool: neo_param()+0x151:
> > can't find switch jump table
> > drivers/usb/core/hub.o: warning: objtool: hub_probe()+0x920: can't
> > find switch jump table
> > drivers/usb/misc/sisusbvga/sisusb.o: warning: objtool:
> > sisusb_write_mem_bulk()+0x4db: can't find switch jump table
> > kernel/rcu/tree.o: warning: objtool: rcu_note_context_switch()+0x6b8:
> > can't find switch jump table
> > lib/zstd/decompress.o: warning: objtool:
> > ZSTD_decodeLiteralsBlock()+0x5e: can't find switch jump table
> >
> > If you want to have a look, I can provide object files and/or reduced test
> > cases for this. My guess is that it is unrelated to the warnings that Nick
> > saw for asm-goto.
>
> I was playing around with building the kernel with LLVM a few months
> ago and used this local patch, but didn't get around to submitting
> upstream because I couldn't reproduce the problem for some reason. I
> think the warnings you're getting sound like what I saw back then:
> https://gist.github.com/thejh/0434662728afb95d72455bf30ece5817
>
> Quoting the commit message from that patch:
>
> ====
> With clang from git master, code can be generated where a function contains
> two indirect jump instructions that use the same switch table. To deal with
> this case and similar ones properly, convert the switch table parsing to
> use two passes:
> ====
>
> Does that sound like what you're seeing?

Thanks Jann, I like this approach. Hopefully it also works with GCC.

The switch tables (and jump tables in general) have been a hot topic in
objtool lately. I have several other patches pending which touch this
code. I'll integrate your patch with the others and try to do some more
testing in GCC.

--
Josh