source
large_stringclasses 2
values | subject
large_stringclasses 112
values | code
large_stringclasses 112
values | critique
large_stringlengths 61
3.04M
⌀ | metadata
dict |
|---|---|---|---|---|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Gavin,
On 1/19/26 06:50, Gavin Shan wrote:
Ah yes, I'll add a system_supports_mpam() check here.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 15:08:39 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Gavin,
On 1/19/26 06:51, Gavin Shan wrote:
Addded.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 15:31:34 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Catalin,
On 1/15/26 19:13, Catalin Marinas wrote:
Yes, I'll remove the inner #ifdef.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 15:47:07 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Gavin,
On 1/19/26 07:01, Gavin Shan wrote:
Sure, I'll align these.
I'll move the #ifdef CONFIG_ARM64_MPAM up to cover these.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 15:49:05 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Reinette,
On 1/13/26 16:49, Reinette Chatre wrote:
Yeah, that leaks the memory and the offline call is unnecessary.
Yes.
Indeed.
Yes, it's missing.
I've reworked the code to move the resctrl_online_*() calls further up
so there is less to do on error, added a kfree(dom) and made the
ctrl_mon cleanup after the monitor domain failure to be conditional on
exposed_alloc_capable.
Yes, added.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 17:20:51 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Gavin,
On 1/19/26 11:57, Gavin Shan wrote:
Similarly to the other blank line checkpatch.pl warning I expect this is
to do with how it handles the __free() annotation. I'm not intending to
change this code unless there is some style guideline that I've missed
or other reason to do so.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 20:27:48 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Shaopeng,
On 1/16/26 11:04, Ben Horgan wrote:
Actually, resctl_arch_cntr_assign_set() only gets called on an attempt
to change the value so I'll keep it as is.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 20:34:06 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Gavin,
On 1/19/26 12:14, Gavin Shan wrote:
That's a real error. Fixed.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 20:48:45 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Gavin,
On 1/19/26 12:16, Gavin Shan wrote:
Fixed
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 20:54:19 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Fenghua,
On 1/15/26 23:20, Fenghua Yu wrote:
Isn't that a policy decision rather than something we should be putting
in a quirk framework?
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 20:56:17 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Gavin,
On 1/19/26 12:18, Gavin Shan wrote:
Fixed
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 19 Jan 2026 20:58:02 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Ben and Jonathan,
On 1/19/26 10:00 PM, Ben Horgan wrote:
Yeah, I'm fine to keep it as of being :-)
Thanks,
Gavin
|
{
"author": "Gavin Shan <gshan@redhat.com>",
"date": "Tue, 20 Jan 2026 09:42:09 +0800",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Ben,
On Fri, Jan 16, 2026 at 11:29 AM Ben Horgan <ben.horgan@arm.com> wrote:
We actually ended up going with the "mon_id_includes_control_id" approach.
The property it represents is rather fundamental to what a monitoring
group actually is and is a low-level implementation detail that is
difficult to hide. Google generally needs support for as many
monitoring IDs as jobs it expects to be able to run on a machine, so
the number of monitoring groups will be routinely maxed out (and there
will be some jobs that are forever stuck in the default group because
no RMIDs were free at the time it started[1])
Thanks,
-Peter
[1] https://lore.kernel.org/lkml/CALPaoCjTwySGX9i7uAtCWLKQpmELKP55xDLJhHmUve8ptsfFTw@mail.gmail.com/
|
{
"author": "Peter Newman <peternewman@google.com>",
"date": "Tue, 20 Jan 2026 16:28:01 +0100",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Ben and Peter,
On 1/20/26 7:28 AM, Peter Newman wrote:
Thank you for confirming. I was hoping we could deprecate num_rmids after introducing a
per resource group file but this does not seem to support all the use cases as highlighted by
Ben.
As I see it, a name like "mon_id_includes_control_id" also implies that "num_rmids", perhaps
linked to a new "num_mon_ids" as Peter suggested in [2], should contain num_pmg * num_partids.
One concern from earlier was that "mon_id_includes_control_id" may be used as a
heuristic for whether monitor groups can be moved or not. Instead I seem to remember that
there was a plan for MPAM to support moving monitor groups, with the caveat that
counters will reset for which resctrl may need another flag.
Reinette
[2] https://lore.kernel.org/lkml/CALPaoChad6=xqz+BQQd=dB915xhj1gusmcrS9ya+T2GyhTQc5Q@mail.gmail.com/
|
{
"author": "Reinette Chatre <reinette.chatre@intel.com>",
"date": "Wed, 21 Jan 2026 09:58:45 -0800",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Ben,
On Mon, Jan 19, 2026 at 12:23:13PM +0000, Ben Horgan wrote:
It's fine to keep it this way if LDTR/STTR are not affected by the MPAM0
register.
Since you use it for CPU suspend/resume, I guess it's fine, it saves us
from having to preserve it in the low-level asm sleep code. I don't have
a strong preference either way.
What if resctrl_arch_set_cdp_enabled() gets preempted between updating
current task partid and setting arm64_mpam_global_default? The mutex
doesn't help.
Is it updated when it goes into the kernel or when we have a context
switch? If you have a long-running user thread that is never scheduled
out, it may not notice the update even if it entered the kernel (but no
context switch).
I see, it should be fine.
--
Catalin
|
{
"author": "Catalin Marinas <catalin.marinas@arm.com>",
"date": "Fri, 23 Jan 2026 14:29:42 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Catalin,
On 1/23/26 14:29, Catalin Marinas wrote:
I see, I had misinterpreted your question.
When looking into this I spotted that the per-cpu default,
arm64_mpam_default, is not updated on the cdp enable and so the default
tasks carry on running with the non-cdp default pmg/partid configuration.
On the race itself, if current->mpam_partid_pmg is set but not
arm64_mpam_global_default then if the current task is preempted at that
point there is a discrepancy. When the task gets context switched back
in then the comparison in mpam_thread_switch() will be false when true
would be expected.
In order to update arm64_mpam_default and make sure the mpam variables
and registers for the online cpus are in the right state by the end of
resctrl_arch_set_cdp_enabled() I'll add a per cpu call to
resctrl_arch_sync_cpu_closid_rmid(). I'll also add something in the
resume path so that arm64_mpam_default gets set correctly for the cpus
that were offline.
Yes, only on context switch.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 26 Jan 2026 14:30:14 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
On 1/26/26 14:30, Ben Horgan wrote:
Rather than the resume path I'll just set all the arm64_mpam_default in
resctrl_arch_set_cdp_enabled(). In code:
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -193,6 +193,7 @@ static void resctrl_reset_task_closids(void)
int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool
enable)
{
u32 partid_i = RESCTRL_RESERVED_CLOSID, partid_d =
RESCTRL_RESERVED_CLOSID;
+ int cpu;
cdp_enabled = enable;
@@ -209,6 +210,10 @@ int resctrl_arch_set_cdp_enabled(enum
resctrl_res_level ignored, bool enable)
resctrl_reset_task_closids();
+ for_each_possible_cpu(cpu)
+ mpam_set_cpu_defaults(cpu, partid_d, partid_i, 0, 0);
+ on_each_cpu(resctrl_arch_sync_cpu_closid_rmid, NULL, 1);
+
return 0;
}
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 26 Jan 2026 14:50:12 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Peter, James,
On 1/19/26 12:47, Peter Newman wrote:
Indeed we should base our discussion on the event definition in the
Intel SDM. For our reference, the description for the external bandwidth
monitoring event (mbm_total) is:
"This event monitors the L3 total external bandwidth to the next level
of the cache hierarchy, including all demand and prefetch misses from
the L3 to the next hierarchy of the memory system. In most platforms,
this represents memory bandwidth."
On a system with MSC measuring memory bandwidth on the L3 caches these
MSC will measure all bandwidth to the next level of the memory hierarchy
which matches the definition of mbm_total. (We assume any MSC on an L3
is at the egress even though acpi/dt doesn't distinguish ingress and
egress.)
For MSC on memory controllers then they don't distinguish which L3 cache
the traffic came from and so unless there is a single L3 then we can't
use these memory bandwidth monitors as they count neither mbm_local nor
mbm_total. When there is a single L3 (and no higher level caches) then
it would match both mbm_total and mbm_local.
Hence, I agree we should just use mbm_total and update the heuristics
such that if the MSC are at the memory only consider them if there are
no higher caches and a single L3.
The introduction of ABMC muddies the waters as the "event_filter" file
defines the meaning of mbm_local and mbm_total. In order to handle this
file properly with MPAM, fs/resctrl changes are needed. We could either
make "event_filter" show the bits that correspond to the mbm counter and
unchangeable or decouple the "event_filter" part of ABMC from the
counter assignment part. As more work is needed to not break abi here
I'll drop the ABMC patches from the next respin of this series.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 26 Jan 2026 16:00:04 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi, Ben,
On 1/19/26 12:56, Ben Horgan wrote:
MBW_MIN is 1% or 5% less than MBW_MAX.
The lower MBW_MIN hints hardware to lower mem bandwidth when mem access
contention. That causes memory performance degradation.
Is it possible to do the following changes to fix the performance issue?
1. By default min mbw is equal to max mbw. So hardware won't lower
performance unless it's needed. This can fix the current performance issue.
2. Add a new schemata line (e.g. MBI:<id>=x;<id>=y;...) to specify min
mbw just like max mbw specified by schemata line "MB:...". User can use
this line to change min mbw per partition per node. This could be added
in the future.
Thanks.
-Fenghua
|
{
"author": "Fenghua Yu <fenghuay@nvidia.com>",
"date": "Thu, 29 Jan 2026 14:14:45 -0800",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Reinette, Peter,
On 1/21/26 17:58, Reinette Chatre wrote:
I had a chat offline with James about this. Currently, userspace expects
either the copy to succeed and the counters not to glitch or the move to
fail. If we were going to support a monitor move in MPAM with counter
reset (or a best effort counter value) we would have to make this opt-in
for userspace. If userspace tries the monitor move while being unaware
of the new flag it would unexpectedly lose counter data. To get this
opt-in behaviour there could be a mount option,
"destructive_monitor_move" or such like. Although this was considered in
the past, we're not currently aware of any usecase for this desctructive
monitor move and so are not proposing adding it or changing the existing
behaviour around this. This doesn't mean that a flag for indicating
whether monitor move is supported or not is not useful; a user may want
to know if monitor move is supported but not to do a monitor move at the
current time.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Fri, 30 Jan 2026 11:07:31 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Replying to myself...
On 1/12/26 16:58, Ben Horgan wrote:
As the counter is named llc_occupancy (llc = last level cache) and we
are naming the resource L3 it would be surprising to have llc_occupancy
on anything other than an L3. Also, that L3 should be a last level
cache. I'll update this as part of a general push to tighten up the
heuristics in this series to make sure that in the future when more
fitting user visible interfaces are added in resctrl we are able to use
them rather than being stuck with something that almost fits.
[...]
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Fri, 30 Jan 2026 11:19:29 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Fenghua,
On 1/29/26 22:14, Fenghua Yu wrote:
Thanks for bringing this up. It raises some more general queries about
the handling of mbw_min and so I'll move the discussion to
[PATCH v3 41/47] arm_mpam: Generate a configuration for min controls
as it isn't specific to the nvidia quirks.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Fri, 30 Jan 2026 12:21:42 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Ben,
On Mon, Jan 26, 2026 at 5:00 PM Ben Horgan <ben.horgan@arm.com> wrote:
The text you quoted from Intel was in the context of the L3. I assume
if such an event were implemented at a different level of the memory
system, it would continue to refer to downstream bandwidth.
That should be ok for now. If I see a system where this makes MBWU
counters inaccessible, we'll continue the discussion then.
I would prefer if you can just leave out the event_filter or make it
unconfigurable on MPAM. The rest of the counter assignment seems to
work well.
Longer term, the event_filter interface is supposed to give us the
ability to define and name our own counter events, but we'll have to
find a way past the decision to define the event filters in terms
copy-pasted from an AMD manual.
Thanks,
-Peter
|
{
"author": "Peter Newman <peternewman@google.com>",
"date": "Fri, 30 Jan 2026 14:04:29 +0100",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Fenghua, Jonathan,
On 1/13/26 15:39, Jonathan Cameron wrote:
I've realised it's not harmless :(
In the discussion on a platform quirk, arm_mpam: Add workaround for
T241-MPAM-4, Fenghua raised the following issues.
"
MBW_MIN is 1% or 5% less than MBW_MAX.
The lower MBW_MIN hints hardware to lower mem bandwidth when mem access
contention. That causes memory performance degradation.
Is it possible to do the following changes to fix the performance issue?
1. By default min mbw is equal to max mbw. So hardware won't lower
performance unless it's needed. This can fix the current performance issue.
2. Add a new schemata line (e.g. MBI:<id>=x;<id>=y;...) to specify min
mbw just like max mbw specified by schemata line "MB:...". User can use
this line to change min mbw per partition per node. This could be added
in the future.
"
On 1.
Thinking about this again, I think adding any heuristic tied to mbw_max
to determine what mbw_min is undesirable. Loading the mpam driver or
mounting resctrl shouldn't change the defaults away from the defaults
for h/w partid 0 or performance characteristics may change unexpectedly.
The spec only gives us suggestions for these but we should go with
those. See table 3.8 in IH0099B.a Mpam System Component Specification.
The MBW_MIN that is 0xFFFF. Also, having mbw_min doesn't necessarily
mean that there is mbw_max. A system that doesn't advertise mbw_min
support to the user should act as if there is no mbw_min support.
On 2.
Yes, adding a new user interface in resctrl is the way to deal with
this. See [1] for a discussion on adding new schema.
Hence, I'll drop this patch, and update the mbw_min default to be 0xFFFF
and for the value not to change even if mbw_max changes. I think this
leaves us in the best position going forward without any heuristics that
may come back to bite us later when proper support for a schema
supporting mbw_min is added to resctrl.
[1] https://lore.kernel.org/lkml/aPtfMFfLV1l%2FRB0L@e133380.arm.com/
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Fri, 30 Jan 2026 14:17:38 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Peter,
On 1/30/26 13:04, Peter Newman wrote:
Yes, that does seem reasonable. That cache level would have to match
with what is reported in resctrl too. I expect that would involve adding
a new entry in enum resctrl_scope.
Good to know. I'm looking into tightening the heuristics in general.
Please shout if any of the changes in heuristics mean that any hardware
or features stop being usable.
If there is an event_filter file it should show the "correct" values and
so just leaving it out would be the way to go. However, unless I'm
missing something even this requires changes in fs/resctrl. As such, I
think it's expedient to defer adding ABMC to the series until we have
decided what to do in fs/resctrl.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Fri, 30 Jan 2026 14:38:00 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Ben,
On 1/30/2026 8:17 AM, Ben Horgan wrote:
Background: I previouslyshared original fix(seecodesnippet below) with
James Morse
~2 years ago to address the errata, which explicitly recommends usinga
5% gap for
mitigation of the Hardware issue (the problem described in commit text
of T241-MPAM-4)
For some reason theoriginalimplementationwas splitinto two patches:
- Generic change applicable toall chips
- Specific fixfor Graceerrata T241-MPAM-4
Issue: Dropping this patch impacts[PATCH v3 45/47] forthe errata fix. If
removalis
necessary, please mergethis changeinto the T241-MPAM-4-specific patch.
--- a/drivers/platform/mpam/mpam_devices.c
+++ b/drivers/platform/mpam/mpam_devices.c
@@ -1190,8 +1190,12 @@ static void mpam_reprogram_ris_partid(struct
mpam_msc_ris *ris, u16 partid, rprops->mbw_pbm_bits);
}
- if (mpam_has_feature(mpam_feat_mbw_min, rprops))
- mpam_write_partsel_reg(msc, MBW_MIN, 0);
+ if (mpam_has_feature(mpam_feat_mbw_min, rprops)) {
+ if (mpam_has_feature(mpam_feat_mbw_max, cfg))
+ mpam_write_partsel_reg(msc, MBW_MIN, cfg->mbw_min);
+ else
+ mpam_write_partsel_reg(msc, MBW_MIN, 0);
+ }
if (mpam_has_feature(mpam_feat_mbw_max, rprops)) {
if (mpam_has_feature(mpam_feat_mbw_max, cfg)) @@
-2332,6 +2336,31 @@ static int __write_config(void *arg)
return 0;
}
+static void mpam_extend_config(struct mpam_class *class, struct mpam_config *cfg)
+{
+ struct mpam_props *cprops = &class->props;
+ u32 min, delta;
+
+ /*
+ * MAX and MIN should be set together. If only one is provided,
+ * generate a configuration for the other. If only one control
+ * type is supported, the other value will be ignored.
+ *
+ * Resctrl can only configure the MAX.
+ *
+ * Parts affected by Nvidia's T241-MPAM-4 depend on this occurring,
+ * and recommend a 5% difference.
+ */
+ if (mpam_has_feature(mpam_feat_mbw_max, cfg) &&
+ !mpam_has_feature(mpam_feat_mbw_min, cfg)){
+ delta = ((5 * MPAMCFG_MBW_MAX_MAX) / 100) - 1;
+ min = max_t(s32, cfg->mbw_max - delta, BIT(cprops->bwa_wd));
+
+ cfg->mbw_min = max_t(s32, cfg->mbw_max - delta, BIT(16 - cprops->bwa_wd));
+ mpam_set_feature(mpam_feat_mbw_min, cfg);
+ }
+}
Shanker
|
{
"author": "Shanker Donthineni <sdonthineni@nvidia.com>",
"date": "Fri, 30 Jan 2026 20:30:01 -0600",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Shanker,
On 1/31/26 02:30, Shanker Donthineni wrote:
What's the behaviour on T241 when MBW_MIN is always 0xFFFF?
I'm worried if we make a policy decision of how to set MBW_MIN based on
MBW_MAX for this platform then we won't be able to support a
configurable MBW_MIN in the future for this platform. As when MBW_MIN
support is added in resctrl the user's configuration for this platform
would change meaning on kernel upgrade.
Thanks,
Ben
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 2 Feb 2026 10:21:28 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Hi Ben,
On 2/2/2026 4:21 AM, Ben Horgan wrote:
Memory bandwidth throttling will not function correctly. The MPAM hardware
monitors MIN and MAX values for each active partition to maintain memory
bandwidth usage between MBW_MIN and MBW_MAX. Therefore, MBW_MIN must be
less than MBW_MAX (IMO, setting MBW_MIN to always 0xFFFF is incorrect)
Grace errata T241-MPAM-4 has two issues:
- MBW_MIN must be greater than 0 (WAR set to one when when it's zero) - In the Grace implementation of memory-bandwidth partitioning (MPAM),
in the absence of contention for bandwidth, the minimum bandwidth
setting can affect the amount of achieved bandwidth. Specifically,
the achieved bandwidth in the absence of contention can settle to any
value between the values of MIN and MAX. This means if the gap between
MIN and MAX is large then the BW can settle closer to MIN. To achieve
BW closer to MAX in the absence of contention, software should configure
a relatively narrow gap between MPAMCFG_MBW_MIN and MPAMCFG_MBW_MAX.
The recommendation is to use a 5% gap, corresponding to an absolute
difference of (0xFFFF * 0.05) = 0xCCC between MPAMCFG_MBW_MIN and
MPAMCFG_MBW_MAX.
Yes, we can't support generic programmable MBW_MIN for Grace chip. The
currentresctrl interface doesnot exposeMBW_MIN, preventingusers from
configuring the recommended5% gap. Without this interfacesupport,
theonly wayto applytheworkaround is through driver-level changes.
What is the timelineforaddingMBW_MIN support? We have two options.
Option-A: Keep the current WAR 5% gap and don't allow users to program MBW_MIN.
Option-B:Remove the5% gap workaround and relyon usersto program MBW_MIN
accordingto the Grace recommendations whentheinterfacebecomes available.
We'll prefer option-B.
Thanks,
Shanker
|
{
"author": "Shanker Donthineni <sdonthineni@nvidia.com>",
"date": "Mon, 2 Feb 2026 10:34:18 -0600",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
The "qup-memory" interconnect path is optional and may not be defined
in all device trees. Unroll the loop-based ICC path initialization to
allow specific error handling for each path type.
The "qup-core" and "qup-config" paths remain mandatory and will fail
probe if missing, while "qup-memory" is now handled as optional and
skipped when not present in the device tree.
Co-developed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v1->v2:
Bjorn:
- Updated commit text.
- Used local variable for more readable.
---
drivers/soc/qcom/qcom-geni-se.c | 36 +++++++++++++++++----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index cd1779b6a91a..b6167b968ef6 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -899,30 +899,32 @@ EXPORT_SYMBOL_GPL(geni_se_rx_dma_unprep);
int geni_icc_get(struct geni_se *se, const char *icc_ddr)
{
- int i, err;
- const char *icc_names[] = {"qup-core", "qup-config", icc_ddr};
+ struct geni_icc_path *icc_paths = se->icc_paths;
if (has_acpi_companion(se->dev))
return 0;
- for (i = 0; i < ARRAY_SIZE(se->icc_paths); i++) {
- if (!icc_names[i])
- continue;
-
- se->icc_paths[i].path = devm_of_icc_get(se->dev, icc_names[i]);
- if (IS_ERR(se->icc_paths[i].path))
- goto err;
+ icc_paths[GENI_TO_CORE].path = devm_of_icc_get(se->dev, "qup-core");
+ if (IS_ERR(icc_paths[GENI_TO_CORE].path))
+ return dev_err_probe(se->dev, PTR_ERR(icc_paths[GENI_TO_CORE].path),
+ "Failed to get 'qup-core' ICC path\n");
+
+ icc_paths[CPU_TO_GENI].path = devm_of_icc_get(se->dev, "qup-config");
+ if (IS_ERR(icc_paths[CPU_TO_GENI].path))
+ return dev_err_probe(se->dev, PTR_ERR(icc_paths[CPU_TO_GENI].path),
+ "Failed to get 'qup-config' ICC path\n");
+
+ /* The DDR path is optional, depending on protocol and hw capabilities */
+ icc_paths[GENI_TO_DDR].path = devm_of_icc_get(se->dev, "qup-memory");
+ if (IS_ERR(icc_paths[GENI_TO_DDR].path)) {
+ if (PTR_ERR(icc_paths[GENI_TO_DDR].path) == -ENODATA)
+ icc_paths[GENI_TO_DDR].path = NULL;
+ else
+ return dev_err_probe(se->dev, PTR_ERR(icc_paths[GENI_TO_DDR].path),
+ "Failed to get 'qup-memory' ICC path\n");
}
return 0;
-
-err:
- err = PTR_ERR(se->icc_paths[i].path);
- if (err != -EPROBE_DEFER)
- dev_err_ratelimited(se->dev, "Failed to get ICC path '%s': %d\n",
- icc_names[i], err);
- return err;
-
}
EXPORT_SYMBOL_GPL(geni_icc_get);
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:10 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
Add a new function geni_icc_set_bw_ab() that allows callers to set
average bandwidth values for all ICC (Interconnect) paths in a single
call. This function takes separate parameters for core, config, and DDR
average bandwidth values and applies them to the respective ICC paths.
This provides a more convenient API for drivers that need to configure
specific average bandwidth values.
Co-developed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
drivers/soc/qcom/qcom-geni-se.c | 22 ++++++++++++++++++++++
include/linux/soc/qcom/geni-se.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index b6167b968ef6..b0542f836453 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -946,6 +946,28 @@ int geni_icc_set_bw(struct geni_se *se)
}
EXPORT_SYMBOL_GPL(geni_icc_set_bw);
+/**
+ * geni_icc_set_bw_ab() - Set average bandwidth for all ICC paths and apply
+ * @se: Pointer to the concerned serial engine.
+ * @core_ab: Average bandwidth in kBps for GENI_TO_CORE path.
+ * @cfg_ab: Average bandwidth in kBps for CPU_TO_GENI path.
+ * @ddr_ab: Average bandwidth in kBps for GENI_TO_DDR path.
+ *
+ * Sets bandwidth values for all ICC paths and applies them. DDR path is
+ * optional and only set if it exists.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+int geni_icc_set_bw_ab(struct geni_se *se, u32 core_ab, u32 cfg_ab, u32 ddr_ab)
+{
+ se->icc_paths[GENI_TO_CORE].avg_bw = core_ab;
+ se->icc_paths[CPU_TO_GENI].avg_bw = cfg_ab;
+ se->icc_paths[GENI_TO_DDR].avg_bw = ddr_ab;
+
+ return geni_icc_set_bw(se);
+}
+EXPORT_SYMBOL_GPL(geni_icc_set_bw_ab);
+
void geni_icc_set_tag(struct geni_se *se, u32 tag)
{
int i;
diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
index 0a984e2579fe..980aabea2157 100644
--- a/include/linux/soc/qcom/geni-se.h
+++ b/include/linux/soc/qcom/geni-se.h
@@ -528,6 +528,7 @@ void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len);
int geni_icc_get(struct geni_se *se, const char *icc_ddr);
int geni_icc_set_bw(struct geni_se *se);
+int geni_icc_set_bw_ab(struct geni_se *se, u32 core_ab, u32 cfg_ab, u32 ddr_ab);
void geni_icc_set_tag(struct geni_se *se, u32 tag);
int geni_icc_enable(struct geni_se *se);
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:11 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
The GENI Serial Engine drivers (I2C, SPI, and SERIAL) currently duplicate
code for initializing shared resources such as clocks and interconnect
paths.
Introduce a new helper API, geni_se_resources_init(), to centralize this
initialization logic, improving modularity and simplifying the probe
function.
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v1 -> v2:
- Updated proper return value for devm_pm_opp_set_clkname()
---
drivers/soc/qcom/qcom-geni-se.c | 47 ++++++++++++++++++++++++++++++++
include/linux/soc/qcom/geni-se.h | 6 ++++
2 files changed, 53 insertions(+)
diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index b0542f836453..75e722cd1a94 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -19,6 +19,7 @@
#include <linux/of_platform.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
+#include <linux/pm_opp.h>
#include <linux/soc/qcom/geni-se.h>
/**
@@ -1012,6 +1013,52 @@ int geni_icc_disable(struct geni_se *se)
}
EXPORT_SYMBOL_GPL(geni_icc_disable);
+/**
+ * geni_se_resources_init() - Initialize resources for a GENI SE device.
+ * @se: Pointer to the geni_se structure representing the GENI SE device.
+ *
+ * This function initializes various resources required by the GENI Serial Engine
+ * (SE) device, including clock resources (core and SE clocks), interconnect
+ * paths for communication.
+ * It retrieves optional and mandatory clock resources, adds an OF-based
+ * operating performance point (OPP) table, and sets up interconnect paths
+ * with default bandwidths. The function also sets a flag (`has_opp`) to
+ * indicate whether OPP support is available for the device.
+ *
+ * Return: 0 on success, or a negative errno on failure.
+ */
+int geni_se_resources_init(struct geni_se *se)
+{
+ int ret;
+
+ se->core_clk = devm_clk_get_optional(se->dev, "core");
+ if (IS_ERR(se->core_clk))
+ return dev_err_probe(se->dev, PTR_ERR(se->core_clk),
+ "Failed to get optional core clk\n");
+
+ se->clk = devm_clk_get(se->dev, "se");
+ if (IS_ERR(se->clk) && !has_acpi_companion(se->dev))
+ return dev_err_probe(se->dev, PTR_ERR(se->clk),
+ "Failed to get SE clk\n");
+
+ ret = devm_pm_opp_set_clkname(se->dev, "se");
+ if (ret)
+ return ret;
+
+ ret = devm_pm_opp_of_add_table(se->dev);
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(se->dev, ret, "Failed to add OPP table\n");
+
+ se->has_opp = (ret == 0);
+
+ ret = geni_icc_get(se, "qup-memory");
+ if (ret)
+ return ret;
+
+ return geni_icc_set_bw_ab(se, GENI_DEFAULT_BW, GENI_DEFAULT_BW, GENI_DEFAULT_BW);
+}
+EXPORT_SYMBOL_GPL(geni_se_resources_init);
+
/**
* geni_find_protocol_fw() - Locate and validate SE firmware for a protocol.
* @dev: Pointer to the device structure.
diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
index 980aabea2157..c182dd0f0bde 100644
--- a/include/linux/soc/qcom/geni-se.h
+++ b/include/linux/soc/qcom/geni-se.h
@@ -60,18 +60,22 @@ struct geni_icc_path {
* @dev: Pointer to the Serial Engine device
* @wrapper: Pointer to the parent QUP Wrapper core
* @clk: Handle to the core serial engine clock
+ * @core_clk: Auxiliary clock, which may be required by a protocol
* @num_clk_levels: Number of valid clock levels in clk_perf_tbl
* @clk_perf_tbl: Table of clock frequency input to serial engine clock
* @icc_paths: Array of ICC paths for SE
+ * @has_opp: Indicates if OPP is supported
*/
struct geni_se {
void __iomem *base;
struct device *dev;
struct geni_wrapper *wrapper;
struct clk *clk;
+ struct clk *core_clk;
unsigned int num_clk_levels;
unsigned long *clk_perf_tbl;
struct geni_icc_path icc_paths[3];
+ bool has_opp;
};
/* Common SE registers */
@@ -535,6 +539,8 @@ int geni_icc_enable(struct geni_se *se);
int geni_icc_disable(struct geni_se *se);
+int geni_se_resources_init(struct geni_se *se);
+
int geni_load_se_firmware(struct geni_se *se, enum geni_se_protocol_type protocol);
#endif
#endif
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:12 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
Currently, core clk is handled individually in protocol drivers like
the I2C driver. Move this clock management to the common clock APIs
(geni_se_clks_on/off) that are already present in the common GENI SE
driver to maintain consistency across all protocol drivers.
Core clk is now properly managed alongside the other clocks (se->clk
and wrapper clocks) in the fundamental clock control functions,
eliminating the need for individual protocol drivers to handle this
clock separately.
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
drivers/soc/qcom/qcom-geni-se.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 75e722cd1a94..2e41595ff912 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -583,6 +583,7 @@ static void geni_se_clks_off(struct geni_se *se)
clk_disable_unprepare(se->clk);
clk_bulk_disable_unprepare(wrapper->num_clks, wrapper->clks);
+ clk_disable_unprepare(se->core_clk);
}
/**
@@ -619,7 +620,18 @@ static int geni_se_clks_on(struct geni_se *se)
ret = clk_prepare_enable(se->clk);
if (ret)
- clk_bulk_disable_unprepare(wrapper->num_clks, wrapper->clks);
+ goto err_bulk_clks;
+
+ ret = clk_prepare_enable(se->core_clk);
+ if (ret)
+ goto err_se_clk;
+
+ return 0;
+
+err_se_clk:
+ clk_disable_unprepare(se->clk);
+err_bulk_clks:
+ clk_bulk_disable_unprepare(wrapper->num_clks, wrapper->clks);
return ret;
}
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:13 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
The GENI SE protocol drivers (I2C, SPI, UART) implement similar resource
activation/deactivation sequences independently, leading to code
duplication.
Introduce geni_se_resources_activate()/geni_se_resources_deactivate() to
power on/off resources.The activate function enables ICC, clocks, and TLMM
whereas the deactivate function disables resources in reverse order
including OPP rate reset, clocks, ICC and TLMM.
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v3 -> v4
Konrad
- Removed core clk.
v2 -> v3
- Added export symbol for new APIs.
v1 -> v2
Bjorn
- Updated commit message based code changes.
- Removed geni_se_resource_state() API.
- Utilized code snippet from geni_se_resources_off()
---
drivers/soc/qcom/qcom-geni-se.c | 67 ++++++++++++++++++++++++++++++++
include/linux/soc/qcom/geni-se.h | 4 ++
2 files changed, 71 insertions(+)
diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 2e41595ff912..17ab5bbeb621 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -1025,6 +1025,73 @@ int geni_icc_disable(struct geni_se *se)
}
EXPORT_SYMBOL_GPL(geni_icc_disable);
+/**
+ * geni_se_resources_deactivate() - Deactivate GENI SE device resources
+ * @se: Pointer to the geni_se structure
+ *
+ * Deactivates device resources for power saving: OPP rate to 0, pin control
+ * to sleep state, turns off clocks, and disables interconnect. Skips ACPI devices.
+ *
+ * Return: 0 on success, negative error code on failure
+ */
+int geni_se_resources_deactivate(struct geni_se *se)
+{
+ int ret;
+
+ if (has_acpi_companion(se->dev))
+ return 0;
+
+ if (se->has_opp)
+ dev_pm_opp_set_rate(se->dev, 0);
+
+ ret = pinctrl_pm_select_sleep_state(se->dev);
+ if (ret)
+ return ret;
+
+ geni_se_clks_off(se);
+
+ return geni_icc_disable(se);
+}
+EXPORT_SYMBOL_GPL(geni_se_resources_deactivate);
+
+/**
+ * geni_se_resources_activate() - Activate GENI SE device resources
+ * @se: Pointer to the geni_se structure
+ *
+ * Activates device resources for operation: enables interconnect, prepares clocks,
+ * and sets pin control to default state. Includes error cleanup. Skips ACPI devices.
+ *
+ * Return: 0 on success, negative error code on failure
+ */
+int geni_se_resources_activate(struct geni_se *se)
+{
+ int ret;
+
+ if (has_acpi_companion(se->dev))
+ return 0;
+
+ ret = geni_icc_enable(se);
+ if (ret)
+ return ret;
+
+ ret = geni_se_clks_on(se);
+ if (ret)
+ goto out_icc_disable;
+
+ ret = pinctrl_pm_select_default_state(se->dev);
+ if (ret) {
+ geni_se_clks_off(se);
+ goto out_icc_disable;
+ }
+
+ return ret;
+
+out_icc_disable:
+ geni_icc_disable(se);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(geni_se_resources_activate);
+
/**
* geni_se_resources_init() - Initialize resources for a GENI SE device.
* @se: Pointer to the geni_se structure representing the GENI SE device.
diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
index c182dd0f0bde..36a68149345c 100644
--- a/include/linux/soc/qcom/geni-se.h
+++ b/include/linux/soc/qcom/geni-se.h
@@ -541,6 +541,10 @@ int geni_icc_disable(struct geni_se *se);
int geni_se_resources_init(struct geni_se *se);
+int geni_se_resources_activate(struct geni_se *se);
+
+int geni_se_resources_deactivate(struct geni_se *se);
+
int geni_load_se_firmware(struct geni_se *se, enum geni_se_protocol_type protocol);
#endif
#endif
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:14 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
The GENI Serial Engine drivers (I2C, SPI, and SERIAL) currently handle
the attachment of power domains. This often leads to duplicated code
logic across different driver probe functions.
Introduce a new helper API, geni_se_domain_attach(), to centralize
the logic for attaching "power" and "perf" domains to the GENI SE
device.
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v3->v4
Konrad
- Updated function documentation
---
drivers/soc/qcom/qcom-geni-se.c | 29 +++++++++++++++++++++++++++++
include/linux/soc/qcom/geni-se.h | 4 ++++
2 files changed, 33 insertions(+)
diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 17ab5bbeb621..d80ae6c36582 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -19,6 +19,7 @@
#include <linux/of_platform.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
#include <linux/pm_opp.h>
#include <linux/soc/qcom/geni-se.h>
@@ -1092,6 +1093,34 @@ int geni_se_resources_activate(struct geni_se *se)
}
EXPORT_SYMBOL_GPL(geni_se_resources_activate);
+/**
+ * geni_se_domain_attach() - Attach power domains to a GENI SE device.
+ * @se: Pointer to the geni_se structure representing the GENI SE device.
+ *
+ * This function attaches the power domains ("power" and "perf") required
+ * in the SCMI auto-VM environment to the GENI Serial Engine device. It
+ * initializes se->pd_list with the attached domains.
+ *
+ * Return: 0 on success, or a negative error code on failure.
+ */
+int geni_se_domain_attach(struct geni_se *se)
+{
+ struct dev_pm_domain_attach_data pd_data = {
+ .pd_flags = PD_FLAG_DEV_LINK_ON,
+ .pd_names = (const char*[]) { "power", "perf" },
+ .num_pd_names = 2,
+ };
+ int ret;
+
+ ret = dev_pm_domain_attach_list(se->dev,
+ &pd_data, &se->pd_list);
+ if (ret <= 0)
+ return -EINVAL;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(geni_se_domain_attach);
+
/**
* geni_se_resources_init() - Initialize resources for a GENI SE device.
* @se: Pointer to the geni_se structure representing the GENI SE device.
diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
index 36a68149345c..5f75159c5531 100644
--- a/include/linux/soc/qcom/geni-se.h
+++ b/include/linux/soc/qcom/geni-se.h
@@ -64,6 +64,7 @@ struct geni_icc_path {
* @num_clk_levels: Number of valid clock levels in clk_perf_tbl
* @clk_perf_tbl: Table of clock frequency input to serial engine clock
* @icc_paths: Array of ICC paths for SE
+ * @pd_list: Power domain list for managing power domains
* @has_opp: Indicates if OPP is supported
*/
struct geni_se {
@@ -75,6 +76,7 @@ struct geni_se {
unsigned int num_clk_levels;
unsigned long *clk_perf_tbl;
struct geni_icc_path icc_paths[3];
+ struct dev_pm_domain_list *pd_list;
bool has_opp;
};
@@ -546,5 +548,7 @@ int geni_se_resources_activate(struct geni_se *se);
int geni_se_resources_deactivate(struct geni_se *se);
int geni_load_se_firmware(struct geni_se *se, enum geni_se_protocol_type protocol);
+
+int geni_se_domain_attach(struct geni_se *se);
#endif
#endif
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:15 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
The GENI Serial Engine (SE) drivers (I2C, SPI, and SERIAL) currently
manage performance levels and operating points directly. This resulting
in code duplication across drivers. such as configuring a specific level
or find and apply an OPP based on a clock frequency.
Introduce two new helper APIs, geni_se_set_perf_level() and
geni_se_set_perf_opp(), addresses this issue by providing a streamlined
method for the GENI Serial Engine (SE) drivers to find and set the OPP
based on the desired performance level, thereby eliminating redundancy.
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
drivers/soc/qcom/qcom-geni-se.c | 50 ++++++++++++++++++++++++++++++++
include/linux/soc/qcom/geni-se.h | 4 +++
2 files changed, 54 insertions(+)
diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index d80ae6c36582..2241d1487031 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -282,6 +282,12 @@ struct se_fw_hdr {
#define geni_setbits32(_addr, _v) writel(readl(_addr) | (_v), _addr)
#define geni_clrbits32(_addr, _v) writel(readl(_addr) & ~(_v), _addr)
+enum domain_idx {
+ DOMAIN_IDX_POWER,
+ DOMAIN_IDX_PERF,
+ DOMAIN_IDX_MAX
+};
+
/**
* geni_se_get_qup_hw_version() - Read the QUP wrapper Hardware version
* @se: Pointer to the corresponding serial engine.
@@ -1093,6 +1099,50 @@ int geni_se_resources_activate(struct geni_se *se)
}
EXPORT_SYMBOL_GPL(geni_se_resources_activate);
+/**
+ * geni_se_set_perf_level() - Set performance level for GENI SE.
+ * @se: Pointer to the struct geni_se instance.
+ * @level: The desired performance level.
+ *
+ * Sets the performance level by directly calling dev_pm_opp_set_level
+ * on the performance device associated with the SE.
+ *
+ * Return: 0 on success, or a negative error code on failure.
+ */
+int geni_se_set_perf_level(struct geni_se *se, unsigned long level)
+{
+ return dev_pm_opp_set_level(se->pd_list->pd_devs[DOMAIN_IDX_PERF], level);
+}
+EXPORT_SYMBOL_GPL(geni_se_set_perf_level);
+
+/**
+ * geni_se_set_perf_opp() - Set performance OPP for GENI SE by frequency.
+ * @se: Pointer to the struct geni_se instance.
+ * @clk_freq: The requested clock frequency.
+ *
+ * Finds the nearest operating performance point (OPP) for the given
+ * clock frequency and applies it to the SE's performance device.
+ *
+ * Return: 0 on success, or a negative error code on failure.
+ */
+int geni_se_set_perf_opp(struct geni_se *se, unsigned long clk_freq)
+{
+ struct device *perf_dev = se->pd_list->pd_devs[DOMAIN_IDX_PERF];
+ struct dev_pm_opp *opp;
+ int ret;
+
+ opp = dev_pm_opp_find_freq_floor(perf_dev, &clk_freq);
+ if (IS_ERR(opp)) {
+ dev_err(se->dev, "failed to find opp for freq %lu\n", clk_freq);
+ return PTR_ERR(opp);
+ }
+
+ ret = dev_pm_opp_set_opp(perf_dev, opp);
+ dev_pm_opp_put(opp);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(geni_se_set_perf_opp);
+
/**
* geni_se_domain_attach() - Attach power domains to a GENI SE device.
* @se: Pointer to the geni_se structure representing the GENI SE device.
diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
index 5f75159c5531..c5e6ab85df09 100644
--- a/include/linux/soc/qcom/geni-se.h
+++ b/include/linux/soc/qcom/geni-se.h
@@ -550,5 +550,9 @@ int geni_se_resources_deactivate(struct geni_se *se);
int geni_load_se_firmware(struct geni_se *se, enum geni_se_protocol_type protocol);
int geni_se_domain_attach(struct geni_se *se);
+
+int geni_se_set_perf_level(struct geni_se *se, unsigned long level);
+
+int geni_se_set_perf_opp(struct geni_se *se, unsigned long clk_freq);
#endif
#endif
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:16 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
Add DT bindings for the QUP GENI I2C controller on sa8255p platforms.
SA8255p platform abstracts resources such as clocks, interconnect and
GPIO pins configuration in Firmware. SCMI power and perf protocol
are utilized to request resource configurations.
SA8255p platform does not require the Serial Engine (SE) common properties
as the SE firmware is loaded and managed by the TrustZone (TZ) secure
environment.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Co-developed-by: Nikunj Kela <quic_nkela@quicinc.com>
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v2->v3:
- Added Reviewed-by tag
v1->v2:
Krzysztof:
- Added dma properties in example node
- Removed minItems from power-domains property
- Added in commit text about common property
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 +++++++++++++++++++
1 file changed, 64 insertions(+)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
diff --git a/Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml b/Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
new file mode 100644
index 000000000000..a61e40b5cbc1
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
@@ -0,0 +1,64 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/qcom,sa8255p-geni-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm SA8255p QUP GENI I2C Controller
+
+maintainers:
+ - Praveen Talari <praveen.talari@oss.qualcomm.com>
+
+properties:
+ compatible:
+ const: qcom,sa8255p-geni-i2c
+
+ reg:
+ maxItems: 1
+
+ dmas:
+ maxItems: 2
+
+ dma-names:
+ items:
+ - const: tx
+ - const: rx
+
+ interrupts:
+ maxItems: 1
+
+ power-domains:
+ maxItems: 2
+
+ power-domain-names:
+ items:
+ - const: power
+ - const: perf
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - power-domains
+
+allOf:
+ - $ref: /schemas/i2c/i2c-controller.yaml#
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/dma/qcom-gpi.h>
+
+ i2c@a90000 {
+ compatible = "qcom,sa8255p-geni-i2c";
+ reg = <0xa90000 0x4000>;
+ interrupts = <GIC_SPI 357 IRQ_TYPE_LEVEL_HIGH>;
+ dmas = <&gpi_dma0 0 0 QCOM_GPI_I2C>,
+ <&gpi_dma0 1 0 QCOM_GPI_I2C>;
+ dma-names = "tx", "rx";
+ power-domains = <&scmi0_pd 0>, <&scmi0_dvfs 0>;
+ power-domain-names = "power", "perf";
+ };
+...
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:17 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
Moving the serial engine setup to geni_i2c_init() API for a cleaner
probe function and utilizes the PM runtime API to control resources
instead of direct clock-related APIs for better resource management.
Enables reusability of the serial engine initialization like
hibernation and deep sleep features where hardware context is lost.
Acked-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v3->v4:
viken:
- Added Acked-by tag
- Removed extra space before invoke of geni_i2c_init().
v1->v2:
Bjorn:
- Updated commit text.
---
drivers/i2c/busses/i2c-qcom-geni.c | 158 ++++++++++++++---------------
1 file changed, 75 insertions(+), 83 deletions(-)
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index ae609bdd2ec4..81ed1596ac9f 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -977,10 +977,77 @@ static int setup_gpi_dma(struct geni_i2c_dev *gi2c)
return ret;
}
+static int geni_i2c_init(struct geni_i2c_dev *gi2c)
+{
+ const struct geni_i2c_desc *desc = NULL;
+ u32 proto, tx_depth;
+ bool fifo_disable;
+ int ret;
+
+ ret = pm_runtime_resume_and_get(gi2c->se.dev);
+ if (ret < 0) {
+ dev_err(gi2c->se.dev, "error turning on device :%d\n", ret);
+ return ret;
+ }
+
+ proto = geni_se_read_proto(&gi2c->se);
+ if (proto == GENI_SE_INVALID_PROTO) {
+ ret = geni_load_se_firmware(&gi2c->se, GENI_SE_I2C);
+ if (ret) {
+ dev_err_probe(gi2c->se.dev, ret, "i2c firmware load failed ret: %d\n", ret);
+ goto err;
+ }
+ } else if (proto != GENI_SE_I2C) {
+ ret = dev_err_probe(gi2c->se.dev, -ENXIO, "Invalid proto %d\n", proto);
+ goto err;
+ }
+
+ desc = device_get_match_data(gi2c->se.dev);
+ if (desc && desc->no_dma_support) {
+ fifo_disable = false;
+ gi2c->no_dma = true;
+ } else {
+ fifo_disable = readl_relaxed(gi2c->se.base + GENI_IF_DISABLE_RO) & FIFO_IF_DISABLE;
+ }
+
+ if (fifo_disable) {
+ /* FIFO is disabled, so we can only use GPI DMA */
+ gi2c->gpi_mode = true;
+ ret = setup_gpi_dma(gi2c);
+ if (ret)
+ goto err;
+
+ dev_dbg(gi2c->se.dev, "Using GPI DMA mode for I2C\n");
+ } else {
+ gi2c->gpi_mode = false;
+ tx_depth = geni_se_get_tx_fifo_depth(&gi2c->se);
+
+ /* I2C Master Hub Serial Elements doesn't have the HW_PARAM_0 register */
+ if (!tx_depth && desc)
+ tx_depth = desc->tx_fifo_depth;
+
+ if (!tx_depth) {
+ ret = dev_err_probe(gi2c->se.dev, -EINVAL,
+ "Invalid TX FIFO depth\n");
+ goto err;
+ }
+
+ gi2c->tx_wm = tx_depth - 1;
+ geni_se_init(&gi2c->se, gi2c->tx_wm, tx_depth);
+ geni_se_config_packing(&gi2c->se, BITS_PER_BYTE,
+ PACKING_BYTES_PW, true, true, true);
+
+ dev_dbg(gi2c->se.dev, "i2c fifo/se-dma mode. fifo depth:%d\n", tx_depth);
+ }
+
+err:
+ pm_runtime_put(gi2c->se.dev);
+ return ret;
+}
+
static int geni_i2c_probe(struct platform_device *pdev)
{
struct geni_i2c_dev *gi2c;
- u32 proto, tx_depth, fifo_disable;
int ret;
struct device *dev = &pdev->dev;
const struct geni_i2c_desc *desc = NULL;
@@ -1060,102 +1127,27 @@ static int geni_i2c_probe(struct platform_device *pdev)
if (ret)
return ret;
- ret = clk_prepare_enable(gi2c->core_clk);
- if (ret)
- return ret;
-
- ret = geni_se_resources_on(&gi2c->se);
- if (ret) {
- dev_err_probe(dev, ret, "Error turning on resources\n");
- goto err_clk;
- }
- proto = geni_se_read_proto(&gi2c->se);
- if (proto == GENI_SE_INVALID_PROTO) {
- ret = geni_load_se_firmware(&gi2c->se, GENI_SE_I2C);
- if (ret) {
- dev_err_probe(dev, ret, "i2c firmware load failed ret: %d\n", ret);
- goto err_resources;
- }
- } else if (proto != GENI_SE_I2C) {
- ret = dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
- goto err_resources;
- }
-
- if (desc && desc->no_dma_support) {
- fifo_disable = false;
- gi2c->no_dma = true;
- } else {
- fifo_disable = readl_relaxed(gi2c->se.base + GENI_IF_DISABLE_RO) & FIFO_IF_DISABLE;
- }
-
- if (fifo_disable) {
- /* FIFO is disabled, so we can only use GPI DMA */
- gi2c->gpi_mode = true;
- ret = setup_gpi_dma(gi2c);
- if (ret)
- goto err_resources;
-
- dev_dbg(dev, "Using GPI DMA mode for I2C\n");
- } else {
- gi2c->gpi_mode = false;
- tx_depth = geni_se_get_tx_fifo_depth(&gi2c->se);
-
- /* I2C Master Hub Serial Elements doesn't have the HW_PARAM_0 register */
- if (!tx_depth && desc)
- tx_depth = desc->tx_fifo_depth;
-
- if (!tx_depth) {
- ret = dev_err_probe(dev, -EINVAL,
- "Invalid TX FIFO depth\n");
- goto err_resources;
- }
-
- gi2c->tx_wm = tx_depth - 1;
- geni_se_init(&gi2c->se, gi2c->tx_wm, tx_depth);
- geni_se_config_packing(&gi2c->se, BITS_PER_BYTE,
- PACKING_BYTES_PW, true, true, true);
-
- dev_dbg(dev, "i2c fifo/se-dma mode. fifo depth:%d\n", tx_depth);
- }
-
- clk_disable_unprepare(gi2c->core_clk);
- ret = geni_se_resources_off(&gi2c->se);
- if (ret) {
- dev_err_probe(dev, ret, "Error turning off resources\n");
- goto err_dma;
- }
-
- ret = geni_icc_disable(&gi2c->se);
- if (ret)
- goto err_dma;
-
gi2c->suspended = 1;
pm_runtime_set_suspended(gi2c->se.dev);
pm_runtime_set_autosuspend_delay(gi2c->se.dev, I2C_AUTO_SUSPEND_DELAY);
pm_runtime_use_autosuspend(gi2c->se.dev);
pm_runtime_enable(gi2c->se.dev);
+ ret = geni_i2c_init(gi2c);
+ if (ret < 0) {
+ pm_runtime_disable(gi2c->se.dev);
+ return ret;
+ }
+
ret = i2c_add_adapter(&gi2c->adap);
if (ret) {
dev_err_probe(dev, ret, "Error adding i2c adapter\n");
pm_runtime_disable(gi2c->se.dev);
- goto err_dma;
+ return ret;
}
dev_dbg(dev, "Geni-I2C adaptor successfully added\n");
- return ret;
-
-err_resources:
- geni_se_resources_off(&gi2c->se);
-err_clk:
- clk_disable_unprepare(gi2c->core_clk);
-
- return ret;
-
-err_dma:
- release_gpi_dma(gi2c);
-
return ret;
}
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:18 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
Refactor the resource initialization in geni_i2c_probe() by introducing
a new geni_i2c_resources_init() function and utilizing the common
geni_se_resources_init() framework and clock frequency mapping, making the
probe function cleaner.
Acked-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v3->v4:
- Added Acked-by tag.
v1->v2:
- Updated commit text.
---
drivers/i2c/busses/i2c-qcom-geni.c | 53 ++++++++++++------------------
1 file changed, 21 insertions(+), 32 deletions(-)
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 81ed1596ac9f..56eebefda75f 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -1045,6 +1045,23 @@ static int geni_i2c_init(struct geni_i2c_dev *gi2c)
return ret;
}
+static int geni_i2c_resources_init(struct geni_i2c_dev *gi2c)
+{
+ int ret;
+
+ ret = geni_se_resources_init(&gi2c->se);
+ if (ret)
+ return ret;
+
+ ret = geni_i2c_clk_map_idx(gi2c);
+ if (ret)
+ return dev_err_probe(gi2c->se.dev, ret, "Invalid clk frequency %d Hz\n",
+ gi2c->clk_freq_out);
+
+ return geni_icc_set_bw_ab(&gi2c->se, GENI_DEFAULT_BW, GENI_DEFAULT_BW,
+ Bps_to_icc(gi2c->clk_freq_out));
+}
+
static int geni_i2c_probe(struct platform_device *pdev)
{
struct geni_i2c_dev *gi2c;
@@ -1064,16 +1081,6 @@ static int geni_i2c_probe(struct platform_device *pdev)
desc = device_get_match_data(&pdev->dev);
- if (desc && desc->has_core_clk) {
- gi2c->core_clk = devm_clk_get(dev, "core");
- if (IS_ERR(gi2c->core_clk))
- return PTR_ERR(gi2c->core_clk);
- }
-
- gi2c->se.clk = devm_clk_get(dev, "se");
- if (IS_ERR(gi2c->se.clk) && !has_acpi_companion(dev))
- return PTR_ERR(gi2c->se.clk);
-
ret = device_property_read_u32(dev, "clock-frequency",
&gi2c->clk_freq_out);
if (ret) {
@@ -1088,16 +1095,15 @@ static int geni_i2c_probe(struct platform_device *pdev)
if (gi2c->irq < 0)
return gi2c->irq;
- ret = geni_i2c_clk_map_idx(gi2c);
- if (ret)
- return dev_err_probe(dev, ret, "Invalid clk frequency %d Hz\n",
- gi2c->clk_freq_out);
-
gi2c->adap.algo = &geni_i2c_algo;
init_completion(&gi2c->done);
spin_lock_init(&gi2c->lock);
platform_set_drvdata(pdev, gi2c);
+ ret = geni_i2c_resources_init(gi2c);
+ if (ret)
+ return ret;
+
/* Keep interrupts disabled initially to allow for low-power modes */
ret = devm_request_irq(dev, gi2c->irq, geni_i2c_irq, IRQF_NO_AUTOEN,
dev_name(dev), gi2c);
@@ -1110,23 +1116,6 @@ static int geni_i2c_probe(struct platform_device *pdev)
gi2c->adap.dev.of_node = dev->of_node;
strscpy(gi2c->adap.name, "Geni-I2C", sizeof(gi2c->adap.name));
- ret = geni_icc_get(&gi2c->se, desc ? desc->icc_ddr : "qup-memory");
- if (ret)
- return ret;
- /*
- * Set the bus quota for core and cpu to a reasonable value for
- * register access.
- * Set quota for DDR based on bus speed.
- */
- gi2c->se.icc_paths[GENI_TO_CORE].avg_bw = GENI_DEFAULT_BW;
- gi2c->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW;
- if (!desc || desc->icc_ddr)
- gi2c->se.icc_paths[GENI_TO_DDR].avg_bw = Bps_to_icc(gi2c->clk_freq_out);
-
- ret = geni_icc_set_bw(&gi2c->se);
- if (ret)
- return ret;
-
gi2c->suspended = 1;
pm_runtime_set_suspended(gi2c->se.dev);
pm_runtime_set_autosuspend_delay(gi2c->se.dev, I2C_AUTO_SUSPEND_DELAY);
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:19 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
To manage GENI serial engine resources during runtime power management,
drivers currently need to call functions for ICC, clock, and
SE resource operations in both suspend and resume paths, resulting in
code duplication across drivers.
The new geni_se_resources_activate() and geni_se_resources_deactivate()
helper APIs addresses this issue by providing a streamlined method to
enable or disable all resources based, thereby eliminating redundancy
across drivers.
Acked-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v3->v4:
- Added Acked-by tag.
v1->v2:
Bjorn:
- Remove geni_se_resources_state() API.
- Used geni_se_resources_activate() and geni_se_resources_deactivate()
to enable/disable resources.
---
drivers/i2c/busses/i2c-qcom-geni.c | 28 +++++-----------------------
1 file changed, 5 insertions(+), 23 deletions(-)
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 56eebefda75f..4ff84bb0fff5 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -1163,18 +1163,15 @@ static int __maybe_unused geni_i2c_runtime_suspend(struct device *dev)
struct geni_i2c_dev *gi2c = dev_get_drvdata(dev);
disable_irq(gi2c->irq);
- ret = geni_se_resources_off(&gi2c->se);
+
+ ret = geni_se_resources_deactivate(&gi2c->se);
if (ret) {
enable_irq(gi2c->irq);
return ret;
-
- } else {
- gi2c->suspended = 1;
}
- clk_disable_unprepare(gi2c->core_clk);
-
- return geni_icc_disable(&gi2c->se);
+ gi2c->suspended = 1;
+ return ret;
}
static int __maybe_unused geni_i2c_runtime_resume(struct device *dev)
@@ -1182,28 +1179,13 @@ static int __maybe_unused geni_i2c_runtime_resume(struct device *dev)
int ret;
struct geni_i2c_dev *gi2c = dev_get_drvdata(dev);
- ret = geni_icc_enable(&gi2c->se);
+ ret = geni_se_resources_activate(&gi2c->se);
if (ret)
return ret;
- ret = clk_prepare_enable(gi2c->core_clk);
- if (ret)
- goto out_icc_disable;
-
- ret = geni_se_resources_on(&gi2c->se);
- if (ret)
- goto out_clk_disable;
-
enable_irq(gi2c->irq);
gi2c->suspended = 0;
- return 0;
-
-out_clk_disable:
- clk_disable_unprepare(gi2c->core_clk);
-out_icc_disable:
- geni_icc_disable(&gi2c->se);
-
return ret;
}
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:20 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
To avoid repeatedly fetching and checking platform data across various
functions, store the struct of_device_id data directly in the i2c
private structure. This change enhances code maintainability and reduces
redundancy.
Acked-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v3->v4
- Added Acked-by tag.
Konrad
- Removed icc_ddr from platfrom data struct
---
drivers/i2c/busses/i2c-qcom-geni.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 4ff84bb0fff5..8fd62d659c2a 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -77,6 +77,12 @@ enum geni_i2c_err_code {
#define XFER_TIMEOUT HZ
#define RST_TIMEOUT HZ
+struct geni_i2c_desc {
+ bool has_core_clk;
+ bool no_dma_support;
+ unsigned int tx_fifo_depth;
+};
+
#define QCOM_I2C_MIN_NUM_OF_MSGS_MULTI_DESC 2
/**
@@ -122,13 +128,7 @@ struct geni_i2c_dev {
bool is_tx_multi_desc_xfer;
u32 num_msgs;
struct geni_i2c_gpi_multi_desc_xfer i2c_multi_desc_config;
-};
-
-struct geni_i2c_desc {
- bool has_core_clk;
- char *icc_ddr;
- bool no_dma_support;
- unsigned int tx_fifo_depth;
+ const struct geni_i2c_desc *dev_data;
};
struct geni_i2c_err_log {
@@ -979,7 +979,6 @@ static int setup_gpi_dma(struct geni_i2c_dev *gi2c)
static int geni_i2c_init(struct geni_i2c_dev *gi2c)
{
- const struct geni_i2c_desc *desc = NULL;
u32 proto, tx_depth;
bool fifo_disable;
int ret;
@@ -1002,8 +1001,7 @@ static int geni_i2c_init(struct geni_i2c_dev *gi2c)
goto err;
}
- desc = device_get_match_data(gi2c->se.dev);
- if (desc && desc->no_dma_support) {
+ if (gi2c->dev_data->no_dma_support) {
fifo_disable = false;
gi2c->no_dma = true;
} else {
@@ -1023,8 +1021,8 @@ static int geni_i2c_init(struct geni_i2c_dev *gi2c)
tx_depth = geni_se_get_tx_fifo_depth(&gi2c->se);
/* I2C Master Hub Serial Elements doesn't have the HW_PARAM_0 register */
- if (!tx_depth && desc)
- tx_depth = desc->tx_fifo_depth;
+ if (!tx_depth && gi2c->dev_data->has_core_clk)
+ tx_depth = gi2c->dev_data->tx_fifo_depth;
if (!tx_depth) {
ret = dev_err_probe(gi2c->se.dev, -EINVAL,
@@ -1067,7 +1065,6 @@ static int geni_i2c_probe(struct platform_device *pdev)
struct geni_i2c_dev *gi2c;
int ret;
struct device *dev = &pdev->dev;
- const struct geni_i2c_desc *desc = NULL;
gi2c = devm_kzalloc(dev, sizeof(*gi2c), GFP_KERNEL);
if (!gi2c)
@@ -1079,7 +1076,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
if (IS_ERR(gi2c->se.base))
return PTR_ERR(gi2c->se.base);
- desc = device_get_match_data(&pdev->dev);
+ gi2c->dev_data = device_get_match_data(&pdev->dev);
ret = device_property_read_u32(dev, "clock-frequency",
&gi2c->clk_freq_out);
@@ -1218,15 +1215,16 @@ static const struct dev_pm_ops geni_i2c_pm_ops = {
NULL)
};
+static const struct geni_i2c_desc geni_i2c = {};
+
static const struct geni_i2c_desc i2c_master_hub = {
.has_core_clk = true,
- .icc_ddr = NULL,
.no_dma_support = true,
.tx_fifo_depth = 16,
};
static const struct of_device_id geni_i2c_dt_match[] = {
- { .compatible = "qcom,geni-i2c" },
+ { .compatible = "qcom,geni-i2c", .data = &geni_i2c },
{ .compatible = "qcom,geni-i2c-master-hub", .data = &i2c_master_hub },
{}
};
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:21 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/13] Enable I2C on SA8255p Qualcomm platforms
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power states(on/off).
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Praveen Talari (13):
soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC
path optional
soc: qcom: geni-se: Add geni_icc_set_bw_ab() function
soc: qcom: geni-se: Introduce helper API for resource initialization
soc: qcom: geni-se: Handle core clk in geni_se_clks_off() and
geni_se_clks_on()
soc: qcom: geni-se: Add resources activation/deactivation helpers
soc: qcom: geni-se: Introduce helper API for attaching power domains
soc: qcom: geni-se: Introduce helper APIs for performance control
dt-bindings: i2c: Describe SA8255p
i2c: qcom-geni: Isolate serial engine setup
i2c: qcom-geni: Move resource initialization to separate function
i2c: qcom-geni: Use resources helper APIs in runtime PM functions
i2c: qcom-geni: Store of_device_id data in driver private struct
i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
---
v3->v4
- Added a new patch(4/13) to handle core clk as part of
geni_se_clks_off/on().
---
.../bindings/i2c/qcom,sa8255p-geni-i2c.yaml | 64 ++++
drivers/i2c/busses/i2c-qcom-geni.c | 303 +++++++++---------
drivers/soc/qcom/qcom-geni-se.c | 265 +++++++++++++--
include/linux/soc/qcom/geni-se.h | 19 ++
4 files changed, 476 insertions(+), 175 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/qcom,sa8255p-geni-i2c.yaml
base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
--
2.34.1
|
The Qualcomm automotive SA8255p SoC relies on firmware to configure
platform resources, including clocks, interconnects and TLMM.
The driver requests resources operations over SCMI using power
and performance protocols.
The SCMI power protocol enables or disables resources like clocks,
interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
such as resume/suspend, to control power on/off.
The SCMI performance protocol manages I2C frequency, with each
frequency rate represented by a performance level. The driver uses
geni_se_set_perf_opp() API to request the desired frequency rate..
As part of geni_se_set_perf_opp(), the OPP for the requested frequency
is obtained using dev_pm_opp_find_freq_floor() and the performance
level is set using dev_pm_opp_set_opp().
Acked-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
v3->v4:
- Added Acked-by tag.
V1->v2:
- Initialized ret to "0" in resume/suspend callbacks.
Bjorn:
- Used seperate APIs for the resouces enable/disable.
---
drivers/i2c/busses/i2c-qcom-geni.c | 56 ++++++++++++++++++++++--------
1 file changed, 42 insertions(+), 14 deletions(-)
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 8fd62d659c2a..2ad31e412b96 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -81,6 +81,10 @@ struct geni_i2c_desc {
bool has_core_clk;
bool no_dma_support;
unsigned int tx_fifo_depth;
+ int (*resources_init)(struct geni_se *se);
+ int (*set_rate)(struct geni_se *se, unsigned long freq);
+ int (*power_on)(struct geni_se *se);
+ int (*power_off)(struct geni_se *se);
};
#define QCOM_I2C_MIN_NUM_OF_MSGS_MULTI_DESC 2
@@ -203,8 +207,9 @@ static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
return -EINVAL;
}
-static void qcom_geni_i2c_conf(struct geni_i2c_dev *gi2c)
+static int qcom_geni_i2c_conf(struct geni_se *se, unsigned long freq)
{
+ struct geni_i2c_dev *gi2c = dev_get_drvdata(se->dev);
const struct geni_i2c_clk_fld *itr = gi2c->clk_fld;
u32 val;
@@ -217,6 +222,7 @@ static void qcom_geni_i2c_conf(struct geni_i2c_dev *gi2c)
val |= itr->t_low_cnt << LOW_COUNTER_SHFT;
val |= itr->t_cycle_cnt;
writel_relaxed(val, gi2c->se.base + SE_I2C_SCL_COUNTERS);
+ return 0;
}
static void geni_i2c_err_misc(struct geni_i2c_dev *gi2c)
@@ -908,7 +914,9 @@ static int geni_i2c_xfer(struct i2c_adapter *adap,
return ret;
}
- qcom_geni_i2c_conf(gi2c);
+ ret = gi2c->dev_data->set_rate(&gi2c->se, gi2c->clk_freq_out);
+ if (ret)
+ return ret;
if (gi2c->gpi_mode)
ret = geni_i2c_gpi_xfer(gi2c, msgs, num);
@@ -1043,8 +1051,9 @@ static int geni_i2c_init(struct geni_i2c_dev *gi2c)
return ret;
}
-static int geni_i2c_resources_init(struct geni_i2c_dev *gi2c)
+static int geni_i2c_resources_init(struct geni_se *se)
{
+ struct geni_i2c_dev *gi2c = dev_get_drvdata(se->dev);
int ret;
ret = geni_se_resources_init(&gi2c->se);
@@ -1097,7 +1106,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
spin_lock_init(&gi2c->lock);
platform_set_drvdata(pdev, gi2c);
- ret = geni_i2c_resources_init(gi2c);
+ ret = gi2c->dev_data->resources_init(&gi2c->se);
if (ret)
return ret;
@@ -1156,15 +1165,17 @@ static void geni_i2c_shutdown(struct platform_device *pdev)
static int __maybe_unused geni_i2c_runtime_suspend(struct device *dev)
{
- int ret;
+ int ret = 0;
struct geni_i2c_dev *gi2c = dev_get_drvdata(dev);
disable_irq(gi2c->irq);
- ret = geni_se_resources_deactivate(&gi2c->se);
- if (ret) {
- enable_irq(gi2c->irq);
- return ret;
+ if (gi2c->dev_data->power_off) {
+ ret = gi2c->dev_data->power_off(&gi2c->se);
+ if (ret) {
+ enable_irq(gi2c->irq);
+ return ret;
+ }
}
gi2c->suspended = 1;
@@ -1173,12 +1184,14 @@ static int __maybe_unused geni_i2c_runtime_suspend(struct device *dev)
static int __maybe_unused geni_i2c_runtime_resume(struct device *dev)
{
- int ret;
+ int ret = 0;
struct geni_i2c_dev *gi2c = dev_get_drvdata(dev);
- ret = geni_se_resources_activate(&gi2c->se);
- if (ret)
- return ret;
+ if (gi2c->dev_data->power_on) {
+ ret = gi2c->dev_data->power_on(&gi2c->se);
+ if (ret)
+ return ret;
+ }
enable_irq(gi2c->irq);
gi2c->suspended = 0;
@@ -1215,17 +1228,32 @@ static const struct dev_pm_ops geni_i2c_pm_ops = {
NULL)
};
-static const struct geni_i2c_desc geni_i2c = {};
+static const struct geni_i2c_desc geni_i2c = {
+ .resources_init = geni_i2c_resources_init,
+ .set_rate = qcom_geni_i2c_conf,
+ .power_on = geni_se_resources_activate,
+ .power_off = geni_se_resources_deactivate,
+};
static const struct geni_i2c_desc i2c_master_hub = {
.has_core_clk = true,
.no_dma_support = true,
.tx_fifo_depth = 16,
+ .resources_init = geni_i2c_resources_init,
+ .set_rate = qcom_geni_i2c_conf,
+ .power_on = geni_se_resources_activate,
+ .power_off = geni_se_resources_deactivate,
+};
+
+static const struct geni_i2c_desc sa8255p_geni_i2c = {
+ .resources_init = geni_se_domain_attach,
+ .set_rate = geni_se_set_perf_opp,
};
static const struct of_device_id geni_i2c_dt_match[] = {
{ .compatible = "qcom,geni-i2c", .data = &geni_i2c },
{ .compatible = "qcom,geni-i2c-master-hub", .data = &i2c_master_hub },
+ { .compatible = "qcom,sa8255p-geni-i2c", .data = &sa8255p_geni_i2c },
{}
};
MODULE_DEVICE_TABLE(of, geni_i2c_dt_match);
--
2.34.1
|
{
"author": "Praveen Talari <praveen.talari@oss.qualcomm.com>",
"date": "Mon, 2 Feb 2026 23:39:22 +0530",
"thread_id": "20260202180922.1692428-7-praveen.talari@oss.qualcomm.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
On Mon, Feb 02, 2026 at 12:03:11PM +0200, Bogdan Sandu wrote:
Was this an AI generated patch?
Either way, it needs to be properly broken up into "one logical change
per patch" like all others.
thanks,
greg k-h
|
{
"author": "Greg KH <gregkh@linuxfoundation.org>",
"date": "Mon, 2 Feb 2026 11:14:26 +0100",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
I can assure you, it is not AI-generated.
per patch" like all others.
Understood. I'll resend it afterwards.
Thank you for your patience.
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 12:18:43 +0200",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 12:18:44 +0200",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
On Mon, Feb 02, 2026 at 12:18:44PM +0200, Bogdan Sandu wrote:
You resent the same thing again?
confused,
greg k-h
|
{
"author": "Greg KH <gregkh@linuxfoundation.org>",
"date": "Mon, 2 Feb 2026 11:32:15 +0100",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
The previous patch has now been separated into four smaller ones, each one fixing a specific type of checkpatch.pl issue.
Bogdan Sandu (4):
media: ipu3: fix alignment
media: ipu3: use tabs
media: ipu3: avoid ending lines with paranthesis
media: ipu3: use BIT()
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:29 +0200",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Fix alignment with parentheses.
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 22 +++++++++++-----------
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 +++++------
drivers/staging/media/ipu3/ipu3.c | 4 ++--
3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..145501e90 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1241,6 +1242,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1250,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1270,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2036,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2169,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..c33186208 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -774,7 +774,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:30 +0200",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Use tabs instead of spaces.
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 145501e90..e990eb5b3 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -1034,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:31 +0200",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Don't end line with paranthesis.
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 13 +++++--------
drivers/staging/media/ipu3/ipu3.c | 3 +--
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index e990eb5b3..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -1226,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index c33186208..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:32 +0200",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Prefer BIT() macro over manual bitshift.
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:33 +0200",
"thread_id": "20260202175033.8640-3-bogdanelsandu2011@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH 1/2] media: rkvdec: reduce excessive stack usage in assemble_hw_pps()
|
From: Arnd Bergmann <arnd@arndb.de>
The rkvdec_pps had a large set of bitfields, all of which
as misaligned. This causes clang-21 and likely other versions to
produce absolutely awful object code and a warning about very
large stack usage, on targets without unaligned access:
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]
Part of the problem here is how all the bitfield accesses are
inlined into a function that already has large structures on
the stack.
Mark set_field_order_cnt() as noinline_for_stack, and split out
the following accesses in assemble_hw_pps() into another noinline
function, both of which now using around 800 bytes of stack in the
same configuration.
There is clearly still something wrong with clang here, but
splitting it into multiple functions reduces the risk of stack
overflow.
Fixes: fde24907570d ("media: rkvdec: Add H264 support for the VDPU383 variant")
Link: https://godbolt.org/z/acP1eKeq9
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
.../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 50 ++++++++++---------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
index 6ab3167addc8..ef69f2a36478 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx {
struct vdpu383_regs_h26x regs;
};
-static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
+static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
{
pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d
pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
}
+static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
+{
+ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
+
+ for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
+ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
+ pps->is_longterm |= (1 << i);
+ pps->ref_field_flags |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
+ pps->ref_colmv_use_flag |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
+ pps->ref_topfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
+ pps->ref_botfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
+ }
+ pps->pic_field_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
+ pps->pic_associated_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
+
+ pps->cur_top_field = dec_params->top_field_order_cnt;
+ pps->cur_bot_field = dec_params->bottom_field_order_cnt;
+}
+
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_run *run)
{
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
struct rkvdec_sps_pps *hw_ps;
u32 pic_width, pic_height;
- u32 i;
/*
* HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
set_field_order_cnt(&hw_ps->pps, dpb);
+ set_dec_params(&hw_ps->pps, dec_params);
- for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
- if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
- hw_ps->pps.is_longterm |= (1 << i);
-
- hw_ps->pps.ref_field_flags |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
- hw_ps->pps.ref_colmv_use_flag |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
- hw_ps->pps.ref_topfield_used |=
- (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
- hw_ps->pps.ref_botfield_used |=
- (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
- }
-
- hw_ps->pps.pic_field_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
- hw_ps->pps.pic_associated_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
-
- hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
- hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
}
static void rkvdec_write_regs(struct rkvdec_ctx *ctx)
--
2.39.5
|
From: Arnd Bergmann <arnd@arndb.de>
The deeply nested loop in rkvdec_init_v4l2_vp9_count_tbl() needs a lot
of registers, so when the clang register allocator runs out, it ends up
spilling countless temporaries to the stack:
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]
Marking this function as noinline_for_stack keeps it out of
rkvdec_vp9_start(), giving the compiler more room for optimization.
The resulting code is good enough that both the total stack usage
and the loop get enough better to stay under the warning limit,
though it's still slow, and would need a larger rework if this
function ends up being called in a fast path.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c
index ba51a7c2fe55..1c875d5a2bac 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c
@@ -893,7 +893,8 @@ static void rkvdec_vp9_done(struct rkvdec_ctx *ctx,
update_ctx_last_info(vp9_ctx);
}
-static void rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx)
+static noinline_for_stack void
+rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx)
{
struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv;
struct rkvdec_vp9_intra_frame_symbol_counts *intra_cnts = vp9_ctx->count_tbl.cpu;
--
2.39.5
|
{
"author": "Arnd Bergmann <arnd@kernel.org>",
"date": "Mon, 2 Feb 2026 10:47:51 +0100",
"thread_id": "5c1b6a5a5a10404e51bc281054d733dc78374994.camel@collabora.com.mbox.gz"
}
|
lkml
|
[PATCH 1/2] media: rkvdec: reduce excessive stack usage in assemble_hw_pps()
|
From: Arnd Bergmann <arnd@arndb.de>
The rkvdec_pps had a large set of bitfields, all of which
as misaligned. This causes clang-21 and likely other versions to
produce absolutely awful object code and a warning about very
large stack usage, on targets without unaligned access:
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]
Part of the problem here is how all the bitfield accesses are
inlined into a function that already has large structures on
the stack.
Mark set_field_order_cnt() as noinline_for_stack, and split out
the following accesses in assemble_hw_pps() into another noinline
function, both of which now using around 800 bytes of stack in the
same configuration.
There is clearly still something wrong with clang here, but
splitting it into multiple functions reduces the risk of stack
overflow.
Fixes: fde24907570d ("media: rkvdec: Add H264 support for the VDPU383 variant")
Link: https://godbolt.org/z/acP1eKeq9
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
.../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 50 ++++++++++---------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
index 6ab3167addc8..ef69f2a36478 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx {
struct vdpu383_regs_h26x regs;
};
-static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
+static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
{
pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d
pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
}
+static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
+{
+ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
+
+ for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
+ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
+ pps->is_longterm |= (1 << i);
+ pps->ref_field_flags |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
+ pps->ref_colmv_use_flag |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
+ pps->ref_topfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
+ pps->ref_botfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
+ }
+ pps->pic_field_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
+ pps->pic_associated_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
+
+ pps->cur_top_field = dec_params->top_field_order_cnt;
+ pps->cur_bot_field = dec_params->bottom_field_order_cnt;
+}
+
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_run *run)
{
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
struct rkvdec_sps_pps *hw_ps;
u32 pic_width, pic_height;
- u32 i;
/*
* HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
set_field_order_cnt(&hw_ps->pps, dpb);
+ set_dec_params(&hw_ps->pps, dec_params);
- for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
- if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
- hw_ps->pps.is_longterm |= (1 << i);
-
- hw_ps->pps.ref_field_flags |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
- hw_ps->pps.ref_colmv_use_flag |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
- hw_ps->pps.ref_topfield_used |=
- (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
- hw_ps->pps.ref_botfield_used |=
- (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
- }
-
- hw_ps->pps.pic_field_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
- hw_ps->pps.pic_associated_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
-
- hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
- hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
}
static void rkvdec_write_regs(struct rkvdec_ctx *ctx)
--
2.39.5
|
Hi Arnd,
Le lundi 02 février 2026 à 10:47 +0100, Arnd Bergmann a écrit :
We had already addressed and validated that on clang-21, which indicates me that
we likely are missing an architecture (or a config) in our CI. Can you document
which architecture, configuration and flags was affected so we can add it on our
side ?
Our media pipeline before sending to Linus and the clang builds trace are in the
following link, in case it matters.
https://gitlab.freedesktop.org/linux-media/media-committers/-/pipelines/1588731
https://gitlab.freedesktop.org/linux-media/media-committers/-/jobs/91604655
Another observation is that you had to enable ASAN to make it miss-behave on for
loop unrolling (with complex bitfield writes). All I've obtained by visiting
the Link: is that its armv7-a architecture.
We've tried really hard to avoid this noninline_for_stack just because compilers
are buggy. I'll have a look again in case I find some ideas, but meanwhile, with
failing architecture in the commit message:
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
{
"author": "Nicolas Dufresne <nicolas.dufresne@collabora.com>",
"date": "Mon, 02 Feb 2026 08:42:41 -0500",
"thread_id": "5c1b6a5a5a10404e51bc281054d733dc78374994.camel@collabora.com.mbox.gz"
}
|
lkml
|
[PATCH 1/2] media: rkvdec: reduce excessive stack usage in assemble_hw_pps()
|
From: Arnd Bergmann <arnd@arndb.de>
The rkvdec_pps had a large set of bitfields, all of which
as misaligned. This causes clang-21 and likely other versions to
produce absolutely awful object code and a warning about very
large stack usage, on targets without unaligned access:
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]
Part of the problem here is how all the bitfield accesses are
inlined into a function that already has large structures on
the stack.
Mark set_field_order_cnt() as noinline_for_stack, and split out
the following accesses in assemble_hw_pps() into another noinline
function, both of which now using around 800 bytes of stack in the
same configuration.
There is clearly still something wrong with clang here, but
splitting it into multiple functions reduces the risk of stack
overflow.
Fixes: fde24907570d ("media: rkvdec: Add H264 support for the VDPU383 variant")
Link: https://godbolt.org/z/acP1eKeq9
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
.../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 50 ++++++++++---------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
index 6ab3167addc8..ef69f2a36478 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx {
struct vdpu383_regs_h26x regs;
};
-static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
+static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
{
pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d
pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
}
+static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
+{
+ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
+
+ for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
+ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
+ pps->is_longterm |= (1 << i);
+ pps->ref_field_flags |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
+ pps->ref_colmv_use_flag |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
+ pps->ref_topfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
+ pps->ref_botfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
+ }
+ pps->pic_field_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
+ pps->pic_associated_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
+
+ pps->cur_top_field = dec_params->top_field_order_cnt;
+ pps->cur_bot_field = dec_params->bottom_field_order_cnt;
+}
+
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_run *run)
{
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
struct rkvdec_sps_pps *hw_ps;
u32 pic_width, pic_height;
- u32 i;
/*
* HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
set_field_order_cnt(&hw_ps->pps, dpb);
+ set_dec_params(&hw_ps->pps, dec_params);
- for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
- if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
- hw_ps->pps.is_longterm |= (1 << i);
-
- hw_ps->pps.ref_field_flags |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
- hw_ps->pps.ref_colmv_use_flag |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
- hw_ps->pps.ref_topfield_used |=
- (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
- hw_ps->pps.ref_botfield_used |=
- (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
- }
-
- hw_ps->pps.pic_field_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
- hw_ps->pps.pic_associated_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
-
- hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
- hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
}
static void rkvdec_write_regs(struct rkvdec_ctx *ctx)
--
2.39.5
|
On Mon, Feb 2, 2026, at 14:42, Nicolas Dufresne wrote:
The configuration that hit this for me was an ARMv7-M NOMMU build. I'm
doing 'randconfig' builds here, so I inevitably hit some corner cases
that all deterministic CI systems miss. I don't think that you should
add ARMv7-M here, since that would take up useful build resources
from something more important. There are no drviers/media/ actual
users on ARMv7-M, and next time it is going to be something else.
Right, this randconfig build likely got closer to the warning
limit because of the inherent overhead in KASAN, but the problem
with the unaligned bitfields was something that I could later
reproduce without KASAN, on ARMv5 and MIPS32r2.
This is something we should fix in clang.
Thanks!
Arnd
|
{
"author": "\"Arnd Bergmann\" <arnd@arndb.de>",
"date": "Mon, 02 Feb 2026 15:09:14 +0100",
"thread_id": "5c1b6a5a5a10404e51bc281054d733dc78374994.camel@collabora.com.mbox.gz"
}
|
lkml
|
[PATCH 1/2] media: rkvdec: reduce excessive stack usage in assemble_hw_pps()
|
From: Arnd Bergmann <arnd@arndb.de>
The rkvdec_pps had a large set of bitfields, all of which
as misaligned. This causes clang-21 and likely other versions to
produce absolutely awful object code and a warning about very
large stack usage, on targets without unaligned access:
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]
Part of the problem here is how all the bitfield accesses are
inlined into a function that already has large structures on
the stack.
Mark set_field_order_cnt() as noinline_for_stack, and split out
the following accesses in assemble_hw_pps() into another noinline
function, both of which now using around 800 bytes of stack in the
same configuration.
There is clearly still something wrong with clang here, but
splitting it into multiple functions reduces the risk of stack
overflow.
Fixes: fde24907570d ("media: rkvdec: Add H264 support for the VDPU383 variant")
Link: https://godbolt.org/z/acP1eKeq9
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
.../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 50 ++++++++++---------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
index 6ab3167addc8..ef69f2a36478 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx {
struct vdpu383_regs_h26x regs;
};
-static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
+static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
{
pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d
pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
}
+static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
+{
+ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
+
+ for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
+ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
+ pps->is_longterm |= (1 << i);
+ pps->ref_field_flags |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
+ pps->ref_colmv_use_flag |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
+ pps->ref_topfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
+ pps->ref_botfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
+ }
+ pps->pic_field_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
+ pps->pic_associated_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
+
+ pps->cur_top_field = dec_params->top_field_order_cnt;
+ pps->cur_bot_field = dec_params->bottom_field_order_cnt;
+}
+
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_run *run)
{
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
struct rkvdec_sps_pps *hw_ps;
u32 pic_width, pic_height;
- u32 i;
/*
* HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
set_field_order_cnt(&hw_ps->pps, dpb);
+ set_dec_params(&hw_ps->pps, dec_params);
- for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
- if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
- hw_ps->pps.is_longterm |= (1 << i);
-
- hw_ps->pps.ref_field_flags |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
- hw_ps->pps.ref_colmv_use_flag |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
- hw_ps->pps.ref_topfield_used |=
- (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
- hw_ps->pps.ref_botfield_used |=
- (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
- }
-
- hw_ps->pps.pic_field_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
- hw_ps->pps.pic_associated_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
-
- hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
- hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
}
static void rkvdec_write_regs(struct rkvdec_ctx *ctx)
--
2.39.5
|
Hi Arnd,
Le lundi 02 février 2026 à 15:09 +0100, Arnd Bergmann a écrit :
All fair comments. I plan to take this into fixes (no changes needed), hopefully
for rc-2.
Performance wise, this code is to replace read/mask/write into hardware
registers which was significantly slower for this amount of registers (~200
32bit integers) and this type of IP (its not sram). This is run once per frame.
In practice, if we hand code the read/mask/write, the performance should
eventually converge to using bitfield and letting the compiler do this masking,
I was being optimistic on how the compiler would behave. If performance of that
is truly a problem, we can always just prepare the ram register ahead of the
operation queue (instead of doing it in the executor).
One thing to remind, you can't optimize the data structure layout, since they
need to match the register layout. But while fixing some of the stack report
previously, I did endup up moving few things out of loops (which is not clearly
feasible in this patch). I did not checked all the code (only the failing one).
One of the bad pattern which costed stack (and overhead probably) was the use of
switch() statement to pick one of the unaligned register location, with that
switch being part of an unrolled loop. If you ever spot these, and have time,
please just manually unroll the switch out of the loop (its actually less code).
thanks to you,
Nicolas
|
{
"author": "Nicolas Dufresne <nicolas.dufresne@collabora.com>",
"date": "Mon, 02 Feb 2026 10:12:53 -0500",
"thread_id": "5c1b6a5a5a10404e51bc281054d733dc78374994.camel@collabora.com.mbox.gz"
}
|
lkml
|
[PATCH 1/2] media: rkvdec: reduce excessive stack usage in assemble_hw_pps()
|
From: Arnd Bergmann <arnd@arndb.de>
The rkvdec_pps had a large set of bitfields, all of which
as misaligned. This causes clang-21 and likely other versions to
produce absolutely awful object code and a warning about very
large stack usage, on targets without unaligned access:
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]
Part of the problem here is how all the bitfield accesses are
inlined into a function that already has large structures on
the stack.
Mark set_field_order_cnt() as noinline_for_stack, and split out
the following accesses in assemble_hw_pps() into another noinline
function, both of which now using around 800 bytes of stack in the
same configuration.
There is clearly still something wrong with clang here, but
splitting it into multiple functions reduces the risk of stack
overflow.
Fixes: fde24907570d ("media: rkvdec: Add H264 support for the VDPU383 variant")
Link: https://godbolt.org/z/acP1eKeq9
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
.../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 50 ++++++++++---------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
index 6ab3167addc8..ef69f2a36478 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx {
struct vdpu383_regs_h26x regs;
};
-static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
+static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
{
pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d
pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
}
+static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
+{
+ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
+
+ for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
+ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
+ pps->is_longterm |= (1 << i);
+ pps->ref_field_flags |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
+ pps->ref_colmv_use_flag |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
+ pps->ref_topfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
+ pps->ref_botfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
+ }
+ pps->pic_field_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
+ pps->pic_associated_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
+
+ pps->cur_top_field = dec_params->top_field_order_cnt;
+ pps->cur_bot_field = dec_params->bottom_field_order_cnt;
+}
+
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_run *run)
{
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
struct rkvdec_sps_pps *hw_ps;
u32 pic_width, pic_height;
- u32 i;
/*
* HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
set_field_order_cnt(&hw_ps->pps, dpb);
+ set_dec_params(&hw_ps->pps, dec_params);
- for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
- if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
- hw_ps->pps.is_longterm |= (1 << i);
-
- hw_ps->pps.ref_field_flags |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
- hw_ps->pps.ref_colmv_use_flag |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
- hw_ps->pps.ref_topfield_used |=
- (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
- hw_ps->pps.ref_botfield_used |=
- (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
- }
-
- hw_ps->pps.pic_field_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
- hw_ps->pps.pic_associated_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
-
- hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
- hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
}
static void rkvdec_write_regs(struct rkvdec_ctx *ctx)
--
2.39.5
|
On Mon, Feb 2, 2026, at 16:12, Nicolas Dufresne wrote:
I think there are multiple things going on here, some of which are
more relevant than others:
- The problem I'm addressing with my patch is purely a clang issue
for CPU architectures with high register pressure when assembling
the structure in memory. As a first-order approximation, you can
see the lines in the output being 12.000 with clang, but only
600 with gcc in the godbolt.org output. The gcc version isn't that
great either, but it is orders of magnitude fewer instructions.
- MMIO reads are clearly a performance killer, so assembling the
structure in memory and using memcpy_toio() to access the
registers as you appear to be doing is the right idea.
- using bitfields for hardware structures is non-portable. In
particular, the order of the fields within a word depends on
byteorder (CONFIG_CPU_BIG_ENDIAN), and the alignment depends
on the architecture, e.g. 'struct { u32 a:16: u32 b: 32; u32 c:16};
has the second member cross a u32 boundary, which leads to
padding between a and b, as well as after c on some architectures
but not others. I would always recommend splitting up bitfields
on word boundaries and adding explicit padding where necessary.
- Since most of the fields are exactly 6 bits offset from a word
boundary, you can try assembling all the *_field_order_cnt*
fields in an array first that has all the bits in the correct
order, but then shift the entire array six bits.
Arnd
|
{
"author": "\"Arnd Bergmann\" <arnd@arndb.de>",
"date": "Mon, 02 Feb 2026 16:59:05 +0100",
"thread_id": "5c1b6a5a5a10404e51bc281054d733dc78374994.camel@collabora.com.mbox.gz"
}
|
lkml
|
[PATCH 1/2] media: rkvdec: reduce excessive stack usage in assemble_hw_pps()
|
From: Arnd Bergmann <arnd@arndb.de>
The rkvdec_pps had a large set of bitfields, all of which
as misaligned. This causes clang-21 and likely other versions to
produce absolutely awful object code and a warning about very
large stack usage, on targets without unaligned access:
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]
Part of the problem here is how all the bitfield accesses are
inlined into a function that already has large structures on
the stack.
Mark set_field_order_cnt() as noinline_for_stack, and split out
the following accesses in assemble_hw_pps() into another noinline
function, both of which now using around 800 bytes of stack in the
same configuration.
There is clearly still something wrong with clang here, but
splitting it into multiple functions reduces the risk of stack
overflow.
Fixes: fde24907570d ("media: rkvdec: Add H264 support for the VDPU383 variant")
Link: https://godbolt.org/z/acP1eKeq9
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
.../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 50 ++++++++++---------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
index 6ab3167addc8..ef69f2a36478 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx {
struct vdpu383_regs_h26x regs;
};
-static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
+static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
{
pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d
pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
}
+static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
+{
+ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
+
+ for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
+ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
+ pps->is_longterm |= (1 << i);
+ pps->ref_field_flags |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
+ pps->ref_colmv_use_flag |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
+ pps->ref_topfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
+ pps->ref_botfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
+ }
+ pps->pic_field_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
+ pps->pic_associated_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
+
+ pps->cur_top_field = dec_params->top_field_order_cnt;
+ pps->cur_bot_field = dec_params->bottom_field_order_cnt;
+}
+
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_run *run)
{
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
struct rkvdec_sps_pps *hw_ps;
u32 pic_width, pic_height;
- u32 i;
/*
* HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
set_field_order_cnt(&hw_ps->pps, dpb);
+ set_dec_params(&hw_ps->pps, dec_params);
- for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
- if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
- hw_ps->pps.is_longterm |= (1 << i);
-
- hw_ps->pps.ref_field_flags |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
- hw_ps->pps.ref_colmv_use_flag |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
- hw_ps->pps.ref_topfield_used |=
- (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
- hw_ps->pps.ref_botfield_used |=
- (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
- }
-
- hw_ps->pps.pic_field_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
- hw_ps->pps.pic_associated_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
-
- hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
- hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
}
static void rkvdec_write_regs(struct rkvdec_ctx *ctx)
--
2.39.5
|
Hi,
Le lundi 02 février 2026 à 16:59 +0100, Arnd Bergmann a écrit :
Ok, got it, clearly the registers bitfield (which is a set of 32bit bitfield) is
fine (appart from endian, but this is deliberatly ignored). These are the one I
had mind, and are optimized with copy_toio.
For the SPS/PPS bistream, which is shared memory with the IP, I tend to agree
this might not have been the ideal choice, though the author did verify
everything with pahole for the relevant architectures (in practice only two
ARM64 SoC use this bitstream format). I'm happy to revisit this eventually. And
would not hurt to share a common bitstream writer, that works with both endian
in V4L2 (or use one from the core if that already exist).
Nicolas
|
{
"author": "Nicolas Dufresne <nicolas.dufresne@collabora.com>",
"date": "Mon, 02 Feb 2026 11:31:40 -0500",
"thread_id": "5c1b6a5a5a10404e51bc281054d733dc78374994.camel@collabora.com.mbox.gz"
}
|
lkml
|
[PATCH 1/2] media: rkvdec: reduce excessive stack usage in assemble_hw_pps()
|
From: Arnd Bergmann <arnd@arndb.de>
The rkvdec_pps had a large set of bitfields, all of which
as misaligned. This causes clang-21 and likely other versions to
produce absolutely awful object code and a warning about very
large stack usage, on targets without unaligned access:
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]
Part of the problem here is how all the bitfield accesses are
inlined into a function that already has large structures on
the stack.
Mark set_field_order_cnt() as noinline_for_stack, and split out
the following accesses in assemble_hw_pps() into another noinline
function, both of which now using around 800 bytes of stack in the
same configuration.
There is clearly still something wrong with clang here, but
splitting it into multiple functions reduces the risk of stack
overflow.
Fixes: fde24907570d ("media: rkvdec: Add H264 support for the VDPU383 variant")
Link: https://godbolt.org/z/acP1eKeq9
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
.../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 50 ++++++++++---------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
index 6ab3167addc8..ef69f2a36478 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx {
struct vdpu383_regs_h26x regs;
};
-static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
+static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
{
pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d
pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
}
+static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
+{
+ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
+
+ for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
+ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
+ pps->is_longterm |= (1 << i);
+ pps->ref_field_flags |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
+ pps->ref_colmv_use_flag |=
+ (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
+ pps->ref_topfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
+ pps->ref_botfield_used |=
+ (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
+ }
+ pps->pic_field_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
+ pps->pic_associated_flag =
+ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
+
+ pps->cur_top_field = dec_params->top_field_order_cnt;
+ pps->cur_bot_field = dec_params->bottom_field_order_cnt;
+}
+
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_run *run)
{
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
struct rkvdec_sps_pps *hw_ps;
u32 pic_width, pic_height;
- u32 i;
/*
* HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
set_field_order_cnt(&hw_ps->pps, dpb);
+ set_dec_params(&hw_ps->pps, dec_params);
- for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
- if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
- hw_ps->pps.is_longterm |= (1 << i);
-
- hw_ps->pps.ref_field_flags |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
- hw_ps->pps.ref_colmv_use_flag |=
- (!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
- hw_ps->pps.ref_topfield_used |=
- (!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
- hw_ps->pps.ref_botfield_used |=
- (!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
- }
-
- hw_ps->pps.pic_field_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
- hw_ps->pps.pic_associated_flag =
- !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
-
- hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
- hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
}
static void rkvdec_write_regs(struct rkvdec_ctx *ctx)
--
2.39.5
|
Le lundi 02 février 2026 à 10:47 +0100, Arnd Bergmann a écrit :
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
{
"author": "Nicolas Dufresne <nicolas.dufresne@collabora.com>",
"date": "Mon, 02 Feb 2026 11:32:16 -0500",
"thread_id": "5c1b6a5a5a10404e51bc281054d733dc78374994.camel@collabora.com.mbox.gz"
}
|
lkml
|
[PATCH 0/2] idpf: skip NULL pointers during deallocation.
|
In idpf txq and rxq error paths, some pointers are not allocated in the
first place. In the corresponding deallocation logic, we should not
deallocate them to prevent kernel panics.
Li Li (2):
idpf: skip deallocating bufq_sets from rx_qgrp if it is NULL.
idpf: skip deallocating txq group's txqs if it is NULL.
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 5 +++++
1 file changed, 5 insertions(+)
--
2.52.0.457.g6b5491de43-goog
|
In idpf_rxq_group_alloc(), if rx_qgrp->splitq.bufq_sets failed to get
allocated:
rx_qgrp->splitq.bufq_sets = kcalloc(vport->num_bufqs_per_qgrp,
sizeof(struct idpf_bufq_set),
GFP_KERNEL);
if (!rx_qgrp->splitq.bufq_sets) {
err = -ENOMEM;
goto err_alloc;
}
idpf_rxq_group_rel() would attempt to deallocate it in
idpf_rxq_sw_queue_rel(), causing a kernel panic:
```
[ 7.967242] early-network-sshd-n-rexd[3148]: knetbase: Info: [ 8.127804] BUG: kernel NULL pointer dereference, address: 00000000000000c0
...
[ 8.129779] RIP: 0010:idpf_rxq_group_rel+0x101/0x170
...
[ 8.133854] Call Trace:
[ 8.133980] <TASK>
[ 8.134092] idpf_vport_queues_alloc+0x286/0x500
[ 8.134313] idpf_vport_open+0x4d/0x3f0
[ 8.134498] idpf_open+0x71/0xb0
[ 8.134668] __dev_open+0x142/0x260
[ 8.134840] netif_open+0x2f/0xe0
[ 8.135004] dev_open+0x3d/0x70
[ 8.135166] bond_enslave+0x5ed/0xf50
[ 8.135345] ? nla_put_ifalias+0x3d/0x90
[ 8.135533] ? kvfree_call_rcu+0xb5/0x3b0
[ 8.135725] ? kvfree_call_rcu+0xb5/0x3b0
[ 8.135916] do_set_master+0x114/0x160
[ 8.136098] do_setlink+0x412/0xfb0
[ 8.136269] ? security_sock_rcv_skb+0x2a/0x50
[ 8.136509] ? sk_filter_trim_cap+0x7c/0x320
[ 8.136714] ? skb_queue_tail+0x20/0x50
[ 8.136899] ? __nla_validate_parse+0x92/0xe50
[ 8.137112] ? security_capable+0x35/0x60
[ 8.137304] rtnl_newlink+0x95c/0xa00
[ 8.137483] ? __rtnl_unlock+0x37/0x70
[ 8.137664] ? netdev_run_todo+0x63/0x530
[ 8.137855] ? allocate_slab+0x280/0x870
[ 8.138044] ? security_capable+0x35/0x60
[ 8.138235] rtnetlink_rcv_msg+0x2e6/0x340
[ 8.138431] ? __pfx_rtnetlink_rcv_msg+0x10/0x10
[ 8.138650] netlink_rcv_skb+0x16a/0x1a0
[ 8.138840] netlink_unicast+0x20a/0x320
[ 8.139028] netlink_sendmsg+0x304/0x3b0
[ 8.139217] __sock_sendmsg+0x89/0xb0
[ 8.139399] ____sys_sendmsg+0x167/0x1c0
[ 8.139588] ? ____sys_recvmsg+0xed/0x150
[ 8.139780] ___sys_sendmsg+0xdd/0x120
[ 8.139960] ? ___sys_recvmsg+0x124/0x1e0
[ 8.140152] ? rcutree_enqueue+0x1f/0xb0
[ 8.140341] ? rcutree_enqueue+0x1f/0xb0
[ 8.140528] ? call_rcu+0xde/0x2a0
[ 8.140695] ? evict+0x286/0x2d0
[ 8.140856] ? rcutree_enqueue+0x1f/0xb0
[ 8.141043] ? kmem_cache_free+0x2c/0x350
[ 8.141236] __x64_sys_sendmsg+0x72/0xc0
[ 8.141424] do_syscall_64+0x6f/0x890
[ 8.141603] entry_SYSCALL_64_after_hwframe+0x76/0x7e
[ 8.141841] RIP: 0033:0x7f2799d21bd0
...
[ 8.149905] Kernel panic - not syncing: Fatal exception
[ 8.175940] Kernel Offset: 0xf800000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[ 8.176425] Rebooting in 10 seconds..
```
Tested: With this patch, the kernel panic no longer appears.
Fixes: 95af467d9a4e ("idpf: configure resources for RX queues")
Signed-off-by: Li Li <boolli@google.com>
---
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index e7b131dba200c..b4dab4a8ee11b 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -1337,6 +1337,8 @@ static void idpf_txq_group_rel(struct idpf_vport *vport)
static void idpf_rxq_sw_queue_rel(struct idpf_rxq_group *rx_qgrp)
{
int i, j;
+ if (!rx_qgrp->splitq.bufq_sets)
+ return;
for (i = 0; i < rx_qgrp->vport->num_bufqs_per_qgrp; i++) {
struct idpf_bufq_set *bufq_set = &rx_qgrp->splitq.bufq_sets[i];
--
2.52.0.457.g6b5491de43-goog
|
{
"author": "Li Li <boolli@google.com>",
"date": "Mon, 12 Jan 2026 23:09:43 +0000",
"thread_id": "20260112230944.3085309-2-boolli@google.com.mbox.gz"
}
|
lkml
|
[PATCH 0/2] idpf: skip NULL pointers during deallocation.
|
In idpf txq and rxq error paths, some pointers are not allocated in the
first place. In the corresponding deallocation logic, we should not
deallocate them to prevent kernel panics.
Li Li (2):
idpf: skip deallocating bufq_sets from rx_qgrp if it is NULL.
idpf: skip deallocating txq group's txqs if it is NULL.
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 5 +++++
1 file changed, 5 insertions(+)
--
2.52.0.457.g6b5491de43-goog
|
In idpf_txq_group_alloc(), if any txq group's txqs failed to
allocate memory:
for (j = 0; j < tx_qgrp->num_txq; j++) {
tx_qgrp->txqs[j] = kzalloc(sizeof(*tx_qgrp->txqs[j]),
GFP_KERNEL);
if (!tx_qgrp->txqs[j])
goto err_alloc;
}
It would cause a NULL ptr kernel panic in idpf_txq_group_rel():
for (j = 0; j < txq_grp->num_txq; j++) {
if (flow_sch_en) {
kfree(txq_grp->txqs[j]->refillq);
txq_grp->txqs[j]->refillq = NULL;
}
kfree(txq_grp->txqs[j]);
txq_grp->txqs[j] = NULL;
}
[ 6.532461] BUG: kernel NULL pointer dereference, address: 0000000000000058
...
[ 6.534433] RIP: 0010:idpf_txq_group_rel+0xc9/0x110
...
[ 6.538513] Call Trace:
[ 6.538639] <TASK>
[ 6.538760] idpf_vport_queues_alloc+0x75/0x550
[ 6.538978] idpf_vport_open+0x4d/0x3f0
[ 6.539164] idpf_open+0x71/0xb0
[ 6.539324] __dev_open+0x142/0x260
[ 6.539506] netif_open+0x2f/0xe0
[ 6.539670] dev_open+0x3d/0x70
[ 6.539827] bond_enslave+0x5ed/0xf50
[ 6.540005] ? rcutree_enqueue+0x1f/0xb0
[ 6.540193] ? call_rcu+0xde/0x2a0
[ 6.540375] ? barn_get_empty_sheaf+0x5c/0x80
[ 6.540594] ? __kfree_rcu_sheaf+0xb6/0x1a0
[ 6.540793] ? nla_put_ifalias+0x3d/0x90
[ 6.540981] ? kvfree_call_rcu+0xb5/0x3b0
[ 6.541173] ? kvfree_call_rcu+0xb5/0x3b0
[ 6.541365] do_set_master+0x114/0x160
[ 6.541547] do_setlink+0x412/0xfb0
[ 6.541717] ? security_sock_rcv_skb+0x2a/0x50
[ 6.541931] ? sk_filter_trim_cap+0x7c/0x320
[ 6.542136] ? skb_queue_tail+0x20/0x50
[ 6.542322] ? __nla_validate_parse+0x92/0xe50
ro[o t t o6 .d5e4f2a5u4l0t]- ? security_capable+0x35/0x60
[ 6.542792] rtnl_newlink+0x95c/0xa00
[ 6.542972] ? __rtnl_unlock+0x37/0x70
[ 6.543152] ? netdev_run_todo+0x63/0x530
[ 6.543343] ? allocate_slab+0x280/0x870
[ 6.543531] ? security_capable+0x35/0x60
[ 6.543722] rtnetlink_rcv_msg+0x2e6/0x340
[ 6.543918] ? __pfx_rtnetlink_rcv_msg+0x10/0x10
[ 6.544138] netlink_rcv_skb+0x16a/0x1a0
[ 6.544328] netlink_unicast+0x20a/0x320
[ 6.544516] netlink_sendmsg+0x304/0x3b0
[ 6.544748] __sock_sendmsg+0x89/0xb0
[ 6.544928] ____sys_sendmsg+0x167/0x1c0
[ 6.545116] ? ____sys_recvmsg+0xed/0x150
[ 6.545308] ___sys_sendmsg+0xdd/0x120
[ 6.545489] ? ___sys_recvmsg+0x124/0x1e0
[ 6.545680] ? rcutree_enqueue+0x1f/0xb0
[ 6.545867] ? rcutree_enqueue+0x1f/0xb0
[ 6.546055] ? call_rcu+0xde/0x2a0
[ 6.546222] ? evict+0x286/0x2d0
[ 6.546389] ? rcutree_enqueue+0x1f/0xb0
[ 6.546577] ? kmem_cache_free+0x2c/0x350
[ 6.546784] __x64_sys_sendmsg+0x72/0xc0
[ 6.546972] do_syscall_64+0x6f/0x890
[ 6.547150] entry_SYSCALL_64_after_hwframe+0x76/0x7e
[ 6.547393] RIP: 0033:0x7fc1a3347bd0
...
[ 6.551375] RIP: 0010:idpf_txq_group_rel+0xc9/0x110
...
[ 6.578856] Rebooting in 10 seconds..
We should skip deallocating txqs[j] if it is NULL in the first place.
Tested: with this patch, the kernel panic no longer appears.
Fixes: 1c325aac10a8 ("idpf: configure resources for TX queues")
Signed-off-by: Li Li <boolli@google.com>
---
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index b4dab4a8ee11b..25207da6c995d 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -1311,6 +1311,9 @@ static void idpf_txq_group_rel(struct idpf_vport *vport)
struct idpf_txq_group *txq_grp = &vport->txq_grps[i];
for (j = 0; j < txq_grp->num_txq; j++) {
+ if (!txq_grp->txqs[j])
+ continue;
+
if (flow_sch_en) {
kfree(txq_grp->txqs[j]->refillq);
txq_grp->txqs[j]->refillq = NULL;
--
2.52.0.457.g6b5491de43-goog
|
{
"author": "Li Li <boolli@google.com>",
"date": "Mon, 12 Jan 2026 23:09:44 +0000",
"thread_id": "20260112230944.3085309-2-boolli@google.com.mbox.gz"
}
|
lkml
|
[PATCH 0/2] idpf: skip NULL pointers during deallocation.
|
In idpf txq and rxq error paths, some pointers are not allocated in the
first place. In the corresponding deallocation logic, we should not
deallocate them to prevent kernel panics.
Li Li (2):
idpf: skip deallocating bufq_sets from rx_qgrp if it is NULL.
idpf: skip deallocating txq group's txqs if it is NULL.
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 5 +++++
1 file changed, 5 insertions(+)
--
2.52.0.457.g6b5491de43-goog
|
Dear Li,
Thank you for your patch.
Am 13.01.26 um 00:09 schrieb Li Li via Intel-wired-lan:
Is it easy to reproduce?
(Just for the future, a blank in the “tag section” is uncommon.)
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
|
{
"author": "Paul Menzel <pmenzel@molgen.mpg.de>",
"date": "Tue, 13 Jan 2026 07:31:26 +0100",
"thread_id": "20260112230944.3085309-2-boolli@google.com.mbox.gz"
}
|
lkml
|
[PATCH 0/2] idpf: skip NULL pointers during deallocation.
|
In idpf txq and rxq error paths, some pointers are not allocated in the
first place. In the corresponding deallocation logic, we should not
deallocate them to prevent kernel panics.
Li Li (2):
idpf: skip deallocating bufq_sets from rx_qgrp if it is NULL.
idpf: skip deallocating txq group's txqs if it is NULL.
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 5 +++++
1 file changed, 5 insertions(+)
--
2.52.0.457.g6b5491de43-goog
|
Dear Li,
Thank you for your patch.
Am 13.01.26 um 00:09 schrieb Li Li:
The reproduction steps would be nice to have documented.
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
|
{
"author": "Paul Menzel <pmenzel@molgen.mpg.de>",
"date": "Tue, 13 Jan 2026 07:43:07 +0100",
"thread_id": "20260112230944.3085309-2-boolli@google.com.mbox.gz"
}
|
lkml
|
[PATCH 0/2] idpf: skip NULL pointers during deallocation.
|
In idpf txq and rxq error paths, some pointers are not allocated in the
first place. In the corresponding deallocation logic, we should not
deallocate them to prevent kernel panics.
Li Li (2):
idpf: skip deallocating bufq_sets from rx_qgrp if it is NULL.
idpf: skip deallocating txq group's txqs if it is NULL.
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 5 +++++
1 file changed, 5 insertions(+)
--
2.52.0.457.g6b5491de43-goog
|
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
|
{
"author": "\"Loktionov, Aleksandr\" <aleksandr.loktionov@intel.com>",
"date": "Tue, 13 Jan 2026 07:34:09 +0000",
"thread_id": "20260112230944.3085309-2-boolli@google.com.mbox.gz"
}
|
lkml
|
[PATCH 0/2] idpf: skip NULL pointers during deallocation.
|
In idpf txq and rxq error paths, some pointers are not allocated in the
first place. In the corresponding deallocation logic, we should not
deallocate them to prevent kernel panics.
Li Li (2):
idpf: skip deallocating bufq_sets from rx_qgrp if it is NULL.
idpf: skip deallocating txq group's txqs if it is NULL.
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 5 +++++
1 file changed, 5 insertions(+)
--
2.52.0.457.g6b5491de43-goog
|
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
|
{
"author": "\"Loktionov, Aleksandr\" <aleksandr.loktionov@intel.com>",
"date": "Tue, 13 Jan 2026 07:34:57 +0000",
"thread_id": "20260112230944.3085309-2-boolli@google.com.mbox.gz"
}
|
lkml
|
[PATCH 0/2] idpf: skip NULL pointers during deallocation.
|
In idpf txq and rxq error paths, some pointers are not allocated in the
first place. In the corresponding deallocation logic, we should not
deallocate them to prevent kernel panics.
Li Li (2):
idpf: skip deallocating bufq_sets from rx_qgrp if it is NULL.
idpf: skip deallocating txq group's txqs if it is NULL.
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 5 +++++
1 file changed, 5 insertions(+)
--
2.52.0.457.g6b5491de43-goog
|
On Mon, Jan 12, 2026 at 10:31 PM Paul Menzel <pmenzel@molgen.mpg.de> wrote:
In our internal environments, we have the idpf driver running on
machines with small RAM, and it's not uncommon for
them to run out of memory and encounter kalloc issues, especially in
kcallocs where we allocate higher order memory.
To reliably reproduce the issue in my own testing, I simply set
rx_qgrp->splitq.bufq_sets to NULL:
rx_qgrp->splitq.bufq_sets = kcalloc(vport->num_bufqs_per_qgrp,
sizeof(struct idpf_bufq_set),
GFP_KERNEL);
rx_qgrp->splitq.bufq_sets = NULL;
If the error path works correctly, we should not see a kernel panic.
Thank you for the info!
|
{
"author": "Li Li <boolli@google.com>",
"date": "Thu, 15 Jan 2026 12:07:12 -0800",
"thread_id": "20260112230944.3085309-2-boolli@google.com.mbox.gz"
}
|
lkml
|
[PATCH v1 0/4] usb: phy: tegra: HSIC adjustments
|
Followup to a recent HSIC bringup with a few small improvements.
Svyatoslav Ryhel (4):
usb: phy: tegra: cosmetic fixes
usb: phy: tegra: return error value from utmi_wait_register
usb: phy: tegra: parametrize HSIC PTS value
usb: phy: tegra: parametrize PORTSC1 register offset
drivers/usb/phy/phy-tegra-usb.c | 45 +++++++++++++++----------------
include/linux/usb/tegra_usb_phy.h | 8 ++++--
2 files changed, 27 insertions(+), 26 deletions(-)
--
2.51.0
|
Change TEGRA_USB_HOSTPC1_DEVLC_PTS_HSIC to its literal value instead of
using the BIT macro, as it is an enumeration. Correct the spelling in the
comment and rename uhsic_registers_shift to uhsic_registers_offset.
These changes are cosmetic and do not affect code behavior.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/usb/phy/phy-tegra-usb.c | 12 ++++++------
include/linux/usb/tegra_usb_phy.h | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index effa767ec019..3a7a74f01d1c 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -48,7 +48,7 @@
#define TEGRA_USB_HOSTPC1_DEVLC 0x1b4
#define TEGRA_USB_HOSTPC1_DEVLC_PTS(x) (((x) & 0x7) << 29)
#define TEGRA_USB_HOSTPC1_DEVLC_PHCD BIT(22)
-#define TEGRA_USB_HOSTPC1_DEVLC_PTS_HSIC BIT(2)
+#define TEGRA_USB_HOSTPC1_DEVLC_PTS_HSIC 4
/* Bits of PORTSC1, which will get cleared by writing 1 into them */
#define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
@@ -169,7 +169,7 @@
/*
* Tegra20 has no UTMIP registers on PHY2 and UHSIC registers start from 0x800
* just where UTMIP registers should have been. This is the case only with Tegra20
- * Tegra30+ have UTMIP registers at 0x800 and UHSIC registers shifter by 0x400
+ * Tegra30+ have UTMIP registers at 0x800 and UHSIC registers are shifted by 0x400
* to 0xc00, but register layout is preserved.
*/
#define UHSIC_PLL_CFG1 0x804
@@ -873,7 +873,7 @@ static int ulpi_phy_power_off(struct tegra_usb_phy *phy)
static u32 tegra_hsic_readl(struct tegra_usb_phy *phy, u32 reg)
{
void __iomem *base = phy->regs;
- u32 shift = phy->soc_config->uhsic_registers_shift;
+ u32 shift = phy->soc_config->uhsic_registers_offset;
return readl_relaxed(base + shift + reg);
}
@@ -881,7 +881,7 @@ static u32 tegra_hsic_readl(struct tegra_usb_phy *phy, u32 reg)
static void tegra_hsic_writel(struct tegra_usb_phy *phy, u32 reg, u32 value)
{
void __iomem *base = phy->regs;
- u32 shift = phy->soc_config->uhsic_registers_shift;
+ u32 shift = phy->soc_config->uhsic_registers_offset;
writel_relaxed(value, base + shift + reg);
}
@@ -1469,7 +1469,7 @@ static const struct tegra_phy_soc_config tegra20_soc_config = {
.requires_usbmode_setup = false,
.requires_extra_tuning_parameters = false,
.requires_pmc_ao_power_up = false,
- .uhsic_registers_shift = 0,
+ .uhsic_registers_offset = 0,
.uhsic_tx_rtune = 0, /* 40 ohm */
};
@@ -1479,7 +1479,7 @@ static const struct tegra_phy_soc_config tegra30_soc_config = {
.requires_usbmode_setup = true,
.requires_extra_tuning_parameters = true,
.requires_pmc_ao_power_up = true,
- .uhsic_registers_shift = 0x400,
+ .uhsic_registers_offset = 0x400,
.uhsic_tx_rtune = 8, /* 50 ohm */
};
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h
index 1a8843bd1e95..fbdd2dcb3a2b 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -24,7 +24,7 @@ struct gpio_desc;
* requires_extra_tuning_parameters: true if xcvr_hsslew, hssquelch_level
* and hsdiscon_level should be set for adequate signal quality
* requires_pmc_ao_power_up: true if USB AO is powered down by default
- * uhsic_registers_shift: for Tegra30+ where HSIC registers were shifted
+ * uhsic_registers_offset: for Tegra30+ where HSIC registers were offset
* comparing to Tegra20 by 0x400, since Tegra20 has no UTMIP on PHY2
* uhsic_tx_rtune: fine tuned 50 Ohm termination resistor for NMOS/PMOS driver
*/
@@ -35,7 +35,7 @@ struct tegra_phy_soc_config {
bool requires_usbmode_setup;
bool requires_extra_tuning_parameters;
bool requires_pmc_ao_power_up;
- u32 uhsic_registers_shift;
+ u32 uhsic_registers_offset;
u32 uhsic_tx_rtune;
};
--
2.51.0
|
{
"author": "Svyatoslav Ryhel <clamor95@gmail.com>",
"date": "Mon, 2 Feb 2026 10:05:23 +0200",
"thread_id": "aabfe8bb-cd04-43f4-b0e5-07aca86c3ae0@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH v1 0/4] usb: phy: tegra: HSIC adjustments
|
Followup to a recent HSIC bringup with a few small improvements.
Svyatoslav Ryhel (4):
usb: phy: tegra: cosmetic fixes
usb: phy: tegra: return error value from utmi_wait_register
usb: phy: tegra: parametrize HSIC PTS value
usb: phy: tegra: parametrize PORTSC1 register offset
drivers/usb/phy/phy-tegra-usb.c | 45 +++++++++++++++----------------
include/linux/usb/tegra_usb_phy.h | 8 ++++--
2 files changed, 27 insertions(+), 26 deletions(-)
--
2.51.0
|
Return exact error value from utmi_wait_register during HSIC power on.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/usb/phy/phy-tegra-usb.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 3a7a74f01d1c..6173b240c3ea 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -891,6 +891,7 @@ static int uhsic_phy_power_on(struct tegra_usb_phy *phy)
struct tegra_utmip_config *config = phy->config;
void __iomem *base = phy->regs;
u32 val;
+ int err = 0;
val = tegra_hsic_readl(phy, UHSIC_PADS_CFG1);
val &= ~(UHSIC_PD_BG | UHSIC_PD_TX | UHSIC_PD_TRK | UHSIC_PD_RX |
@@ -984,12 +985,14 @@ static int uhsic_phy_power_on(struct tegra_usb_phy *phy)
val |= UHSIC_TX_RTUNE(phy->soc_config->uhsic_tx_rtune);
tegra_hsic_writel(phy, UHSIC_PADS_CFG0, val);
- if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID,
- USB_PHY_CLK_VALID))
+ err = utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID,
+ USB_PHY_CLK_VALID);
+
+ if (err)
dev_err(phy->u_phy.dev,
"Timeout waiting for PHY to stabilize on enable (HSIC)\n");
- return 0;
+ return err;
}
static int uhsic_phy_power_off(struct tegra_usb_phy *phy)
--
2.51.0
|
{
"author": "Svyatoslav Ryhel <clamor95@gmail.com>",
"date": "Mon, 2 Feb 2026 10:05:24 +0200",
"thread_id": "aabfe8bb-cd04-43f4-b0e5-07aca86c3ae0@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH v1 0/4] usb: phy: tegra: HSIC adjustments
|
Followup to a recent HSIC bringup with a few small improvements.
Svyatoslav Ryhel (4):
usb: phy: tegra: cosmetic fixes
usb: phy: tegra: return error value from utmi_wait_register
usb: phy: tegra: parametrize HSIC PTS value
usb: phy: tegra: parametrize PORTSC1 register offset
drivers/usb/phy/phy-tegra-usb.c | 45 +++++++++++++++----------------
include/linux/usb/tegra_usb_phy.h | 8 ++++--
2 files changed, 27 insertions(+), 26 deletions(-)
--
2.51.0
|
The parallel transceiver select used in HSIC mode differs on Tegra20,
where it uses the UTMI value (0), whereas Tegra30+ uses a dedicated HSIC
value. Reflect this in the SoC config.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/usb/phy/phy-tegra-usb.c | 7 +++----
include/linux/usb/tegra_usb_phy.h | 2 ++
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 6173b240c3ea..812d99443180 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -957,10 +957,7 @@ static int uhsic_phy_power_on(struct tegra_usb_phy *phy)
writel_relaxed(val, base + USB_USBMODE);
}
- if (phy->soc_config->has_hostpc)
- set_pts(phy, TEGRA_USB_HOSTPC1_DEVLC_PTS_HSIC);
- else
- set_pts(phy, 0);
+ set_pts(phy, phy->soc_config->uhsic_pts_value);
val = readl_relaxed(base + USB_TXFILLTUNING);
if ((val & USB_FIFO_TXFILL_MASK) != USB_FIFO_TXFILL_THRES(0x10)) {
@@ -1474,6 +1471,7 @@ static const struct tegra_phy_soc_config tegra20_soc_config = {
.requires_pmc_ao_power_up = false,
.uhsic_registers_offset = 0,
.uhsic_tx_rtune = 0, /* 40 ohm */
+ .uhsic_pts_value = 0, /* UTMI */
};
static const struct tegra_phy_soc_config tegra30_soc_config = {
@@ -1484,6 +1482,7 @@ static const struct tegra_phy_soc_config tegra30_soc_config = {
.requires_pmc_ao_power_up = true,
.uhsic_registers_offset = 0x400,
.uhsic_tx_rtune = 8, /* 50 ohm */
+ .uhsic_pts_value = TEGRA_USB_HOSTPC1_DEVLC_PTS_HSIC,
};
static const struct of_device_id tegra_usb_phy_id_table[] = {
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h
index fbdd2dcb3a2b..81d9f22e58b5 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -27,6 +27,7 @@ struct gpio_desc;
* uhsic_registers_offset: for Tegra30+ where HSIC registers were offset
* comparing to Tegra20 by 0x400, since Tegra20 has no UTMIP on PHY2
* uhsic_tx_rtune: fine tuned 50 Ohm termination resistor for NMOS/PMOS driver
+ * uhsic_pts_value: parallel transceiver select enumeration value
*/
struct tegra_phy_soc_config {
@@ -37,6 +38,7 @@ struct tegra_phy_soc_config {
bool requires_pmc_ao_power_up;
u32 uhsic_registers_offset;
u32 uhsic_tx_rtune;
+ u32 uhsic_pts_value;
};
struct tegra_utmip_config {
--
2.51.0
|
{
"author": "Svyatoslav Ryhel <clamor95@gmail.com>",
"date": "Mon, 2 Feb 2026 10:05:25 +0200",
"thread_id": "aabfe8bb-cd04-43f4-b0e5-07aca86c3ae0@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH v1 0/4] usb: phy: tegra: HSIC adjustments
|
Followup to a recent HSIC bringup with a few small improvements.
Svyatoslav Ryhel (4):
usb: phy: tegra: cosmetic fixes
usb: phy: tegra: return error value from utmi_wait_register
usb: phy: tegra: parametrize HSIC PTS value
usb: phy: tegra: parametrize PORTSC1 register offset
drivers/usb/phy/phy-tegra-usb.c | 45 +++++++++++++++----------------
include/linux/usb/tegra_usb_phy.h | 8 ++++--
2 files changed, 27 insertions(+), 26 deletions(-)
--
2.51.0
|
The PORTSC1 register has a different offset in Tegra20 compared to
Tegra30+, yet they share a crucial set of registers required for HSIC
functionality. Reflect this register offset change in the SoC config.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/usb/phy/phy-tegra-usb.c | 17 ++++++-----------
include/linux/usb/tegra_usb_phy.h | 2 ++
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 812d99443180..00443a7beaeb 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -965,17 +965,10 @@ static int uhsic_phy_power_on(struct tegra_usb_phy *phy)
writel_relaxed(val, base + USB_TXFILLTUNING);
}
- if (phy->soc_config->has_hostpc) {
- val = readl_relaxed(base + TEGRA30_USB_PORTSC1);
- val &= ~(TEGRA_USB_PORTSC1_WKOC | TEGRA_USB_PORTSC1_WKDS |
- TEGRA_USB_PORTSC1_WKCN);
- writel_relaxed(val, base + TEGRA30_USB_PORTSC1);
- } else {
- val = readl_relaxed(base + TEGRA_USB_PORTSC1);
- val &= ~(TEGRA_USB_PORTSC1_WKOC | TEGRA_USB_PORTSC1_WKDS |
- TEGRA_USB_PORTSC1_WKCN);
- writel_relaxed(val, base + TEGRA_USB_PORTSC1);
- }
+ val = readl_relaxed(base + phy->soc_config->portsc1_offset);
+ val &= ~(TEGRA_USB_PORTSC1_WKOC | TEGRA_USB_PORTSC1_WKDS |
+ TEGRA_USB_PORTSC1_WKCN);
+ writel_relaxed(val, base + phy->soc_config->portsc1_offset);
val = tegra_hsic_readl(phy, UHSIC_PADS_CFG0);
val &= ~UHSIC_TX_RTUNEN;
@@ -1472,6 +1465,7 @@ static const struct tegra_phy_soc_config tegra20_soc_config = {
.uhsic_registers_offset = 0,
.uhsic_tx_rtune = 0, /* 40 ohm */
.uhsic_pts_value = 0, /* UTMI */
+ .portsc1_offset = TEGRA_USB_PORTSC1,
};
static const struct tegra_phy_soc_config tegra30_soc_config = {
@@ -1483,6 +1477,7 @@ static const struct tegra_phy_soc_config tegra30_soc_config = {
.uhsic_registers_offset = 0x400,
.uhsic_tx_rtune = 8, /* 50 ohm */
.uhsic_pts_value = TEGRA_USB_HOSTPC1_DEVLC_PTS_HSIC,
+ .portsc1_offset = TEGRA30_USB_PORTSC1,
};
static const struct of_device_id tegra_usb_phy_id_table[] = {
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h
index 81d9f22e58b5..57e22aae6247 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -28,6 +28,7 @@ struct gpio_desc;
* comparing to Tegra20 by 0x400, since Tegra20 has no UTMIP on PHY2
* uhsic_tx_rtune: fine tuned 50 Ohm termination resistor for NMOS/PMOS driver
* uhsic_pts_value: parallel transceiver select enumeration value
+ * portsc1_offset: register offset of PORTSC1
*/
struct tegra_phy_soc_config {
@@ -39,6 +40,7 @@ struct tegra_phy_soc_config {
u32 uhsic_registers_offset;
u32 uhsic_tx_rtune;
u32 uhsic_pts_value;
+ u32 portsc1_offset;
};
struct tegra_utmip_config {
--
2.51.0
|
{
"author": "Svyatoslav Ryhel <clamor95@gmail.com>",
"date": "Mon, 2 Feb 2026 10:05:26 +0200",
"thread_id": "aabfe8bb-cd04-43f4-b0e5-07aca86c3ae0@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH v1 0/4] usb: phy: tegra: HSIC adjustments
|
Followup to a recent HSIC bringup with a few small improvements.
Svyatoslav Ryhel (4):
usb: phy: tegra: cosmetic fixes
usb: phy: tegra: return error value from utmi_wait_register
usb: phy: tegra: parametrize HSIC PTS value
usb: phy: tegra: parametrize PORTSC1 register offset
drivers/usb/phy/phy-tegra-usb.c | 45 +++++++++++++++----------------
include/linux/usb/tegra_usb_phy.h | 8 ++++--
2 files changed, 27 insertions(+), 26 deletions(-)
--
2.51.0
|
On Monday, February 2, 2026 5:05 PM Svyatoslav Ryhel wrote:
Series
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
|
{
"author": "Mikko Perttunen <mperttunen@nvidia.com>",
"date": "Mon, 02 Feb 2026 17:10:37 +0900",
"thread_id": "aabfe8bb-cd04-43f4-b0e5-07aca86c3ae0@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH v1 0/4] usb: phy: tegra: HSIC adjustments
|
Followup to a recent HSIC bringup with a few small improvements.
Svyatoslav Ryhel (4):
usb: phy: tegra: cosmetic fixes
usb: phy: tegra: return error value from utmi_wait_register
usb: phy: tegra: parametrize HSIC PTS value
usb: phy: tegra: parametrize PORTSC1 register offset
drivers/usb/phy/phy-tegra-usb.c | 45 +++++++++++++++----------------
include/linux/usb/tegra_usb_phy.h | 8 ++++--
2 files changed, 27 insertions(+), 26 deletions(-)
--
2.51.0
|
On 2/2/26 11:05 AM, Svyatoslav Ryhel wrote:
This initialization seems pointless -- the newly added variable gets overwritten
by you later...
[...]
MBR, Sergey
|
{
"author": "Sergey Shtylyov <sergei.shtylyov@gmail.com>",
"date": "Mon, 2 Feb 2026 15:05:03 +0300",
"thread_id": "aabfe8bb-cd04-43f4-b0e5-07aca86c3ae0@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH v1 0/4] usb: phy: tegra: HSIC adjustments
|
Followup to a recent HSIC bringup with a few small improvements.
Svyatoslav Ryhel (4):
usb: phy: tegra: cosmetic fixes
usb: phy: tegra: return error value from utmi_wait_register
usb: phy: tegra: parametrize HSIC PTS value
usb: phy: tegra: parametrize PORTSC1 register offset
drivers/usb/phy/phy-tegra-usb.c | 45 +++++++++++++++----------------
include/linux/usb/tegra_usb_phy.h | 8 ++++--
2 files changed, 27 insertions(+), 26 deletions(-)
--
2.51.0
|
пн, 2 лют. 2026 р. о 14:05 Sergey Shtylyov <sergei.shtylyov@gmail.com> пише:
So? let it better be initialized and rewritten then later on catch errors.
|
{
"author": "Svyatoslav Ryhel <clamor95@gmail.com>",
"date": "Mon, 2 Feb 2026 14:14:13 +0200",
"thread_id": "aabfe8bb-cd04-43f4-b0e5-07aca86c3ae0@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH v1 0/4] usb: phy: tegra: HSIC adjustments
|
Followup to a recent HSIC bringup with a few small improvements.
Svyatoslav Ryhel (4):
usb: phy: tegra: cosmetic fixes
usb: phy: tegra: return error value from utmi_wait_register
usb: phy: tegra: parametrize HSIC PTS value
usb: phy: tegra: parametrize PORTSC1 register offset
drivers/usb/phy/phy-tegra-usb.c | 45 +++++++++++++++----------------
include/linux/usb/tegra_usb_phy.h | 8 ++++--
2 files changed, 27 insertions(+), 26 deletions(-)
--
2.51.0
|
On 2/2/26 3:14 PM, Svyatoslav Ryhel wrote:
I'm not sure what errors you mean here. To me, it (contrariwise) seems to
mask the possible errors when you forget to set err to e.g. -ENOMEM before
returning (when adding a call to kmalloc() or any other function that doesn't
return an error code itself)...
I'm pretty sure gcc will drop this initialization when generating the object
code and (what's worse) the static analyzers will trip on this code telling you
that the value 0 is unused...
[...]
MBR, Sergey
|
{
"author": "Sergey Shtylyov <sergei.shtylyov@gmail.com>",
"date": "Mon, 2 Feb 2026 21:01:36 +0300",
"thread_id": "aabfe8bb-cd04-43f4-b0e5-07aca86c3ae0@gmail.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
Currently the vdso doesn't include .note.gnu.property or a GNU noexec
stack annotation (the -z noexecstack in the linker script is
ineffective because we specify PHDRs explicitly.)
The motivation is that the dynamic linker currently do not check
these.
However, this is a weak excuse: the vdso*.so are also supposed to be
usable at link libraries, and there is no reason why the dynamic
linker might not want or need to check these in the future, so add
them back in -- it is trivial enough.
Use symbolic constants for the PHDR permission flags.
[ v4: drop unrelated formatting changes ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/common/vdso-layout.lds.S | 38 ++++++++++++--------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/arch/x86/entry/vdso/common/vdso-layout.lds.S b/arch/x86/entry/vdso/common/vdso-layout.lds.S
index ec1ac191a057..a1e30be3e83d 100644
--- a/arch/x86/entry/vdso/common/vdso-layout.lds.S
+++ b/arch/x86/entry/vdso/common/vdso-layout.lds.S
@@ -47,18 +47,18 @@ SECTIONS
*(.gnu.linkonce.b.*)
} :text
- /*
- * Discard .note.gnu.property sections which are unused and have
- * different alignment requirement from vDSO note sections.
- */
- /DISCARD/ : {
+ .note.gnu.property : {
*(.note.gnu.property)
- }
- .note : { *(.note.*) } :text :note
-
- .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
- .eh_frame : { KEEP (*(.eh_frame)) } :text
+ } :text :note :gnu_property
+ .note : {
+ *(.note*)
+ } :text :note
+ .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
+ .eh_frame : {
+ KEEP (*(.eh_frame))
+ *(.eh_frame.*)
+ } :text
/*
* Text is well-separated from actual data: there's plenty of
@@ -87,15 +87,23 @@ SECTIONS
* Very old versions of ld do not recognize this name token; use the constant.
*/
#define PT_GNU_EH_FRAME 0x6474e550
+#define PT_GNU_STACK 0x6474e551
+#define PT_GNU_PROPERTY 0x6474e553
/*
* We must supply the ELF program headers explicitly to get just one
* PT_LOAD segment, and set the flags explicitly to make segments read-only.
- */
+*/
+#define PF_R FLAGS(4)
+#define PF_RW FLAGS(6)
+#define PF_RX FLAGS(5)
+
PHDRS
{
- text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
- dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
- note PT_NOTE FLAGS(4); /* PF_R */
- eh_frame_hdr PT_GNU_EH_FRAME;
+ text PT_LOAD PF_RX FILEHDR PHDRS;
+ dynamic PT_DYNAMIC PF_R;
+ note PT_NOTE PF_R;
+ eh_frame_hdr PT_GNU_EH_FRAME PF_R;
+ gnu_stack PT_GNU_STACK PF_RW;
+ gnu_property PT_GNU_PROPERTY PF_R;
}
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:26:01 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
A macro SYSCALL_ENTER_KERNEL was defined in sigreturn.S, with the
ability of overriding it. The override capability, however, is not
used anywhere, and the macro name is potentially confusing because it
seems to imply that sysenter/syscall could be used here, which is NOT
true: the sigreturn system calls MUST use int $0x80.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/vdso32/sigreturn.S | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/x86/entry/vdso/vdso32/sigreturn.S b/arch/x86/entry/vdso/vdso32/sigreturn.S
index 1bd068f72d4c..965900c6763b 100644
--- a/arch/x86/entry/vdso/vdso32/sigreturn.S
+++ b/arch/x86/entry/vdso/vdso32/sigreturn.S
@@ -3,10 +3,6 @@
#include <asm/unistd_32.h>
#include <asm/asm-offsets.h>
-#ifndef SYSCALL_ENTER_KERNEL
-#define SYSCALL_ENTER_KERNEL int $0x80
-#endif
-
.text
.globl __kernel_sigreturn
.type __kernel_sigreturn,@function
@@ -16,7 +12,7 @@ __kernel_sigreturn:
.LSTART_sigreturn:
popl %eax /* XXX does this mean it needs unwind info? */
movl $__NR_sigreturn, %eax
- SYSCALL_ENTER_KERNEL
+ int $0x80
.LEND_sigreturn:
SYM_INNER_LABEL(vdso32_sigreturn_landing_pad, SYM_L_GLOBAL)
nop
@@ -28,7 +24,7 @@ SYM_INNER_LABEL(vdso32_sigreturn_landing_pad, SYM_L_GLOBAL)
__kernel_rt_sigreturn:
.LSTART_rt_sigreturn:
movl $__NR_rt_sigreturn, %eax
- SYSCALL_ENTER_KERNEL
+ int $0x80
.LEND_rt_sigreturn:
SYM_INNER_LABEL(vdso32_rt_sigreturn_landing_pad, SYM_L_GLOBAL)
nop
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:25:59 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
It is generally better to build tools in arch/x86/tools to keep host
cflags proliferation down, and to reduce makefile sequencing issues.
Move the vdso build tool vdso2c into arch/x86/tools in preparation for
refactoring the vdso makefiles.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/Makefile | 2 +-
arch/x86/entry/vdso/Makefile | 7 +++----
arch/x86/tools/Makefile | 15 ++++++++++-----
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
5 files changed, 14 insertions(+), 10 deletions(-)
rename arch/x86/{entry/vdso => tools}/vdso2c.c (100%)
rename arch/x86/{entry/vdso => tools}/vdso2c.h (100%)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1d403a3612ea..9ab7522ced18 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -252,7 +252,7 @@ endif
archscripts: scripts_basic
- $(Q)$(MAKE) $(build)=arch/x86/tools relocs
+ $(Q)$(MAKE) $(build)=arch/x86/tools relocs vdso2c
###
# Syscall table generation
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 7f833026d5b2..3d9b09f00c70 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -38,13 +38,12 @@ VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 \
$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
$(call if_changed,vdso_and_check)
-HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi -I$(srctree)/arch/$(SUBARCH)/include/uapi
-hostprogs += vdso2c
+VDSO2C = $(objtree)/arch/x86/tools/vdso2c
quiet_cmd_vdso2c = VDSO2C $@
- cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
+ cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
-$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
+$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(VDSO2C) FORCE
$(call if_changed,vdso2c)
#
diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
index 7278e2545c35..39a183fffd04 100644
--- a/arch/x86/tools/Makefile
+++ b/arch/x86/tools/Makefile
@@ -38,9 +38,14 @@ $(obj)/insn_decoder_test.o: $(srctree)/tools/arch/x86/lib/insn.c $(srctree)/tool
$(obj)/insn_sanity.o: $(srctree)/tools/arch/x86/lib/insn.c $(srctree)/tools/arch/x86/lib/inat.c $(srctree)/tools/arch/x86/include/asm/inat_types.h $(srctree)/tools/arch/x86/include/asm/inat.h $(srctree)/tools/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
-HOST_EXTRACFLAGS += -I$(srctree)/tools/include
-hostprogs += relocs
-relocs-objs := relocs_32.o relocs_64.o relocs_common.o
-PHONY += relocs
-relocs: $(obj)/relocs
+HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi \
+ -I$(srctree)/arch/$(SUBARCH)/include/uapi
+
+hostprogs += relocs vdso2c
+relocs-objs := relocs_32.o relocs_64.o relocs_common.o
+
+always-y := $(hostprogs)
+
+PHONY += $(hostprogs)
+$(hostprogs): %: $(obj)/%
@:
diff --git a/arch/x86/entry/vdso/vdso2c.c b/arch/x86/tools/vdso2c.c
similarity index 100%
rename from arch/x86/entry/vdso/vdso2c.c
rename to arch/x86/tools/vdso2c.c
diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/tools/vdso2c.h
similarity index 100%
rename from arch/x86/entry/vdso/vdso2c.h
rename to arch/x86/tools/vdso2c.h
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:25:56 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
The vdso32 sigreturn.S contains open-coded DWARF bytecode, which
includes a hack for gdb to not try to step back to a previous call
instruction when backtracing from a signal handler.
Neither of those are necessary anymore: the backtracing issue is
handled by ".cfi_entry simple" and ".cfi_signal_frame", both of which
have been supported for a very long time now, which allows the
remaining frame to be built using regular .cfi annotations.
Add a few more register offsets to the signal frame just for good
measure.
Replace the nop on fallthrough of the system call (which should never,
ever happen) with a ud2a trap.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/vdso32/sigreturn.S | 146 ++++++-------------------
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/kernel/asm-offsets.c | 6 +
3 files changed, 39 insertions(+), 114 deletions(-)
diff --git a/arch/x86/entry/vdso/vdso32/sigreturn.S b/arch/x86/entry/vdso/vdso32/sigreturn.S
index 965900c6763b..25b0ac4b4bfe 100644
--- a/arch/x86/entry/vdso/vdso32/sigreturn.S
+++ b/arch/x86/entry/vdso/vdso32/sigreturn.S
@@ -1,136 +1,54 @@
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/linkage.h>
#include <asm/unistd_32.h>
+#include <asm/dwarf2.h>
#include <asm/asm-offsets.h>
+.macro STARTPROC_SIGNAL_FRAME sc
+ CFI_STARTPROC simple
+ CFI_SIGNAL_FRAME
+ /* -4 as pretcode has already been popped */
+ CFI_DEF_CFA esp, \sc - 4
+ CFI_OFFSET eip, IA32_SIGCONTEXT_ip
+ CFI_OFFSET eax, IA32_SIGCONTEXT_ax
+ CFI_OFFSET ebx, IA32_SIGCONTEXT_bx
+ CFI_OFFSET ecx, IA32_SIGCONTEXT_cx
+ CFI_OFFSET edx, IA32_SIGCONTEXT_dx
+ CFI_OFFSET esp, IA32_SIGCONTEXT_sp
+ CFI_OFFSET ebp, IA32_SIGCONTEXT_bp
+ CFI_OFFSET esi, IA32_SIGCONTEXT_si
+ CFI_OFFSET edi, IA32_SIGCONTEXT_di
+ CFI_OFFSET es, IA32_SIGCONTEXT_es
+ CFI_OFFSET cs, IA32_SIGCONTEXT_cs
+ CFI_OFFSET ss, IA32_SIGCONTEXT_ss
+ CFI_OFFSET ds, IA32_SIGCONTEXT_ds
+ CFI_OFFSET eflags, IA32_SIGCONTEXT_flags
+.endm
+
.text
.globl __kernel_sigreturn
.type __kernel_sigreturn,@function
- nop /* this guy is needed for .LSTARTFDEDLSI1 below (watch for HACK) */
ALIGN
__kernel_sigreturn:
-.LSTART_sigreturn:
- popl %eax /* XXX does this mean it needs unwind info? */
+ STARTPROC_SIGNAL_FRAME IA32_SIGFRAME_sigcontext
+ popl %eax
+ CFI_ADJUST_CFA_OFFSET -4
movl $__NR_sigreturn, %eax
int $0x80
-.LEND_sigreturn:
SYM_INNER_LABEL(vdso32_sigreturn_landing_pad, SYM_L_GLOBAL)
- nop
- .size __kernel_sigreturn,.-.LSTART_sigreturn
+ ud2a
+ CFI_ENDPROC
+ .size __kernel_sigreturn,.-__kernel_sigreturn
.globl __kernel_rt_sigreturn
.type __kernel_rt_sigreturn,@function
ALIGN
__kernel_rt_sigreturn:
-.LSTART_rt_sigreturn:
+ STARTPROC_SIGNAL_FRAME IA32_RT_SIGFRAME_sigcontext
movl $__NR_rt_sigreturn, %eax
int $0x80
-.LEND_rt_sigreturn:
SYM_INNER_LABEL(vdso32_rt_sigreturn_landing_pad, SYM_L_GLOBAL)
- nop
- .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
- .previous
-
- .section .eh_frame,"a",@progbits
-.LSTARTFRAMEDLSI1:
- .long .LENDCIEDLSI1-.LSTARTCIEDLSI1
-.LSTARTCIEDLSI1:
- .long 0 /* CIE ID */
- .byte 1 /* Version number */
- .string "zRS" /* NUL-terminated augmentation string */
- .uleb128 1 /* Code alignment factor */
- .sleb128 -4 /* Data alignment factor */
- .byte 8 /* Return address register column */
- .uleb128 1 /* Augmentation value length */
- .byte 0x1b /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
- .byte 0 /* DW_CFA_nop */
- .align 4
-.LENDCIEDLSI1:
- .long .LENDFDEDLSI1-.LSTARTFDEDLSI1 /* Length FDE */
-.LSTARTFDEDLSI1:
- .long .LSTARTFDEDLSI1-.LSTARTFRAMEDLSI1 /* CIE pointer */
- /* HACK: The dwarf2 unwind routines will subtract 1 from the
- return address to get an address in the middle of the
- presumed call instruction. Since we didn't get here via
- a call, we need to include the nop before the real start
- to make up for it. */
- .long .LSTART_sigreturn-1-. /* PC-relative start address */
- .long .LEND_sigreturn-.LSTART_sigreturn+1
- .uleb128 0 /* Augmentation */
- /* What follows are the instructions for the table generation.
- We record the locations of each register saved. This is
- complicated by the fact that the "CFA" is always assumed to
- be the value of the stack pointer in the caller. This means
- that we must define the CFA of this body of code to be the
- saved value of the stack pointer in the sigcontext. Which
- also means that there is no fixed relation to the other
- saved registers, which means that we must use DW_CFA_expression
- to compute their addresses. It also means that when we
- adjust the stack with the popl, we have to do it all over again. */
-
-#define do_cfa_expr(offset) \
- .byte 0x0f; /* DW_CFA_def_cfa_expression */ \
- .uleb128 1f-0f; /* length */ \
-0: .byte 0x74; /* DW_OP_breg4 */ \
- .sleb128 offset; /* offset */ \
- .byte 0x06; /* DW_OP_deref */ \
-1:
-
-#define do_expr(regno, offset) \
- .byte 0x10; /* DW_CFA_expression */ \
- .uleb128 regno; /* regno */ \
- .uleb128 1f-0f; /* length */ \
-0: .byte 0x74; /* DW_OP_breg4 */ \
- .sleb128 offset; /* offset */ \
-1:
-
- do_cfa_expr(IA32_SIGCONTEXT_sp+4)
- do_expr(0, IA32_SIGCONTEXT_ax+4)
- do_expr(1, IA32_SIGCONTEXT_cx+4)
- do_expr(2, IA32_SIGCONTEXT_dx+4)
- do_expr(3, IA32_SIGCONTEXT_bx+4)
- do_expr(5, IA32_SIGCONTEXT_bp+4)
- do_expr(6, IA32_SIGCONTEXT_si+4)
- do_expr(7, IA32_SIGCONTEXT_di+4)
- do_expr(8, IA32_SIGCONTEXT_ip+4)
-
- .byte 0x42 /* DW_CFA_advance_loc 2 -- nop; popl eax. */
-
- do_cfa_expr(IA32_SIGCONTEXT_sp)
- do_expr(0, IA32_SIGCONTEXT_ax)
- do_expr(1, IA32_SIGCONTEXT_cx)
- do_expr(2, IA32_SIGCONTEXT_dx)
- do_expr(3, IA32_SIGCONTEXT_bx)
- do_expr(5, IA32_SIGCONTEXT_bp)
- do_expr(6, IA32_SIGCONTEXT_si)
- do_expr(7, IA32_SIGCONTEXT_di)
- do_expr(8, IA32_SIGCONTEXT_ip)
-
- .align 4
-.LENDFDEDLSI1:
-
- .long .LENDFDEDLSI2-.LSTARTFDEDLSI2 /* Length FDE */
-.LSTARTFDEDLSI2:
- .long .LSTARTFDEDLSI2-.LSTARTFRAMEDLSI1 /* CIE pointer */
- /* HACK: See above wrt unwind library assumptions. */
- .long .LSTART_rt_sigreturn-1-. /* PC-relative start address */
- .long .LEND_rt_sigreturn-.LSTART_rt_sigreturn+1
- .uleb128 0 /* Augmentation */
- /* What follows are the instructions for the table generation.
- We record the locations of each register saved. This is
- slightly less complicated than the above, since we don't
- modify the stack pointer in the process. */
-
- do_cfa_expr(IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_sp)
- do_expr(0, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ax)
- do_expr(1, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_cx)
- do_expr(2, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_dx)
- do_expr(3, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_bx)
- do_expr(5, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_bp)
- do_expr(6, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_si)
- do_expr(7, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_di)
- do_expr(8, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ip)
-
- .align 4
-.LENDFDEDLSI2:
+ ud2a
+ CFI_ENDPROC
+ .size __kernel_rt_sigreturn,.-__kernel_rt_sigreturn
.previous
diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h
index 302e11b15da8..09c9684d3ad6 100644
--- a/arch/x86/include/asm/dwarf2.h
+++ b/arch/x86/include/asm/dwarf2.h
@@ -20,6 +20,7 @@
#define CFI_RESTORE_STATE .cfi_restore_state
#define CFI_UNDEFINED .cfi_undefined
#define CFI_ESCAPE .cfi_escape
+#define CFI_SIGNAL_FRAME .cfi_signal_frame
#ifndef BUILD_VDSO
/*
diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
index 25fcde525c68..081816888f7a 100644
--- a/arch/x86/kernel/asm-offsets.c
+++ b/arch/x86/kernel/asm-offsets.c
@@ -63,8 +63,14 @@ static void __used common(void)
OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
+ OFFSET(IA32_SIGCONTEXT_es, sigcontext_32, es);
+ OFFSET(IA32_SIGCONTEXT_cs, sigcontext_32, cs);
+ OFFSET(IA32_SIGCONTEXT_ss, sigcontext_32, ss);
+ OFFSET(IA32_SIGCONTEXT_ds, sigcontext_32, ds);
+ OFFSET(IA32_SIGCONTEXT_flags, sigcontext_32, flags);
BLANK();
+ OFFSET(IA32_SIGFRAME_sigcontext, sigframe_ia32, sc);
OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
#endif
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:26:00 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
The vdso .so files are named vdso*.so. These structures are binary
images and descriptions of these files, so it is more consistent for
them to have a naming that more directly mirrors the filenames.
It is also very slightly more compact (by one character...) and
simplifies the Makefile just a little bit.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 ++++-------
arch/x86/entry/vdso/Makefile | 8 ++++----
arch/x86/entry/vdso/vma.c | 10 +++++-----
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +++---
arch/x86/kernel/process_64.c | 6 +++---
arch/x86/kernel/signal_32.c | 4 ++--
8 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c
index a67a644d0cfe..8e829575e12f 100644
--- a/arch/x86/entry/syscall_32.c
+++ b/arch/x86/entry/syscall_32.c
@@ -319,7 +319,7 @@ __visible noinstr bool do_fast_syscall_32(struct pt_regs *regs)
* convention. Adjust regs so it looks like we entered using int80.
*/
unsigned long landing_pad = (unsigned long)current->mm->context.vdso +
- vdso_image_32.sym_int80_landing_pad;
+ vdso32_image.sym_int80_landing_pad;
/*
* SYSENTER loses EIP, and even SYSCALL32 needs us to skip forward
diff --git a/arch/x86/entry/vdso/.gitignore b/arch/x86/entry/vdso/.gitignore
index 37a6129d597b..eb60859dbcbf 100644
--- a/arch/x86/entry/vdso/.gitignore
+++ b/arch/x86/entry/vdso/.gitignore
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
-vdso.lds
-vdsox32.lds
-vdso32-syscall-syms.lds
-vdso32-sysenter-syms.lds
-vdso32-int80-syms.lds
-vdso-image-*.c
-vdso2c
+*.lds
+*.so
+*.so.dbg
+vdso*-image.c
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index f247f5f5cb44..7f833026d5b2 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -16,9 +16,9 @@ vobjs-$(CONFIG_X86_SGX) += vsgx.o
obj-y += vma.o extable.o
# vDSO images to build:
-obj-$(CONFIG_X86_64) += vdso-image-64.o
-obj-$(CONFIG_X86_X32_ABI) += vdso-image-x32.o
-obj-$(CONFIG_COMPAT_32) += vdso-image-32.o vdso32-setup.o
+obj-$(CONFIG_X86_64) += vdso64-image.o
+obj-$(CONFIG_X86_X32_ABI) += vdsox32-image.o
+obj-$(CONFIG_COMPAT_32) += vdso32-image.o vdso32-setup.o
vobjs := $(addprefix $(obj)/, $(vobjs-y))
vobjs32 := $(addprefix $(obj)/, $(vobjs32-y))
@@ -44,7 +44,7 @@ hostprogs += vdso2c
quiet_cmd_vdso2c = VDSO2C $@
cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
-$(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
+$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
$(call if_changed,vdso2c)
#
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index afe105b2f907..8f98c2d7c7a9 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -65,7 +65,7 @@ static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
static void vdso_fix_landing(const struct vdso_image *image,
struct vm_area_struct *new_vma)
{
- if (in_ia32_syscall() && image == &vdso_image_32) {
+ if (in_ia32_syscall() && image == &vdso32_image) {
struct pt_regs *regs = current_pt_regs();
unsigned long vdso_land = image->sym_int80_landing_pad;
unsigned long old_land_addr = vdso_land +
@@ -230,7 +230,7 @@ static int load_vdso32(void)
if (vdso32_enabled != 1) /* Other values all mean "disabled" */
return 0;
- return map_vdso(&vdso_image_32, 0);
+ return map_vdso(&vdso32_image, 0);
}
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
@@ -239,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
if (!vdso64_enabled)
return 0;
- return map_vdso(&vdso_image_64, 0);
+ return map_vdso(&vdso64_image, 0);
}
return load_vdso32();
@@ -252,7 +252,7 @@ int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
if (IS_ENABLED(CONFIG_X86_X32_ABI) && x32) {
if (!vdso64_enabled)
return 0;
- return map_vdso(&vdso_image_x32, 0);
+ return map_vdso(&vdsox32_image, 0);
}
if (IS_ENABLED(CONFIG_IA32_EMULATION))
@@ -267,7 +267,7 @@ bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
const struct vdso_image *image = current->mm->context.vdso_image;
unsigned long vdso = (unsigned long) current->mm->context.vdso;
- if (in_ia32_syscall() && image == &vdso_image_32) {
+ if (in_ia32_syscall() && image == &vdso32_image) {
if (regs->ip == vdso + image->sym_vdso32_sigreturn_landing_pad ||
regs->ip == vdso + image->sym_vdso32_rt_sigreturn_landing_pad)
return true;
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 6c8fdc96be7e..2ba5f166e58f 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -361,7 +361,7 @@ else if (IS_ENABLED(CONFIG_IA32_EMULATION)) \
#define VDSO_ENTRY \
((unsigned long)current->mm->context.vdso + \
- vdso_image_32.sym___kernel_vsyscall)
+ vdso32_image.sym___kernel_vsyscall)
struct linux_binprm;
diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index b7253ef3205a..e8afbe9faa5b 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -27,9 +27,9 @@ struct vdso_image {
long sym_vdso32_rt_sigreturn_landing_pad;
};
-extern const struct vdso_image vdso_image_64;
-extern const struct vdso_image vdso_image_x32;
-extern const struct vdso_image vdso_image_32;
+extern const struct vdso_image vdso64_image;
+extern const struct vdso_image vdsox32_image;
+extern const struct vdso_image vdso32_image;
extern int __init init_vdso_image(const struct vdso_image *image);
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 432c0a004c60..08e72f429870 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -941,14 +941,14 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
#ifdef CONFIG_CHECKPOINT_RESTORE
# ifdef CONFIG_X86_X32_ABI
case ARCH_MAP_VDSO_X32:
- return prctl_map_vdso(&vdso_image_x32, arg2);
+ return prctl_map_vdso(&vdsox32_image, arg2);
# endif
# ifdef CONFIG_IA32_EMULATION
case ARCH_MAP_VDSO_32:
- return prctl_map_vdso(&vdso_image_32, arg2);
+ return prctl_map_vdso(&vdso32_image, arg2);
# endif
case ARCH_MAP_VDSO_64:
- return prctl_map_vdso(&vdso_image_64, arg2);
+ return prctl_map_vdso(&vdso64_image, arg2);
#endif
#ifdef CONFIG_ADDRESS_MASKING
case ARCH_GET_UNTAG_MASK:
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 42bbc42bd350..e55cf19e68fe 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -282,7 +282,7 @@ int ia32_setup_frame(struct ksignal *ksig, struct pt_regs *regs)
/* Return stub is in 32bit vsyscall page */
if (current->mm->context.vdso)
restorer = current->mm->context.vdso +
- vdso_image_32.sym___kernel_sigreturn;
+ vdso32_image.sym___kernel_sigreturn;
else
restorer = &frame->retcode;
}
@@ -368,7 +368,7 @@ int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
restorer = ksig->ka.sa.sa_restorer;
else
restorer = current->mm->context.vdso +
- vdso_image_32.sym___kernel_rt_sigreturn;
+ vdso32_image.sym___kernel_rt_sigreturn;
unsafe_put_user(ptr_to_compat(restorer), &frame->pretcode, Efault);
/*
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:25:55 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
There is no fundamental reason to use the int80_landing_pad symbol to
adjust ip when moving the vdso. If ip falls within the vdso, and the
vdso is moved, we should change the ip accordingly, regardless of mode
or location within the vdso. This *currently* can only happen on 32
bits, but there isn't any reason not to do so generically.
Note that if this is ever possible from a vdso-internal call, then the
user space stack will also needed to be adjusted (as well as the
shadow stack, if enabled.) Fortunately this is not currently the case.
At the moment, we don't even consider other threads when moving the
vdso. The assumption is that it is only used by process freeze/thaw
for migration, where this is not an issue.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/vma.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 8f98c2d7c7a9..e7fd7517370f 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -65,16 +65,12 @@ static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
static void vdso_fix_landing(const struct vdso_image *image,
struct vm_area_struct *new_vma)
{
- if (in_ia32_syscall() && image == &vdso32_image) {
- struct pt_regs *regs = current_pt_regs();
- unsigned long vdso_land = image->sym_int80_landing_pad;
- unsigned long old_land_addr = vdso_land +
- (unsigned long)current->mm->context.vdso;
-
- /* Fixing userspace landing - look at do_fast_syscall_32 */
- if (regs->ip == old_land_addr)
- regs->ip = new_vma->vm_start + vdso_land;
- }
+ struct pt_regs *regs = current_pt_regs();
+ unsigned long ipoffset = regs->ip -
+ (unsigned long)current->mm->context.vdso;
+
+ if (ipoffset < image->size)
+ regs->ip = new_vma->vm_start + ipoffset;
}
static int vdso_mremap(const struct vm_special_mapping *sm,
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:25:58 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
When neither sysenter32 nor syscall32 is available (on either
FRED-capable 64-bit hardware or old 32-bit hardware), there is no
reason to do a bunch of stack shuffling in __kernel_vsyscall.
Unfortunately, just overwriting the initial "push" instructions will
mess up the CFI annotations, so suffer the 3-byte NOP if not
applicable.
Similarly, inline the int $0x80 when doing inline system calls in the
vdso instead of calling __kernel_vsyscall.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/vdso32/system_call.S | 18 ++++++++++++++----
arch/x86/include/asm/vdso/sys_call.h | 4 +++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso/vdso32/system_call.S
index 7b1c0f16e511..9157cf9c5749 100644
--- a/arch/x86/entry/vdso/vdso32/system_call.S
+++ b/arch/x86/entry/vdso/vdso32/system_call.S
@@ -14,6 +14,18 @@
ALIGN
__kernel_vsyscall:
CFI_STARTPROC
+
+ /*
+ * If using int $0x80, there is no reason to muck about with the
+ * stack here. Unfortunately just overwriting the push instructions
+ * would mess up the CFI annotations, but it is only a 3-byte
+ * NOP in that case. This could be avoided by patching the
+ * vdso symbol table (not the code) and entry point, but that
+ * would a fair bit of tooling work or by simply compiling
+ * two different vDSO images, but that doesn't seem worth it.
+ */
+ ALTERNATIVE "int $0x80; ret", "", X86_FEATURE_SYSFAST32
+
/*
* Reshuffle regs so that all of any of the entry instructions
* will preserve enough state.
@@ -52,11 +64,9 @@ __kernel_vsyscall:
#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
- /* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
- ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSFAST32, \
- SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
+ ALTERNATIVE SYSENTER_SEQUENCE, SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
- /* Enter using int $0x80 */
+ /* Re-enter using int $0x80 */
int $0x80
SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL)
diff --git a/arch/x86/include/asm/vdso/sys_call.h b/arch/x86/include/asm/vdso/sys_call.h
index dcfd17c6dd57..5806b1cd6aef 100644
--- a/arch/x86/include/asm/vdso/sys_call.h
+++ b/arch/x86/include/asm/vdso/sys_call.h
@@ -20,7 +20,9 @@
# define __sys_reg4 "r10"
# define __sys_reg5 "r8"
#else
-# define __sys_instr "call __kernel_vsyscall"
+# define __sys_instr ALTERNATIVE("ds;ds;ds;int $0x80", \
+ "call __kernel_vsyscall", \
+ X86_FEATURE_SYSFAST32)
# define __sys_clobber "memory"
# define __sys_nr(x,y) __NR_ ## x ## y
# define __sys_reg1 "ebx"
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:26:04 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
Abstract out the calling of true system calls from the vdso into
macros.
It has been a very long time since gcc did not allow %ebx or %ebp in
inline asm in 32-bit PIC mode; remove the corresponding hacks.
Remove the use of memory output constraints in gettimeofday.h in favor
of "memory" clobbers. The resulting code is identical for the current
use cases, as the system call is usually a terminal fallback anyway,
and it merely complicates the macroization.
This patch adds only a handful of more lines of code than it removes,
and in fact could be made substantially smaller by removing the macros
for the argument counts that aren't currently used, however, it seems
better to be general from the start.
[ v3: remove stray comment from prototyping; remove VDSO_SYSCALL6()
since it would require special handling on 32 bits and is
currently unused. (Uros Biszjak)
Indent nested preprocessor directives. ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/include/asm/vdso/gettimeofday.h | 108 ++---------------------
arch/x86/include/asm/vdso/sys_call.h | 103 +++++++++++++++++++++
2 files changed, 111 insertions(+), 100 deletions(-)
create mode 100644 arch/x86/include/asm/vdso/sys_call.h
diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h
index 73b2e7ee8f0f..3cf214cc4a75 100644
--- a/arch/x86/include/asm/vdso/gettimeofday.h
+++ b/arch/x86/include/asm/vdso/gettimeofday.h
@@ -18,6 +18,7 @@
#include <asm/msr.h>
#include <asm/pvclock.h>
#include <clocksource/hyperv_timer.h>
+#include <asm/vdso/sys_call.h>
#define VDSO_HAS_TIME 1
@@ -53,130 +54,37 @@ extern struct ms_hyperv_tsc_page hvclock_page
__attribute__((visibility("hidden")));
#endif
-#ifndef BUILD_VDSO32
-
static __always_inline
long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
{
- long ret;
-
- asm ("syscall" : "=a" (ret), "=m" (*_ts) :
- "0" (__NR_clock_gettime), "D" (_clkid), "S" (_ts) :
- "rcx", "r11");
-
- return ret;
+ return VDSO_SYSCALL2(clock_gettime,64,_clkid,_ts);
}
static __always_inline
long gettimeofday_fallback(struct __kernel_old_timeval *_tv,
struct timezone *_tz)
{
- long ret;
-
- asm("syscall" : "=a" (ret) :
- "0" (__NR_gettimeofday), "D" (_tv), "S" (_tz) : "memory");
-
- return ret;
+ return VDSO_SYSCALL2(gettimeofday,,_tv,_tz);
}
static __always_inline
long clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
{
- long ret;
-
- asm ("syscall" : "=a" (ret), "=m" (*_ts) :
- "0" (__NR_clock_getres), "D" (_clkid), "S" (_ts) :
- "rcx", "r11");
-
- return ret;
+ return VDSO_SYSCALL2(clock_getres,_time64,_clkid,_ts);
}
-#else
-
-static __always_inline
-long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
-{
- long ret;
-
- asm (
- "mov %%ebx, %%edx \n"
- "mov %[clock], %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret), "=m" (*_ts)
- : "0" (__NR_clock_gettime64), [clock] "g" (_clkid), "c" (_ts)
- : "edx");
-
- return ret;
-}
+#ifndef CONFIG_X86_64
static __always_inline
long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
{
- long ret;
-
- asm (
- "mov %%ebx, %%edx \n"
- "mov %[clock], %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret), "=m" (*_ts)
- : "0" (__NR_clock_gettime), [clock] "g" (_clkid), "c" (_ts)
- : "edx");
-
- return ret;
-}
-
-static __always_inline
-long gettimeofday_fallback(struct __kernel_old_timeval *_tv,
- struct timezone *_tz)
-{
- long ret;
-
- asm(
- "mov %%ebx, %%edx \n"
- "mov %2, %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret)
- : "0" (__NR_gettimeofday), "g" (_tv), "c" (_tz)
- : "memory", "edx");
-
- return ret;
+ return VDSO_SYSCALL2(clock_gettime,,_clkid,_ts);
}
static __always_inline long
-clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
-{
- long ret;
-
- asm (
- "mov %%ebx, %%edx \n"
- "mov %[clock], %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret), "=m" (*_ts)
- : "0" (__NR_clock_getres_time64), [clock] "g" (_clkid), "c" (_ts)
- : "edx");
-
- return ret;
-}
-
-static __always_inline
-long clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
+clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
{
- long ret;
-
- asm (
- "mov %%ebx, %%edx \n"
- "mov %[clock], %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret), "=m" (*_ts)
- : "0" (__NR_clock_getres), [clock] "g" (_clkid), "c" (_ts)
- : "edx");
-
- return ret;
+ return VDSO_SYSCALL2(clock_getres,,_clkid,_ts);
}
#endif
diff --git a/arch/x86/include/asm/vdso/sys_call.h b/arch/x86/include/asm/vdso/sys_call.h
new file mode 100644
index 000000000000..dcfd17c6dd57
--- /dev/null
+++ b/arch/x86/include/asm/vdso/sys_call.h
@@ -0,0 +1,103 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Macros for issuing an inline system call from the vDSO.
+ */
+
+#ifndef X86_ASM_VDSO_SYS_CALL_H
+#define X86_ASM_VDSO_SYS_CALL_H
+
+#include <linux/compiler.h>
+#include <asm/cpufeatures.h>
+#include <asm/alternative.h>
+
+#ifdef CONFIG_X86_64
+# define __sys_instr "syscall"
+# define __sys_clobber "rcx", "r11", "memory"
+# define __sys_nr(x,y) __NR_ ## x
+# define __sys_reg1 "rdi"
+# define __sys_reg2 "rsi"
+# define __sys_reg3 "rdx"
+# define __sys_reg4 "r10"
+# define __sys_reg5 "r8"
+#else
+# define __sys_instr "call __kernel_vsyscall"
+# define __sys_clobber "memory"
+# define __sys_nr(x,y) __NR_ ## x ## y
+# define __sys_reg1 "ebx"
+# define __sys_reg2 "ecx"
+# define __sys_reg3 "edx"
+# define __sys_reg4 "esi"
+# define __sys_reg5 "edi"
+#endif
+
+/*
+ * Example usage:
+ *
+ * result = VDSO_SYSCALL3(foo,64,x,y,z);
+ *
+ * ... calls foo(x,y,z) on 64 bits, and foo64(x,y,z) on 32 bits.
+ *
+ * VDSO_SYSCALL6() is currently missing, because it would require
+ * special handling for %ebp on 32 bits when the vdso is compiled with
+ * frame pointers enabled (the default on 32 bits.) Add it as a special
+ * case when and if it becomes necessary.
+ */
+#define _VDSO_SYSCALL(name,suf32,...) \
+ ({ \
+ long _sys_num_ret = __sys_nr(name,suf32); \
+ asm_inline volatile( \
+ __sys_instr \
+ : "+a" (_sys_num_ret) \
+ : __VA_ARGS__ \
+ : __sys_clobber); \
+ _sys_num_ret; \
+ })
+
+#define VDSO_SYSCALL0(name,suf32) \
+ _VDSO_SYSCALL(name,suf32)
+#define VDSO_SYSCALL1(name,suf32,a1) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1)); \
+ })
+#define VDSO_SYSCALL2(name,suf32,a1,a2) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ register long _sys_arg2 asm(__sys_reg2) = (long)(a2); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1), "r" (_sys_arg2)); \
+ })
+#define VDSO_SYSCALL3(name,suf32,a1,a2,a3) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ register long _sys_arg2 asm(__sys_reg2) = (long)(a2); \
+ register long _sys_arg3 asm(__sys_reg3) = (long)(a3); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1), "r" (_sys_arg2), \
+ "r" (_sys_arg3)); \
+ })
+#define VDSO_SYSCALL4(name,suf32,a1,a2,a3,a4) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ register long _sys_arg2 asm(__sys_reg2) = (long)(a2); \
+ register long _sys_arg3 asm(__sys_reg3) = (long)(a3); \
+ register long _sys_arg4 asm(__sys_reg4) = (long)(a4); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1), "r" (_sys_arg2), \
+ "r" (_sys_arg3), "r" (_sys_arg4)); \
+ })
+#define VDSO_SYSCALL5(name,suf32,a1,a2,a3,a4,a5) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ register long _sys_arg2 asm(__sys_reg2) = (long)(a2); \
+ register long _sys_arg3 asm(__sys_reg3) = (long)(a3); \
+ register long _sys_arg4 asm(__sys_reg4) = (long)(a4); \
+ register long _sys_arg5 asm(__sys_reg5) = (long)(a5); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1), "r" (_sys_arg2), \
+ "r" (_sys_arg3), "r" (_sys_arg4), \
+ "r" (_sys_arg5)); \
+ })
+
+#endif /* X86_VDSO_SYS_CALL_H */
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:26:02 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
In most cases, the use of "fast 32-bit system call" depends either on
X86_FEATURE_SEP or X86_FEATURE_SYSENTER32 || X86_FEATURE_SYSCALL32.
However, nearly all the logic for both is identical.
Define X86_FEATURE_SYSFAST32 which indicates that *either* SYSENTER32 or
SYSCALL32 should be used, for either 32- or 64-bit kernels. This
defaults to SYSENTER; use SYSCALL if the SYSCALL32 bit is also set.
As this removes ALL existing uses of X86_FEATURE_SYSENTER32, which is
a kernel-only synthetic feature bit, simply remove it and replace it
with X86_FEATURE_SYSFAST32.
This leaves an unused alternative for a true 32-bit kernel, but that
should really not matter in any way.
The clearing of X86_FEATURE_SYSCALL32 can be removed once the patches
for automatically clearing disabled features has been merged.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/Kconfig.cpufeatures | 8 +++++++
arch/x86/entry/vdso/vdso32/system_call.S | 8 ++-----
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/kernel/cpu/centaur.c | 3 ---
arch/x86/kernel/cpu/common.c | 8 +++++++
arch/x86/kernel/cpu/intel.c | 4 +---
arch/x86/kernel/cpu/zhaoxin.c | 4 +---
arch/x86/kernel/fred.c | 2 +-
arch/x86/xen/setup.c | 28 +++++++++++++++---------
arch/x86/xen/smp_pv.c | 5 ++---
arch/x86/xen/xen-ops.h | 1 -
11 files changed, 42 insertions(+), 31 deletions(-)
diff --git a/arch/x86/Kconfig.cpufeatures b/arch/x86/Kconfig.cpufeatures
index 733d5aff2456..423ac795baa7 100644
--- a/arch/x86/Kconfig.cpufeatures
+++ b/arch/x86/Kconfig.cpufeatures
@@ -56,6 +56,10 @@ config X86_REQUIRED_FEATURE_MOVBE
def_bool y
depends on MATOM
+config X86_REQUIRED_FEATURE_SYSFAST32
+ def_bool y
+ depends on X86_64 && !X86_FRED
+
config X86_REQUIRED_FEATURE_CPUID
def_bool y
depends on X86_64
@@ -120,6 +124,10 @@ config X86_DISABLED_FEATURE_CENTAUR_MCR
def_bool y
depends on X86_64
+config X86_DISABLED_FEATURE_SYSCALL32
+ def_bool y
+ depends on !X86_64
+
config X86_DISABLED_FEATURE_PCID
def_bool y
depends on !X86_64
diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso/vdso32/system_call.S
index 2a15634bbe75..7b1c0f16e511 100644
--- a/arch/x86/entry/vdso/vdso32/system_call.S
+++ b/arch/x86/entry/vdso/vdso32/system_call.S
@@ -52,13 +52,9 @@ __kernel_vsyscall:
#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
-#ifdef BUILD_VDSO32_64
/* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
- ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \
- SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
-#else
- ALTERNATIVE "", SYSENTER_SEQUENCE, X86_FEATURE_SEP
-#endif
+ ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSFAST32, \
+ SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
/* Enter using int $0x80 */
int $0x80
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index c3b53beb1300..63b0f9aa9b3e 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -84,7 +84,7 @@
#define X86_FEATURE_PEBS ( 3*32+12) /* "pebs" Precise-Event Based Sampling */
#define X86_FEATURE_BTS ( 3*32+13) /* "bts" Branch Trace Store */
#define X86_FEATURE_SYSCALL32 ( 3*32+14) /* syscall in IA32 userspace */
-#define X86_FEATURE_SYSENTER32 ( 3*32+15) /* sysenter in IA32 userspace */
+#define X86_FEATURE_SYSFAST32 ( 3*32+15) /* sysenter/syscall in IA32 userspace */
#define X86_FEATURE_REP_GOOD ( 3*32+16) /* "rep_good" REP microcode works well */
#define X86_FEATURE_AMD_LBR_V2 ( 3*32+17) /* "amd_lbr_v2" AMD Last Branch Record Extension Version 2 */
#define X86_FEATURE_CLEAR_CPU_BUF ( 3*32+18) /* Clear CPU buffers using VERW */
diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index a3b55db35c96..9833f837141c 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -102,9 +102,6 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
(c->x86 >= 7))
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-#ifdef CONFIG_X86_64
- set_cpu_cap(c, X86_FEATURE_SYSENTER32);
-#endif
if (c->x86_power & (1 << 8)) {
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index e7ab22fce3b5..1c3261cae40c 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1068,6 +1068,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
init_scattered_cpuid_features(c);
init_speculation_control(c);
+ if (IS_ENABLED(CONFIG_X86_64) || cpu_has(c, X86_FEATURE_SEP))
+ set_cpu_cap(c, X86_FEATURE_SYSFAST32);
+
/*
* Clear/Set all flags overridden by options, after probe.
* This needs to happen each time we re-probe, which may happen
@@ -1813,6 +1816,11 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
* that it can't be enabled in 32-bit mode.
*/
setup_clear_cpu_cap(X86_FEATURE_PCID);
+
+ /*
+ * Never use SYSCALL on a 32-bit kernel
+ */
+ setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
#endif
/*
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 98ae4c37c93e..646ff33c4651 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -236,9 +236,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
clear_cpu_cap(c, X86_FEATURE_PSE);
}
-#ifdef CONFIG_X86_64
- set_cpu_cap(c, X86_FEATURE_SYSENTER32);
-#else
+#ifndef CONFIG_X86_64
/* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
if (c->x86 == 15 && c->x86_cache_alignment == 64)
c->x86_cache_alignment = 128;
diff --git a/arch/x86/kernel/cpu/zhaoxin.c b/arch/x86/kernel/cpu/zhaoxin.c
index 89b1c8a70fe8..031379b7d4fa 100644
--- a/arch/x86/kernel/cpu/zhaoxin.c
+++ b/arch/x86/kernel/cpu/zhaoxin.c
@@ -59,9 +59,7 @@ static void early_init_zhaoxin(struct cpuinfo_x86 *c)
{
if (c->x86 >= 0x6)
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-#ifdef CONFIG_X86_64
- set_cpu_cap(c, X86_FEATURE_SYSENTER32);
-#endif
+
if (c->x86_power & (1 << 8)) {
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
diff --git a/arch/x86/kernel/fred.c b/arch/x86/kernel/fred.c
index 816187da3a47..e736b19e18de 100644
--- a/arch/x86/kernel/fred.c
+++ b/arch/x86/kernel/fred.c
@@ -68,7 +68,7 @@ void cpu_init_fred_exceptions(void)
idt_invalidate();
/* Use int $0x80 for 32-bit system calls in FRED mode */
- setup_clear_cpu_cap(X86_FEATURE_SYSENTER32);
+ setup_clear_cpu_cap(X86_FEATURE_SYSFAST32);
setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
}
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 3823e52aef52..ac8021c3a997 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -990,13 +990,6 @@ static int register_callback(unsigned type, const void *func)
return HYPERVISOR_callback_op(CALLBACKOP_register, &callback);
}
-void xen_enable_sysenter(void)
-{
- if (cpu_feature_enabled(X86_FEATURE_SYSENTER32) &&
- register_callback(CALLBACKTYPE_sysenter, xen_entry_SYSENTER_compat))
- setup_clear_cpu_cap(X86_FEATURE_SYSENTER32);
-}
-
void xen_enable_syscall(void)
{
int ret;
@@ -1008,11 +1001,27 @@ void xen_enable_syscall(void)
mechanism for syscalls. */
}
- if (cpu_feature_enabled(X86_FEATURE_SYSCALL32) &&
- register_callback(CALLBACKTYPE_syscall32, xen_entry_SYSCALL_compat))
+ if (!cpu_feature_enabled(X86_FEATURE_SYSFAST32))
+ return;
+
+ if (cpu_feature_enabled(X86_FEATURE_SYSCALL32)) {
+ /* Use SYSCALL32 */
+ ret = register_callback(CALLBACKTYPE_syscall32,
+ xen_entry_SYSCALL_compat);
+
+ } else {
+ /* Use SYSENTER32 */
+ ret = register_callback(CALLBACKTYPE_sysenter,
+ xen_entry_SYSENTER_compat);
+ }
+
+ if (ret) {
setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
+ setup_clear_cpu_cap(X86_FEATURE_SYSFAST32);
+ }
}
+
static void __init xen_pvmmu_arch_setup(void)
{
HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
@@ -1022,7 +1031,6 @@ static void __init xen_pvmmu_arch_setup(void)
register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback))
BUG();
- xen_enable_sysenter();
xen_enable_syscall();
}
diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
index 9bb8ff8bff30..c40f326f0c3a 100644
--- a/arch/x86/xen/smp_pv.c
+++ b/arch/x86/xen/smp_pv.c
@@ -65,10 +65,9 @@ static void cpu_bringup(void)
touch_softlockup_watchdog();
/* PVH runs in ring 0 and allows us to do native syscalls. Yay! */
- if (!xen_feature(XENFEAT_supervisor_mode_kernel)) {
- xen_enable_sysenter();
+ if (!xen_feature(XENFEAT_supervisor_mode_kernel))
xen_enable_syscall();
- }
+
cpu = smp_processor_id();
identify_secondary_cpu(cpu);
set_cpu_sibling_map(cpu);
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 090349baec09..f6c331b20fad 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -60,7 +60,6 @@ phys_addr_t __init xen_find_free_area(phys_addr_t size);
char * __init xen_memory_setup(void);
void __init xen_arch_setup(void);
void xen_banner(void);
-void xen_enable_sysenter(void);
void xen_enable_syscall(void);
void xen_vcpu_restore(void);
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:26:03 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
- Separate out the vdso sources into common, vdso32, and vdso64
directories.
- Build the 32- and 64-bit vdsos in their respective subdirectories;
this greatly simplifies the build flags handling.
- Unify the mangling of Makefile flags between the 32- and 64-bit
vdso code as much as possible; all common rules are put in
arch/x86/entry/vdso/common/Makefile.include. The remaining
is very simple for 32 bits; the 64-bit one is only slightly more
complicated because it contains the x32 generation rule.
- Define __DISABLE_EXPORTS when building the vdso. This need seems to
have been masked by different ordering compile flags before.
- Change CONFIG_X86_64 to BUILD_VDSO32_64 in vdso32/system_call.S,
to make it compatible with including fake_32bit_build.h.
- The -fcf-protection= option was "leaking" from the kernel build,
for reasons that was not clear to me. Futhermore, several
distributions ship with it set to a default value other than
"-fcf-protection=none". Make it match the configuration options
for *user space*.
Note that this patch may seem large, but the vast majority of it is
simply code movement.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/Makefile | 161 +-----------------
arch/x86/entry/vdso/common/Makefile.include | 89 ++++++++++
.../entry/vdso/{vdso-note.S => common/note.S} | 5 +-
.../entry/vdso/{ => common}/vclock_gettime.c | 0
.../entry/vdso/{ => common}/vdso-layout.lds.S | 0
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/system_call.S | 2 +-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 +++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
.../x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
21 files changed, 180 insertions(+), 186 deletions(-)
create mode 100644 arch/x86/entry/vdso/common/Makefile.include
rename arch/x86/entry/vdso/{vdso-note.S => common/note.S} (62%)
rename arch/x86/entry/vdso/{ => common}/vclock_gettime.c (100%)
rename arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S (100%)
rename arch/x86/entry/vdso/{ => common}/vgetcpu.c (100%)
create mode 100644 arch/x86/entry/vdso/vdso32/Makefile
create mode 100644 arch/x86/entry/vdso/vdso64/Makefile
create mode 100644 arch/x86/entry/vdso/vdso64/note.S
create mode 100644 arch/x86/entry/vdso/vdso64/vclock_gettime.c
rename arch/x86/entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} (94%)
rename arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S (92%)
create mode 100644 arch/x86/entry/vdso/vdso64/vgetcpu.c
rename arch/x86/entry/vdso/{ => vdso64}/vgetrandom-chacha.S (100%)
rename arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c (91%)
rename arch/x86/entry/vdso/{ => vdso64}/vsgx.S (100%)
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 3d9b09f00c70..987b43fd4cd3 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -3,159 +3,10 @@
# Building vDSO images for x86.
#
-# Include the generic Makefile to check the built vDSO:
-include $(srctree)/lib/vdso/Makefile.include
+# Regular kernel objects
+obj-y := vma.o extable.o
+obj-$(CONFIG_COMPAT_32) += vdso32-setup.o
-# Files to link into the vDSO:
-vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vgetrandom.o vgetrandom-chacha.o
-vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
-vobjs32-y += vdso32/vclock_gettime.o vdso32/vgetcpu.o
-vobjs-$(CONFIG_X86_SGX) += vsgx.o
-
-# Files to link into the kernel:
-obj-y += vma.o extable.o
-
-# vDSO images to build:
-obj-$(CONFIG_X86_64) += vdso64-image.o
-obj-$(CONFIG_X86_X32_ABI) += vdsox32-image.o
-obj-$(CONFIG_COMPAT_32) += vdso32-image.o vdso32-setup.o
-
-vobjs := $(addprefix $(obj)/, $(vobjs-y))
-vobjs32 := $(addprefix $(obj)/, $(vobjs32-y))
-
-$(obj)/vdso.o: $(obj)/vdso.so
-
-targets += vdso.lds $(vobjs-y)
-targets += vdso32/vdso32.lds $(vobjs32-y)
-
-targets += $(foreach x, 64 x32 32, vdso-image-$(x).c vdso$(x).so vdso$(x).so.dbg)
-
-CPPFLAGS_vdso.lds += -P -C
-
-VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 \
- -z max-page-size=4096
-
-$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
- $(call if_changed,vdso_and_check)
-
-VDSO2C = $(objtree)/arch/x86/tools/vdso2c
-
-quiet_cmd_vdso2c = VDSO2C $@
- cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
-
-$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(VDSO2C) FORCE
- $(call if_changed,vdso2c)
-
-#
-# Don't omit frame pointers for ease of userspace debugging, but do
-# optimize sibling calls.
-#
-CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
- $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
- -fno-omit-frame-pointer -foptimize-sibling-calls \
- -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
-
-ifdef CONFIG_MITIGATION_RETPOLINE
-ifneq ($(RETPOLINE_VDSO_CFLAGS),)
- CFL += $(RETPOLINE_VDSO_CFLAGS)
-endif
-endif
-
-$(vobjs): KBUILD_CFLAGS := $(filter-out $(PADDING_CFLAGS) $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) $(RANDSTRUCT_CFLAGS) $(KSTACK_ERASE_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
-$(vobjs): KBUILD_AFLAGS += -DBUILD_VDSO
-
-#
-# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
-#
-CFLAGS_REMOVE_vclock_gettime.o = -pg
-CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
-CFLAGS_REMOVE_vgetcpu.o = -pg
-CFLAGS_REMOVE_vdso32/vgetcpu.o = -pg
-CFLAGS_REMOVE_vsgx.o = -pg
-CFLAGS_REMOVE_vgetrandom.o = -pg
-
-#
-# X32 processes use x32 vDSO to access 64bit kernel data.
-#
-# Build x32 vDSO image:
-# 1. Compile x32 vDSO as 64bit.
-# 2. Convert object files to x32.
-# 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
-# so that it can reach 64bit address space with 64bit pointers.
-#
-
-CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \
- -z max-page-size=4096
-
-# x32-rebranded versions
-vobjx32s-y := $(vobjs-y:.o=-x32.o)
-
-# same thing, but in the output directory
-vobjx32s := $(addprefix $(obj)/, $(vobjx32s-y))
-
-# Convert 64bit object file to x32 for x32 vDSO.
-quiet_cmd_x32 = X32 $@
- cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@
-
-$(obj)/%-x32.o: $(obj)/%.o FORCE
- $(call if_changed,x32)
-
-targets += vdsox32.lds $(vobjx32s-y)
-
-$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section __ex_table
-$(obj)/%.so: $(obj)/%.so.dbg FORCE
- $(call if_changed,objcopy)
-
-$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
- $(call if_changed,vdso_and_check)
-
-CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
-
-KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
-$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
-$(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32
-
-KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
-KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(KSTACK_ERASE_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_CFI),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(PADDING_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic
-KBUILD_CFLAGS_32 += -fno-stack-protector
-KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
-KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
-KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
-KBUILD_CFLAGS_32 += -DBUILD_VDSO
-
-ifdef CONFIG_MITIGATION_RETPOLINE
-ifneq ($(RETPOLINE_VDSO_CFLAGS),)
- KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS)
-endif
-endif
-
-$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
-
-$(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE
- $(call if_changed,vdso_and_check)
-
-#
-# The DSO images are built using a special linker script.
-#
-quiet_cmd_vdso = VDSO $@
- cmd_vdso = $(LD) -o $@ \
- $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
- -T $(filter %.lds,$^) $(filter %.o,$^)
-
-VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 --no-undefined \
- $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack
-
-quiet_cmd_vdso_and_check = VDSO $@
- cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
+# vDSO directories
+obj-$(CONFIG_X86_64) += vdso64/
+obj-$(CONFIG_COMPAT_32) += vdso32/
diff --git a/arch/x86/entry/vdso/common/Makefile.include b/arch/x86/entry/vdso/common/Makefile.include
new file mode 100644
index 000000000000..3514b4a6869b
--- /dev/null
+++ b/arch/x86/entry/vdso/common/Makefile.include
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Building vDSO images for x86.
+#
+
+# Include the generic Makefile to check the built vDSO:
+include $(srctree)/lib/vdso/Makefile.include
+
+obj-y += $(foreach x,$(vdsos-y),vdso$(x)-image.o)
+
+targets += $(foreach x,$(vdsos-y),vdso$(x)-image.c vdso$(x).so vdso$(x).so.dbg vdso$(x).lds)
+targets += $(vobjs-y)
+
+# vobjs-y with $(obj)/ prepended
+vobjs := $(addprefix $(obj)/,$(vobjs-y))
+
+# Options for vdso*.lds
+CPPFLAGS_VDSO_LDS := -P -C -I$(src)/..
+$(obj)/%.lds : KBUILD_CPPFLAGS += $(CPPFLAGS_VDSO_LDS)
+
+#
+# Options from KBUILD_[AC]FLAGS that should *NOT* be kept
+#
+flags-remove-y += \
+ -D__KERNEL__ -mcmodel=kernel -mregparm=3 \
+ -fno-pic -fno-PIC -fno-pie fno-PIE \
+ -mfentry -pg \
+ $(RANDSTRUCT_CFLAGS) $(GCC_PLUGIN_CFLAGS) $(KSTACK_ERASE_CFLAGS) \
+ $(RETPOLINE_CFLAGS) $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \
+ $(PADDING_CFLAGS)
+
+#
+# Don't omit frame pointers for ease of userspace debugging, but do
+# optimize sibling calls.
+#
+flags-y += -D__DISABLE_EXPORTS
+flags-y += -DDISABLE_BRANCH_PROFILING
+flags-y += -DBUILD_VDSO
+flags-y += -I$(src)/.. -I$(srctree)
+flags-y += -O2 -fpic
+flags-y += -fno-stack-protector
+flags-y += -fno-omit-frame-pointer
+flags-y += -foptimize-sibling-calls
+flags-y += -fasynchronous-unwind-tables
+
+# Reset cf protections enabled by compiler default
+flags-y += $(call cc-option, -fcf-protection=none)
+flags-$(X86_USER_SHADOW_STACK) += $(call cc-option, -fcf-protection=return)
+# When user space IBT is supported, enable this.
+# flags-$(CONFIG_USER_IBT) += $(call cc-option, -fcf-protection=branch)
+
+flags-$(CONFIG_MITIGATION_RETPOLINE) += $(RETPOLINE_VDSO_CFLAGS)
+
+# These need to be conditional on $(vobjs) as they do not apply to
+# the output vdso*-image.o files which are standard kernel objects.
+$(vobjs) : KBUILD_AFLAGS := \
+ $(filter-out $(flags-remove-y),$(KBUILD_AFLAGS)) $(flags-y)
+$(vobjs) : KBUILD_CFLAGS := \
+ $(filter-out $(flags-remove-y),$(KBUILD_CFLAGS)) $(flags-y)
+
+#
+# The VDSO images are built using a special linker script.
+#
+VDSO_LDFLAGS := -shared --hash-style=both --build-id=sha1 --no-undefined \
+ $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack
+
+quiet_cmd_vdso = VDSO $@
+ cmd_vdso = $(LD) -o $@ \
+ $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$*) \
+ -T $(filter %.lds,$^) $(filter %.o,$^)
+quiet_cmd_vdso_and_check = VDSO $@
+ cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
+
+$(obj)/vdso%.so.dbg: $(obj)/vdso%.lds FORCE
+ $(call if_changed,vdso_and_check)
+
+$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section __ex_table
+$(obj)/%.so: $(obj)/%.so.dbg FORCE
+ $(call if_changed,objcopy)
+
+VDSO2C = $(objtree)/arch/x86/tools/vdso2c
+
+quiet_cmd_vdso2c = VDSO2C $@
+ cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
+
+$(obj)/%-image.c: $(obj)/%.so.dbg $(obj)/%.so $(VDSO2C) FORCE
+ $(call if_changed,vdso2c)
+
+$(obj)/%-image.o: $(obj)/%-image.c
diff --git a/arch/x86/entry/vdso/vdso-note.S b/arch/x86/entry/vdso/common/note.S
similarity index 62%
rename from arch/x86/entry/vdso/vdso-note.S
rename to arch/x86/entry/vdso/common/note.S
index 79423170118f..2cbd39939dc6 100644
--- a/arch/x86/entry/vdso/vdso-note.S
+++ b/arch/x86/entry/vdso/common/note.S
@@ -1,13 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
* Here we can supply some information useful to userland.
*/
#include <linux/build-salt.h>
-#include <linux/uts.h>
#include <linux/version.h>
#include <linux/elfnote.h>
+/* Ideally this would use UTS_NAME, but using a quoted string here
+ doesn't work. Remember to change this when changing the
+ kernel's name. */
ELFNOTE_START(Linux, 0, "a")
.long LINUX_VERSION_CODE
ELFNOTE_END
diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/common/vclock_gettime.c
similarity index 100%
rename from arch/x86/entry/vdso/vclock_gettime.c
rename to arch/x86/entry/vdso/common/vclock_gettime.c
diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/common/vdso-layout.lds.S
similarity index 100%
rename from arch/x86/entry/vdso/vdso-layout.lds.S
rename to arch/x86/entry/vdso/common/vdso-layout.lds.S
diff --git a/arch/x86/entry/vdso/vgetcpu.c b/arch/x86/entry/vdso/common/vgetcpu.c
similarity index 100%
rename from arch/x86/entry/vdso/vgetcpu.c
rename to arch/x86/entry/vdso/common/vgetcpu.c
diff --git a/arch/x86/entry/vdso/vdso32/Makefile b/arch/x86/entry/vdso/vdso32/Makefile
new file mode 100644
index 000000000000..add6afb484ba
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso32/Makefile
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# 32-bit vDSO images for x86.
+#
+
+# The vDSOs built in this directory
+vdsos-y := 32
+
+# Files to link into the vDSO:
+vobjs-y := note.o vclock_gettime.o vgetcpu.o
+vobjs-y += system_call.o sigreturn.o
+
+# Compilation flags
+flags-y := -DBUILD_VDSO32 -m32 -mregparm=0
+flags-$(CONFIG_X86_64) += -include $(src)/fake_32bit_build.h
+flags-remove-y := -m64
+
+# The location of this include matters!
+include $(src)/../common/Makefile.include
+
+# Linker options for the vdso
+VDSO_LDFLAGS_32 := -m elf_i386 -soname linux-gate.so.1
+
+$(obj)/vdso32.so.dbg: $(vobjs)
diff --git a/arch/x86/entry/vdso/vdso32/note.S b/arch/x86/entry/vdso/vdso32/note.S
index 2cbd39939dc6..62d8aa51ce99 100644
--- a/arch/x86/entry/vdso/vdso32/note.S
+++ b/arch/x86/entry/vdso/vdso32/note.S
@@ -1,18 +1 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
- * Here we can supply some information useful to userland.
- */
-
-#include <linux/build-salt.h>
-#include <linux/version.h>
-#include <linux/elfnote.h>
-
-/* Ideally this would use UTS_NAME, but using a quoted string here
- doesn't work. Remember to change this when changing the
- kernel's name. */
-ELFNOTE_START(Linux, 0, "a")
- .long LINUX_VERSION_CODE
-ELFNOTE_END
-
-BUILD_SALT
+#include "common/note.S"
diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso/vdso32/system_call.S
index d33c6513fd2c..2a15634bbe75 100644
--- a/arch/x86/entry/vdso/vdso32/system_call.S
+++ b/arch/x86/entry/vdso/vdso32/system_call.S
@@ -52,7 +52,7 @@ __kernel_vsyscall:
#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
-#ifdef CONFIG_X86_64
+#ifdef BUILD_VDSO32_64
/* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \
SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
diff --git a/arch/x86/entry/vdso/vdso32/vclock_gettime.c b/arch/x86/entry/vdso/vdso32/vclock_gettime.c
index 86981decfea8..1481f0021b9f 100644
--- a/arch/x86/entry/vdso/vdso32/vclock_gettime.c
+++ b/arch/x86/entry/vdso/vdso32/vclock_gettime.c
@@ -1,4 +1 @@
-// SPDX-License-Identifier: GPL-2.0
-#define BUILD_VDSO32
-#include "fake_32bit_build.h"
-#include "../vclock_gettime.c"
+#include "common/vclock_gettime.c"
diff --git a/arch/x86/entry/vdso/vdso32/vdso32.lds.S b/arch/x86/entry/vdso/vdso32/vdso32.lds.S
index 8a3be07006bb..8a853543fc0d 100644
--- a/arch/x86/entry/vdso/vdso32/vdso32.lds.S
+++ b/arch/x86/entry/vdso/vdso32/vdso32.lds.S
@@ -11,7 +11,7 @@
#define BUILD_VDSO32
-#include "../vdso-layout.lds.S"
+#include "common/vdso-layout.lds.S"
/* The ELF entry point can be used to set the AT_SYSINFO value. */
ENTRY(__kernel_vsyscall);
diff --git a/arch/x86/entry/vdso/vdso32/vgetcpu.c b/arch/x86/entry/vdso/vdso32/vgetcpu.c
index 3a9791f5e998..00cc8325a020 100644
--- a/arch/x86/entry/vdso/vdso32/vgetcpu.c
+++ b/arch/x86/entry/vdso/vdso32/vgetcpu.c
@@ -1,3 +1 @@
-// SPDX-License-Identifier: GPL-2.0
-#include "fake_32bit_build.h"
-#include "../vgetcpu.c"
+#include "common/vgetcpu.c"
diff --git a/arch/x86/entry/vdso/vdso64/Makefile b/arch/x86/entry/vdso/vdso64/Makefile
new file mode 100644
index 000000000000..bfffaf1aeecc
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/Makefile
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# 64-bit vDSO images for x86.
+#
+
+# The vDSOs built in this directory
+vdsos-y := 64
+vdsos-$(CONFIG_X86_X32_ABI) += x32
+
+# Files to link into the vDSO:
+vobjs-y := note.o vclock_gettime.o vgetcpu.o
+vobjs-y += vgetrandom.o vgetrandom-chacha.o
+vobjs-$(CONFIG_X86_SGX) += vsgx.o
+
+# Compilation flags
+flags-y := -DBUILD_VDSO64 -m64 -mcmodel=small
+
+# The location of this include matters!
+include $(src)/../common/Makefile.include
+
+#
+# X32 processes use x32 vDSO to access 64bit kernel data.
+#
+# Build x32 vDSO image:
+# 1. Compile x32 vDSO as 64bit.
+# 2. Convert object files to x32.
+# 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
+# so that it can reach 64bit address space with 64bit pointers.
+#
+
+# Convert 64bit object file to x32 for x32 vDSO.
+quiet_cmd_x32 = X32 $@
+ cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@
+
+$(obj)/%-x32.o: $(obj)/%.o FORCE
+ $(call if_changed,x32)
+
+vobjsx32 = $(patsubst %.o,%-x32.o,$(vobjs))
+targets += $(patsubst %.o,%-x32.o,$(vobjs-y))
+
+# Linker options for the vdso
+VDSO_LDFLAGS_64 := -m elf_x86_64 -soname linux-vdso.so.1 -z max-page-size=4096
+VDSO_LDFLAGS_x32 := $(subst elf_x86_64,elf32_x86_64,$(VDSO_LDFLAGS_64))
+
+$(obj)/vdso64.so.dbg: $(vobjs)
+$(obj)/vdsox32.so.dbg: $(vobjsx32)
diff --git a/arch/x86/entry/vdso/vdso64/note.S b/arch/x86/entry/vdso/vdso64/note.S
new file mode 100644
index 000000000000..62d8aa51ce99
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/note.S
@@ -0,0 +1 @@
+#include "common/note.S"
diff --git a/arch/x86/entry/vdso/vdso64/vclock_gettime.c b/arch/x86/entry/vdso/vdso64/vclock_gettime.c
new file mode 100644
index 000000000000..1481f0021b9f
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vclock_gettime.c
@@ -0,0 +1 @@
+#include "common/vclock_gettime.c"
diff --git a/arch/x86/entry/vdso/vdso.lds.S b/arch/x86/entry/vdso/vdso64/vdso64.lds.S
similarity index 94%
rename from arch/x86/entry/vdso/vdso.lds.S
rename to arch/x86/entry/vdso/vdso64/vdso64.lds.S
index 0bab5f4af6d1..5ce3f2b6373a 100644
--- a/arch/x86/entry/vdso/vdso.lds.S
+++ b/arch/x86/entry/vdso/vdso64/vdso64.lds.S
@@ -9,7 +9,7 @@
#define BUILD_VDSO64
-#include "vdso-layout.lds.S"
+#include "common/vdso-layout.lds.S"
/*
* This controls what userland symbols we export from the vDSO.
diff --git a/arch/x86/entry/vdso/vdsox32.lds.S b/arch/x86/entry/vdso/vdso64/vdsox32.lds.S
similarity index 92%
rename from arch/x86/entry/vdso/vdsox32.lds.S
rename to arch/x86/entry/vdso/vdso64/vdsox32.lds.S
index 16a8050a4fb6..3dbd20c8dacc 100644
--- a/arch/x86/entry/vdso/vdsox32.lds.S
+++ b/arch/x86/entry/vdso/vdso64/vdsox32.lds.S
@@ -9,7 +9,7 @@
#define BUILD_VDSOX32
-#include "vdso-layout.lds.S"
+#include "common/vdso-layout.lds.S"
/*
* This controls what userland symbols we export from the vDSO.
diff --git a/arch/x86/entry/vdso/vdso64/vgetcpu.c b/arch/x86/entry/vdso/vdso64/vgetcpu.c
new file mode 100644
index 000000000000..00cc8325a020
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vgetcpu.c
@@ -0,0 +1 @@
+#include "common/vgetcpu.c"
diff --git a/arch/x86/entry/vdso/vgetrandom-chacha.S b/arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S
similarity index 100%
rename from arch/x86/entry/vdso/vgetrandom-chacha.S
rename to arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S
diff --git a/arch/x86/entry/vdso/vgetrandom.c b/arch/x86/entry/vdso/vdso64/vgetrandom.c
similarity index 91%
rename from arch/x86/entry/vdso/vgetrandom.c
rename to arch/x86/entry/vdso/vdso64/vgetrandom.c
index 430862b8977c..6a95d36b12d9 100644
--- a/arch/x86/entry/vdso/vgetrandom.c
+++ b/arch/x86/entry/vdso/vdso64/vgetrandom.c
@@ -4,7 +4,7 @@
*/
#include <linux/types.h>
-#include "../../../../lib/vdso/getrandom.c"
+#include "lib/vdso/getrandom.c"
ssize_t __vdso_getrandom(void *buffer, size_t len, unsigned int flags, void *opaque_state, size_t opaque_len)
{
diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vdso64/vsgx.S
similarity index 100%
rename from arch/x86/entry/vdso/vsgx.S
rename to arch/x86/entry/vdso/vdso64/vsgx.S
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 16 Dec 2025 13:25:57 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
On Tue, Dec 16, 2025 at 4:26 PM H. Peter Anvin <hpa@zytor.com> wrote:
Do we even still support the old linkers that need these constants?
Brian Gerst
|
{
"author": "Brian Gerst <brgerst@gmail.com>",
"date": "Wed, 17 Dec 2025 21:16:08 -0500",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
On Wed, Dec 17, 2025 at 9:16 PM Brian Gerst <brgerst@gmail.com> wrote:
Digging into the binutils source, PT_GNU_EH_FRAME and PT_GNU_STACK
were added to the parser around bintils-2.15. PT_GNU_PROPERTY was
added in binutils-2.38, which is newer than the minimum supported
version of binutils-2.30.
Probably better to just leave them then.
Brian Gerst
|
{
"author": "Brian Gerst <brgerst@gmail.com>",
"date": "Thu, 18 Dec 2025 01:56:49 -0500",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
On Tue, Dec 16, 2025 at 10:26 PM H. Peter Anvin <hpa@zytor.com> wrote:
Acked-by: Uros Bizjak <ubizjak@gmail.com>
|
{
"author": "Uros Bizjak <ubizjak@gmail.com>",
"date": "Tue, 6 Jan 2026 19:09:48 +0100",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
When neither sysenter32 nor syscall32 is available (on either
FRED-capable 64-bit hardware or old 32-bit hardware), there is no
reason to do a bunch of stack shuffling in __kernel_vsyscall.
Unfortunately, just overwriting the initial "push" instructions will
mess up the CFI annotations, so suffer the 3-byte NOP if not
applicable.
Similarly, inline the int $0x80 when doing inline system calls in the
vdso instead of calling __kernel_vsyscall.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/vdso32/system_call.S | 18 ++++++++++++++----
arch/x86/include/asm/vdso/sys_call.h | 4 +++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso/vdso32/system_call.S
index 7b1c0f16e511..9157cf9c5749 100644
--- a/arch/x86/entry/vdso/vdso32/system_call.S
+++ b/arch/x86/entry/vdso/vdso32/system_call.S
@@ -14,6 +14,18 @@
ALIGN
__kernel_vsyscall:
CFI_STARTPROC
+
+ /*
+ * If using int $0x80, there is no reason to muck about with the
+ * stack here. Unfortunately just overwriting the push instructions
+ * would mess up the CFI annotations, but it is only a 3-byte
+ * NOP in that case. This could be avoided by patching the
+ * vdso symbol table (not the code) and entry point, but that
+ * would a fair bit of tooling work or by simply compiling
+ * two different vDSO images, but that doesn't seem worth it.
+ */
+ ALTERNATIVE "int $0x80; ret", "", X86_FEATURE_SYSFAST32
+
/*
* Reshuffle regs so that all of any of the entry instructions
* will preserve enough state.
@@ -52,11 +64,9 @@ __kernel_vsyscall:
#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
- /* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
- ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSFAST32, \
- SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
+ ALTERNATIVE SYSENTER_SEQUENCE, SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
- /* Enter using int $0x80 */
+ /* Re-enter using int $0x80 */
int $0x80
SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL)
diff --git a/arch/x86/include/asm/vdso/sys_call.h b/arch/x86/include/asm/vdso/sys_call.h
index dcfd17c6dd57..5806b1cd6aef 100644
--- a/arch/x86/include/asm/vdso/sys_call.h
+++ b/arch/x86/include/asm/vdso/sys_call.h
@@ -20,7 +20,9 @@
# define __sys_reg4 "r10"
# define __sys_reg5 "r8"
#else
-# define __sys_instr "call __kernel_vsyscall"
+# define __sys_instr ALTERNATIVE("ds;ds;ds;int $0x80", \
+ "call __kernel_vsyscall", \
+ X86_FEATURE_SYSFAST32)
# define __sys_clobber "memory"
# define __sys_nr(x,y) __NR_ ## x ## y
# define __sys_reg1 "ebx"
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:43 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
Currently the vdso doesn't include .note.gnu.property or a GNU noexec
stack annotation (the -z noexecstack in the linker script is
ineffective because we specify PHDRs explicitly.)
The motivation is that the dynamic linker currently do not check
these.
However, this is a weak excuse: the vdso*.so are also supposed to be
usable at link libraries, and there is no reason why the dynamic
linker might not want or need to check these in the future, so add
them back in -- it is trivial enough.
Use symbolic constants for the PHDR permission flags.
[ v4: drop unrelated formatting changes ]
[ v4.1: drop one last bogus formatting change (Brian Gerst) ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/common/vdso-layout.lds.S | 36 ++++++++++++--------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/arch/x86/entry/vdso/common/vdso-layout.lds.S b/arch/x86/entry/vdso/common/vdso-layout.lds.S
index ec1ac191a057..f050fd723712 100644
--- a/arch/x86/entry/vdso/common/vdso-layout.lds.S
+++ b/arch/x86/entry/vdso/common/vdso-layout.lds.S
@@ -47,18 +47,18 @@ SECTIONS
*(.gnu.linkonce.b.*)
} :text
- /*
- * Discard .note.gnu.property sections which are unused and have
- * different alignment requirement from vDSO note sections.
- */
- /DISCARD/ : {
+ .note.gnu.property : {
*(.note.gnu.property)
- }
- .note : { *(.note.*) } :text :note
-
- .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
- .eh_frame : { KEEP (*(.eh_frame)) } :text
+ } :text :note :gnu_property
+ .note : {
+ *(.note*)
+ } :text :note
+ .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
+ .eh_frame : {
+ KEEP (*(.eh_frame))
+ *(.eh_frame.*)
+ } :text
/*
* Text is well-separated from actual data: there's plenty of
@@ -87,15 +87,23 @@ SECTIONS
* Very old versions of ld do not recognize this name token; use the constant.
*/
#define PT_GNU_EH_FRAME 0x6474e550
+#define PT_GNU_STACK 0x6474e551
+#define PT_GNU_PROPERTY 0x6474e553
/*
* We must supply the ELF program headers explicitly to get just one
* PT_LOAD segment, and set the flags explicitly to make segments read-only.
*/
+#define PF_R FLAGS(4)
+#define PF_RW FLAGS(6)
+#define PF_RX FLAGS(5)
+
PHDRS
{
- text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
- dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
- note PT_NOTE FLAGS(4); /* PF_R */
- eh_frame_hdr PT_GNU_EH_FRAME;
+ text PT_LOAD PF_RX FILEHDR PHDRS;
+ dynamic PT_DYNAMIC PF_R;
+ note PT_NOTE PF_R;
+ eh_frame_hdr PT_GNU_EH_FRAME PF_R;
+ gnu_stack PT_GNU_STACK PF_RW;
+ gnu_property PT_GNU_PROPERTY PF_R;
}
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:40 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
In most cases, the use of "fast 32-bit system call" depends either on
X86_FEATURE_SEP or X86_FEATURE_SYSENTER32 || X86_FEATURE_SYSCALL32.
However, nearly all the logic for both is identical.
Define X86_FEATURE_SYSFAST32 which indicates that *either* SYSENTER32 or
SYSCALL32 should be used, for either 32- or 64-bit kernels. This
defaults to SYSENTER; use SYSCALL if the SYSCALL32 bit is also set.
As this removes ALL existing uses of X86_FEATURE_SYSENTER32, which is
a kernel-only synthetic feature bit, simply remove it and replace it
with X86_FEATURE_SYSFAST32.
This leaves an unused alternative for a true 32-bit kernel, but that
should really not matter in any way.
The clearing of X86_FEATURE_SYSCALL32 can be removed once the patches
for automatically clearing disabled features has been merged.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/Kconfig.cpufeatures | 8 +++++++
arch/x86/entry/vdso/vdso32/system_call.S | 8 ++-----
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/kernel/cpu/centaur.c | 3 ---
arch/x86/kernel/cpu/common.c | 8 +++++++
arch/x86/kernel/cpu/intel.c | 4 +---
arch/x86/kernel/cpu/zhaoxin.c | 4 +---
arch/x86/kernel/fred.c | 2 +-
arch/x86/xen/setup.c | 28 +++++++++++++++---------
arch/x86/xen/smp_pv.c | 5 ++---
arch/x86/xen/xen-ops.h | 1 -
11 files changed, 42 insertions(+), 31 deletions(-)
diff --git a/arch/x86/Kconfig.cpufeatures b/arch/x86/Kconfig.cpufeatures
index 733d5aff2456..423ac795baa7 100644
--- a/arch/x86/Kconfig.cpufeatures
+++ b/arch/x86/Kconfig.cpufeatures
@@ -56,6 +56,10 @@ config X86_REQUIRED_FEATURE_MOVBE
def_bool y
depends on MATOM
+config X86_REQUIRED_FEATURE_SYSFAST32
+ def_bool y
+ depends on X86_64 && !X86_FRED
+
config X86_REQUIRED_FEATURE_CPUID
def_bool y
depends on X86_64
@@ -120,6 +124,10 @@ config X86_DISABLED_FEATURE_CENTAUR_MCR
def_bool y
depends on X86_64
+config X86_DISABLED_FEATURE_SYSCALL32
+ def_bool y
+ depends on !X86_64
+
config X86_DISABLED_FEATURE_PCID
def_bool y
depends on !X86_64
diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso/vdso32/system_call.S
index 2a15634bbe75..7b1c0f16e511 100644
--- a/arch/x86/entry/vdso/vdso32/system_call.S
+++ b/arch/x86/entry/vdso/vdso32/system_call.S
@@ -52,13 +52,9 @@ __kernel_vsyscall:
#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
-#ifdef BUILD_VDSO32_64
/* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
- ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \
- SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
-#else
- ALTERNATIVE "", SYSENTER_SEQUENCE, X86_FEATURE_SEP
-#endif
+ ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSFAST32, \
+ SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
/* Enter using int $0x80 */
int $0x80
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index c3b53beb1300..63b0f9aa9b3e 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -84,7 +84,7 @@
#define X86_FEATURE_PEBS ( 3*32+12) /* "pebs" Precise-Event Based Sampling */
#define X86_FEATURE_BTS ( 3*32+13) /* "bts" Branch Trace Store */
#define X86_FEATURE_SYSCALL32 ( 3*32+14) /* syscall in IA32 userspace */
-#define X86_FEATURE_SYSENTER32 ( 3*32+15) /* sysenter in IA32 userspace */
+#define X86_FEATURE_SYSFAST32 ( 3*32+15) /* sysenter/syscall in IA32 userspace */
#define X86_FEATURE_REP_GOOD ( 3*32+16) /* "rep_good" REP microcode works well */
#define X86_FEATURE_AMD_LBR_V2 ( 3*32+17) /* "amd_lbr_v2" AMD Last Branch Record Extension Version 2 */
#define X86_FEATURE_CLEAR_CPU_BUF ( 3*32+18) /* Clear CPU buffers using VERW */
diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index a3b55db35c96..9833f837141c 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -102,9 +102,6 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
(c->x86 >= 7))
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-#ifdef CONFIG_X86_64
- set_cpu_cap(c, X86_FEATURE_SYSENTER32);
-#endif
if (c->x86_power & (1 << 8)) {
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index e7ab22fce3b5..1c3261cae40c 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1068,6 +1068,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
init_scattered_cpuid_features(c);
init_speculation_control(c);
+ if (IS_ENABLED(CONFIG_X86_64) || cpu_has(c, X86_FEATURE_SEP))
+ set_cpu_cap(c, X86_FEATURE_SYSFAST32);
+
/*
* Clear/Set all flags overridden by options, after probe.
* This needs to happen each time we re-probe, which may happen
@@ -1813,6 +1816,11 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
* that it can't be enabled in 32-bit mode.
*/
setup_clear_cpu_cap(X86_FEATURE_PCID);
+
+ /*
+ * Never use SYSCALL on a 32-bit kernel
+ */
+ setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
#endif
/*
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 98ae4c37c93e..646ff33c4651 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -236,9 +236,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
clear_cpu_cap(c, X86_FEATURE_PSE);
}
-#ifdef CONFIG_X86_64
- set_cpu_cap(c, X86_FEATURE_SYSENTER32);
-#else
+#ifndef CONFIG_X86_64
/* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
if (c->x86 == 15 && c->x86_cache_alignment == 64)
c->x86_cache_alignment = 128;
diff --git a/arch/x86/kernel/cpu/zhaoxin.c b/arch/x86/kernel/cpu/zhaoxin.c
index 89b1c8a70fe8..031379b7d4fa 100644
--- a/arch/x86/kernel/cpu/zhaoxin.c
+++ b/arch/x86/kernel/cpu/zhaoxin.c
@@ -59,9 +59,7 @@ static void early_init_zhaoxin(struct cpuinfo_x86 *c)
{
if (c->x86 >= 0x6)
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-#ifdef CONFIG_X86_64
- set_cpu_cap(c, X86_FEATURE_SYSENTER32);
-#endif
+
if (c->x86_power & (1 << 8)) {
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
diff --git a/arch/x86/kernel/fred.c b/arch/x86/kernel/fred.c
index 816187da3a47..e736b19e18de 100644
--- a/arch/x86/kernel/fred.c
+++ b/arch/x86/kernel/fred.c
@@ -68,7 +68,7 @@ void cpu_init_fred_exceptions(void)
idt_invalidate();
/* Use int $0x80 for 32-bit system calls in FRED mode */
- setup_clear_cpu_cap(X86_FEATURE_SYSENTER32);
+ setup_clear_cpu_cap(X86_FEATURE_SYSFAST32);
setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
}
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 3823e52aef52..ac8021c3a997 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -990,13 +990,6 @@ static int register_callback(unsigned type, const void *func)
return HYPERVISOR_callback_op(CALLBACKOP_register, &callback);
}
-void xen_enable_sysenter(void)
-{
- if (cpu_feature_enabled(X86_FEATURE_SYSENTER32) &&
- register_callback(CALLBACKTYPE_sysenter, xen_entry_SYSENTER_compat))
- setup_clear_cpu_cap(X86_FEATURE_SYSENTER32);
-}
-
void xen_enable_syscall(void)
{
int ret;
@@ -1008,11 +1001,27 @@ void xen_enable_syscall(void)
mechanism for syscalls. */
}
- if (cpu_feature_enabled(X86_FEATURE_SYSCALL32) &&
- register_callback(CALLBACKTYPE_syscall32, xen_entry_SYSCALL_compat))
+ if (!cpu_feature_enabled(X86_FEATURE_SYSFAST32))
+ return;
+
+ if (cpu_feature_enabled(X86_FEATURE_SYSCALL32)) {
+ /* Use SYSCALL32 */
+ ret = register_callback(CALLBACKTYPE_syscall32,
+ xen_entry_SYSCALL_compat);
+
+ } else {
+ /* Use SYSENTER32 */
+ ret = register_callback(CALLBACKTYPE_sysenter,
+ xen_entry_SYSENTER_compat);
+ }
+
+ if (ret) {
setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
+ setup_clear_cpu_cap(X86_FEATURE_SYSFAST32);
+ }
}
+
static void __init xen_pvmmu_arch_setup(void)
{
HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
@@ -1022,7 +1031,6 @@ static void __init xen_pvmmu_arch_setup(void)
register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback))
BUG();
- xen_enable_sysenter();
xen_enable_syscall();
}
diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
index 9bb8ff8bff30..c40f326f0c3a 100644
--- a/arch/x86/xen/smp_pv.c
+++ b/arch/x86/xen/smp_pv.c
@@ -65,10 +65,9 @@ static void cpu_bringup(void)
touch_softlockup_watchdog();
/* PVH runs in ring 0 and allows us to do native syscalls. Yay! */
- if (!xen_feature(XENFEAT_supervisor_mode_kernel)) {
- xen_enable_sysenter();
+ if (!xen_feature(XENFEAT_supervisor_mode_kernel))
xen_enable_syscall();
- }
+
cpu = smp_processor_id();
identify_secondary_cpu(cpu);
set_cpu_sibling_map(cpu);
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 090349baec09..f6c331b20fad 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -60,7 +60,6 @@ phys_addr_t __init xen_find_free_area(phys_addr_t size);
char * __init xen_memory_setup(void);
void __init xen_arch_setup(void);
void xen_banner(void);
-void xen_enable_sysenter(void);
void xen_enable_syscall(void);
void xen_vcpu_restore(void);
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:42 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
Abstract out the calling of true system calls from the vdso into
macros.
It has been a very long time since gcc did not allow %ebx or %ebp in
inline asm in 32-bit PIC mode; remove the corresponding hacks.
Remove the use of memory output constraints in gettimeofday.h in favor
of "memory" clobbers. The resulting code is identical for the current
use cases, as the system call is usually a terminal fallback anyway,
and it merely complicates the macroization.
This patch adds only a handful of more lines of code than it removes,
and in fact could be made substantially smaller by removing the macros
for the argument counts that aren't currently used, however, it seems
better to be general from the start.
[ v3: remove stray comment from prototyping; remove VDSO_SYSCALL6()
since it would require special handling on 32 bits and is
currently unused. (Uros Bizjak).
Indent nested preprocessor directives. ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/include/asm/vdso/gettimeofday.h | 108 ++---------------------
arch/x86/include/asm/vdso/sys_call.h | 103 +++++++++++++++++++++
2 files changed, 111 insertions(+), 100 deletions(-)
create mode 100644 arch/x86/include/asm/vdso/sys_call.h
diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h
index 73b2e7ee8f0f..3cf214cc4a75 100644
--- a/arch/x86/include/asm/vdso/gettimeofday.h
+++ b/arch/x86/include/asm/vdso/gettimeofday.h
@@ -18,6 +18,7 @@
#include <asm/msr.h>
#include <asm/pvclock.h>
#include <clocksource/hyperv_timer.h>
+#include <asm/vdso/sys_call.h>
#define VDSO_HAS_TIME 1
@@ -53,130 +54,37 @@ extern struct ms_hyperv_tsc_page hvclock_page
__attribute__((visibility("hidden")));
#endif
-#ifndef BUILD_VDSO32
-
static __always_inline
long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
{
- long ret;
-
- asm ("syscall" : "=a" (ret), "=m" (*_ts) :
- "0" (__NR_clock_gettime), "D" (_clkid), "S" (_ts) :
- "rcx", "r11");
-
- return ret;
+ return VDSO_SYSCALL2(clock_gettime,64,_clkid,_ts);
}
static __always_inline
long gettimeofday_fallback(struct __kernel_old_timeval *_tv,
struct timezone *_tz)
{
- long ret;
-
- asm("syscall" : "=a" (ret) :
- "0" (__NR_gettimeofday), "D" (_tv), "S" (_tz) : "memory");
-
- return ret;
+ return VDSO_SYSCALL2(gettimeofday,,_tv,_tz);
}
static __always_inline
long clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
{
- long ret;
-
- asm ("syscall" : "=a" (ret), "=m" (*_ts) :
- "0" (__NR_clock_getres), "D" (_clkid), "S" (_ts) :
- "rcx", "r11");
-
- return ret;
+ return VDSO_SYSCALL2(clock_getres,_time64,_clkid,_ts);
}
-#else
-
-static __always_inline
-long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
-{
- long ret;
-
- asm (
- "mov %%ebx, %%edx \n"
- "mov %[clock], %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret), "=m" (*_ts)
- : "0" (__NR_clock_gettime64), [clock] "g" (_clkid), "c" (_ts)
- : "edx");
-
- return ret;
-}
+#ifndef CONFIG_X86_64
static __always_inline
long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
{
- long ret;
-
- asm (
- "mov %%ebx, %%edx \n"
- "mov %[clock], %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret), "=m" (*_ts)
- : "0" (__NR_clock_gettime), [clock] "g" (_clkid), "c" (_ts)
- : "edx");
-
- return ret;
-}
-
-static __always_inline
-long gettimeofday_fallback(struct __kernel_old_timeval *_tv,
- struct timezone *_tz)
-{
- long ret;
-
- asm(
- "mov %%ebx, %%edx \n"
- "mov %2, %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret)
- : "0" (__NR_gettimeofday), "g" (_tv), "c" (_tz)
- : "memory", "edx");
-
- return ret;
+ return VDSO_SYSCALL2(clock_gettime,,_clkid,_ts);
}
static __always_inline long
-clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
-{
- long ret;
-
- asm (
- "mov %%ebx, %%edx \n"
- "mov %[clock], %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret), "=m" (*_ts)
- : "0" (__NR_clock_getres_time64), [clock] "g" (_clkid), "c" (_ts)
- : "edx");
-
- return ret;
-}
-
-static __always_inline
-long clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
+clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
{
- long ret;
-
- asm (
- "mov %%ebx, %%edx \n"
- "mov %[clock], %%ebx \n"
- "call __kernel_vsyscall \n"
- "mov %%edx, %%ebx \n"
- : "=a" (ret), "=m" (*_ts)
- : "0" (__NR_clock_getres), [clock] "g" (_clkid), "c" (_ts)
- : "edx");
-
- return ret;
+ return VDSO_SYSCALL2(clock_getres,,_clkid,_ts);
}
#endif
diff --git a/arch/x86/include/asm/vdso/sys_call.h b/arch/x86/include/asm/vdso/sys_call.h
new file mode 100644
index 000000000000..dcfd17c6dd57
--- /dev/null
+++ b/arch/x86/include/asm/vdso/sys_call.h
@@ -0,0 +1,103 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Macros for issuing an inline system call from the vDSO.
+ */
+
+#ifndef X86_ASM_VDSO_SYS_CALL_H
+#define X86_ASM_VDSO_SYS_CALL_H
+
+#include <linux/compiler.h>
+#include <asm/cpufeatures.h>
+#include <asm/alternative.h>
+
+#ifdef CONFIG_X86_64
+# define __sys_instr "syscall"
+# define __sys_clobber "rcx", "r11", "memory"
+# define __sys_nr(x,y) __NR_ ## x
+# define __sys_reg1 "rdi"
+# define __sys_reg2 "rsi"
+# define __sys_reg3 "rdx"
+# define __sys_reg4 "r10"
+# define __sys_reg5 "r8"
+#else
+# define __sys_instr "call __kernel_vsyscall"
+# define __sys_clobber "memory"
+# define __sys_nr(x,y) __NR_ ## x ## y
+# define __sys_reg1 "ebx"
+# define __sys_reg2 "ecx"
+# define __sys_reg3 "edx"
+# define __sys_reg4 "esi"
+# define __sys_reg5 "edi"
+#endif
+
+/*
+ * Example usage:
+ *
+ * result = VDSO_SYSCALL3(foo,64,x,y,z);
+ *
+ * ... calls foo(x,y,z) on 64 bits, and foo64(x,y,z) on 32 bits.
+ *
+ * VDSO_SYSCALL6() is currently missing, because it would require
+ * special handling for %ebp on 32 bits when the vdso is compiled with
+ * frame pointers enabled (the default on 32 bits.) Add it as a special
+ * case when and if it becomes necessary.
+ */
+#define _VDSO_SYSCALL(name,suf32,...) \
+ ({ \
+ long _sys_num_ret = __sys_nr(name,suf32); \
+ asm_inline volatile( \
+ __sys_instr \
+ : "+a" (_sys_num_ret) \
+ : __VA_ARGS__ \
+ : __sys_clobber); \
+ _sys_num_ret; \
+ })
+
+#define VDSO_SYSCALL0(name,suf32) \
+ _VDSO_SYSCALL(name,suf32)
+#define VDSO_SYSCALL1(name,suf32,a1) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1)); \
+ })
+#define VDSO_SYSCALL2(name,suf32,a1,a2) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ register long _sys_arg2 asm(__sys_reg2) = (long)(a2); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1), "r" (_sys_arg2)); \
+ })
+#define VDSO_SYSCALL3(name,suf32,a1,a2,a3) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ register long _sys_arg2 asm(__sys_reg2) = (long)(a2); \
+ register long _sys_arg3 asm(__sys_reg3) = (long)(a3); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1), "r" (_sys_arg2), \
+ "r" (_sys_arg3)); \
+ })
+#define VDSO_SYSCALL4(name,suf32,a1,a2,a3,a4) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ register long _sys_arg2 asm(__sys_reg2) = (long)(a2); \
+ register long _sys_arg3 asm(__sys_reg3) = (long)(a3); \
+ register long _sys_arg4 asm(__sys_reg4) = (long)(a4); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1), "r" (_sys_arg2), \
+ "r" (_sys_arg3), "r" (_sys_arg4)); \
+ })
+#define VDSO_SYSCALL5(name,suf32,a1,a2,a3,a4,a5) \
+ ({ \
+ register long _sys_arg1 asm(__sys_reg1) = (long)(a1); \
+ register long _sys_arg2 asm(__sys_reg2) = (long)(a2); \
+ register long _sys_arg3 asm(__sys_reg3) = (long)(a3); \
+ register long _sys_arg4 asm(__sys_reg4) = (long)(a4); \
+ register long _sys_arg5 asm(__sys_reg5) = (long)(a5); \
+ _VDSO_SYSCALL(name,suf32, \
+ "r" (_sys_arg1), "r" (_sys_arg2), \
+ "r" (_sys_arg3), "r" (_sys_arg4), \
+ "r" (_sys_arg5)); \
+ })
+
+#endif /* X86_VDSO_SYS_CALL_H */
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:41 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
The vdso32 sigreturn.S contains open-coded DWARF bytecode, which
includes a hack for gdb to not try to step back to a previous call
instruction when backtracing from a signal handler.
Neither of those are necessary anymore: the backtracing issue is
handled by ".cfi_entry simple" and ".cfi_signal_frame", both of which
have been supported for a very long time now, which allows the
remaining frame to be built using regular .cfi annotations.
Add a few more register offsets to the signal frame just for good
measure.
Replace the nop on fallthrough of the system call (which should never,
ever happen) with a ud2a trap.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/vdso32/sigreturn.S | 146 ++++++-------------------
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/kernel/asm-offsets.c | 6 +
3 files changed, 39 insertions(+), 114 deletions(-)
diff --git a/arch/x86/entry/vdso/vdso32/sigreturn.S b/arch/x86/entry/vdso/vdso32/sigreturn.S
index 965900c6763b..25b0ac4b4bfe 100644
--- a/arch/x86/entry/vdso/vdso32/sigreturn.S
+++ b/arch/x86/entry/vdso/vdso32/sigreturn.S
@@ -1,136 +1,54 @@
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/linkage.h>
#include <asm/unistd_32.h>
+#include <asm/dwarf2.h>
#include <asm/asm-offsets.h>
+.macro STARTPROC_SIGNAL_FRAME sc
+ CFI_STARTPROC simple
+ CFI_SIGNAL_FRAME
+ /* -4 as pretcode has already been popped */
+ CFI_DEF_CFA esp, \sc - 4
+ CFI_OFFSET eip, IA32_SIGCONTEXT_ip
+ CFI_OFFSET eax, IA32_SIGCONTEXT_ax
+ CFI_OFFSET ebx, IA32_SIGCONTEXT_bx
+ CFI_OFFSET ecx, IA32_SIGCONTEXT_cx
+ CFI_OFFSET edx, IA32_SIGCONTEXT_dx
+ CFI_OFFSET esp, IA32_SIGCONTEXT_sp
+ CFI_OFFSET ebp, IA32_SIGCONTEXT_bp
+ CFI_OFFSET esi, IA32_SIGCONTEXT_si
+ CFI_OFFSET edi, IA32_SIGCONTEXT_di
+ CFI_OFFSET es, IA32_SIGCONTEXT_es
+ CFI_OFFSET cs, IA32_SIGCONTEXT_cs
+ CFI_OFFSET ss, IA32_SIGCONTEXT_ss
+ CFI_OFFSET ds, IA32_SIGCONTEXT_ds
+ CFI_OFFSET eflags, IA32_SIGCONTEXT_flags
+.endm
+
.text
.globl __kernel_sigreturn
.type __kernel_sigreturn,@function
- nop /* this guy is needed for .LSTARTFDEDLSI1 below (watch for HACK) */
ALIGN
__kernel_sigreturn:
-.LSTART_sigreturn:
- popl %eax /* XXX does this mean it needs unwind info? */
+ STARTPROC_SIGNAL_FRAME IA32_SIGFRAME_sigcontext
+ popl %eax
+ CFI_ADJUST_CFA_OFFSET -4
movl $__NR_sigreturn, %eax
int $0x80
-.LEND_sigreturn:
SYM_INNER_LABEL(vdso32_sigreturn_landing_pad, SYM_L_GLOBAL)
- nop
- .size __kernel_sigreturn,.-.LSTART_sigreturn
+ ud2a
+ CFI_ENDPROC
+ .size __kernel_sigreturn,.-__kernel_sigreturn
.globl __kernel_rt_sigreturn
.type __kernel_rt_sigreturn,@function
ALIGN
__kernel_rt_sigreturn:
-.LSTART_rt_sigreturn:
+ STARTPROC_SIGNAL_FRAME IA32_RT_SIGFRAME_sigcontext
movl $__NR_rt_sigreturn, %eax
int $0x80
-.LEND_rt_sigreturn:
SYM_INNER_LABEL(vdso32_rt_sigreturn_landing_pad, SYM_L_GLOBAL)
- nop
- .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
- .previous
-
- .section .eh_frame,"a",@progbits
-.LSTARTFRAMEDLSI1:
- .long .LENDCIEDLSI1-.LSTARTCIEDLSI1
-.LSTARTCIEDLSI1:
- .long 0 /* CIE ID */
- .byte 1 /* Version number */
- .string "zRS" /* NUL-terminated augmentation string */
- .uleb128 1 /* Code alignment factor */
- .sleb128 -4 /* Data alignment factor */
- .byte 8 /* Return address register column */
- .uleb128 1 /* Augmentation value length */
- .byte 0x1b /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
- .byte 0 /* DW_CFA_nop */
- .align 4
-.LENDCIEDLSI1:
- .long .LENDFDEDLSI1-.LSTARTFDEDLSI1 /* Length FDE */
-.LSTARTFDEDLSI1:
- .long .LSTARTFDEDLSI1-.LSTARTFRAMEDLSI1 /* CIE pointer */
- /* HACK: The dwarf2 unwind routines will subtract 1 from the
- return address to get an address in the middle of the
- presumed call instruction. Since we didn't get here via
- a call, we need to include the nop before the real start
- to make up for it. */
- .long .LSTART_sigreturn-1-. /* PC-relative start address */
- .long .LEND_sigreturn-.LSTART_sigreturn+1
- .uleb128 0 /* Augmentation */
- /* What follows are the instructions for the table generation.
- We record the locations of each register saved. This is
- complicated by the fact that the "CFA" is always assumed to
- be the value of the stack pointer in the caller. This means
- that we must define the CFA of this body of code to be the
- saved value of the stack pointer in the sigcontext. Which
- also means that there is no fixed relation to the other
- saved registers, which means that we must use DW_CFA_expression
- to compute their addresses. It also means that when we
- adjust the stack with the popl, we have to do it all over again. */
-
-#define do_cfa_expr(offset) \
- .byte 0x0f; /* DW_CFA_def_cfa_expression */ \
- .uleb128 1f-0f; /* length */ \
-0: .byte 0x74; /* DW_OP_breg4 */ \
- .sleb128 offset; /* offset */ \
- .byte 0x06; /* DW_OP_deref */ \
-1:
-
-#define do_expr(regno, offset) \
- .byte 0x10; /* DW_CFA_expression */ \
- .uleb128 regno; /* regno */ \
- .uleb128 1f-0f; /* length */ \
-0: .byte 0x74; /* DW_OP_breg4 */ \
- .sleb128 offset; /* offset */ \
-1:
-
- do_cfa_expr(IA32_SIGCONTEXT_sp+4)
- do_expr(0, IA32_SIGCONTEXT_ax+4)
- do_expr(1, IA32_SIGCONTEXT_cx+4)
- do_expr(2, IA32_SIGCONTEXT_dx+4)
- do_expr(3, IA32_SIGCONTEXT_bx+4)
- do_expr(5, IA32_SIGCONTEXT_bp+4)
- do_expr(6, IA32_SIGCONTEXT_si+4)
- do_expr(7, IA32_SIGCONTEXT_di+4)
- do_expr(8, IA32_SIGCONTEXT_ip+4)
-
- .byte 0x42 /* DW_CFA_advance_loc 2 -- nop; popl eax. */
-
- do_cfa_expr(IA32_SIGCONTEXT_sp)
- do_expr(0, IA32_SIGCONTEXT_ax)
- do_expr(1, IA32_SIGCONTEXT_cx)
- do_expr(2, IA32_SIGCONTEXT_dx)
- do_expr(3, IA32_SIGCONTEXT_bx)
- do_expr(5, IA32_SIGCONTEXT_bp)
- do_expr(6, IA32_SIGCONTEXT_si)
- do_expr(7, IA32_SIGCONTEXT_di)
- do_expr(8, IA32_SIGCONTEXT_ip)
-
- .align 4
-.LENDFDEDLSI1:
-
- .long .LENDFDEDLSI2-.LSTARTFDEDLSI2 /* Length FDE */
-.LSTARTFDEDLSI2:
- .long .LSTARTFDEDLSI2-.LSTARTFRAMEDLSI1 /* CIE pointer */
- /* HACK: See above wrt unwind library assumptions. */
- .long .LSTART_rt_sigreturn-1-. /* PC-relative start address */
- .long .LEND_rt_sigreturn-.LSTART_rt_sigreturn+1
- .uleb128 0 /* Augmentation */
- /* What follows are the instructions for the table generation.
- We record the locations of each register saved. This is
- slightly less complicated than the above, since we don't
- modify the stack pointer in the process. */
-
- do_cfa_expr(IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_sp)
- do_expr(0, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ax)
- do_expr(1, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_cx)
- do_expr(2, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_dx)
- do_expr(3, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_bx)
- do_expr(5, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_bp)
- do_expr(6, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_si)
- do_expr(7, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_di)
- do_expr(8, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ip)
-
- .align 4
-.LENDFDEDLSI2:
+ ud2a
+ CFI_ENDPROC
+ .size __kernel_rt_sigreturn,.-__kernel_rt_sigreturn
.previous
diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h
index 302e11b15da8..09c9684d3ad6 100644
--- a/arch/x86/include/asm/dwarf2.h
+++ b/arch/x86/include/asm/dwarf2.h
@@ -20,6 +20,7 @@
#define CFI_RESTORE_STATE .cfi_restore_state
#define CFI_UNDEFINED .cfi_undefined
#define CFI_ESCAPE .cfi_escape
+#define CFI_SIGNAL_FRAME .cfi_signal_frame
#ifndef BUILD_VDSO
/*
diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
index 25fcde525c68..081816888f7a 100644
--- a/arch/x86/kernel/asm-offsets.c
+++ b/arch/x86/kernel/asm-offsets.c
@@ -63,8 +63,14 @@ static void __used common(void)
OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
+ OFFSET(IA32_SIGCONTEXT_es, sigcontext_32, es);
+ OFFSET(IA32_SIGCONTEXT_cs, sigcontext_32, cs);
+ OFFSET(IA32_SIGCONTEXT_ss, sigcontext_32, ss);
+ OFFSET(IA32_SIGCONTEXT_ds, sigcontext_32, ds);
+ OFFSET(IA32_SIGCONTEXT_flags, sigcontext_32, flags);
BLANK();
+ OFFSET(IA32_SIGFRAME_sigcontext, sigframe_ia32, sc);
OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
#endif
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:39 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
There is no fundamental reason to use the int80_landing_pad symbol to
adjust ip when moving the vdso. If ip falls within the vdso, and the
vdso is moved, we should change the ip accordingly, regardless of mode
or location within the vdso. This *currently* can only happen on 32
bits, but there isn't any reason not to do so generically.
Note that if this is ever possible from a vdso-internal call, then the
user space stack will also needed to be adjusted (as well as the
shadow stack, if enabled.) Fortunately this is not currently the case.
At the moment, we don't even consider other threads when moving the
vdso. The assumption is that it is only used by process freeze/thaw
for migration, where this is not an issue.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/vma.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 8f98c2d7c7a9..e7fd7517370f 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -65,16 +65,12 @@ static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
static void vdso_fix_landing(const struct vdso_image *image,
struct vm_area_struct *new_vma)
{
- if (in_ia32_syscall() && image == &vdso32_image) {
- struct pt_regs *regs = current_pt_regs();
- unsigned long vdso_land = image->sym_int80_landing_pad;
- unsigned long old_land_addr = vdso_land +
- (unsigned long)current->mm->context.vdso;
-
- /* Fixing userspace landing - look at do_fast_syscall_32 */
- if (regs->ip == old_land_addr)
- regs->ip = new_vma->vm_start + vdso_land;
- }
+ struct pt_regs *regs = current_pt_regs();
+ unsigned long ipoffset = regs->ip -
+ (unsigned long)current->mm->context.vdso;
+
+ if (ipoffset < image->size)
+ regs->ip = new_vma->vm_start + ipoffset;
}
static int vdso_mremap(const struct vm_special_mapping *sm,
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:37 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
It is generally better to build tools in arch/x86/tools to keep host
cflags proliferation down, and to reduce makefile sequencing issues.
Move the vdso build tool vdso2c into arch/x86/tools in preparation for
refactoring the vdso makefiles.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/Makefile | 2 +-
arch/x86/entry/vdso/Makefile | 7 +++----
arch/x86/tools/Makefile | 15 ++++++++++-----
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
5 files changed, 14 insertions(+), 10 deletions(-)
rename arch/x86/{entry/vdso => tools}/vdso2c.c (100%)
rename arch/x86/{entry/vdso => tools}/vdso2c.h (100%)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1d403a3612ea..9ab7522ced18 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -252,7 +252,7 @@ endif
archscripts: scripts_basic
- $(Q)$(MAKE) $(build)=arch/x86/tools relocs
+ $(Q)$(MAKE) $(build)=arch/x86/tools relocs vdso2c
###
# Syscall table generation
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 7f833026d5b2..3d9b09f00c70 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -38,13 +38,12 @@ VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 \
$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
$(call if_changed,vdso_and_check)
-HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi -I$(srctree)/arch/$(SUBARCH)/include/uapi
-hostprogs += vdso2c
+VDSO2C = $(objtree)/arch/x86/tools/vdso2c
quiet_cmd_vdso2c = VDSO2C $@
- cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
+ cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
-$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
+$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(VDSO2C) FORCE
$(call if_changed,vdso2c)
#
diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
index 7278e2545c35..39a183fffd04 100644
--- a/arch/x86/tools/Makefile
+++ b/arch/x86/tools/Makefile
@@ -38,9 +38,14 @@ $(obj)/insn_decoder_test.o: $(srctree)/tools/arch/x86/lib/insn.c $(srctree)/tool
$(obj)/insn_sanity.o: $(srctree)/tools/arch/x86/lib/insn.c $(srctree)/tools/arch/x86/lib/inat.c $(srctree)/tools/arch/x86/include/asm/inat_types.h $(srctree)/tools/arch/x86/include/asm/inat.h $(srctree)/tools/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
-HOST_EXTRACFLAGS += -I$(srctree)/tools/include
-hostprogs += relocs
-relocs-objs := relocs_32.o relocs_64.o relocs_common.o
-PHONY += relocs
-relocs: $(obj)/relocs
+HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi \
+ -I$(srctree)/arch/$(SUBARCH)/include/uapi
+
+hostprogs += relocs vdso2c
+relocs-objs := relocs_32.o relocs_64.o relocs_common.o
+
+always-y := $(hostprogs)
+
+PHONY += $(hostprogs)
+$(hostprogs): %: $(obj)/%
@:
diff --git a/arch/x86/entry/vdso/vdso2c.c b/arch/x86/tools/vdso2c.c
similarity index 100%
rename from arch/x86/entry/vdso/vdso2c.c
rename to arch/x86/tools/vdso2c.c
diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/tools/vdso2c.h
similarity index 100%
rename from arch/x86/entry/vdso/vdso2c.h
rename to arch/x86/tools/vdso2c.h
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:35 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
The vdso .so files are named vdso*.so. These structures are binary
images and descriptions of these files, so it is more consistent for
them to have a naming that more directly mirrors the filenames.
It is also very slightly more compact (by one character...) and
simplifies the Makefile just a little bit.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 ++++-------
arch/x86/entry/vdso/Makefile | 8 ++++----
arch/x86/entry/vdso/vma.c | 10 +++++-----
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +++---
arch/x86/kernel/process_64.c | 6 +++---
arch/x86/kernel/signal_32.c | 4 ++--
8 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c
index a67a644d0cfe..8e829575e12f 100644
--- a/arch/x86/entry/syscall_32.c
+++ b/arch/x86/entry/syscall_32.c
@@ -319,7 +319,7 @@ __visible noinstr bool do_fast_syscall_32(struct pt_regs *regs)
* convention. Adjust regs so it looks like we entered using int80.
*/
unsigned long landing_pad = (unsigned long)current->mm->context.vdso +
- vdso_image_32.sym_int80_landing_pad;
+ vdso32_image.sym_int80_landing_pad;
/*
* SYSENTER loses EIP, and even SYSCALL32 needs us to skip forward
diff --git a/arch/x86/entry/vdso/.gitignore b/arch/x86/entry/vdso/.gitignore
index 37a6129d597b..eb60859dbcbf 100644
--- a/arch/x86/entry/vdso/.gitignore
+++ b/arch/x86/entry/vdso/.gitignore
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
-vdso.lds
-vdsox32.lds
-vdso32-syscall-syms.lds
-vdso32-sysenter-syms.lds
-vdso32-int80-syms.lds
-vdso-image-*.c
-vdso2c
+*.lds
+*.so
+*.so.dbg
+vdso*-image.c
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index f247f5f5cb44..7f833026d5b2 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -16,9 +16,9 @@ vobjs-$(CONFIG_X86_SGX) += vsgx.o
obj-y += vma.o extable.o
# vDSO images to build:
-obj-$(CONFIG_X86_64) += vdso-image-64.o
-obj-$(CONFIG_X86_X32_ABI) += vdso-image-x32.o
-obj-$(CONFIG_COMPAT_32) += vdso-image-32.o vdso32-setup.o
+obj-$(CONFIG_X86_64) += vdso64-image.o
+obj-$(CONFIG_X86_X32_ABI) += vdsox32-image.o
+obj-$(CONFIG_COMPAT_32) += vdso32-image.o vdso32-setup.o
vobjs := $(addprefix $(obj)/, $(vobjs-y))
vobjs32 := $(addprefix $(obj)/, $(vobjs32-y))
@@ -44,7 +44,7 @@ hostprogs += vdso2c
quiet_cmd_vdso2c = VDSO2C $@
cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
-$(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
+$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
$(call if_changed,vdso2c)
#
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index afe105b2f907..8f98c2d7c7a9 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -65,7 +65,7 @@ static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
static void vdso_fix_landing(const struct vdso_image *image,
struct vm_area_struct *new_vma)
{
- if (in_ia32_syscall() && image == &vdso_image_32) {
+ if (in_ia32_syscall() && image == &vdso32_image) {
struct pt_regs *regs = current_pt_regs();
unsigned long vdso_land = image->sym_int80_landing_pad;
unsigned long old_land_addr = vdso_land +
@@ -230,7 +230,7 @@ static int load_vdso32(void)
if (vdso32_enabled != 1) /* Other values all mean "disabled" */
return 0;
- return map_vdso(&vdso_image_32, 0);
+ return map_vdso(&vdso32_image, 0);
}
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
@@ -239,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
if (!vdso64_enabled)
return 0;
- return map_vdso(&vdso_image_64, 0);
+ return map_vdso(&vdso64_image, 0);
}
return load_vdso32();
@@ -252,7 +252,7 @@ int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
if (IS_ENABLED(CONFIG_X86_X32_ABI) && x32) {
if (!vdso64_enabled)
return 0;
- return map_vdso(&vdso_image_x32, 0);
+ return map_vdso(&vdsox32_image, 0);
}
if (IS_ENABLED(CONFIG_IA32_EMULATION))
@@ -267,7 +267,7 @@ bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
const struct vdso_image *image = current->mm->context.vdso_image;
unsigned long vdso = (unsigned long) current->mm->context.vdso;
- if (in_ia32_syscall() && image == &vdso_image_32) {
+ if (in_ia32_syscall() && image == &vdso32_image) {
if (regs->ip == vdso + image->sym_vdso32_sigreturn_landing_pad ||
regs->ip == vdso + image->sym_vdso32_rt_sigreturn_landing_pad)
return true;
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 6c8fdc96be7e..2ba5f166e58f 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -361,7 +361,7 @@ else if (IS_ENABLED(CONFIG_IA32_EMULATION)) \
#define VDSO_ENTRY \
((unsigned long)current->mm->context.vdso + \
- vdso_image_32.sym___kernel_vsyscall)
+ vdso32_image.sym___kernel_vsyscall)
struct linux_binprm;
diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index b7253ef3205a..e8afbe9faa5b 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -27,9 +27,9 @@ struct vdso_image {
long sym_vdso32_rt_sigreturn_landing_pad;
};
-extern const struct vdso_image vdso_image_64;
-extern const struct vdso_image vdso_image_x32;
-extern const struct vdso_image vdso_image_32;
+extern const struct vdso_image vdso64_image;
+extern const struct vdso_image vdsox32_image;
+extern const struct vdso_image vdso32_image;
extern int __init init_vdso_image(const struct vdso_image *image);
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 432c0a004c60..08e72f429870 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -941,14 +941,14 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
#ifdef CONFIG_CHECKPOINT_RESTORE
# ifdef CONFIG_X86_X32_ABI
case ARCH_MAP_VDSO_X32:
- return prctl_map_vdso(&vdso_image_x32, arg2);
+ return prctl_map_vdso(&vdsox32_image, arg2);
# endif
# ifdef CONFIG_IA32_EMULATION
case ARCH_MAP_VDSO_32:
- return prctl_map_vdso(&vdso_image_32, arg2);
+ return prctl_map_vdso(&vdso32_image, arg2);
# endif
case ARCH_MAP_VDSO_64:
- return prctl_map_vdso(&vdso_image_64, arg2);
+ return prctl_map_vdso(&vdso64_image, arg2);
#endif
#ifdef CONFIG_ADDRESS_MASKING
case ARCH_GET_UNTAG_MASK:
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 42bbc42bd350..e55cf19e68fe 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -282,7 +282,7 @@ int ia32_setup_frame(struct ksignal *ksig, struct pt_regs *regs)
/* Return stub is in 32bit vsyscall page */
if (current->mm->context.vdso)
restorer = current->mm->context.vdso +
- vdso_image_32.sym___kernel_sigreturn;
+ vdso32_image.sym___kernel_sigreturn;
else
restorer = &frame->retcode;
}
@@ -368,7 +368,7 @@ int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
restorer = ksig->ka.sa.sa_restorer;
else
restorer = current->mm->context.vdso +
- vdso_image_32.sym___kernel_rt_sigreturn;
+ vdso32_image.sym___kernel_rt_sigreturn;
unsafe_put_user(ptr_to_compat(restorer), &frame->pretcode, Efault);
/*
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:34 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
This is intended as a ping, since I think the v4 got swallowed by the
holidays. v4.1 IS BASICALLY A REBASE AND RESEND OF v4; THE ONLY CODE
CHANGE IS A SINGLE SPACE CHARACTER.
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation in vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v4 to v4.1:
- Fix a single bogus whitespace character change in patch 7.
- Fix the spelling of Uros Bizjak's name in the comment to patch 8.
- Rebased onto v6.19-rc4.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- Remove stray comment from prototyping (Uros Bizjak)
- Remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Bizjak)
- Indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:33 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
A macro SYSCALL_ENTER_KERNEL was defined in sigreturn.S, with the
ability of overriding it. The override capability, however, is not
used anywhere, and the macro name is potentially confusing because it
seems to imply that sysenter/syscall could be used here, which is NOT
true: the sigreturn system calls MUST use int $0x80.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/vdso32/sigreturn.S | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/x86/entry/vdso/vdso32/sigreturn.S b/arch/x86/entry/vdso/vdso32/sigreturn.S
index 1bd068f72d4c..965900c6763b 100644
--- a/arch/x86/entry/vdso/vdso32/sigreturn.S
+++ b/arch/x86/entry/vdso/vdso32/sigreturn.S
@@ -3,10 +3,6 @@
#include <asm/unistd_32.h>
#include <asm/asm-offsets.h>
-#ifndef SYSCALL_ENTER_KERNEL
-#define SYSCALL_ENTER_KERNEL int $0x80
-#endif
-
.text
.globl __kernel_sigreturn
.type __kernel_sigreturn,@function
@@ -16,7 +12,7 @@ __kernel_sigreturn:
.LSTART_sigreturn:
popl %eax /* XXX does this mean it needs unwind info? */
movl $__NR_sigreturn, %eax
- SYSCALL_ENTER_KERNEL
+ int $0x80
.LEND_sigreturn:
SYM_INNER_LABEL(vdso32_sigreturn_landing_pad, SYM_L_GLOBAL)
nop
@@ -28,7 +24,7 @@ SYM_INNER_LABEL(vdso32_sigreturn_landing_pad, SYM_L_GLOBAL)
__kernel_rt_sigreturn:
.LSTART_rt_sigreturn:
movl $__NR_rt_sigreturn, %eax
- SYSCALL_ENTER_KERNEL
+ int $0x80
.LEND_rt_sigreturn:
SYM_INNER_LABEL(vdso32_rt_sigreturn_landing_pad, SYM_L_GLOBAL)
nop
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:38 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
- Separate out the vdso sources into common, vdso32, and vdso64
directories.
- Build the 32- and 64-bit vdsos in their respective subdirectories;
this greatly simplifies the build flags handling.
- Unify the mangling of Makefile flags between the 32- and 64-bit
vdso code as much as possible; all common rules are put in
arch/x86/entry/vdso/common/Makefile.include. The remaining
is very simple for 32 bits; the 64-bit one is only slightly more
complicated because it contains the x32 generation rule.
- Define __DISABLE_EXPORTS when building the vdso. This need seems to
have been masked by different ordering compile flags before.
- Change CONFIG_X86_64 to BUILD_VDSO32_64 in vdso32/system_call.S,
to make it compatible with including fake_32bit_build.h.
- The -fcf-protection= option was "leaking" from the kernel build,
for reasons that was not clear to me. Futhermore, several
distributions ship with it set to a default value other than
"-fcf-protection=none". Make it match the configuration options
for *user space*.
Note that this patch may seem large, but the vast majority of it is
simply code movement.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/entry/vdso/Makefile | 161 +-----------------
arch/x86/entry/vdso/common/Makefile.include | 89 ++++++++++
.../entry/vdso/{vdso-note.S => common/note.S} | 5 +-
.../entry/vdso/{ => common}/vclock_gettime.c | 0
.../entry/vdso/{ => common}/vdso-layout.lds.S | 0
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/system_call.S | 2 +-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 +++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
.../x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
21 files changed, 180 insertions(+), 186 deletions(-)
create mode 100644 arch/x86/entry/vdso/common/Makefile.include
rename arch/x86/entry/vdso/{vdso-note.S => common/note.S} (62%)
rename arch/x86/entry/vdso/{ => common}/vclock_gettime.c (100%)
rename arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S (100%)
rename arch/x86/entry/vdso/{ => common}/vgetcpu.c (100%)
create mode 100644 arch/x86/entry/vdso/vdso32/Makefile
create mode 100644 arch/x86/entry/vdso/vdso64/Makefile
create mode 100644 arch/x86/entry/vdso/vdso64/note.S
create mode 100644 arch/x86/entry/vdso/vdso64/vclock_gettime.c
rename arch/x86/entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} (94%)
rename arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S (92%)
create mode 100644 arch/x86/entry/vdso/vdso64/vgetcpu.c
rename arch/x86/entry/vdso/{ => vdso64}/vgetrandom-chacha.S (100%)
rename arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c (91%)
rename arch/x86/entry/vdso/{ => vdso64}/vsgx.S (100%)
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 3d9b09f00c70..987b43fd4cd3 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -3,159 +3,10 @@
# Building vDSO images for x86.
#
-# Include the generic Makefile to check the built vDSO:
-include $(srctree)/lib/vdso/Makefile.include
+# Regular kernel objects
+obj-y := vma.o extable.o
+obj-$(CONFIG_COMPAT_32) += vdso32-setup.o
-# Files to link into the vDSO:
-vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vgetrandom.o vgetrandom-chacha.o
-vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
-vobjs32-y += vdso32/vclock_gettime.o vdso32/vgetcpu.o
-vobjs-$(CONFIG_X86_SGX) += vsgx.o
-
-# Files to link into the kernel:
-obj-y += vma.o extable.o
-
-# vDSO images to build:
-obj-$(CONFIG_X86_64) += vdso64-image.o
-obj-$(CONFIG_X86_X32_ABI) += vdsox32-image.o
-obj-$(CONFIG_COMPAT_32) += vdso32-image.o vdso32-setup.o
-
-vobjs := $(addprefix $(obj)/, $(vobjs-y))
-vobjs32 := $(addprefix $(obj)/, $(vobjs32-y))
-
-$(obj)/vdso.o: $(obj)/vdso.so
-
-targets += vdso.lds $(vobjs-y)
-targets += vdso32/vdso32.lds $(vobjs32-y)
-
-targets += $(foreach x, 64 x32 32, vdso-image-$(x).c vdso$(x).so vdso$(x).so.dbg)
-
-CPPFLAGS_vdso.lds += -P -C
-
-VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 \
- -z max-page-size=4096
-
-$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
- $(call if_changed,vdso_and_check)
-
-VDSO2C = $(objtree)/arch/x86/tools/vdso2c
-
-quiet_cmd_vdso2c = VDSO2C $@
- cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
-
-$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(VDSO2C) FORCE
- $(call if_changed,vdso2c)
-
-#
-# Don't omit frame pointers for ease of userspace debugging, but do
-# optimize sibling calls.
-#
-CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
- $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
- -fno-omit-frame-pointer -foptimize-sibling-calls \
- -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
-
-ifdef CONFIG_MITIGATION_RETPOLINE
-ifneq ($(RETPOLINE_VDSO_CFLAGS),)
- CFL += $(RETPOLINE_VDSO_CFLAGS)
-endif
-endif
-
-$(vobjs): KBUILD_CFLAGS := $(filter-out $(PADDING_CFLAGS) $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) $(RANDSTRUCT_CFLAGS) $(KSTACK_ERASE_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
-$(vobjs): KBUILD_AFLAGS += -DBUILD_VDSO
-
-#
-# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
-#
-CFLAGS_REMOVE_vclock_gettime.o = -pg
-CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
-CFLAGS_REMOVE_vgetcpu.o = -pg
-CFLAGS_REMOVE_vdso32/vgetcpu.o = -pg
-CFLAGS_REMOVE_vsgx.o = -pg
-CFLAGS_REMOVE_vgetrandom.o = -pg
-
-#
-# X32 processes use x32 vDSO to access 64bit kernel data.
-#
-# Build x32 vDSO image:
-# 1. Compile x32 vDSO as 64bit.
-# 2. Convert object files to x32.
-# 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
-# so that it can reach 64bit address space with 64bit pointers.
-#
-
-CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \
- -z max-page-size=4096
-
-# x32-rebranded versions
-vobjx32s-y := $(vobjs-y:.o=-x32.o)
-
-# same thing, but in the output directory
-vobjx32s := $(addprefix $(obj)/, $(vobjx32s-y))
-
-# Convert 64bit object file to x32 for x32 vDSO.
-quiet_cmd_x32 = X32 $@
- cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@
-
-$(obj)/%-x32.o: $(obj)/%.o FORCE
- $(call if_changed,x32)
-
-targets += vdsox32.lds $(vobjx32s-y)
-
-$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section __ex_table
-$(obj)/%.so: $(obj)/%.so.dbg FORCE
- $(call if_changed,objcopy)
-
-$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
- $(call if_changed,vdso_and_check)
-
-CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
-
-KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
-$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
-$(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32
-
-KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
-KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(KSTACK_ERASE_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_CFI),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(PADDING_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic
-KBUILD_CFLAGS_32 += -fno-stack-protector
-KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
-KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
-KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
-KBUILD_CFLAGS_32 += -DBUILD_VDSO
-
-ifdef CONFIG_MITIGATION_RETPOLINE
-ifneq ($(RETPOLINE_VDSO_CFLAGS),)
- KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS)
-endif
-endif
-
-$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
-
-$(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE
- $(call if_changed,vdso_and_check)
-
-#
-# The DSO images are built using a special linker script.
-#
-quiet_cmd_vdso = VDSO $@
- cmd_vdso = $(LD) -o $@ \
- $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
- -T $(filter %.lds,$^) $(filter %.o,$^)
-
-VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 --no-undefined \
- $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack
-
-quiet_cmd_vdso_and_check = VDSO $@
- cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
+# vDSO directories
+obj-$(CONFIG_X86_64) += vdso64/
+obj-$(CONFIG_COMPAT_32) += vdso32/
diff --git a/arch/x86/entry/vdso/common/Makefile.include b/arch/x86/entry/vdso/common/Makefile.include
new file mode 100644
index 000000000000..3514b4a6869b
--- /dev/null
+++ b/arch/x86/entry/vdso/common/Makefile.include
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Building vDSO images for x86.
+#
+
+# Include the generic Makefile to check the built vDSO:
+include $(srctree)/lib/vdso/Makefile.include
+
+obj-y += $(foreach x,$(vdsos-y),vdso$(x)-image.o)
+
+targets += $(foreach x,$(vdsos-y),vdso$(x)-image.c vdso$(x).so vdso$(x).so.dbg vdso$(x).lds)
+targets += $(vobjs-y)
+
+# vobjs-y with $(obj)/ prepended
+vobjs := $(addprefix $(obj)/,$(vobjs-y))
+
+# Options for vdso*.lds
+CPPFLAGS_VDSO_LDS := -P -C -I$(src)/..
+$(obj)/%.lds : KBUILD_CPPFLAGS += $(CPPFLAGS_VDSO_LDS)
+
+#
+# Options from KBUILD_[AC]FLAGS that should *NOT* be kept
+#
+flags-remove-y += \
+ -D__KERNEL__ -mcmodel=kernel -mregparm=3 \
+ -fno-pic -fno-PIC -fno-pie fno-PIE \
+ -mfentry -pg \
+ $(RANDSTRUCT_CFLAGS) $(GCC_PLUGIN_CFLAGS) $(KSTACK_ERASE_CFLAGS) \
+ $(RETPOLINE_CFLAGS) $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \
+ $(PADDING_CFLAGS)
+
+#
+# Don't omit frame pointers for ease of userspace debugging, but do
+# optimize sibling calls.
+#
+flags-y += -D__DISABLE_EXPORTS
+flags-y += -DDISABLE_BRANCH_PROFILING
+flags-y += -DBUILD_VDSO
+flags-y += -I$(src)/.. -I$(srctree)
+flags-y += -O2 -fpic
+flags-y += -fno-stack-protector
+flags-y += -fno-omit-frame-pointer
+flags-y += -foptimize-sibling-calls
+flags-y += -fasynchronous-unwind-tables
+
+# Reset cf protections enabled by compiler default
+flags-y += $(call cc-option, -fcf-protection=none)
+flags-$(X86_USER_SHADOW_STACK) += $(call cc-option, -fcf-protection=return)
+# When user space IBT is supported, enable this.
+# flags-$(CONFIG_USER_IBT) += $(call cc-option, -fcf-protection=branch)
+
+flags-$(CONFIG_MITIGATION_RETPOLINE) += $(RETPOLINE_VDSO_CFLAGS)
+
+# These need to be conditional on $(vobjs) as they do not apply to
+# the output vdso*-image.o files which are standard kernel objects.
+$(vobjs) : KBUILD_AFLAGS := \
+ $(filter-out $(flags-remove-y),$(KBUILD_AFLAGS)) $(flags-y)
+$(vobjs) : KBUILD_CFLAGS := \
+ $(filter-out $(flags-remove-y),$(KBUILD_CFLAGS)) $(flags-y)
+
+#
+# The VDSO images are built using a special linker script.
+#
+VDSO_LDFLAGS := -shared --hash-style=both --build-id=sha1 --no-undefined \
+ $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack
+
+quiet_cmd_vdso = VDSO $@
+ cmd_vdso = $(LD) -o $@ \
+ $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$*) \
+ -T $(filter %.lds,$^) $(filter %.o,$^)
+quiet_cmd_vdso_and_check = VDSO $@
+ cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
+
+$(obj)/vdso%.so.dbg: $(obj)/vdso%.lds FORCE
+ $(call if_changed,vdso_and_check)
+
+$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section __ex_table
+$(obj)/%.so: $(obj)/%.so.dbg FORCE
+ $(call if_changed,objcopy)
+
+VDSO2C = $(objtree)/arch/x86/tools/vdso2c
+
+quiet_cmd_vdso2c = VDSO2C $@
+ cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
+
+$(obj)/%-image.c: $(obj)/%.so.dbg $(obj)/%.so $(VDSO2C) FORCE
+ $(call if_changed,vdso2c)
+
+$(obj)/%-image.o: $(obj)/%-image.c
diff --git a/arch/x86/entry/vdso/vdso-note.S b/arch/x86/entry/vdso/common/note.S
similarity index 62%
rename from arch/x86/entry/vdso/vdso-note.S
rename to arch/x86/entry/vdso/common/note.S
index 79423170118f..2cbd39939dc6 100644
--- a/arch/x86/entry/vdso/vdso-note.S
+++ b/arch/x86/entry/vdso/common/note.S
@@ -1,13 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
* Here we can supply some information useful to userland.
*/
#include <linux/build-salt.h>
-#include <linux/uts.h>
#include <linux/version.h>
#include <linux/elfnote.h>
+/* Ideally this would use UTS_NAME, but using a quoted string here
+ doesn't work. Remember to change this when changing the
+ kernel's name. */
ELFNOTE_START(Linux, 0, "a")
.long LINUX_VERSION_CODE
ELFNOTE_END
diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/common/vclock_gettime.c
similarity index 100%
rename from arch/x86/entry/vdso/vclock_gettime.c
rename to arch/x86/entry/vdso/common/vclock_gettime.c
diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/common/vdso-layout.lds.S
similarity index 100%
rename from arch/x86/entry/vdso/vdso-layout.lds.S
rename to arch/x86/entry/vdso/common/vdso-layout.lds.S
diff --git a/arch/x86/entry/vdso/vgetcpu.c b/arch/x86/entry/vdso/common/vgetcpu.c
similarity index 100%
rename from arch/x86/entry/vdso/vgetcpu.c
rename to arch/x86/entry/vdso/common/vgetcpu.c
diff --git a/arch/x86/entry/vdso/vdso32/Makefile b/arch/x86/entry/vdso/vdso32/Makefile
new file mode 100644
index 000000000000..add6afb484ba
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso32/Makefile
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# 32-bit vDSO images for x86.
+#
+
+# The vDSOs built in this directory
+vdsos-y := 32
+
+# Files to link into the vDSO:
+vobjs-y := note.o vclock_gettime.o vgetcpu.o
+vobjs-y += system_call.o sigreturn.o
+
+# Compilation flags
+flags-y := -DBUILD_VDSO32 -m32 -mregparm=0
+flags-$(CONFIG_X86_64) += -include $(src)/fake_32bit_build.h
+flags-remove-y := -m64
+
+# The location of this include matters!
+include $(src)/../common/Makefile.include
+
+# Linker options for the vdso
+VDSO_LDFLAGS_32 := -m elf_i386 -soname linux-gate.so.1
+
+$(obj)/vdso32.so.dbg: $(vobjs)
diff --git a/arch/x86/entry/vdso/vdso32/note.S b/arch/x86/entry/vdso/vdso32/note.S
index 2cbd39939dc6..62d8aa51ce99 100644
--- a/arch/x86/entry/vdso/vdso32/note.S
+++ b/arch/x86/entry/vdso/vdso32/note.S
@@ -1,18 +1 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
- * Here we can supply some information useful to userland.
- */
-
-#include <linux/build-salt.h>
-#include <linux/version.h>
-#include <linux/elfnote.h>
-
-/* Ideally this would use UTS_NAME, but using a quoted string here
- doesn't work. Remember to change this when changing the
- kernel's name. */
-ELFNOTE_START(Linux, 0, "a")
- .long LINUX_VERSION_CODE
-ELFNOTE_END
-
-BUILD_SALT
+#include "common/note.S"
diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso/vdso32/system_call.S
index d33c6513fd2c..2a15634bbe75 100644
--- a/arch/x86/entry/vdso/vdso32/system_call.S
+++ b/arch/x86/entry/vdso/vdso32/system_call.S
@@ -52,7 +52,7 @@ __kernel_vsyscall:
#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
-#ifdef CONFIG_X86_64
+#ifdef BUILD_VDSO32_64
/* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \
SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
diff --git a/arch/x86/entry/vdso/vdso32/vclock_gettime.c b/arch/x86/entry/vdso/vdso32/vclock_gettime.c
index 86981decfea8..1481f0021b9f 100644
--- a/arch/x86/entry/vdso/vdso32/vclock_gettime.c
+++ b/arch/x86/entry/vdso/vdso32/vclock_gettime.c
@@ -1,4 +1 @@
-// SPDX-License-Identifier: GPL-2.0
-#define BUILD_VDSO32
-#include "fake_32bit_build.h"
-#include "../vclock_gettime.c"
+#include "common/vclock_gettime.c"
diff --git a/arch/x86/entry/vdso/vdso32/vdso32.lds.S b/arch/x86/entry/vdso/vdso32/vdso32.lds.S
index 8a3be07006bb..8a853543fc0d 100644
--- a/arch/x86/entry/vdso/vdso32/vdso32.lds.S
+++ b/arch/x86/entry/vdso/vdso32/vdso32.lds.S
@@ -11,7 +11,7 @@
#define BUILD_VDSO32
-#include "../vdso-layout.lds.S"
+#include "common/vdso-layout.lds.S"
/* The ELF entry point can be used to set the AT_SYSINFO value. */
ENTRY(__kernel_vsyscall);
diff --git a/arch/x86/entry/vdso/vdso32/vgetcpu.c b/arch/x86/entry/vdso/vdso32/vgetcpu.c
index 3a9791f5e998..00cc8325a020 100644
--- a/arch/x86/entry/vdso/vdso32/vgetcpu.c
+++ b/arch/x86/entry/vdso/vdso32/vgetcpu.c
@@ -1,3 +1 @@
-// SPDX-License-Identifier: GPL-2.0
-#include "fake_32bit_build.h"
-#include "../vgetcpu.c"
+#include "common/vgetcpu.c"
diff --git a/arch/x86/entry/vdso/vdso64/Makefile b/arch/x86/entry/vdso/vdso64/Makefile
new file mode 100644
index 000000000000..bfffaf1aeecc
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/Makefile
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# 64-bit vDSO images for x86.
+#
+
+# The vDSOs built in this directory
+vdsos-y := 64
+vdsos-$(CONFIG_X86_X32_ABI) += x32
+
+# Files to link into the vDSO:
+vobjs-y := note.o vclock_gettime.o vgetcpu.o
+vobjs-y += vgetrandom.o vgetrandom-chacha.o
+vobjs-$(CONFIG_X86_SGX) += vsgx.o
+
+# Compilation flags
+flags-y := -DBUILD_VDSO64 -m64 -mcmodel=small
+
+# The location of this include matters!
+include $(src)/../common/Makefile.include
+
+#
+# X32 processes use x32 vDSO to access 64bit kernel data.
+#
+# Build x32 vDSO image:
+# 1. Compile x32 vDSO as 64bit.
+# 2. Convert object files to x32.
+# 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
+# so that it can reach 64bit address space with 64bit pointers.
+#
+
+# Convert 64bit object file to x32 for x32 vDSO.
+quiet_cmd_x32 = X32 $@
+ cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@
+
+$(obj)/%-x32.o: $(obj)/%.o FORCE
+ $(call if_changed,x32)
+
+vobjsx32 = $(patsubst %.o,%-x32.o,$(vobjs))
+targets += $(patsubst %.o,%-x32.o,$(vobjs-y))
+
+# Linker options for the vdso
+VDSO_LDFLAGS_64 := -m elf_x86_64 -soname linux-vdso.so.1 -z max-page-size=4096
+VDSO_LDFLAGS_x32 := $(subst elf_x86_64,elf32_x86_64,$(VDSO_LDFLAGS_64))
+
+$(obj)/vdso64.so.dbg: $(vobjs)
+$(obj)/vdsox32.so.dbg: $(vobjsx32)
diff --git a/arch/x86/entry/vdso/vdso64/note.S b/arch/x86/entry/vdso/vdso64/note.S
new file mode 100644
index 000000000000..62d8aa51ce99
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/note.S
@@ -0,0 +1 @@
+#include "common/note.S"
diff --git a/arch/x86/entry/vdso/vdso64/vclock_gettime.c b/arch/x86/entry/vdso/vdso64/vclock_gettime.c
new file mode 100644
index 000000000000..1481f0021b9f
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vclock_gettime.c
@@ -0,0 +1 @@
+#include "common/vclock_gettime.c"
diff --git a/arch/x86/entry/vdso/vdso.lds.S b/arch/x86/entry/vdso/vdso64/vdso64.lds.S
similarity index 94%
rename from arch/x86/entry/vdso/vdso.lds.S
rename to arch/x86/entry/vdso/vdso64/vdso64.lds.S
index 0bab5f4af6d1..5ce3f2b6373a 100644
--- a/arch/x86/entry/vdso/vdso.lds.S
+++ b/arch/x86/entry/vdso/vdso64/vdso64.lds.S
@@ -9,7 +9,7 @@
#define BUILD_VDSO64
-#include "vdso-layout.lds.S"
+#include "common/vdso-layout.lds.S"
/*
* This controls what userland symbols we export from the vDSO.
diff --git a/arch/x86/entry/vdso/vdsox32.lds.S b/arch/x86/entry/vdso/vdso64/vdsox32.lds.S
similarity index 92%
rename from arch/x86/entry/vdso/vdsox32.lds.S
rename to arch/x86/entry/vdso/vdso64/vdsox32.lds.S
index 16a8050a4fb6..3dbd20c8dacc 100644
--- a/arch/x86/entry/vdso/vdsox32.lds.S
+++ b/arch/x86/entry/vdso/vdso64/vdsox32.lds.S
@@ -9,7 +9,7 @@
#define BUILD_VDSOX32
-#include "vdso-layout.lds.S"
+#include "common/vdso-layout.lds.S"
/*
* This controls what userland symbols we export from the vDSO.
diff --git a/arch/x86/entry/vdso/vdso64/vgetcpu.c b/arch/x86/entry/vdso/vdso64/vgetcpu.c
new file mode 100644
index 000000000000..00cc8325a020
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vgetcpu.c
@@ -0,0 +1 @@
+#include "common/vgetcpu.c"
diff --git a/arch/x86/entry/vdso/vgetrandom-chacha.S b/arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S
similarity index 100%
rename from arch/x86/entry/vdso/vgetrandom-chacha.S
rename to arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S
diff --git a/arch/x86/entry/vdso/vgetrandom.c b/arch/x86/entry/vdso/vdso64/vgetrandom.c
similarity index 91%
rename from arch/x86/entry/vdso/vgetrandom.c
rename to arch/x86/entry/vdso/vdso64/vgetrandom.c
index 430862b8977c..6a95d36b12d9 100644
--- a/arch/x86/entry/vdso/vgetrandom.c
+++ b/arch/x86/entry/vdso/vdso64/vgetrandom.c
@@ -4,7 +4,7 @@
*/
#include <linux/types.h>
-#include "../../../../lib/vdso/getrandom.c"
+#include "lib/vdso/getrandom.c"
ssize_t __vdso_getrandom(void *buffer, size_t len, unsigned int flags, void *opaque_state, size_t opaque_len)
{
diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vdso64/vsgx.S
similarity index 100%
rename from arch/x86/entry/vdso/vsgx.S
rename to arch/x86/entry/vdso/vdso64/vsgx.S
--
2.52.0
|
{
"author": "\"H. Peter Anvin\" <hpa@zytor.com>",
"date": "Tue, 6 Jan 2026 13:18:36 -0800",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
On 06/01/2026 9:18 pm, H. Peter Anvin wrote:
The v4/v4.1 notes will presumably want dropping before committing?
|
{
"author": "Andrew Cooper <andrew.cooper3@citrix.com>",
"date": "Wed, 7 Jan 2026 12:10:52 +0000",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 93d73005bff4f600696ce30e366e742c3373b13d
Gitweb: https://git.kernel.org/tip/93d73005bff4f600696ce30e366e742c3373b13d
Author: H. Peter Anvin <hpa@zytor.com>
AuthorDate: Tue, 16 Dec 2025 13:25:55 -08:00
Committer: Dave Hansen <dave.hansen@linux.intel.com>
CommitterDate: Tue, 13 Jan 2026 15:33:20 -08:00
x86/entry/vdso: Rename vdso_image_* to vdso*_image
The vdso .so files are named vdso*.so. These structures are binary
images and descriptions of these files, so it is more consistent for
them to have a naming that more directly mirrors the filenames.
It is also very slightly more compact (by one character...) and
simplifies the Makefile just a little bit.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://patch.msgid.link/20251216212606.1325678-2-hpa@zytor.com
---
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 ++++-------
arch/x86/entry/vdso/Makefile | 8 ++++----
arch/x86/entry/vdso/vma.c | 10 +++++-----
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +++---
arch/x86/kernel/process_64.c | 6 +++---
arch/x86/kernel/signal_32.c | 4 ++--
8 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c
index a67a644..8e82957 100644
--- a/arch/x86/entry/syscall_32.c
+++ b/arch/x86/entry/syscall_32.c
@@ -319,7 +319,7 @@ __visible noinstr bool do_fast_syscall_32(struct pt_regs *regs)
* convention. Adjust regs so it looks like we entered using int80.
*/
unsigned long landing_pad = (unsigned long)current->mm->context.vdso +
- vdso_image_32.sym_int80_landing_pad;
+ vdso32_image.sym_int80_landing_pad;
/*
* SYSENTER loses EIP, and even SYSCALL32 needs us to skip forward
diff --git a/arch/x86/entry/vdso/.gitignore b/arch/x86/entry/vdso/.gitignore
index 37a6129..eb60859 100644
--- a/arch/x86/entry/vdso/.gitignore
+++ b/arch/x86/entry/vdso/.gitignore
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
-vdso.lds
-vdsox32.lds
-vdso32-syscall-syms.lds
-vdso32-sysenter-syms.lds
-vdso32-int80-syms.lds
-vdso-image-*.c
-vdso2c
+*.lds
+*.so
+*.so.dbg
+vdso*-image.c
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index f247f5f..7f83302 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -16,9 +16,9 @@ vobjs-$(CONFIG_X86_SGX) += vsgx.o
obj-y += vma.o extable.o
# vDSO images to build:
-obj-$(CONFIG_X86_64) += vdso-image-64.o
-obj-$(CONFIG_X86_X32_ABI) += vdso-image-x32.o
-obj-$(CONFIG_COMPAT_32) += vdso-image-32.o vdso32-setup.o
+obj-$(CONFIG_X86_64) += vdso64-image.o
+obj-$(CONFIG_X86_X32_ABI) += vdsox32-image.o
+obj-$(CONFIG_COMPAT_32) += vdso32-image.o vdso32-setup.o
vobjs := $(addprefix $(obj)/, $(vobjs-y))
vobjs32 := $(addprefix $(obj)/, $(vobjs32-y))
@@ -44,7 +44,7 @@ hostprogs += vdso2c
quiet_cmd_vdso2c = VDSO2C $@
cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
-$(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
+$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
$(call if_changed,vdso2c)
#
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index afe105b..8f98c2d 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -65,7 +65,7 @@ static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
static void vdso_fix_landing(const struct vdso_image *image,
struct vm_area_struct *new_vma)
{
- if (in_ia32_syscall() && image == &vdso_image_32) {
+ if (in_ia32_syscall() && image == &vdso32_image) {
struct pt_regs *regs = current_pt_regs();
unsigned long vdso_land = image->sym_int80_landing_pad;
unsigned long old_land_addr = vdso_land +
@@ -230,7 +230,7 @@ static int load_vdso32(void)
if (vdso32_enabled != 1) /* Other values all mean "disabled" */
return 0;
- return map_vdso(&vdso_image_32, 0);
+ return map_vdso(&vdso32_image, 0);
}
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
@@ -239,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
if (!vdso64_enabled)
return 0;
- return map_vdso(&vdso_image_64, 0);
+ return map_vdso(&vdso64_image, 0);
}
return load_vdso32();
@@ -252,7 +252,7 @@ int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
if (IS_ENABLED(CONFIG_X86_X32_ABI) && x32) {
if (!vdso64_enabled)
return 0;
- return map_vdso(&vdso_image_x32, 0);
+ return map_vdso(&vdsox32_image, 0);
}
if (IS_ENABLED(CONFIG_IA32_EMULATION))
@@ -267,7 +267,7 @@ bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
const struct vdso_image *image = current->mm->context.vdso_image;
unsigned long vdso = (unsigned long) current->mm->context.vdso;
- if (in_ia32_syscall() && image == &vdso_image_32) {
+ if (in_ia32_syscall() && image == &vdso32_image) {
if (regs->ip == vdso + image->sym_vdso32_sigreturn_landing_pad ||
regs->ip == vdso + image->sym_vdso32_rt_sigreturn_landing_pad)
return true;
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 6c8fdc9..2ba5f16 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -361,7 +361,7 @@ else if (IS_ENABLED(CONFIG_IA32_EMULATION)) \
#define VDSO_ENTRY \
((unsigned long)current->mm->context.vdso + \
- vdso_image_32.sym___kernel_vsyscall)
+ vdso32_image.sym___kernel_vsyscall)
struct linux_binprm;
diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index b7253ef..e8afbe9 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -27,9 +27,9 @@ struct vdso_image {
long sym_vdso32_rt_sigreturn_landing_pad;
};
-extern const struct vdso_image vdso_image_64;
-extern const struct vdso_image vdso_image_x32;
-extern const struct vdso_image vdso_image_32;
+extern const struct vdso_image vdso64_image;
+extern const struct vdso_image vdsox32_image;
+extern const struct vdso_image vdso32_image;
extern int __init init_vdso_image(const struct vdso_image *image);
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 432c0a0..08e72f4 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -941,14 +941,14 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
#ifdef CONFIG_CHECKPOINT_RESTORE
# ifdef CONFIG_X86_X32_ABI
case ARCH_MAP_VDSO_X32:
- return prctl_map_vdso(&vdso_image_x32, arg2);
+ return prctl_map_vdso(&vdsox32_image, arg2);
# endif
# ifdef CONFIG_IA32_EMULATION
case ARCH_MAP_VDSO_32:
- return prctl_map_vdso(&vdso_image_32, arg2);
+ return prctl_map_vdso(&vdso32_image, arg2);
# endif
case ARCH_MAP_VDSO_64:
- return prctl_map_vdso(&vdso_image_64, arg2);
+ return prctl_map_vdso(&vdso64_image, arg2);
#endif
#ifdef CONFIG_ADDRESS_MASKING
case ARCH_GET_UNTAG_MASK:
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 42bbc42..e55cf19 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -282,7 +282,7 @@ int ia32_setup_frame(struct ksignal *ksig, struct pt_regs *regs)
/* Return stub is in 32bit vsyscall page */
if (current->mm->context.vdso)
restorer = current->mm->context.vdso +
- vdso_image_32.sym___kernel_sigreturn;
+ vdso32_image.sym___kernel_sigreturn;
else
restorer = &frame->retcode;
}
@@ -368,7 +368,7 @@ int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
restorer = ksig->ka.sa.sa_restorer;
else
restorer = current->mm->context.vdso +
- vdso_image_32.sym___kernel_rt_sigreturn;
+ vdso32_image.sym___kernel_rt_sigreturn;
unsafe_put_user(ptr_to_compat(restorer), &frame->pretcode, Efault);
/*
|
{
"author": "\"tip-bot2 for H. Peter Anvin\" <tip-bot2@linutronix.de>",
"date": "Wed, 14 Jan 2026 00:01:26 -0000",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: a76108d05ee13cddb72b620752a80b2c3e87aee1
Gitweb: https://git.kernel.org/tip/a76108d05ee13cddb72b620752a80b2c3e87aee1
Author: H. Peter Anvin <hpa@zytor.com>
AuthorDate: Tue, 16 Dec 2025 13:25:56 -08:00
Committer: Dave Hansen <dave.hansen@linux.intel.com>
CommitterDate: Tue, 13 Jan 2026 15:33:20 -08:00
x86/entry/vdso: Move vdso2c to arch/x86/tools
It is generally better to build tools in arch/x86/tools to keep host
cflags proliferation down, and to reduce makefile sequencing issues.
Move the vdso build tool vdso2c into arch/x86/tools in preparation for
refactoring the vdso makefiles.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://patch.msgid.link/20251216212606.1325678-3-hpa@zytor.com
---
arch/x86/Makefile | 2 +-
arch/x86/entry/vdso/Makefile | 7 +-
arch/x86/entry/vdso/vdso2c.c | 233 +----------------------------------
arch/x86/entry/vdso/vdso2c.h | 208 +------------------------------
arch/x86/tools/Makefile | 15 +-
arch/x86/tools/vdso2c.c | 233 ++++++++++++++++++++++++++++++++++-
arch/x86/tools/vdso2c.h | 208 ++++++++++++++++++++++++++++++-
7 files changed, 455 insertions(+), 451 deletions(-)
delete mode 100644 arch/x86/entry/vdso/vdso2c.c
delete mode 100644 arch/x86/entry/vdso/vdso2c.h
create mode 100644 arch/x86/tools/vdso2c.c
create mode 100644 arch/x86/tools/vdso2c.h
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1d403a3..9ab7522 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -252,7 +252,7 @@ endif
archscripts: scripts_basic
- $(Q)$(MAKE) $(build)=arch/x86/tools relocs
+ $(Q)$(MAKE) $(build)=arch/x86/tools relocs vdso2c
###
# Syscall table generation
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 7f83302..3d9b09f 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -38,13 +38,12 @@ VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 \
$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
$(call if_changed,vdso_and_check)
-HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi -I$(srctree)/arch/$(SUBARCH)/include/uapi
-hostprogs += vdso2c
+VDSO2C = $(objtree)/arch/x86/tools/vdso2c
quiet_cmd_vdso2c = VDSO2C $@
- cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
+ cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
-$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
+$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(VDSO2C) FORCE
$(call if_changed,vdso2c)
#
diff --git a/arch/x86/entry/vdso/vdso2c.c b/arch/x86/entry/vdso/vdso2c.c
deleted file mode 100644
index f84e8f8..0000000
--- a/arch/x86/entry/vdso/vdso2c.c
+++ /dev/null
@@ -1,233 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * vdso2c - A vdso image preparation tool
- * Copyright (c) 2014 Andy Lutomirski and others
- *
- * vdso2c requires stripped and unstripped input. It would be trivial
- * to fully strip the input in here, but, for reasons described below,
- * we need to write a section table. Doing this is more or less
- * equivalent to dropping all non-allocatable sections, but it's
- * easier to let objcopy handle that instead of doing it ourselves.
- * If we ever need to do something fancier than what objcopy provides,
- * it would be straightforward to add here.
- *
- * We're keep a section table for a few reasons:
- *
- * The Go runtime had a couple of bugs: it would read the section
- * table to try to figure out how many dynamic symbols there were (it
- * shouldn't have looked at the section table at all) and, if there
- * were no SHT_SYNDYM section table entry, it would use an
- * uninitialized value for the number of symbols. An empty DYNSYM
- * table would work, but I see no reason not to write a valid one (and
- * keep full performance for old Go programs). This hack is only
- * needed on x86_64.
- *
- * The bug was introduced on 2012-08-31 by:
- * https://code.google.com/p/go/source/detail?r=56ea40aac72b
- * and was fixed on 2014-06-13 by:
- * https://code.google.com/p/go/source/detail?r=fc1cd5e12595
- *
- * Binutils has issues debugging the vDSO: it reads the section table to
- * find SHT_NOTE; it won't look at PT_NOTE for the in-memory vDSO, which
- * would break build-id if we removed the section table. Binutils
- * also requires that shstrndx != 0. See:
- * https://sourceware.org/bugzilla/show_bug.cgi?id=17064
- *
- * elfutils might not look for PT_NOTE if there is a section table at
- * all. I don't know whether this matters for any practical purpose.
- *
- * For simplicity, rather than hacking up a partial section table, we
- * just write a mostly complete one. We omit non-dynamic symbols,
- * though, since they're rather large.
- *
- * Once binutils gets fixed, we might be able to drop this for all but
- * the 64-bit vdso, since build-id only works in kernel RPMs, and
- * systems that update to new enough kernel RPMs will likely update
- * binutils in sync. build-id has never worked for home-built kernel
- * RPMs without manual symlinking, and I suspect that no one ever does
- * that.
- */
-
-#include <inttypes.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <err.h>
-
-#include <sys/mman.h>
-#include <sys/types.h>
-
-#include <tools/le_byteshift.h>
-
-#include <linux/elf.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-
-const char *outfilename;
-
-struct vdso_sym {
- const char *name;
- bool export;
-};
-
-struct vdso_sym required_syms[] = {
- {"VDSO32_NOTE_MASK", true},
- {"__kernel_vsyscall", true},
- {"__kernel_sigreturn", true},
- {"__kernel_rt_sigreturn", true},
- {"int80_landing_pad", true},
- {"vdso32_rt_sigreturn_landing_pad", true},
- {"vdso32_sigreturn_landing_pad", true},
-};
-
-__attribute__((format(printf, 1, 2))) __attribute__((noreturn))
-static void fail(const char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
- fprintf(stderr, "Error: ");
- vfprintf(stderr, format, ap);
- if (outfilename)
- unlink(outfilename);
- exit(1);
- va_end(ap);
-}
-
-/*
- * Evil macros for little-endian reads and writes
- */
-#define GLE(x, bits, ifnot) \
- __builtin_choose_expr( \
- (sizeof(*(x)) == bits/8), \
- (__typeof__(*(x)))get_unaligned_le##bits(x), ifnot)
-
-extern void bad_get_le(void);
-#define LAST_GLE(x) \
- __builtin_choose_expr(sizeof(*(x)) == 1, *(x), bad_get_le())
-
-#define GET_LE(x) \
- GLE(x, 64, GLE(x, 32, GLE(x, 16, LAST_GLE(x))))
-
-#define PLE(x, val, bits, ifnot) \
- __builtin_choose_expr( \
- (sizeof(*(x)) == bits/8), \
- put_unaligned_le##bits((val), (x)), ifnot)
-
-extern void bad_put_le(void);
-#define LAST_PLE(x, val) \
- __builtin_choose_expr(sizeof(*(x)) == 1, *(x) = (val), bad_put_le())
-
-#define PUT_LE(x, val) \
- PLE(x, val, 64, PLE(x, val, 32, PLE(x, val, 16, LAST_PLE(x, val))))
-
-
-#define NSYMS ARRAY_SIZE(required_syms)
-
-#define BITSFUNC3(name, bits, suffix) name##bits##suffix
-#define BITSFUNC2(name, bits, suffix) BITSFUNC3(name, bits, suffix)
-#define BITSFUNC(name) BITSFUNC2(name, ELF_BITS, )
-
-#define INT_BITS BITSFUNC2(int, ELF_BITS, _t)
-
-#define ELF_BITS_XFORM2(bits, x) Elf##bits##_##x
-#define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x)
-#define ELF(x) ELF_BITS_XFORM(ELF_BITS, x)
-
-#define ELF_BITS 64
-#include "vdso2c.h"
-#undef ELF_BITS
-
-#define ELF_BITS 32
-#include "vdso2c.h"
-#undef ELF_BITS
-
-static void go(void *raw_addr, size_t raw_len,
- void *stripped_addr, size_t stripped_len,
- FILE *outfile, const char *name)
-{
- Elf64_Ehdr *hdr = (Elf64_Ehdr *)raw_addr;
-
- if (hdr->e_ident[EI_CLASS] == ELFCLASS64) {
- go64(raw_addr, raw_len, stripped_addr, stripped_len,
- outfile, name);
- } else if (hdr->e_ident[EI_CLASS] == ELFCLASS32) {
- go32(raw_addr, raw_len, stripped_addr, stripped_len,
- outfile, name);
- } else {
- fail("unknown ELF class\n");
- }
-}
-
-static void map_input(const char *name, void **addr, size_t *len, int prot)
-{
- off_t tmp_len;
-
- int fd = open(name, O_RDONLY);
- if (fd == -1)
- err(1, "open(%s)", name);
-
- tmp_len = lseek(fd, 0, SEEK_END);
- if (tmp_len == (off_t)-1)
- err(1, "lseek");
- *len = (size_t)tmp_len;
-
- *addr = mmap(NULL, tmp_len, prot, MAP_PRIVATE, fd, 0);
- if (*addr == MAP_FAILED)
- err(1, "mmap");
-
- close(fd);
-}
-
-int main(int argc, char **argv)
-{
- size_t raw_len, stripped_len;
- void *raw_addr, *stripped_addr;
- FILE *outfile;
- char *name, *tmp;
- int namelen;
-
- if (argc != 4) {
- printf("Usage: vdso2c RAW_INPUT STRIPPED_INPUT OUTPUT\n");
- return 1;
- }
-
- /*
- * Figure out the struct name. If we're writing to a .so file,
- * generate raw output instead.
- */
- name = strdup(argv[3]);
- namelen = strlen(name);
- if (namelen >= 3 && !strcmp(name + namelen - 3, ".so")) {
- name = NULL;
- } else {
- tmp = strrchr(name, '/');
- if (tmp)
- name = tmp + 1;
- tmp = strchr(name, '.');
- if (tmp)
- *tmp = '\0';
- for (tmp = name; *tmp; tmp++)
- if (*tmp == '-')
- *tmp = '_';
- }
-
- map_input(argv[1], &raw_addr, &raw_len, PROT_READ);
- map_input(argv[2], &stripped_addr, &stripped_len, PROT_READ);
-
- outfilename = argv[3];
- outfile = fopen(outfilename, "w");
- if (!outfile)
- err(1, "fopen(%s)", outfilename);
-
- go(raw_addr, raw_len, stripped_addr, stripped_len, outfile, name);
-
- munmap(raw_addr, raw_len);
- munmap(stripped_addr, stripped_len);
- fclose(outfile);
-
- return 0;
-}
diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
deleted file mode 100644
index 78ed1c1..0000000
--- a/arch/x86/entry/vdso/vdso2c.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * This file is included twice from vdso2c.c. It generates code for 32-bit
- * and 64-bit vDSOs. We need both for 64-bit builds, since 32-bit vDSOs
- * are built for 32-bit userspace.
- */
-
-static void BITSFUNC(copy)(FILE *outfile, const unsigned char *data, size_t len)
-{
- size_t i;
-
- for (i = 0; i < len; i++) {
- if (i % 10 == 0)
- fprintf(outfile, "\n\t");
- fprintf(outfile, "0x%02X, ", (int)(data)[i]);
- }
-}
-
-
-/*
- * Extract a section from the input data into a standalone blob. Used to
- * capture kernel-only data that needs to persist indefinitely, e.g. the
- * exception fixup tables, but only in the kernel, i.e. the section can
- * be stripped from the final vDSO image.
- */
-static void BITSFUNC(extract)(const unsigned char *data, size_t data_len,
- FILE *outfile, ELF(Shdr) *sec, const char *name)
-{
- unsigned long offset;
- size_t len;
-
- offset = (unsigned long)GET_LE(&sec->sh_offset);
- len = (size_t)GET_LE(&sec->sh_size);
-
- if (offset + len > data_len)
- fail("section to extract overruns input data");
-
- fprintf(outfile, "static const unsigned char %s[%zu] = {", name, len);
- BITSFUNC(copy)(outfile, data + offset, len);
- fprintf(outfile, "\n};\n\n");
-}
-
-static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
- void *stripped_addr, size_t stripped_len,
- FILE *outfile, const char *image_name)
-{
- int found_load = 0;
- unsigned long load_size = -1; /* Work around bogus warning */
- unsigned long mapping_size;
- ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
- unsigned long i, syms_nr;
- ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
- *alt_sec = NULL, *extable_sec = NULL;
- ELF(Dyn) *dyn = 0, *dyn_end = 0;
- const char *secstrings;
- INT_BITS syms[NSYMS] = {};
-
- ELF(Phdr) *pt = (ELF(Phdr) *)(raw_addr + GET_LE(&hdr->e_phoff));
-
- if (GET_LE(&hdr->e_type) != ET_DYN)
- fail("input is not a shared object\n");
-
- /* Walk the segment table. */
- for (i = 0; i < GET_LE(&hdr->e_phnum); i++) {
- if (GET_LE(&pt[i].p_type) == PT_LOAD) {
- if (found_load)
- fail("multiple PT_LOAD segs\n");
-
- if (GET_LE(&pt[i].p_offset) != 0 ||
- GET_LE(&pt[i].p_vaddr) != 0)
- fail("PT_LOAD in wrong place\n");
-
- if (GET_LE(&pt[i].p_memsz) != GET_LE(&pt[i].p_filesz))
- fail("cannot handle memsz != filesz\n");
-
- load_size = GET_LE(&pt[i].p_memsz);
- found_load = 1;
- } else if (GET_LE(&pt[i].p_type) == PT_DYNAMIC) {
- dyn = raw_addr + GET_LE(&pt[i].p_offset);
- dyn_end = raw_addr + GET_LE(&pt[i].p_offset) +
- GET_LE(&pt[i].p_memsz);
- }
- }
- if (!found_load)
- fail("no PT_LOAD seg\n");
-
- if (stripped_len < load_size)
- fail("stripped input is too short\n");
-
- if (!dyn)
- fail("input has no PT_DYNAMIC section -- your toolchain is buggy\n");
-
- /* Walk the dynamic table */
- for (i = 0; dyn + i < dyn_end &&
- GET_LE(&dyn[i].d_tag) != DT_NULL; i++) {
- typeof(dyn[i].d_tag) tag = GET_LE(&dyn[i].d_tag);
- if (tag == DT_REL || tag == DT_RELSZ || tag == DT_RELA ||
- tag == DT_RELENT || tag == DT_TEXTREL)
- fail("vdso image contains dynamic relocations\n");
- }
-
- /* Walk the section table */
- secstrings_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
- GET_LE(&hdr->e_shentsize)*GET_LE(&hdr->e_shstrndx);
- secstrings = raw_addr + GET_LE(&secstrings_hdr->sh_offset);
- for (i = 0; i < GET_LE(&hdr->e_shnum); i++) {
- ELF(Shdr) *sh = raw_addr + GET_LE(&hdr->e_shoff) +
- GET_LE(&hdr->e_shentsize) * i;
- if (GET_LE(&sh->sh_type) == SHT_SYMTAB)
- symtab_hdr = sh;
-
- if (!strcmp(secstrings + GET_LE(&sh->sh_name),
- ".altinstructions"))
- alt_sec = sh;
- if (!strcmp(secstrings + GET_LE(&sh->sh_name), "__ex_table"))
- extable_sec = sh;
- }
-
- if (!symtab_hdr)
- fail("no symbol table\n");
-
- strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
- GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link);
-
- syms_nr = GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
- /* Walk the symbol table */
- for (i = 0; i < syms_nr; i++) {
- unsigned int k;
- ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
- GET_LE(&symtab_hdr->sh_entsize) * i;
- const char *sym_name = raw_addr +
- GET_LE(&strtab_hdr->sh_offset) +
- GET_LE(&sym->st_name);
-
- for (k = 0; k < NSYMS; k++) {
- if (!strcmp(sym_name, required_syms[k].name)) {
- if (syms[k]) {
- fail("duplicate symbol %s\n",
- required_syms[k].name);
- }
-
- /*
- * Careful: we use negative addresses, but
- * st_value is unsigned, so we rely
- * on syms[k] being a signed type of the
- * correct width.
- */
- syms[k] = GET_LE(&sym->st_value);
- }
- }
- }
-
- if (!image_name) {
- fwrite(stripped_addr, stripped_len, 1, outfile);
- return;
- }
-
- mapping_size = (stripped_len + 4095) / 4096 * 4096;
-
- fprintf(outfile, "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */\n\n");
- fprintf(outfile, "#include <linux/linkage.h>\n");
- fprintf(outfile, "#include <linux/init.h>\n");
- fprintf(outfile, "#include <asm/page_types.h>\n");
- fprintf(outfile, "#include <asm/vdso.h>\n");
- fprintf(outfile, "\n");
- fprintf(outfile,
- "static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
- mapping_size);
- for (i = 0; i < stripped_len; i++) {
- if (i % 10 == 0)
- fprintf(outfile, "\n\t");
- fprintf(outfile, "0x%02X, ",
- (int)((unsigned char *)stripped_addr)[i]);
- }
- fprintf(outfile, "\n};\n\n");
- if (extable_sec)
- BITSFUNC(extract)(raw_addr, raw_len, outfile,
- extable_sec, "extable");
-
- fprintf(outfile, "const struct vdso_image %s = {\n", image_name);
- fprintf(outfile, "\t.data = raw_data,\n");
- fprintf(outfile, "\t.size = %lu,\n", mapping_size);
- if (alt_sec) {
- fprintf(outfile, "\t.alt = %lu,\n",
- (unsigned long)GET_LE(&alt_sec->sh_offset));
- fprintf(outfile, "\t.alt_len = %lu,\n",
- (unsigned long)GET_LE(&alt_sec->sh_size));
- }
- if (extable_sec) {
- fprintf(outfile, "\t.extable_base = %lu,\n",
- (unsigned long)GET_LE(&extable_sec->sh_offset));
- fprintf(outfile, "\t.extable_len = %lu,\n",
- (unsigned long)GET_LE(&extable_sec->sh_size));
- fprintf(outfile, "\t.extable = extable,\n");
- }
-
- for (i = 0; i < NSYMS; i++) {
- if (required_syms[i].export && syms[i])
- fprintf(outfile, "\t.sym_%s = %" PRIi64 ",\n",
- required_syms[i].name, (int64_t)syms[i]);
- }
- fprintf(outfile, "};\n\n");
- fprintf(outfile, "static __init int init_%s(void) {\n", image_name);
- fprintf(outfile, "\treturn init_vdso_image(&%s);\n", image_name);
- fprintf(outfile, "};\n");
- fprintf(outfile, "subsys_initcall(init_%s);\n", image_name);
-
-}
diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
index 7278e25..39a183f 100644
--- a/arch/x86/tools/Makefile
+++ b/arch/x86/tools/Makefile
@@ -38,9 +38,14 @@ $(obj)/insn_decoder_test.o: $(srctree)/tools/arch/x86/lib/insn.c $(srctree)/tool
$(obj)/insn_sanity.o: $(srctree)/tools/arch/x86/lib/insn.c $(srctree)/tools/arch/x86/lib/inat.c $(srctree)/tools/arch/x86/include/asm/inat_types.h $(srctree)/tools/arch/x86/include/asm/inat.h $(srctree)/tools/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
-HOST_EXTRACFLAGS += -I$(srctree)/tools/include
-hostprogs += relocs
-relocs-objs := relocs_32.o relocs_64.o relocs_common.o
-PHONY += relocs
-relocs: $(obj)/relocs
+HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi \
+ -I$(srctree)/arch/$(SUBARCH)/include/uapi
+
+hostprogs += relocs vdso2c
+relocs-objs := relocs_32.o relocs_64.o relocs_common.o
+
+always-y := $(hostprogs)
+
+PHONY += $(hostprogs)
+$(hostprogs): %: $(obj)/%
@:
diff --git a/arch/x86/tools/vdso2c.c b/arch/x86/tools/vdso2c.c
new file mode 100644
index 0000000..f84e8f8
--- /dev/null
+++ b/arch/x86/tools/vdso2c.c
@@ -0,0 +1,233 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * vdso2c - A vdso image preparation tool
+ * Copyright (c) 2014 Andy Lutomirski and others
+ *
+ * vdso2c requires stripped and unstripped input. It would be trivial
+ * to fully strip the input in here, but, for reasons described below,
+ * we need to write a section table. Doing this is more or less
+ * equivalent to dropping all non-allocatable sections, but it's
+ * easier to let objcopy handle that instead of doing it ourselves.
+ * If we ever need to do something fancier than what objcopy provides,
+ * it would be straightforward to add here.
+ *
+ * We're keep a section table for a few reasons:
+ *
+ * The Go runtime had a couple of bugs: it would read the section
+ * table to try to figure out how many dynamic symbols there were (it
+ * shouldn't have looked at the section table at all) and, if there
+ * were no SHT_SYNDYM section table entry, it would use an
+ * uninitialized value for the number of symbols. An empty DYNSYM
+ * table would work, but I see no reason not to write a valid one (and
+ * keep full performance for old Go programs). This hack is only
+ * needed on x86_64.
+ *
+ * The bug was introduced on 2012-08-31 by:
+ * https://code.google.com/p/go/source/detail?r=56ea40aac72b
+ * and was fixed on 2014-06-13 by:
+ * https://code.google.com/p/go/source/detail?r=fc1cd5e12595
+ *
+ * Binutils has issues debugging the vDSO: it reads the section table to
+ * find SHT_NOTE; it won't look at PT_NOTE for the in-memory vDSO, which
+ * would break build-id if we removed the section table. Binutils
+ * also requires that shstrndx != 0. See:
+ * https://sourceware.org/bugzilla/show_bug.cgi?id=17064
+ *
+ * elfutils might not look for PT_NOTE if there is a section table at
+ * all. I don't know whether this matters for any practical purpose.
+ *
+ * For simplicity, rather than hacking up a partial section table, we
+ * just write a mostly complete one. We omit non-dynamic symbols,
+ * though, since they're rather large.
+ *
+ * Once binutils gets fixed, we might be able to drop this for all but
+ * the 64-bit vdso, since build-id only works in kernel RPMs, and
+ * systems that update to new enough kernel RPMs will likely update
+ * binutils in sync. build-id has never worked for home-built kernel
+ * RPMs without manual symlinking, and I suspect that no one ever does
+ * that.
+ */
+
+#include <inttypes.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <err.h>
+
+#include <sys/mman.h>
+#include <sys/types.h>
+
+#include <tools/le_byteshift.h>
+
+#include <linux/elf.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+const char *outfilename;
+
+struct vdso_sym {
+ const char *name;
+ bool export;
+};
+
+struct vdso_sym required_syms[] = {
+ {"VDSO32_NOTE_MASK", true},
+ {"__kernel_vsyscall", true},
+ {"__kernel_sigreturn", true},
+ {"__kernel_rt_sigreturn", true},
+ {"int80_landing_pad", true},
+ {"vdso32_rt_sigreturn_landing_pad", true},
+ {"vdso32_sigreturn_landing_pad", true},
+};
+
+__attribute__((format(printf, 1, 2))) __attribute__((noreturn))
+static void fail(const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ fprintf(stderr, "Error: ");
+ vfprintf(stderr, format, ap);
+ if (outfilename)
+ unlink(outfilename);
+ exit(1);
+ va_end(ap);
+}
+
+/*
+ * Evil macros for little-endian reads and writes
+ */
+#define GLE(x, bits, ifnot) \
+ __builtin_choose_expr( \
+ (sizeof(*(x)) == bits/8), \
+ (__typeof__(*(x)))get_unaligned_le##bits(x), ifnot)
+
+extern void bad_get_le(void);
+#define LAST_GLE(x) \
+ __builtin_choose_expr(sizeof(*(x)) == 1, *(x), bad_get_le())
+
+#define GET_LE(x) \
+ GLE(x, 64, GLE(x, 32, GLE(x, 16, LAST_GLE(x))))
+
+#define PLE(x, val, bits, ifnot) \
+ __builtin_choose_expr( \
+ (sizeof(*(x)) == bits/8), \
+ put_unaligned_le##bits((val), (x)), ifnot)
+
+extern void bad_put_le(void);
+#define LAST_PLE(x, val) \
+ __builtin_choose_expr(sizeof(*(x)) == 1, *(x) = (val), bad_put_le())
+
+#define PUT_LE(x, val) \
+ PLE(x, val, 64, PLE(x, val, 32, PLE(x, val, 16, LAST_PLE(x, val))))
+
+
+#define NSYMS ARRAY_SIZE(required_syms)
+
+#define BITSFUNC3(name, bits, suffix) name##bits##suffix
+#define BITSFUNC2(name, bits, suffix) BITSFUNC3(name, bits, suffix)
+#define BITSFUNC(name) BITSFUNC2(name, ELF_BITS, )
+
+#define INT_BITS BITSFUNC2(int, ELF_BITS, _t)
+
+#define ELF_BITS_XFORM2(bits, x) Elf##bits##_##x
+#define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x)
+#define ELF(x) ELF_BITS_XFORM(ELF_BITS, x)
+
+#define ELF_BITS 64
+#include "vdso2c.h"
+#undef ELF_BITS
+
+#define ELF_BITS 32
+#include "vdso2c.h"
+#undef ELF_BITS
+
+static void go(void *raw_addr, size_t raw_len,
+ void *stripped_addr, size_t stripped_len,
+ FILE *outfile, const char *name)
+{
+ Elf64_Ehdr *hdr = (Elf64_Ehdr *)raw_addr;
+
+ if (hdr->e_ident[EI_CLASS] == ELFCLASS64) {
+ go64(raw_addr, raw_len, stripped_addr, stripped_len,
+ outfile, name);
+ } else if (hdr->e_ident[EI_CLASS] == ELFCLASS32) {
+ go32(raw_addr, raw_len, stripped_addr, stripped_len,
+ outfile, name);
+ } else {
+ fail("unknown ELF class\n");
+ }
+}
+
+static void map_input(const char *name, void **addr, size_t *len, int prot)
+{
+ off_t tmp_len;
+
+ int fd = open(name, O_RDONLY);
+ if (fd == -1)
+ err(1, "open(%s)", name);
+
+ tmp_len = lseek(fd, 0, SEEK_END);
+ if (tmp_len == (off_t)-1)
+ err(1, "lseek");
+ *len = (size_t)tmp_len;
+
+ *addr = mmap(NULL, tmp_len, prot, MAP_PRIVATE, fd, 0);
+ if (*addr == MAP_FAILED)
+ err(1, "mmap");
+
+ close(fd);
+}
+
+int main(int argc, char **argv)
+{
+ size_t raw_len, stripped_len;
+ void *raw_addr, *stripped_addr;
+ FILE *outfile;
+ char *name, *tmp;
+ int namelen;
+
+ if (argc != 4) {
+ printf("Usage: vdso2c RAW_INPUT STRIPPED_INPUT OUTPUT\n");
+ return 1;
+ }
+
+ /*
+ * Figure out the struct name. If we're writing to a .so file,
+ * generate raw output instead.
+ */
+ name = strdup(argv[3]);
+ namelen = strlen(name);
+ if (namelen >= 3 && !strcmp(name + namelen - 3, ".so")) {
+ name = NULL;
+ } else {
+ tmp = strrchr(name, '/');
+ if (tmp)
+ name = tmp + 1;
+ tmp = strchr(name, '.');
+ if (tmp)
+ *tmp = '\0';
+ for (tmp = name; *tmp; tmp++)
+ if (*tmp == '-')
+ *tmp = '_';
+ }
+
+ map_input(argv[1], &raw_addr, &raw_len, PROT_READ);
+ map_input(argv[2], &stripped_addr, &stripped_len, PROT_READ);
+
+ outfilename = argv[3];
+ outfile = fopen(outfilename, "w");
+ if (!outfile)
+ err(1, "fopen(%s)", outfilename);
+
+ go(raw_addr, raw_len, stripped_addr, stripped_len, outfile, name);
+
+ munmap(raw_addr, raw_len);
+ munmap(stripped_addr, stripped_len);
+ fclose(outfile);
+
+ return 0;
+}
diff --git a/arch/x86/tools/vdso2c.h b/arch/x86/tools/vdso2c.h
new file mode 100644
index 0000000..78ed1c1
--- /dev/null
+++ b/arch/x86/tools/vdso2c.h
@@ -0,0 +1,208 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * This file is included twice from vdso2c.c. It generates code for 32-bit
+ * and 64-bit vDSOs. We need both for 64-bit builds, since 32-bit vDSOs
+ * are built for 32-bit userspace.
+ */
+
+static void BITSFUNC(copy)(FILE *outfile, const unsigned char *data, size_t len)
+{
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ if (i % 10 == 0)
+ fprintf(outfile, "\n\t");
+ fprintf(outfile, "0x%02X, ", (int)(data)[i]);
+ }
+}
+
+
+/*
+ * Extract a section from the input data into a standalone blob. Used to
+ * capture kernel-only data that needs to persist indefinitely, e.g. the
+ * exception fixup tables, but only in the kernel, i.e. the section can
+ * be stripped from the final vDSO image.
+ */
+static void BITSFUNC(extract)(const unsigned char *data, size_t data_len,
+ FILE *outfile, ELF(Shdr) *sec, const char *name)
+{
+ unsigned long offset;
+ size_t len;
+
+ offset = (unsigned long)GET_LE(&sec->sh_offset);
+ len = (size_t)GET_LE(&sec->sh_size);
+
+ if (offset + len > data_len)
+ fail("section to extract overruns input data");
+
+ fprintf(outfile, "static const unsigned char %s[%zu] = {", name, len);
+ BITSFUNC(copy)(outfile, data + offset, len);
+ fprintf(outfile, "\n};\n\n");
+}
+
+static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
+ void *stripped_addr, size_t stripped_len,
+ FILE *outfile, const char *image_name)
+{
+ int found_load = 0;
+ unsigned long load_size = -1; /* Work around bogus warning */
+ unsigned long mapping_size;
+ ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
+ unsigned long i, syms_nr;
+ ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
+ *alt_sec = NULL, *extable_sec = NULL;
+ ELF(Dyn) *dyn = 0, *dyn_end = 0;
+ const char *secstrings;
+ INT_BITS syms[NSYMS] = {};
+
+ ELF(Phdr) *pt = (ELF(Phdr) *)(raw_addr + GET_LE(&hdr->e_phoff));
+
+ if (GET_LE(&hdr->e_type) != ET_DYN)
+ fail("input is not a shared object\n");
+
+ /* Walk the segment table. */
+ for (i = 0; i < GET_LE(&hdr->e_phnum); i++) {
+ if (GET_LE(&pt[i].p_type) == PT_LOAD) {
+ if (found_load)
+ fail("multiple PT_LOAD segs\n");
+
+ if (GET_LE(&pt[i].p_offset) != 0 ||
+ GET_LE(&pt[i].p_vaddr) != 0)
+ fail("PT_LOAD in wrong place\n");
+
+ if (GET_LE(&pt[i].p_memsz) != GET_LE(&pt[i].p_filesz))
+ fail("cannot handle memsz != filesz\n");
+
+ load_size = GET_LE(&pt[i].p_memsz);
+ found_load = 1;
+ } else if (GET_LE(&pt[i].p_type) == PT_DYNAMIC) {
+ dyn = raw_addr + GET_LE(&pt[i].p_offset);
+ dyn_end = raw_addr + GET_LE(&pt[i].p_offset) +
+ GET_LE(&pt[i].p_memsz);
+ }
+ }
+ if (!found_load)
+ fail("no PT_LOAD seg\n");
+
+ if (stripped_len < load_size)
+ fail("stripped input is too short\n");
+
+ if (!dyn)
+ fail("input has no PT_DYNAMIC section -- your toolchain is buggy\n");
+
+ /* Walk the dynamic table */
+ for (i = 0; dyn + i < dyn_end &&
+ GET_LE(&dyn[i].d_tag) != DT_NULL; i++) {
+ typeof(dyn[i].d_tag) tag = GET_LE(&dyn[i].d_tag);
+ if (tag == DT_REL || tag == DT_RELSZ || tag == DT_RELA ||
+ tag == DT_RELENT || tag == DT_TEXTREL)
+ fail("vdso image contains dynamic relocations\n");
+ }
+
+ /* Walk the section table */
+ secstrings_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
+ GET_LE(&hdr->e_shentsize)*GET_LE(&hdr->e_shstrndx);
+ secstrings = raw_addr + GET_LE(&secstrings_hdr->sh_offset);
+ for (i = 0; i < GET_LE(&hdr->e_shnum); i++) {
+ ELF(Shdr) *sh = raw_addr + GET_LE(&hdr->e_shoff) +
+ GET_LE(&hdr->e_shentsize) * i;
+ if (GET_LE(&sh->sh_type) == SHT_SYMTAB)
+ symtab_hdr = sh;
+
+ if (!strcmp(secstrings + GET_LE(&sh->sh_name),
+ ".altinstructions"))
+ alt_sec = sh;
+ if (!strcmp(secstrings + GET_LE(&sh->sh_name), "__ex_table"))
+ extable_sec = sh;
+ }
+
+ if (!symtab_hdr)
+ fail("no symbol table\n");
+
+ strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
+ GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link);
+
+ syms_nr = GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
+ /* Walk the symbol table */
+ for (i = 0; i < syms_nr; i++) {
+ unsigned int k;
+ ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
+ GET_LE(&symtab_hdr->sh_entsize) * i;
+ const char *sym_name = raw_addr +
+ GET_LE(&strtab_hdr->sh_offset) +
+ GET_LE(&sym->st_name);
+
+ for (k = 0; k < NSYMS; k++) {
+ if (!strcmp(sym_name, required_syms[k].name)) {
+ if (syms[k]) {
+ fail("duplicate symbol %s\n",
+ required_syms[k].name);
+ }
+
+ /*
+ * Careful: we use negative addresses, but
+ * st_value is unsigned, so we rely
+ * on syms[k] being a signed type of the
+ * correct width.
+ */
+ syms[k] = GET_LE(&sym->st_value);
+ }
+ }
+ }
+
+ if (!image_name) {
+ fwrite(stripped_addr, stripped_len, 1, outfile);
+ return;
+ }
+
+ mapping_size = (stripped_len + 4095) / 4096 * 4096;
+
+ fprintf(outfile, "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */\n\n");
+ fprintf(outfile, "#include <linux/linkage.h>\n");
+ fprintf(outfile, "#include <linux/init.h>\n");
+ fprintf(outfile, "#include <asm/page_types.h>\n");
+ fprintf(outfile, "#include <asm/vdso.h>\n");
+ fprintf(outfile, "\n");
+ fprintf(outfile,
+ "static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
+ mapping_size);
+ for (i = 0; i < stripped_len; i++) {
+ if (i % 10 == 0)
+ fprintf(outfile, "\n\t");
+ fprintf(outfile, "0x%02X, ",
+ (int)((unsigned char *)stripped_addr)[i]);
+ }
+ fprintf(outfile, "\n};\n\n");
+ if (extable_sec)
+ BITSFUNC(extract)(raw_addr, raw_len, outfile,
+ extable_sec, "extable");
+
+ fprintf(outfile, "const struct vdso_image %s = {\n", image_name);
+ fprintf(outfile, "\t.data = raw_data,\n");
+ fprintf(outfile, "\t.size = %lu,\n", mapping_size);
+ if (alt_sec) {
+ fprintf(outfile, "\t.alt = %lu,\n",
+ (unsigned long)GET_LE(&alt_sec->sh_offset));
+ fprintf(outfile, "\t.alt_len = %lu,\n",
+ (unsigned long)GET_LE(&alt_sec->sh_size));
+ }
+ if (extable_sec) {
+ fprintf(outfile, "\t.extable_base = %lu,\n",
+ (unsigned long)GET_LE(&extable_sec->sh_offset));
+ fprintf(outfile, "\t.extable_len = %lu,\n",
+ (unsigned long)GET_LE(&extable_sec->sh_size));
+ fprintf(outfile, "\t.extable = extable,\n");
+ }
+
+ for (i = 0; i < NSYMS; i++) {
+ if (required_syms[i].export && syms[i])
+ fprintf(outfile, "\t.sym_%s = %" PRIi64 ",\n",
+ required_syms[i].name, (int64_t)syms[i]);
+ }
+ fprintf(outfile, "};\n\n");
+ fprintf(outfile, "static __init int init_%s(void) {\n", image_name);
+ fprintf(outfile, "\treturn init_vdso_image(&%s);\n", image_name);
+ fprintf(outfile, "};\n");
+ fprintf(outfile, "subsys_initcall(init_%s);\n", image_name);
+
+}
|
{
"author": "\"tip-bot2 for H. Peter Anvin\" <tip-bot2@linutronix.de>",
"date": "Wed, 14 Jan 2026 00:01:25 -0000",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
lkml
|
[PATCH v4 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
|
This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.
Be more strict about sanitizing and standardizing the vdso build
options.
Disable CFI for the vdso until the kernel adds user space IBT support.
Modernize the DWARF generation vdso32/sigreturn.S.
Add macros to cleanly call system calls from vdso source code.
Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.
When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.
Changes from v3 to v4:
- Improved description of patch 01/10.
- Split out the move of vdso2c to tools into a separate patch.
- Remove unrelated formatting changes from vdso-layout.lds.S.
- Fix *-x32.o being missing from "targets".
- Rebased onto v6.19-rc1.
Changes from v2 to v3:
In arch/x86/include/asm/vdso/sys_call.h:
- remove stray comment from prototyping (Uros Biszjak)
- remove VDSO_SYSCALL6() since it would require special
handling on 32 bits with frame pointers and is
currently unused. (Uros Biszjak)
- indent nested preprocessor directives.
Changes from v1 to v2:
Too many to count - much of the patchset has been reworked
Patches:
x86/entry/vdso: rename vdso_image_* to vdso*_image
x86/entry/vdso: move vdso2c to arch/x86/tools
x86/entry/vdso: refactor the vdso build
x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
x86/vdso: abstract out vdso system call internals
x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
x86/entry/vdso32: when using int $0x80, use it directly
---
arch/x86/Kconfig.cpufeatures | 8 +
arch/x86/Makefile | 2 +-
arch/x86/entry/syscall_32.c | 2 +-
arch/x86/entry/vdso/.gitignore | 11 +-
arch/x86/entry/vdso/Makefile | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include | 89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} | 5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c | 0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S | 38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c | 0
arch/x86/entry/vdso/vdso32/Makefile | 24 +++
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S | 22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++++
arch/x86/entry/vdso/vdso64/note.S | 1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S | 2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S | 0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c | 2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S | 0
arch/x86/entry/vdso/vma.c | 24 ++-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/dwarf2.h | 1 +
arch/x86/include/asm/elf.h | 2 +-
arch/x86/include/asm/vdso.h | 6 +-
arch/x86/include/asm/vdso/gettimeofday.h | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c | 6 +
arch/x86/kernel/cpu/centaur.c | 3 -
arch/x86/kernel/cpu/common.c | 8 +
arch/x86/kernel/cpu/intel.c | 4 +-
arch/x86/kernel/cpu/zhaoxin.c | 4 +-
arch/x86/kernel/fred.c | 2 +-
arch/x86/kernel/process_64.c | 6 +-
arch/x86/kernel/signal_32.c | 4 +-
arch/x86/tools/Makefile | 15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c | 0
arch/x86/{entry/vdso => tools}/vdso2c.h | 0
arch/x86/xen/setup.c | 28 ++--
arch/x86/xen/smp_pv.c | 5 +-
arch/x86/xen/xen-ops.h | 1 -
47 files changed, 444 insertions(+), 490 deletions(-)
|
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 693c819fedcdcabfda7488e2d5e355a84c2fd1b0
Gitweb: https://git.kernel.org/tip/693c819fedcdcabfda7488e2d5e355a84c2fd1b0
Author: H. Peter Anvin <hpa@zytor.com>
AuthorDate: Tue, 16 Dec 2025 13:25:57 -08:00
Committer: Dave Hansen <dave.hansen@linux.intel.com>
CommitterDate: Tue, 13 Jan 2026 15:35:09 -08:00
x86/entry/vdso: Refactor the vdso build
- Separate out the vdso sources into common, vdso32, and vdso64
directories.
- Build the 32- and 64-bit vdsos in their respective subdirectories;
this greatly simplifies the build flags handling.
- Unify the mangling of Makefile flags between the 32- and 64-bit
vdso code as much as possible; all common rules are put in
arch/x86/entry/vdso/common/Makefile.include. The remaining
is very simple for 32 bits; the 64-bit one is only slightly more
complicated because it contains the x32 generation rule.
- Define __DISABLE_EXPORTS when building the vdso. This need seems to
have been masked by different ordering compile flags before.
- Change CONFIG_X86_64 to BUILD_VDSO32_64 in vdso32/system_call.S,
to make it compatible with including fake_32bit_build.h.
- The -fcf-protection= option was "leaking" from the kernel build,
for reasons that was not clear to me. Furthermore, several
distributions ship with it set to a default value other than
"-fcf-protection=none". Make it match the configuration options
for *user space*.
Note that this patch may seem large, but the vast majority of it is
simply code movement.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://patch.msgid.link/20251216212606.1325678-4-hpa@zytor.com
---
arch/x86/entry/vdso/Makefile | 161 +--------------
arch/x86/entry/vdso/common/Makefile.include | 89 ++++++++-
arch/x86/entry/vdso/common/note.S | 18 ++-
arch/x86/entry/vdso/common/vclock_gettime.c | 77 +++++++-
arch/x86/entry/vdso/common/vdso-layout.lds.S | 101 +++++++++-
arch/x86/entry/vdso/common/vgetcpu.c | 22 ++-
arch/x86/entry/vdso/vclock_gettime.c | 77 +-------
arch/x86/entry/vdso/vdso-layout.lds.S | 101 +---------
arch/x86/entry/vdso/vdso-note.S | 15 +-
arch/x86/entry/vdso/vdso.lds.S | 37 +---
arch/x86/entry/vdso/vdso32/Makefile | 24 ++-
arch/x86/entry/vdso/vdso32/note.S | 19 +--
arch/x86/entry/vdso/vdso32/system_call.S | 2 +-
arch/x86/entry/vdso/vdso32/vclock_gettime.c | 5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c | 4 +-
arch/x86/entry/vdso/vdso64/Makefile | 46 ++++-
arch/x86/entry/vdso/vdso64/note.S | 1 +-
arch/x86/entry/vdso/vdso64/vclock_gettime.c | 1 +-
arch/x86/entry/vdso/vdso64/vdso64.lds.S | 37 +++-
arch/x86/entry/vdso/vdso64/vdsox32.lds.S | 27 ++-
arch/x86/entry/vdso/vdso64/vgetcpu.c | 1 +-
arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S | 178 ++++++++++++++++-
arch/x86/entry/vdso/vdso64/vgetrandom.c | 15 +-
arch/x86/entry/vdso/vdso64/vsgx.S | 150 +++++++++++++-
arch/x86/entry/vdso/vdsox32.lds.S | 27 +--
arch/x86/entry/vdso/vgetcpu.c | 22 +--
arch/x86/entry/vdso/vgetrandom-chacha.S | 178 +----------------
arch/x86/entry/vdso/vgetrandom.c | 15 +-
arch/x86/entry/vdso/vsgx.S | 150 +-------------
30 files changed, 798 insertions(+), 804 deletions(-)
create mode 100644 arch/x86/entry/vdso/common/Makefile.include
create mode 100644 arch/x86/entry/vdso/common/note.S
create mode 100644 arch/x86/entry/vdso/common/vclock_gettime.c
create mode 100644 arch/x86/entry/vdso/common/vdso-layout.lds.S
create mode 100644 arch/x86/entry/vdso/common/vgetcpu.c
delete mode 100644 arch/x86/entry/vdso/vclock_gettime.c
delete mode 100644 arch/x86/entry/vdso/vdso-layout.lds.S
delete mode 100644 arch/x86/entry/vdso/vdso-note.S
delete mode 100644 arch/x86/entry/vdso/vdso.lds.S
create mode 100644 arch/x86/entry/vdso/vdso32/Makefile
create mode 100644 arch/x86/entry/vdso/vdso64/Makefile
create mode 100644 arch/x86/entry/vdso/vdso64/note.S
create mode 100644 arch/x86/entry/vdso/vdso64/vclock_gettime.c
create mode 100644 arch/x86/entry/vdso/vdso64/vdso64.lds.S
create mode 100644 arch/x86/entry/vdso/vdso64/vdsox32.lds.S
create mode 100644 arch/x86/entry/vdso/vdso64/vgetcpu.c
create mode 100644 arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S
create mode 100644 arch/x86/entry/vdso/vdso64/vgetrandom.c
create mode 100644 arch/x86/entry/vdso/vdso64/vsgx.S
delete mode 100644 arch/x86/entry/vdso/vdsox32.lds.S
delete mode 100644 arch/x86/entry/vdso/vgetcpu.c
delete mode 100644 arch/x86/entry/vdso/vgetrandom-chacha.S
delete mode 100644 arch/x86/entry/vdso/vgetrandom.c
delete mode 100644 arch/x86/entry/vdso/vsgx.S
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 3d9b09f..987b43f 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -3,159 +3,10 @@
# Building vDSO images for x86.
#
-# Include the generic Makefile to check the built vDSO:
-include $(srctree)/lib/vdso/Makefile.include
+# Regular kernel objects
+obj-y := vma.o extable.o
+obj-$(CONFIG_COMPAT_32) += vdso32-setup.o
-# Files to link into the vDSO:
-vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vgetrandom.o vgetrandom-chacha.o
-vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
-vobjs32-y += vdso32/vclock_gettime.o vdso32/vgetcpu.o
-vobjs-$(CONFIG_X86_SGX) += vsgx.o
-
-# Files to link into the kernel:
-obj-y += vma.o extable.o
-
-# vDSO images to build:
-obj-$(CONFIG_X86_64) += vdso64-image.o
-obj-$(CONFIG_X86_X32_ABI) += vdsox32-image.o
-obj-$(CONFIG_COMPAT_32) += vdso32-image.o vdso32-setup.o
-
-vobjs := $(addprefix $(obj)/, $(vobjs-y))
-vobjs32 := $(addprefix $(obj)/, $(vobjs32-y))
-
-$(obj)/vdso.o: $(obj)/vdso.so
-
-targets += vdso.lds $(vobjs-y)
-targets += vdso32/vdso32.lds $(vobjs32-y)
-
-targets += $(foreach x, 64 x32 32, vdso-image-$(x).c vdso$(x).so vdso$(x).so.dbg)
-
-CPPFLAGS_vdso.lds += -P -C
-
-VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 \
- -z max-page-size=4096
-
-$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
- $(call if_changed,vdso_and_check)
-
-VDSO2C = $(objtree)/arch/x86/tools/vdso2c
-
-quiet_cmd_vdso2c = VDSO2C $@
- cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
-
-$(obj)/vdso%-image.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(VDSO2C) FORCE
- $(call if_changed,vdso2c)
-
-#
-# Don't omit frame pointers for ease of userspace debugging, but do
-# optimize sibling calls.
-#
-CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
- $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
- -fno-omit-frame-pointer -foptimize-sibling-calls \
- -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
-
-ifdef CONFIG_MITIGATION_RETPOLINE
-ifneq ($(RETPOLINE_VDSO_CFLAGS),)
- CFL += $(RETPOLINE_VDSO_CFLAGS)
-endif
-endif
-
-$(vobjs): KBUILD_CFLAGS := $(filter-out $(PADDING_CFLAGS) $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) $(RANDSTRUCT_CFLAGS) $(KSTACK_ERASE_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
-$(vobjs): KBUILD_AFLAGS += -DBUILD_VDSO
-
-#
-# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
-#
-CFLAGS_REMOVE_vclock_gettime.o = -pg
-CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
-CFLAGS_REMOVE_vgetcpu.o = -pg
-CFLAGS_REMOVE_vdso32/vgetcpu.o = -pg
-CFLAGS_REMOVE_vsgx.o = -pg
-CFLAGS_REMOVE_vgetrandom.o = -pg
-
-#
-# X32 processes use x32 vDSO to access 64bit kernel data.
-#
-# Build x32 vDSO image:
-# 1. Compile x32 vDSO as 64bit.
-# 2. Convert object files to x32.
-# 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
-# so that it can reach 64bit address space with 64bit pointers.
-#
-
-CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \
- -z max-page-size=4096
-
-# x32-rebranded versions
-vobjx32s-y := $(vobjs-y:.o=-x32.o)
-
-# same thing, but in the output directory
-vobjx32s := $(addprefix $(obj)/, $(vobjx32s-y))
-
-# Convert 64bit object file to x32 for x32 vDSO.
-quiet_cmd_x32 = X32 $@
- cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@
-
-$(obj)/%-x32.o: $(obj)/%.o FORCE
- $(call if_changed,x32)
-
-targets += vdsox32.lds $(vobjx32s-y)
-
-$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section __ex_table
-$(obj)/%.so: $(obj)/%.so.dbg FORCE
- $(call if_changed,objcopy)
-
-$(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
- $(call if_changed,vdso_and_check)
-
-CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
-
-KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
-$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
-$(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32
-
-KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
-KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(KSTACK_ERASE_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(CC_FLAGS_CFI),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 := $(filter-out $(PADDING_CFLAGS),$(KBUILD_CFLAGS_32))
-KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic
-KBUILD_CFLAGS_32 += -fno-stack-protector
-KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
-KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
-KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
-KBUILD_CFLAGS_32 += -DBUILD_VDSO
-
-ifdef CONFIG_MITIGATION_RETPOLINE
-ifneq ($(RETPOLINE_VDSO_CFLAGS),)
- KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS)
-endif
-endif
-
-$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
-
-$(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE
- $(call if_changed,vdso_and_check)
-
-#
-# The DSO images are built using a special linker script.
-#
-quiet_cmd_vdso = VDSO $@
- cmd_vdso = $(LD) -o $@ \
- $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
- -T $(filter %.lds,$^) $(filter %.o,$^)
-
-VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 --no-undefined \
- $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack
-
-quiet_cmd_vdso_and_check = VDSO $@
- cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
+# vDSO directories
+obj-$(CONFIG_X86_64) += vdso64/
+obj-$(CONFIG_COMPAT_32) += vdso32/
diff --git a/arch/x86/entry/vdso/common/Makefile.include b/arch/x86/entry/vdso/common/Makefile.include
new file mode 100644
index 0000000..3514b4a
--- /dev/null
+++ b/arch/x86/entry/vdso/common/Makefile.include
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Building vDSO images for x86.
+#
+
+# Include the generic Makefile to check the built vDSO:
+include $(srctree)/lib/vdso/Makefile.include
+
+obj-y += $(foreach x,$(vdsos-y),vdso$(x)-image.o)
+
+targets += $(foreach x,$(vdsos-y),vdso$(x)-image.c vdso$(x).so vdso$(x).so.dbg vdso$(x).lds)
+targets += $(vobjs-y)
+
+# vobjs-y with $(obj)/ prepended
+vobjs := $(addprefix $(obj)/,$(vobjs-y))
+
+# Options for vdso*.lds
+CPPFLAGS_VDSO_LDS := -P -C -I$(src)/..
+$(obj)/%.lds : KBUILD_CPPFLAGS += $(CPPFLAGS_VDSO_LDS)
+
+#
+# Options from KBUILD_[AC]FLAGS that should *NOT* be kept
+#
+flags-remove-y += \
+ -D__KERNEL__ -mcmodel=kernel -mregparm=3 \
+ -fno-pic -fno-PIC -fno-pie fno-PIE \
+ -mfentry -pg \
+ $(RANDSTRUCT_CFLAGS) $(GCC_PLUGIN_CFLAGS) $(KSTACK_ERASE_CFLAGS) \
+ $(RETPOLINE_CFLAGS) $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \
+ $(PADDING_CFLAGS)
+
+#
+# Don't omit frame pointers for ease of userspace debugging, but do
+# optimize sibling calls.
+#
+flags-y += -D__DISABLE_EXPORTS
+flags-y += -DDISABLE_BRANCH_PROFILING
+flags-y += -DBUILD_VDSO
+flags-y += -I$(src)/.. -I$(srctree)
+flags-y += -O2 -fpic
+flags-y += -fno-stack-protector
+flags-y += -fno-omit-frame-pointer
+flags-y += -foptimize-sibling-calls
+flags-y += -fasynchronous-unwind-tables
+
+# Reset cf protections enabled by compiler default
+flags-y += $(call cc-option, -fcf-protection=none)
+flags-$(X86_USER_SHADOW_STACK) += $(call cc-option, -fcf-protection=return)
+# When user space IBT is supported, enable this.
+# flags-$(CONFIG_USER_IBT) += $(call cc-option, -fcf-protection=branch)
+
+flags-$(CONFIG_MITIGATION_RETPOLINE) += $(RETPOLINE_VDSO_CFLAGS)
+
+# These need to be conditional on $(vobjs) as they do not apply to
+# the output vdso*-image.o files which are standard kernel objects.
+$(vobjs) : KBUILD_AFLAGS := \
+ $(filter-out $(flags-remove-y),$(KBUILD_AFLAGS)) $(flags-y)
+$(vobjs) : KBUILD_CFLAGS := \
+ $(filter-out $(flags-remove-y),$(KBUILD_CFLAGS)) $(flags-y)
+
+#
+# The VDSO images are built using a special linker script.
+#
+VDSO_LDFLAGS := -shared --hash-style=both --build-id=sha1 --no-undefined \
+ $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack
+
+quiet_cmd_vdso = VDSO $@
+ cmd_vdso = $(LD) -o $@ \
+ $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$*) \
+ -T $(filter %.lds,$^) $(filter %.o,$^)
+quiet_cmd_vdso_and_check = VDSO $@
+ cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check)
+
+$(obj)/vdso%.so.dbg: $(obj)/vdso%.lds FORCE
+ $(call if_changed,vdso_and_check)
+
+$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section __ex_table
+$(obj)/%.so: $(obj)/%.so.dbg FORCE
+ $(call if_changed,objcopy)
+
+VDSO2C = $(objtree)/arch/x86/tools/vdso2c
+
+quiet_cmd_vdso2c = VDSO2C $@
+ cmd_vdso2c = $(VDSO2C) $< $(<:%.dbg=%) $@
+
+$(obj)/%-image.c: $(obj)/%.so.dbg $(obj)/%.so $(VDSO2C) FORCE
+ $(call if_changed,vdso2c)
+
+$(obj)/%-image.o: $(obj)/%-image.c
diff --git a/arch/x86/entry/vdso/common/note.S b/arch/x86/entry/vdso/common/note.S
new file mode 100644
index 0000000..2cbd399
--- /dev/null
+++ b/arch/x86/entry/vdso/common/note.S
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
+ * Here we can supply some information useful to userland.
+ */
+
+#include <linux/build-salt.h>
+#include <linux/version.h>
+#include <linux/elfnote.h>
+
+/* Ideally this would use UTS_NAME, but using a quoted string here
+ doesn't work. Remember to change this when changing the
+ kernel's name. */
+ELFNOTE_START(Linux, 0, "a")
+ .long LINUX_VERSION_CODE
+ELFNOTE_END
+
+BUILD_SALT
diff --git a/arch/x86/entry/vdso/common/vclock_gettime.c b/arch/x86/entry/vdso/common/vclock_gettime.c
new file mode 100644
index 0000000..0debc19
--- /dev/null
+++ b/arch/x86/entry/vdso/common/vclock_gettime.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Fast user context implementation of clock_gettime, gettimeofday, and time.
+ *
+ * Copyright 2006 Andi Kleen, SUSE Labs.
+ * Copyright 2019 ARM Limited
+ *
+ * 32 Bit compat layer by Stefani Seibold <stefani@seibold.net>
+ * sponsored by Rohde & Schwarz GmbH & Co. KG Munich/Germany
+ */
+#include <linux/time.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <vdso/gettime.h>
+
+#include "../../../../lib/vdso/gettimeofday.c"
+
+int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
+{
+ return __cvdso_gettimeofday(tv, tz);
+}
+
+int gettimeofday(struct __kernel_old_timeval *, struct timezone *)
+ __attribute__((weak, alias("__vdso_gettimeofday")));
+
+__kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
+{
+ return __cvdso_time(t);
+}
+
+__kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time")));
+
+
+#if defined(CONFIG_X86_64) && !defined(BUILD_VDSO32_64)
+/* both 64-bit and x32 use these */
+int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
+{
+ return __cvdso_clock_gettime(clock, ts);
+}
+
+int clock_gettime(clockid_t, struct __kernel_timespec *)
+ __attribute__((weak, alias("__vdso_clock_gettime")));
+
+int __vdso_clock_getres(clockid_t clock,
+ struct __kernel_timespec *res)
+{
+ return __cvdso_clock_getres(clock, res);
+}
+int clock_getres(clockid_t, struct __kernel_timespec *)
+ __attribute__((weak, alias("__vdso_clock_getres")));
+
+#else
+/* i386 only */
+int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts)
+{
+ return __cvdso_clock_gettime32(clock, ts);
+}
+
+int clock_gettime(clockid_t, struct old_timespec32 *)
+ __attribute__((weak, alias("__vdso_clock_gettime")));
+
+int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts)
+{
+ return __cvdso_clock_gettime(clock, ts);
+}
+
+int clock_gettime64(clockid_t, struct __kernel_timespec *)
+ __attribute__((weak, alias("__vdso_clock_gettime64")));
+
+int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res)
+{
+ return __cvdso_clock_getres_time32(clock, res);
+}
+
+int clock_getres(clockid_t, struct old_timespec32 *)
+ __attribute__((weak, alias("__vdso_clock_getres")));
+#endif
diff --git a/arch/x86/entry/vdso/common/vdso-layout.lds.S b/arch/x86/entry/vdso/common/vdso-layout.lds.S
new file mode 100644
index 0000000..ec1ac19
--- /dev/null
+++ b/arch/x86/entry/vdso/common/vdso-layout.lds.S
@@ -0,0 +1,101 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <asm/vdso.h>
+#include <asm/vdso/vsyscall.h>
+#include <vdso/datapage.h>
+
+/*
+ * Linker script for vDSO. This is an ELF shared object prelinked to
+ * its virtual address, and with only one read-only segment.
+ * This script controls its layout.
+ */
+
+SECTIONS
+{
+ /*
+ * User/kernel shared data is before the vDSO. This may be a little
+ * uglier than putting it after the vDSO, but it avoids issues with
+ * non-allocatable things that dangle past the end of the PT_LOAD
+ * segment.
+ */
+
+ VDSO_VVAR_SYMS
+
+ vclock_pages = VDSO_VCLOCK_PAGES_START(vdso_u_data);
+ pvclock_page = vclock_pages + VDSO_PAGE_PVCLOCK_OFFSET * PAGE_SIZE;
+ hvclock_page = vclock_pages + VDSO_PAGE_HVCLOCK_OFFSET * PAGE_SIZE;
+
+ . = SIZEOF_HEADERS;
+
+ .hash : { *(.hash) } :text
+ .gnu.hash : { *(.gnu.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+
+ .dynamic : { *(.dynamic) } :text :dynamic
+
+ .rodata : {
+ *(.rodata*)
+ *(.data*)
+ *(.sdata*)
+ *(.got.plt) *(.got)
+ *(.gnu.linkonce.d.*)
+ *(.bss*)
+ *(.dynbss*)
+ *(.gnu.linkonce.b.*)
+ } :text
+
+ /*
+ * Discard .note.gnu.property sections which are unused and have
+ * different alignment requirement from vDSO note sections.
+ */
+ /DISCARD/ : {
+ *(.note.gnu.property)
+ }
+ .note : { *(.note.*) } :text :note
+
+ .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
+ .eh_frame : { KEEP (*(.eh_frame)) } :text
+
+
+ /*
+ * Text is well-separated from actual data: there's plenty of
+ * stuff that isn't used at runtime in between.
+ */
+
+ .text : {
+ *(.text*)
+ } :text =0x90909090,
+
+
+
+ .altinstructions : { *(.altinstructions) } :text
+ .altinstr_replacement : { *(.altinstr_replacement) } :text
+
+ __ex_table : { *(__ex_table) } :text
+
+ /DISCARD/ : {
+ *(.discard)
+ *(.discard.*)
+ *(__bug_table)
+ }
+}
+
+/*
+ * Very old versions of ld do not recognize this name token; use the constant.
+ */
+#define PT_GNU_EH_FRAME 0x6474e550
+
+/*
+ * We must supply the ELF program headers explicitly to get just one
+ * PT_LOAD segment, and set the flags explicitly to make segments read-only.
+ */
+PHDRS
+{
+ text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
+ dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
+ note PT_NOTE FLAGS(4); /* PF_R */
+ eh_frame_hdr PT_GNU_EH_FRAME;
+}
diff --git a/arch/x86/entry/vdso/common/vgetcpu.c b/arch/x86/entry/vdso/common/vgetcpu.c
new file mode 100644
index 0000000..e464030
--- /dev/null
+++ b/arch/x86/entry/vdso/common/vgetcpu.c
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2006 Andi Kleen, SUSE Labs.
+ *
+ * Fast user context implementation of getcpu()
+ */
+
+#include <linux/kernel.h>
+#include <linux/getcpu.h>
+#include <asm/segment.h>
+#include <vdso/processor.h>
+
+notrace long
+__vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
+{
+ vdso_read_cpunode(cpu, node);
+
+ return 0;
+}
+
+long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
+ __attribute__((weak, alias("__vdso_getcpu")));
diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c
deleted file mode 100644
index 0debc19..0000000
--- a/arch/x86/entry/vdso/vclock_gettime.c
+++ /dev/null
@@ -1,77 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Fast user context implementation of clock_gettime, gettimeofday, and time.
- *
- * Copyright 2006 Andi Kleen, SUSE Labs.
- * Copyright 2019 ARM Limited
- *
- * 32 Bit compat layer by Stefani Seibold <stefani@seibold.net>
- * sponsored by Rohde & Schwarz GmbH & Co. KG Munich/Germany
- */
-#include <linux/time.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <vdso/gettime.h>
-
-#include "../../../../lib/vdso/gettimeofday.c"
-
-int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
-{
- return __cvdso_gettimeofday(tv, tz);
-}
-
-int gettimeofday(struct __kernel_old_timeval *, struct timezone *)
- __attribute__((weak, alias("__vdso_gettimeofday")));
-
-__kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
-{
- return __cvdso_time(t);
-}
-
-__kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time")));
-
-
-#if defined(CONFIG_X86_64) && !defined(BUILD_VDSO32_64)
-/* both 64-bit and x32 use these */
-int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
-{
- return __cvdso_clock_gettime(clock, ts);
-}
-
-int clock_gettime(clockid_t, struct __kernel_timespec *)
- __attribute__((weak, alias("__vdso_clock_gettime")));
-
-int __vdso_clock_getres(clockid_t clock,
- struct __kernel_timespec *res)
-{
- return __cvdso_clock_getres(clock, res);
-}
-int clock_getres(clockid_t, struct __kernel_timespec *)
- __attribute__((weak, alias("__vdso_clock_getres")));
-
-#else
-/* i386 only */
-int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts)
-{
- return __cvdso_clock_gettime32(clock, ts);
-}
-
-int clock_gettime(clockid_t, struct old_timespec32 *)
- __attribute__((weak, alias("__vdso_clock_gettime")));
-
-int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts)
-{
- return __cvdso_clock_gettime(clock, ts);
-}
-
-int clock_gettime64(clockid_t, struct __kernel_timespec *)
- __attribute__((weak, alias("__vdso_clock_gettime64")));
-
-int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res)
-{
- return __cvdso_clock_getres_time32(clock, res);
-}
-
-int clock_getres(clockid_t, struct old_timespec32 *)
- __attribute__((weak, alias("__vdso_clock_getres")));
-#endif
diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S
deleted file mode 100644
index ec1ac19..0000000
--- a/arch/x86/entry/vdso/vdso-layout.lds.S
+++ /dev/null
@@ -1,101 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#include <asm/vdso.h>
-#include <asm/vdso/vsyscall.h>
-#include <vdso/datapage.h>
-
-/*
- * Linker script for vDSO. This is an ELF shared object prelinked to
- * its virtual address, and with only one read-only segment.
- * This script controls its layout.
- */
-
-SECTIONS
-{
- /*
- * User/kernel shared data is before the vDSO. This may be a little
- * uglier than putting it after the vDSO, but it avoids issues with
- * non-allocatable things that dangle past the end of the PT_LOAD
- * segment.
- */
-
- VDSO_VVAR_SYMS
-
- vclock_pages = VDSO_VCLOCK_PAGES_START(vdso_u_data);
- pvclock_page = vclock_pages + VDSO_PAGE_PVCLOCK_OFFSET * PAGE_SIZE;
- hvclock_page = vclock_pages + VDSO_PAGE_HVCLOCK_OFFSET * PAGE_SIZE;
-
- . = SIZEOF_HEADERS;
-
- .hash : { *(.hash) } :text
- .gnu.hash : { *(.gnu.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
-
- .dynamic : { *(.dynamic) } :text :dynamic
-
- .rodata : {
- *(.rodata*)
- *(.data*)
- *(.sdata*)
- *(.got.plt) *(.got)
- *(.gnu.linkonce.d.*)
- *(.bss*)
- *(.dynbss*)
- *(.gnu.linkonce.b.*)
- } :text
-
- /*
- * Discard .note.gnu.property sections which are unused and have
- * different alignment requirement from vDSO note sections.
- */
- /DISCARD/ : {
- *(.note.gnu.property)
- }
- .note : { *(.note.*) } :text :note
-
- .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
- .eh_frame : { KEEP (*(.eh_frame)) } :text
-
-
- /*
- * Text is well-separated from actual data: there's plenty of
- * stuff that isn't used at runtime in between.
- */
-
- .text : {
- *(.text*)
- } :text =0x90909090,
-
-
-
- .altinstructions : { *(.altinstructions) } :text
- .altinstr_replacement : { *(.altinstr_replacement) } :text
-
- __ex_table : { *(__ex_table) } :text
-
- /DISCARD/ : {
- *(.discard)
- *(.discard.*)
- *(__bug_table)
- }
-}
-
-/*
- * Very old versions of ld do not recognize this name token; use the constant.
- */
-#define PT_GNU_EH_FRAME 0x6474e550
-
-/*
- * We must supply the ELF program headers explicitly to get just one
- * PT_LOAD segment, and set the flags explicitly to make segments read-only.
- */
-PHDRS
-{
- text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
- dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
- note PT_NOTE FLAGS(4); /* PF_R */
- eh_frame_hdr PT_GNU_EH_FRAME;
-}
diff --git a/arch/x86/entry/vdso/vdso-note.S b/arch/x86/entry/vdso/vdso-note.S
deleted file mode 100644
index 7942317..0000000
--- a/arch/x86/entry/vdso/vdso-note.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
- * Here we can supply some information useful to userland.
- */
-
-#include <linux/build-salt.h>
-#include <linux/uts.h>
-#include <linux/version.h>
-#include <linux/elfnote.h>
-
-ELFNOTE_START(Linux, 0, "a")
- .long LINUX_VERSION_CODE
-ELFNOTE_END
-
-BUILD_SALT
diff --git a/arch/x86/entry/vdso/vdso.lds.S b/arch/x86/entry/vdso/vdso.lds.S
deleted file mode 100644
index 0bab5f4..0000000
--- a/arch/x86/entry/vdso/vdso.lds.S
+++ /dev/null
@@ -1,37 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Linker script for 64-bit vDSO.
- * We #include the file to define the layout details.
- *
- * This file defines the version script giving the user-exported symbols in
- * the DSO.
- */
-
-#define BUILD_VDSO64
-
-#include "vdso-layout.lds.S"
-
-/*
- * This controls what userland symbols we export from the vDSO.
- */
-VERSION {
- LINUX_2.6 {
- global:
- clock_gettime;
- __vdso_clock_gettime;
- gettimeofday;
- __vdso_gettimeofday;
- getcpu;
- __vdso_getcpu;
- time;
- __vdso_time;
- clock_getres;
- __vdso_clock_getres;
-#ifdef CONFIG_X86_SGX
- __vdso_sgx_enter_enclave;
-#endif
- getrandom;
- __vdso_getrandom;
- local: *;
- };
-}
diff --git a/arch/x86/entry/vdso/vdso32/Makefile b/arch/x86/entry/vdso/vdso32/Makefile
new file mode 100644
index 0000000..add6afb
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso32/Makefile
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# 32-bit vDSO images for x86.
+#
+
+# The vDSOs built in this directory
+vdsos-y := 32
+
+# Files to link into the vDSO:
+vobjs-y := note.o vclock_gettime.o vgetcpu.o
+vobjs-y += system_call.o sigreturn.o
+
+# Compilation flags
+flags-y := -DBUILD_VDSO32 -m32 -mregparm=0
+flags-$(CONFIG_X86_64) += -include $(src)/fake_32bit_build.h
+flags-remove-y := -m64
+
+# The location of this include matters!
+include $(src)/../common/Makefile.include
+
+# Linker options for the vdso
+VDSO_LDFLAGS_32 := -m elf_i386 -soname linux-gate.so.1
+
+$(obj)/vdso32.so.dbg: $(vobjs)
diff --git a/arch/x86/entry/vdso/vdso32/note.S b/arch/x86/entry/vdso/vdso32/note.S
index 2cbd399..62d8aa5 100644
--- a/arch/x86/entry/vdso/vdso32/note.S
+++ b/arch/x86/entry/vdso/vdso32/note.S
@@ -1,18 +1 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
- * Here we can supply some information useful to userland.
- */
-
-#include <linux/build-salt.h>
-#include <linux/version.h>
-#include <linux/elfnote.h>
-
-/* Ideally this would use UTS_NAME, but using a quoted string here
- doesn't work. Remember to change this when changing the
- kernel's name. */
-ELFNOTE_START(Linux, 0, "a")
- .long LINUX_VERSION_CODE
-ELFNOTE_END
-
-BUILD_SALT
+#include "common/note.S"
diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso/vdso32/system_call.S
index d33c651..2a15634 100644
--- a/arch/x86/entry/vdso/vdso32/system_call.S
+++ b/arch/x86/entry/vdso/vdso32/system_call.S
@@ -52,7 +52,7 @@ __kernel_vsyscall:
#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
-#ifdef CONFIG_X86_64
+#ifdef BUILD_VDSO32_64
/* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \
SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
diff --git a/arch/x86/entry/vdso/vdso32/vclock_gettime.c b/arch/x86/entry/vdso/vdso32/vclock_gettime.c
index 86981de..1481f00 100644
--- a/arch/x86/entry/vdso/vdso32/vclock_gettime.c
+++ b/arch/x86/entry/vdso/vdso32/vclock_gettime.c
@@ -1,4 +1 @@
-// SPDX-License-Identifier: GPL-2.0
-#define BUILD_VDSO32
-#include "fake_32bit_build.h"
-#include "../vclock_gettime.c"
+#include "common/vclock_gettime.c"
diff --git a/arch/x86/entry/vdso/vdso32/vdso32.lds.S b/arch/x86/entry/vdso/vdso32/vdso32.lds.S
index 8a3be07..8a85354 100644
--- a/arch/x86/entry/vdso/vdso32/vdso32.lds.S
+++ b/arch/x86/entry/vdso/vdso32/vdso32.lds.S
@@ -11,7 +11,7 @@
#define BUILD_VDSO32
-#include "../vdso-layout.lds.S"
+#include "common/vdso-layout.lds.S"
/* The ELF entry point can be used to set the AT_SYSINFO value. */
ENTRY(__kernel_vsyscall);
diff --git a/arch/x86/entry/vdso/vdso32/vgetcpu.c b/arch/x86/entry/vdso/vdso32/vgetcpu.c
index 3a9791f..00cc832 100644
--- a/arch/x86/entry/vdso/vdso32/vgetcpu.c
+++ b/arch/x86/entry/vdso/vdso32/vgetcpu.c
@@ -1,3 +1 @@
-// SPDX-License-Identifier: GPL-2.0
-#include "fake_32bit_build.h"
-#include "../vgetcpu.c"
+#include "common/vgetcpu.c"
diff --git a/arch/x86/entry/vdso/vdso64/Makefile b/arch/x86/entry/vdso/vdso64/Makefile
new file mode 100644
index 0000000..bfffaf1
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/Makefile
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# 64-bit vDSO images for x86.
+#
+
+# The vDSOs built in this directory
+vdsos-y := 64
+vdsos-$(CONFIG_X86_X32_ABI) += x32
+
+# Files to link into the vDSO:
+vobjs-y := note.o vclock_gettime.o vgetcpu.o
+vobjs-y += vgetrandom.o vgetrandom-chacha.o
+vobjs-$(CONFIG_X86_SGX) += vsgx.o
+
+# Compilation flags
+flags-y := -DBUILD_VDSO64 -m64 -mcmodel=small
+
+# The location of this include matters!
+include $(src)/../common/Makefile.include
+
+#
+# X32 processes use x32 vDSO to access 64bit kernel data.
+#
+# Build x32 vDSO image:
+# 1. Compile x32 vDSO as 64bit.
+# 2. Convert object files to x32.
+# 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
+# so that it can reach 64bit address space with 64bit pointers.
+#
+
+# Convert 64bit object file to x32 for x32 vDSO.
+quiet_cmd_x32 = X32 $@
+ cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@
+
+$(obj)/%-x32.o: $(obj)/%.o FORCE
+ $(call if_changed,x32)
+
+vobjsx32 = $(patsubst %.o,%-x32.o,$(vobjs))
+targets += $(patsubst %.o,%-x32.o,$(vobjs-y))
+
+# Linker options for the vdso
+VDSO_LDFLAGS_64 := -m elf_x86_64 -soname linux-vdso.so.1 -z max-page-size=4096
+VDSO_LDFLAGS_x32 := $(subst elf_x86_64,elf32_x86_64,$(VDSO_LDFLAGS_64))
+
+$(obj)/vdso64.so.dbg: $(vobjs)
+$(obj)/vdsox32.so.dbg: $(vobjsx32)
diff --git a/arch/x86/entry/vdso/vdso64/note.S b/arch/x86/entry/vdso/vdso64/note.S
new file mode 100644
index 0000000..62d8aa5
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/note.S
@@ -0,0 +1 @@
+#include "common/note.S"
diff --git a/arch/x86/entry/vdso/vdso64/vclock_gettime.c b/arch/x86/entry/vdso/vdso64/vclock_gettime.c
new file mode 100644
index 0000000..1481f00
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vclock_gettime.c
@@ -0,0 +1 @@
+#include "common/vclock_gettime.c"
diff --git a/arch/x86/entry/vdso/vdso64/vdso64.lds.S b/arch/x86/entry/vdso/vdso64/vdso64.lds.S
new file mode 100644
index 0000000..5ce3f2b
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vdso64.lds.S
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Linker script for 64-bit vDSO.
+ * We #include the file to define the layout details.
+ *
+ * This file defines the version script giving the user-exported symbols in
+ * the DSO.
+ */
+
+#define BUILD_VDSO64
+
+#include "common/vdso-layout.lds.S"
+
+/*
+ * This controls what userland symbols we export from the vDSO.
+ */
+VERSION {
+ LINUX_2.6 {
+ global:
+ clock_gettime;
+ __vdso_clock_gettime;
+ gettimeofday;
+ __vdso_gettimeofday;
+ getcpu;
+ __vdso_getcpu;
+ time;
+ __vdso_time;
+ clock_getres;
+ __vdso_clock_getres;
+#ifdef CONFIG_X86_SGX
+ __vdso_sgx_enter_enclave;
+#endif
+ getrandom;
+ __vdso_getrandom;
+ local: *;
+ };
+}
diff --git a/arch/x86/entry/vdso/vdso64/vdsox32.lds.S b/arch/x86/entry/vdso/vdso64/vdsox32.lds.S
new file mode 100644
index 0000000..3dbd20c
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vdsox32.lds.S
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Linker script for x32 vDSO.
+ * We #include the file to define the layout details.
+ *
+ * This file defines the version script giving the user-exported symbols in
+ * the DSO.
+ */
+
+#define BUILD_VDSOX32
+
+#include "common/vdso-layout.lds.S"
+
+/*
+ * This controls what userland symbols we export from the vDSO.
+ */
+VERSION {
+ LINUX_2.6 {
+ global:
+ __vdso_clock_gettime;
+ __vdso_gettimeofday;
+ __vdso_getcpu;
+ __vdso_time;
+ __vdso_clock_getres;
+ local: *;
+ };
+}
diff --git a/arch/x86/entry/vdso/vdso64/vgetcpu.c b/arch/x86/entry/vdso/vdso64/vgetcpu.c
new file mode 100644
index 0000000..00cc832
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vgetcpu.c
@@ -0,0 +1 @@
+#include "common/vgetcpu.c"
diff --git a/arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S b/arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S
new file mode 100644
index 0000000..bcba563
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S
@@ -0,0 +1,178 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ */
+
+#include <linux/linkage.h>
+#include <asm/frame.h>
+
+.section .rodata, "a"
+.align 16
+CONSTANTS: .octa 0x6b20657479622d323320646e61707865
+.text
+
+/*
+ * Very basic SSE2 implementation of ChaCha20. Produces a given positive number
+ * of blocks of output with a nonce of 0, taking an input key and 8-byte
+ * counter. Importantly does not spill to the stack. Its arguments are:
+ *
+ * rdi: output bytes
+ * rsi: 32-byte key input
+ * rdx: 8-byte counter input/output
+ * rcx: number of 64-byte blocks to write to output
+ */
+SYM_FUNC_START(__arch_chacha20_blocks_nostack)
+
+.set output, %rdi
+.set key, %rsi
+.set counter, %rdx
+.set nblocks, %rcx
+.set i, %al
+/* xmm registers are *not* callee-save. */
+.set temp, %xmm0
+.set state0, %xmm1
+.set state1, %xmm2
+.set state2, %xmm3
+.set state3, %xmm4
+.set copy0, %xmm5
+.set copy1, %xmm6
+.set copy2, %xmm7
+.set copy3, %xmm8
+.set one, %xmm9
+
+ /* copy0 = "expand 32-byte k" */
+ movaps CONSTANTS(%rip),copy0
+ /* copy1,copy2 = key */
+ movups 0x00(key),copy1
+ movups 0x10(key),copy2
+ /* copy3 = counter || zero nonce */
+ movq 0x00(counter),copy3
+ /* one = 1 || 0 */
+ movq $1,%rax
+ movq %rax,one
+
+.Lblock:
+ /* state0,state1,state2,state3 = copy0,copy1,copy2,copy3 */
+ movdqa copy0,state0
+ movdqa copy1,state1
+ movdqa copy2,state2
+ movdqa copy3,state3
+
+ movb $10,i
+.Lpermute:
+ /* state0 += state1, state3 = rotl32(state3 ^ state0, 16) */
+ paddd state1,state0
+ pxor state0,state3
+ movdqa state3,temp
+ pslld $16,temp
+ psrld $16,state3
+ por temp,state3
+
+ /* state2 += state3, state1 = rotl32(state1 ^ state2, 12) */
+ paddd state3,state2
+ pxor state2,state1
+ movdqa state1,temp
+ pslld $12,temp
+ psrld $20,state1
+ por temp,state1
+
+ /* state0 += state1, state3 = rotl32(state3 ^ state0, 8) */
+ paddd state1,state0
+ pxor state0,state3
+ movdqa state3,temp
+ pslld $8,temp
+ psrld $24,state3
+ por temp,state3
+
+ /* state2 += state3, state1 = rotl32(state1 ^ state2, 7) */
+ paddd state3,state2
+ pxor state2,state1
+ movdqa state1,temp
+ pslld $7,temp
+ psrld $25,state1
+ por temp,state1
+
+ /* state1[0,1,2,3] = state1[1,2,3,0] */
+ pshufd $0x39,state1,state1
+ /* state2[0,1,2,3] = state2[2,3,0,1] */
+ pshufd $0x4e,state2,state2
+ /* state3[0,1,2,3] = state3[3,0,1,2] */
+ pshufd $0x93,state3,state3
+
+ /* state0 += state1, state3 = rotl32(state3 ^ state0, 16) */
+ paddd state1,state0
+ pxor state0,state3
+ movdqa state3,temp
+ pslld $16,temp
+ psrld $16,state3
+ por temp,state3
+
+ /* state2 += state3, state1 = rotl32(state1 ^ state2, 12) */
+ paddd state3,state2
+ pxor state2,state1
+ movdqa state1,temp
+ pslld $12,temp
+ psrld $20,state1
+ por temp,state1
+
+ /* state0 += state1, state3 = rotl32(state3 ^ state0, 8) */
+ paddd state1,state0
+ pxor state0,state3
+ movdqa state3,temp
+ pslld $8,temp
+ psrld $24,state3
+ por temp,state3
+
+ /* state2 += state3, state1 = rotl32(state1 ^ state2, 7) */
+ paddd state3,state2
+ pxor state2,state1
+ movdqa state1,temp
+ pslld $7,temp
+ psrld $25,state1
+ por temp,state1
+
+ /* state1[0,1,2,3] = state1[3,0,1,2] */
+ pshufd $0x93,state1,state1
+ /* state2[0,1,2,3] = state2[2,3,0,1] */
+ pshufd $0x4e,state2,state2
+ /* state3[0,1,2,3] = state3[1,2,3,0] */
+ pshufd $0x39,state3,state3
+
+ decb i
+ jnz .Lpermute
+
+ /* output0 = state0 + copy0 */
+ paddd copy0,state0
+ movups state0,0x00(output)
+ /* output1 = state1 + copy1 */
+ paddd copy1,state1
+ movups state1,0x10(output)
+ /* output2 = state2 + copy2 */
+ paddd copy2,state2
+ movups state2,0x20(output)
+ /* output3 = state3 + copy3 */
+ paddd copy3,state3
+ movups state3,0x30(output)
+
+ /* ++copy3.counter */
+ paddq one,copy3
+
+ /* output += 64, --nblocks */
+ addq $64,output
+ decq nblocks
+ jnz .Lblock
+
+ /* counter = copy3.counter */
+ movq copy3,0x00(counter)
+
+ /* Zero out the potentially sensitive regs, in case nothing uses these again. */
+ pxor state0,state0
+ pxor state1,state1
+ pxor state2,state2
+ pxor state3,state3
+ pxor copy1,copy1
+ pxor copy2,copy2
+ pxor temp,temp
+
+ ret
+SYM_FUNC_END(__arch_chacha20_blocks_nostack)
diff --git a/arch/x86/entry/vdso/vdso64/vgetrandom.c b/arch/x86/entry/vdso/vdso64/vgetrandom.c
new file mode 100644
index 0000000..6a95d36
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vgetrandom.c
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ */
+#include <linux/types.h>
+
+#include "lib/vdso/getrandom.c"
+
+ssize_t __vdso_getrandom(void *buffer, size_t len, unsigned int flags, void *opaque_state, size_t opaque_len)
+{
+ return __cvdso_getrandom(buffer, len, flags, opaque_state, opaque_len);
+}
+
+ssize_t getrandom(void *, size_t, unsigned int, void *, size_t)
+ __attribute__((weak, alias("__vdso_getrandom")));
diff --git a/arch/x86/entry/vdso/vdso64/vsgx.S b/arch/x86/entry/vdso/vdso64/vsgx.S
new file mode 100644
index 0000000..37a3d4c
--- /dev/null
+++ b/arch/x86/entry/vdso/vdso64/vsgx.S
@@ -0,0 +1,150 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <linux/linkage.h>
+#include <asm/errno.h>
+#include <asm/enclu.h>
+
+#include "extable.h"
+
+/* Relative to %rbp. */
+#define SGX_ENCLAVE_OFFSET_OF_RUN 16
+
+/* The offsets relative to struct sgx_enclave_run. */
+#define SGX_ENCLAVE_RUN_TCS 0
+#define SGX_ENCLAVE_RUN_LEAF 8
+#define SGX_ENCLAVE_RUN_EXCEPTION_VECTOR 12
+#define SGX_ENCLAVE_RUN_EXCEPTION_ERROR_CODE 14
+#define SGX_ENCLAVE_RUN_EXCEPTION_ADDR 16
+#define SGX_ENCLAVE_RUN_USER_HANDLER 24
+#define SGX_ENCLAVE_RUN_USER_DATA 32 /* not used */
+#define SGX_ENCLAVE_RUN_RESERVED_START 40
+#define SGX_ENCLAVE_RUN_RESERVED_END 256
+
+.code64
+.section .text, "ax"
+
+SYM_FUNC_START(__vdso_sgx_enter_enclave)
+ /* Prolog */
+ .cfi_startproc
+ push %rbp
+ .cfi_adjust_cfa_offset 8
+ .cfi_rel_offset %rbp, 0
+ mov %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ push %rbx
+ .cfi_rel_offset %rbx, -8
+
+ mov %ecx, %eax
+.Lenter_enclave:
+ /* EENTER <= function <= ERESUME */
+ cmp $EENTER, %eax
+ jb .Linvalid_input
+ cmp $ERESUME, %eax
+ ja .Linvalid_input
+
+ mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rcx
+
+ /* Validate that the reserved area contains only zeros. */
+ mov $SGX_ENCLAVE_RUN_RESERVED_START, %rbx
+1:
+ cmpq $0, (%rcx, %rbx)
+ jne .Linvalid_input
+ add $8, %rbx
+ cmpq $SGX_ENCLAVE_RUN_RESERVED_END, %rbx
+ jne 1b
+
+ /* Load TCS and AEP */
+ mov SGX_ENCLAVE_RUN_TCS(%rcx), %rbx
+ lea .Lasync_exit_pointer(%rip), %rcx
+
+ /* Single ENCLU serving as both EENTER and AEP (ERESUME) */
+.Lasync_exit_pointer:
+.Lenclu_eenter_eresume:
+ enclu
+
+ /* EEXIT jumps here unless the enclave is doing something fancy. */
+ mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rbx
+
+ /* Set exit_reason. */
+ movl $EEXIT, SGX_ENCLAVE_RUN_LEAF(%rbx)
+
+ /* Invoke userspace's exit handler if one was provided. */
+.Lhandle_exit:
+ cmpq $0, SGX_ENCLAVE_RUN_USER_HANDLER(%rbx)
+ jne .Linvoke_userspace_handler
+
+ /* Success, in the sense that ENCLU was attempted. */
+ xor %eax, %eax
+
+.Lout:
+ pop %rbx
+ leave
+ .cfi_def_cfa %rsp, 8
+ RET
+
+ /* The out-of-line code runs with the pre-leave stack frame. */
+ .cfi_def_cfa %rbp, 16
+
+.Linvalid_input:
+ mov $(-EINVAL), %eax
+ jmp .Lout
+
+.Lhandle_exception:
+ mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rbx
+
+ /* Set the exception info. */
+ mov %eax, (SGX_ENCLAVE_RUN_LEAF)(%rbx)
+ mov %di, (SGX_ENCLAVE_RUN_EXCEPTION_VECTOR)(%rbx)
+ mov %si, (SGX_ENCLAVE_RUN_EXCEPTION_ERROR_CODE)(%rbx)
+ mov %rdx, (SGX_ENCLAVE_RUN_EXCEPTION_ADDR)(%rbx)
+ jmp .Lhandle_exit
+
+.Linvoke_userspace_handler:
+ /* Pass the untrusted RSP (at exit) to the callback via %rcx. */
+ mov %rsp, %rcx
+
+ /* Save struct sgx_enclave_exception %rbx is about to be clobbered. */
+ mov %rbx, %rax
+
+ /* Save the untrusted RSP offset in %rbx (non-volatile register). */
+ mov %rsp, %rbx
+ and $0xf, %rbx
+
+ /*
+ * Align stack per x86_64 ABI. Note, %rsp needs to be 16-byte aligned
+ * _after_ pushing the parameters on the stack, hence the bonus push.
+ */
+ and $-0x10, %rsp
+ push %rax
+
+ /* Push struct sgx_enclave_exception as a param to the callback. */
+ push %rax
+
+ /* Clear RFLAGS.DF per x86_64 ABI */
+ cld
+
+ /*
+ * Load the callback pointer to %rax and lfence for LVI (load value
+ * injection) protection before making the call.
+ */
+ mov SGX_ENCLAVE_RUN_USER_HANDLER(%rax), %rax
+ lfence
+ call *%rax
+
+ /* Undo the post-exit %rsp adjustment. */
+ lea 0x10(%rsp, %rbx), %rsp
+
+ /*
+ * If the return from callback is zero or negative, return immediately,
+ * else re-execute ENCLU with the positive return value interpreted as
+ * the requested ENCLU function.
+ */
+ cmp $0, %eax
+ jle .Lout
+ jmp .Lenter_enclave
+
+ .cfi_endproc
+
+_ASM_VDSO_EXTABLE_HANDLE(.Lenclu_eenter_eresume, .Lhandle_exception)
+
+SYM_FUNC_END(__vdso_sgx_enter_enclave)
diff --git a/arch/x86/entry/vdso/vdsox32.lds.S b/arch/x86/entry/vdso/vdsox32.lds.S
deleted file mode 100644
index 16a8050..0000000
--- a/arch/x86/entry/vdso/vdsox32.lds.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Linker script for x32 vDSO.
- * We #include the file to define the layout details.
- *
- * This file defines the version script giving the user-exported symbols in
- * the DSO.
- */
-
-#define BUILD_VDSOX32
-
-#include "vdso-layout.lds.S"
-
-/*
- * This controls what userland symbols we export from the vDSO.
- */
-VERSION {
- LINUX_2.6 {
- global:
- __vdso_clock_gettime;
- __vdso_gettimeofday;
- __vdso_getcpu;
- __vdso_time;
- __vdso_clock_getres;
- local: *;
- };
-}
diff --git a/arch/x86/entry/vdso/vgetcpu.c b/arch/x86/entry/vdso/vgetcpu.c
deleted file mode 100644
index e464030..0000000
--- a/arch/x86/entry/vdso/vgetcpu.c
+++ /dev/null
@@ -1,22 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright 2006 Andi Kleen, SUSE Labs.
- *
- * Fast user context implementation of getcpu()
- */
-
-#include <linux/kernel.h>
-#include <linux/getcpu.h>
-#include <asm/segment.h>
-#include <vdso/processor.h>
-
-notrace long
-__vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
-{
- vdso_read_cpunode(cpu, node);
-
- return 0;
-}
-
-long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
- __attribute__((weak, alias("__vdso_getcpu")));
diff --git a/arch/x86/entry/vdso/vgetrandom-chacha.S b/arch/x86/entry/vdso/vgetrandom-chacha.S
deleted file mode 100644
index bcba563..0000000
--- a/arch/x86/entry/vdso/vgetrandom-chacha.S
+++ /dev/null
@@ -1,178 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
- */
-
-#include <linux/linkage.h>
-#include <asm/frame.h>
-
-.section .rodata, "a"
-.align 16
-CONSTANTS: .octa 0x6b20657479622d323320646e61707865
-.text
-
-/*
- * Very basic SSE2 implementation of ChaCha20. Produces a given positive number
- * of blocks of output with a nonce of 0, taking an input key and 8-byte
- * counter. Importantly does not spill to the stack. Its arguments are:
- *
- * rdi: output bytes
- * rsi: 32-byte key input
- * rdx: 8-byte counter input/output
- * rcx: number of 64-byte blocks to write to output
- */
-SYM_FUNC_START(__arch_chacha20_blocks_nostack)
-
-.set output, %rdi
-.set key, %rsi
-.set counter, %rdx
-.set nblocks, %rcx
-.set i, %al
-/* xmm registers are *not* callee-save. */
-.set temp, %xmm0
-.set state0, %xmm1
-.set state1, %xmm2
-.set state2, %xmm3
-.set state3, %xmm4
-.set copy0, %xmm5
-.set copy1, %xmm6
-.set copy2, %xmm7
-.set copy3, %xmm8
-.set one, %xmm9
-
- /* copy0 = "expand 32-byte k" */
- movaps CONSTANTS(%rip),copy0
- /* copy1,copy2 = key */
- movups 0x00(key),copy1
- movups 0x10(key),copy2
- /* copy3 = counter || zero nonce */
- movq 0x00(counter),copy3
- /* one = 1 || 0 */
- movq $1,%rax
- movq %rax,one
-
-.Lblock:
- /* state0,state1,state2,state3 = copy0,copy1,copy2,copy3 */
- movdqa copy0,state0
- movdqa copy1,state1
- movdqa copy2,state2
- movdqa copy3,state3
-
- movb $10,i
-.Lpermute:
- /* state0 += state1, state3 = rotl32(state3 ^ state0, 16) */
- paddd state1,state0
- pxor state0,state3
- movdqa state3,temp
- pslld $16,temp
- psrld $16,state3
- por temp,state3
-
- /* state2 += state3, state1 = rotl32(state1 ^ state2, 12) */
- paddd state3,state2
- pxor state2,state1
- movdqa state1,temp
- pslld $12,temp
- psrld $20,state1
- por temp,state1
-
- /* state0 += state1, state3 = rotl32(state3 ^ state0, 8) */
- paddd state1,state0
- pxor state0,state3
- movdqa state3,temp
- pslld $8,temp
- psrld $24,state3
- por temp,state3
-
- /* state2 += state3, state1 = rotl32(state1 ^ state2, 7) */
- paddd state3,state2
- pxor state2,state1
- movdqa state1,temp
- pslld $7,temp
- psrld $25,state1
- por temp,state1
-
- /* state1[0,1,2,3] = state1[1,2,3,0] */
- pshufd $0x39,state1,state1
- /* state2[0,1,2,3] = state2[2,3,0,1] */
- pshufd $0x4e,state2,state2
- /* state3[0,1,2,3] = state3[3,0,1,2] */
- pshufd $0x93,state3,state3
-
- /* state0 += state1, state3 = rotl32(state3 ^ state0, 16) */
- paddd state1,state0
- pxor state0,state3
- movdqa state3,temp
- pslld $16,temp
- psrld $16,state3
- por temp,state3
-
- /* state2 += state3, state1 = rotl32(state1 ^ state2, 12) */
- paddd state3,state2
- pxor state2,state1
- movdqa state1,temp
- pslld $12,temp
- psrld $20,state1
- por temp,state1
-
- /* state0 += state1, state3 = rotl32(state3 ^ state0, 8) */
- paddd state1,state0
- pxor state0,state3
- movdqa state3,temp
- pslld $8,temp
- psrld $24,state3
- por temp,state3
-
- /* state2 += state3, state1 = rotl32(state1 ^ state2, 7) */
- paddd state3,state2
- pxor state2,state1
- movdqa state1,temp
- pslld $7,temp
- psrld $25,state1
- por temp,state1
-
- /* state1[0,1,2,3] = state1[3,0,1,2] */
- pshufd $0x93,state1,state1
- /* state2[0,1,2,3] = state2[2,3,0,1] */
- pshufd $0x4e,state2,state2
- /* state3[0,1,2,3] = state3[1,2,3,0] */
- pshufd $0x39,state3,state3
-
- decb i
- jnz .Lpermute
-
- /* output0 = state0 + copy0 */
- paddd copy0,state0
- movups state0,0x00(output)
- /* output1 = state1 + copy1 */
- paddd copy1,state1
- movups state1,0x10(output)
- /* output2 = state2 + copy2 */
- paddd copy2,state2
- movups state2,0x20(output)
- /* output3 = state3 + copy3 */
- paddd copy3,state3
- movups state3,0x30(output)
-
- /* ++copy3.counter */
- paddq one,copy3
-
- /* output += 64, --nblocks */
- addq $64,output
- decq nblocks
- jnz .Lblock
-
- /* counter = copy3.counter */
- movq copy3,0x00(counter)
-
- /* Zero out the potentially sensitive regs, in case nothing uses these again. */
- pxor state0,state0
- pxor state1,state1
- pxor state2,state2
- pxor state3,state3
- pxor copy1,copy1
- pxor copy2,copy2
- pxor temp,temp
-
- ret
-SYM_FUNC_END(__arch_chacha20_blocks_nostack)
diff --git a/arch/x86/entry/vdso/vgetrandom.c b/arch/x86/entry/vdso/vgetrandom.c
deleted file mode 100644
index 430862b..0000000
--- a/arch/x86/entry/vdso/vgetrandom.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
- */
-#include <linux/types.h>
-
-#include "../../../../lib/vdso/getrandom.c"
-
-ssize_t __vdso_getrandom(void *buffer, size_t len, unsigned int flags, void *opaque_state, size_t opaque_len)
-{
- return __cvdso_getrandom(buffer, len, flags, opaque_state, opaque_len);
-}
-
-ssize_t getrandom(void *, size_t, unsigned int, void *, size_t)
- __attribute__((weak, alias("__vdso_getrandom")));
diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S
deleted file mode 100644
index 37a3d4c..0000000
--- a/arch/x86/entry/vdso/vsgx.S
+++ /dev/null
@@ -1,150 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#include <linux/linkage.h>
-#include <asm/errno.h>
-#include <asm/enclu.h>
-
-#include "extable.h"
-
-/* Relative to %rbp. */
-#define SGX_ENCLAVE_OFFSET_OF_RUN 16
-
-/* The offsets relative to struct sgx_enclave_run. */
-#define SGX_ENCLAVE_RUN_TCS 0
-#define SGX_ENCLAVE_RUN_LEAF 8
-#define SGX_ENCLAVE_RUN_EXCEPTION_VECTOR 12
-#define SGX_ENCLAVE_RUN_EXCEPTION_ERROR_CODE 14
-#define SGX_ENCLAVE_RUN_EXCEPTION_ADDR 16
-#define SGX_ENCLAVE_RUN_USER_HANDLER 24
-#define SGX_ENCLAVE_RUN_USER_DATA 32 /* not used */
-#define SGX_ENCLAVE_RUN_RESERVED_START 40
-#define SGX_ENCLAVE_RUN_RESERVED_END 256
-
-.code64
-.section .text, "ax"
-
-SYM_FUNC_START(__vdso_sgx_enter_enclave)
- /* Prolog */
- .cfi_startproc
- push %rbp
- .cfi_adjust_cfa_offset 8
- .cfi_rel_offset %rbp, 0
- mov %rsp, %rbp
- .cfi_def_cfa_register %rbp
- push %rbx
- .cfi_rel_offset %rbx, -8
-
- mov %ecx, %eax
-.Lenter_enclave:
- /* EENTER <= function <= ERESUME */
- cmp $EENTER, %eax
- jb .Linvalid_input
- cmp $ERESUME, %eax
- ja .Linvalid_input
-
- mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rcx
-
- /* Validate that the reserved area contains only zeros. */
- mov $SGX_ENCLAVE_RUN_RESERVED_START, %rbx
-1:
- cmpq $0, (%rcx, %rbx)
- jne .Linvalid_input
- add $8, %rbx
- cmpq $SGX_ENCLAVE_RUN_RESERVED_END, %rbx
- jne 1b
-
- /* Load TCS and AEP */
- mov SGX_ENCLAVE_RUN_TCS(%rcx), %rbx
- lea .Lasync_exit_pointer(%rip), %rcx
-
- /* Single ENCLU serving as both EENTER and AEP (ERESUME) */
-.Lasync_exit_pointer:
-.Lenclu_eenter_eresume:
- enclu
-
- /* EEXIT jumps here unless the enclave is doing something fancy. */
- mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rbx
-
- /* Set exit_reason. */
- movl $EEXIT, SGX_ENCLAVE_RUN_LEAF(%rbx)
-
- /* Invoke userspace's exit handler if one was provided. */
-.Lhandle_exit:
- cmpq $0, SGX_ENCLAVE_RUN_USER_HANDLER(%rbx)
- jne .Linvoke_userspace_handler
-
- /* Success, in the sense that ENCLU was attempted. */
- xor %eax, %eax
-
-.Lout:
- pop %rbx
- leave
- .cfi_def_cfa %rsp, 8
- RET
-
- /* The out-of-line code runs with the pre-leave stack frame. */
- .cfi_def_cfa %rbp, 16
-
-.Linvalid_input:
- mov $(-EINVAL), %eax
- jmp .Lout
-
-.Lhandle_exception:
- mov SGX_ENCLAVE_OFFSET_OF_RUN(%rbp), %rbx
-
- /* Set the exception info. */
- mov %eax, (SGX_ENCLAVE_RUN_LEAF)(%rbx)
- mov %di, (SGX_ENCLAVE_RUN_EXCEPTION_VECTOR)(%rbx)
- mov %si, (SGX_ENCLAVE_RUN_EXCEPTION_ERROR_CODE)(%rbx)
- mov %rdx, (SGX_ENCLAVE_RUN_EXCEPTION_ADDR)(%rbx)
- jmp .Lhandle_exit
-
-.Linvoke_userspace_handler:
- /* Pass the untrusted RSP (at exit) to the callback via %rcx. */
- mov %rsp, %rcx
-
- /* Save struct sgx_enclave_exception %rbx is about to be clobbered. */
- mov %rbx, %rax
-
- /* Save the untrusted RSP offset in %rbx (non-volatile register). */
- mov %rsp, %rbx
- and $0xf, %rbx
-
- /*
- * Align stack per x86_64 ABI. Note, %rsp needs to be 16-byte aligned
- * _after_ pushing the parameters on the stack, hence the bonus push.
- */
- and $-0x10, %rsp
- push %rax
-
- /* Push struct sgx_enclave_exception as a param to the callback. */
- push %rax
-
- /* Clear RFLAGS.DF per x86_64 ABI */
- cld
-
- /*
- * Load the callback pointer to %rax and lfence for LVI (load value
- * injection) protection before making the call.
- */
- mov SGX_ENCLAVE_RUN_USER_HANDLER(%rax), %rax
- lfence
- call *%rax
-
- /* Undo the post-exit %rsp adjustment. */
- lea 0x10(%rsp, %rbx), %rsp
-
- /*
- * If the return from callback is zero or negative, return immediately,
- * else re-execute ENCLU with the positive return value interpreted as
- * the requested ENCLU function.
- */
- cmp $0, %eax
- jle .Lout
- jmp .Lenter_enclave
-
- .cfi_endproc
-
-_ASM_VDSO_EXTABLE_HANDLE(.Lenclu_eenter_eresume, .Lhandle_exception)
-
-SYM_FUNC_END(__vdso_sgx_enter_enclave)
|
{
"author": "\"tip-bot2 for H. Peter Anvin\" <tip-bot2@linutronix.de>",
"date": "Wed, 14 Jan 2026 00:01:23 -0000",
"thread_id": "223707e2-3231-4037-bd1f-490ddf6aeeb6@linux.ibm.com.mbox.gz"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.