Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Documentation for this file: https://EditorConfig.org

root = true

# Unix-style newlines ending every file,
# as some compilers complain about files not ending in newline
[*]
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
end_of_line = lf

# Ignore for OPI-s
[*.{opi,bob,def}]
insert_final_newline = unset
end_of_line = unset

[*Makefile*]
trim_trailing_whitespace = false
tab_width = 4
indent_style = tab

[{*.{md,lyx},Doxyfile,LICENSE,copyright}]
charset = unset
trim_trailing_whitespace = false
22 changes: 22 additions & 0 deletions .github/codeql/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "CodeQL Config"

# Queries and the suites they belong to are documented at
# https://codeql.github.com/codeql-query-help/cpp/

queries:
- uses: security-and-quality
# Choose the above from 3 query suites:
# default
# The default set of queries
# security-extended
# `default` suite plus lower severity and precision queries
# security-and-quality
# `security-extended`, plus maintainability and reliability queries

query-filters:
-
exclude:
id: cpp/use-of-goto
-
exclude:
problem.severity: recommendation
16 changes: 16 additions & 0 deletions .github/workflows/check-editorconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check EditorConfig

on:
push: {}
pull_request: {}

permissions:
contents: read

jobs:
editorconfig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: EditorConfig compliance check
uses: editorconfig-checker/action-editorconfig-checker@v2
54 changes: 54 additions & 0 deletions .github/workflows/kmod-codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CodeQL Linux kernel module

on:
push:
paths:
- ".github/workflows/kmod-codeql.yml"
- "linux/**"
pull_request:
paths:
- ".github/workflows/kmod-codeql.yml"
- "linux/**"
workflow_dispatch:

permissions:
contents: read
actions: read
security-events: write

jobs:
analyze:
name: CodeQL (C/C++)
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Info
run: |
uname -a
gcc --version

- name: Deps
run: |
sudo apt-get update
sudo apt-get -y install linux-headers-$(uname -r) kmod libelf-dev make

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
# Optional stronger rules:
# queries: security-and-quality
# Optional smaller SARIF:
# add-snippets: false

- name: Build (extraction only)
run: |
make -C linux

- name: Analyze
uses: github/codeql-action/analyze@v3
with:
category: "/language:cpp"
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@

# Set the 'name:' properties to values that work for you (pvxs)

name: devlib2
name: Module Build and Test

# Trigger on pushes and PRs to any branch
on:
push:
paths-ignore:
- "documentation/**"
- "**/*.md"
paths:
- ".github/workflows/module-build.yml"
- "configure/**"
- "common/**"
- "exploreApp/**"
- "pciApp/**"
- "vmeApp/**"
- "testApp/**"
- "Makefile"
pull_request:
paths-ignore:
- "documentation/**"
- "**/*.md"
paths:
- ".github/workflows/module-build.yml"
- "configure/**"
- "common/**"
- "exploreApp/**"
- "pciApp/**"
- "vmeApp/**"
- "testApp/**"
- "Makefile"
workflow_dispatch:

permissions:
contents: read
pull-requests: write
issues: write
statuses: write

env:
SETUP_PATH: .ci-local:.ci
EPICS_TEST_IMPRECISE_TIMING: YES
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/module-codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CodeQL Module

on:
push:
branches: [master, gha]
paths:
- ".github/workflows/module-codeql.yml"
- "common/**"
- "exploreApp/**"
- "pciApp/**"
- "vmeApp/**"
pull_request:
branches: [master]
paths:
- ".github/workflows/module-codeql.yml"
- "common/**"
- "exploreApp/**"
- "pciApp/**"
- "vmeApp/**"

permissions:
contents: read
security-events: write

env:
SETUP_PATH: .ci-local:.ci
BASE: "7.0"
CMP: gcc
BCFG: default

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: Deps
run: |
sudo apt-get update
sudo apt-get -y install qemu-system-x86 gdb

- name: Prepare deps (ci-scripts)
run: python3 .ci/cue.py prepare

- name: Initialize CodeQL (manual build)
uses: github/codeql-action/init@v3
with:
languages: cpp
build-mode: manual
config-file: ./.github/codeql/config.yml

- name: Build (ci-scripts)
run: |
python3 .ci/cue.py build

- name: Analyze
uses: github/codeql-action/analyze@v3
with:
category: "/language:cpp"
13 changes: 13 additions & 0 deletions linux/pci_generic_msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ int mmap_generic_msi(struct uio_info *info, struct vm_area_struct *vma)
return -EINVAL;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
vm_flags_set(vma, VM_IO | VM_RESERVED);
#elif defined(RHEL_RELEASE_CODE) && (RHEL_RELEASE_CODE >= 0x905)
vm_flags_set(vma, VM_IO | VM_RESERVED);
#else
vma->vm_flags |= VM_IO | VM_RESERVED;
#endif

vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);

return remap_pfn_range(vma,
Expand Down Expand Up @@ -163,9 +170,15 @@ static int probe_generic_msi(struct pci_dev *pdev,
}

{
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
struct msi_desc *desc = irq_get_msi_desc(pdev->irq);
priv->maskable = desc ? desc->msi_attrib.maskbit : 0;
dev_info(&pdev->dev, "MSI is %smaskable\n", priv->maskable ? "" : "not ");
#else
// Newer kernels: msi_desc not active
priv->maskable = 0;
dev_info(&pdev->dev, "MSI enabled (mask-bit introspection not available).\n");
#endif
}

err = uio_register_device(&pdev->dev, &priv->uio);
Expand Down