Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frontend support for some constructs used in the Linux kernel #1798

Merged
merged 9 commits into from
Apr 27, 2024

Conversation

fbrausse
Copy link
Collaborator

This PR adds a new command-line option --include-file mapping to the -include option for Clang (also supported by GCC), which the kernel uses to include certain headers before the actual source code being translated. For now I'm testing this on drivers/cxl/pci.c via the following command line, corresponding to the (relevant) flags used by kernel's build system itself:

esbmc /usr/src/linux/drivers/cxl/pci.c -I /usr/src/linux/arch/x86/include/ -I /usr/src/linux/arch/x86/include/generated/  -I /usr/src/linux/include -I /usr/src/linux/arch/x86/include/uapi -I /usr/src/linux/arch/x86/include/generated/uapi -I /usr/src/linux/include/uapi -I /usr/src/linux/include/generated/uapi --include-file /usr/src/linux/./include/linux/compiler-version.h --include-file /usr/src/linux/./include/linux/kconfig.h --include-file /usr/src/linux/./include/linux/compiler_types.h  -D__KERNEL__ -DMODULE -DKBUILD_BASENAME='"pci"' -DKBUILD_MODNAME='"cxl_pci"' -D__KBUILD_MODNAME=kmod_cxl_pc

Additionally clang-c frontend support for features used in that driver (and its included headers):

With these changes, I'm now finally getting

ERROR: main symbol `main' not found

i.e., the C frontend handles all constructs in the unmodified kernel's CXL driver's "pci.c" file.

@fbrausse fbrausse changed the title Add support for some constructs used in the Linux kernel Add frontend support for some constructs used in the Linux kernel Apr 25, 2024
Copy link
Member

@mikhailramalho mikhailramalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the handling of the builtin offset to be done in the adjust code, but I guess we'll loose the information about the node, so LGTM

@lucasccordeiro
Copy link
Contributor

Thanks, @fbrausse. Could you please run this PR over the SV-COMP benchmarks?

@fbrausse
Copy link
Collaborator Author

I would prefer the handling of the builtin offset to be done in the adjust code, but I guess we'll loose the information about the node, so LGTM

Indeed it would be better to have this as a separate exprt, not just in order to move it to the adjuster, but also because basically we already have this functionality implemented in the function compute_pointer_offset(). In addition, as the dynamic offsetof isn't handling the C++ base class member case right now, we could factor it out into a separate method so the C++ frontend can override it. Can we leave that for another PR, though? I'll add a TODO.

@mikhailramalho
Copy link
Member

mikhailramalho commented Apr 25, 2024 via email

@fbrausse
Copy link
Collaborator Author

Master:

Statistics:          23805 Files
  correct:           15336
    correct true:     8701
    correct false:    6635
  incorrect:            50
    incorrect true:     18
    incorrect false:    32
  unknown:            8419
  Score:             22949 (max: 38482)

https://github.com/esbmc/esbmc/actions/runs/8849874090

This PR:

Statistics:          23805 Files
  correct:           15328
    correct true:     8702
    correct false:    6626
  incorrect:            50
    incorrect true:     18
    incorrect false:    32
  unknown:            8427
  Score:             22942 (max: 38482)

https://github.com/esbmc/esbmc/actions/runs/8852150400

@lucasccordeiro lucasccordeiro merged commit f0cca1a into master Apr 27, 2024
10 checks passed
@lucasccordeiro lucasccordeiro deleted the fb/cxl branch April 27, 2024 06:19
@lucasccordeiro
Copy link
Contributor

Thanks for submitting this PR, @fbrausse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants