Skip to content

[TEST] SoundWire sysfs upstream changes#4799

Closed
plbossart wants to merge 7 commits intothesofproject:topic/sof-devfrom
plbossart:test/sysfs-upstream
Closed

[TEST] SoundWire sysfs upstream changes#4799
plbossart wants to merge 7 commits intothesofproject:topic/sof-devfrom
plbossart:test/sysfs-upstream

Conversation

@plbossart
Copy link
Copy Markdown
Member

need to check if the hierarchy is preserved.

djbw and others added 6 commits January 31, 2024 09:05
Add a mechanism for named attribute_groups to hide their directory at
sysfs_update_group() time, or otherwise skip emitting the group
directory when the group is first registered. It piggybacks on
is_visible() in a similar manner as SYSFS_PREALLOC, i.e. special flags
in the upper bits of the returned mode. To use it, specify a symbol
prefix to DEFINE_SYSFS_GROUP_VISIBLE(), and then pass that same prefix
to SYSFS_GROUP_VISIBLE() when assigning the @is_visible() callback:

	DEFINE_SYSFS_GROUP_VISIBLE($prefix)

	struct attribute_group $prefix_group = {
		.name = $name,
		.is_visible = SYSFS_GROUP_VISIBLE($prefix),
	};

SYSFS_GROUP_VISIBLE() expects a definition of $prefix_group_visible()
and $prefix_attr_visible(), where $prefix_group_visible() just returns
true / false and $prefix_attr_visible() behaves as normal.

The motivation for this capability is to centralize PCI device
authentication in the PCI core with a named sysfs group while keeping
that group hidden for devices and platforms that do not meet the
requirements. In a PCI topology, most devices will not support
authentication, a small subset will support just PCI CMA (Component
Measurement and Authentication), a smaller subset will support PCI CMA +
PCIe IDE (Link Integrity and Encryption), and only next generation
server hosts will start to include a platform TSM (TEE Security
Manager).

Without this capability the alternatives are:

* Check if all attributes are invisible and if so, hide the directory.
  Beyond trouble getting this to work [1], this is an ABI change for
  scenarios if userspace happens to depend on group visibility absent any
  attributes. I.e. this new capability avoids regression since it does
  not retroactively apply to existing cases.

* Publish an empty /sys/bus/pci/devices/$pdev/tsm/ directory for all PCI
  devices (i.e. for the case when TSM platform support is present, but
  device support is absent). Unfortunate that this will be a vestigial
  empty directory in the vast majority of cases.

* Reintroduce usage of runtime calls to sysfs_{create,remove}_group()
  in the PCI core. Bjorn has already indicated that he does not want to
  see any growth of pci_sysfs_init() [2].

* Drop the named group and simulate a directory by prefixing all
  TSM-related attributes with "tsm_". Unfortunate to not use the naming
  capability of a sysfs group as intended.

In comparison, there is a small potential for regression if for some
reason an @is_visible() callback had dependencies on how many times it
was called. Additionally, it is no longer an error to update a group
that does not have its directory already present, and it is no longer a
WARN() to remove a group that was never visible.

Link: https://lore.kernel.org/all/2024012321-envious-procedure-4a58@gregkh/ [1]
Link: https://lore.kernel.org/linux-pci/20231019200110.GA1410324@bhelgaas/ [2]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
…t of groups

The sysfs logic already creates a list of groups for the device, so add
the sdw_slave_dev_attr_group group to that list instead of having to do
a two-step process of adding a group list and then an individual group.

This is a step on the way to moving all of the sysfs attribute handling
into the default driver core attribute group logic so that the soundwire
core does not have to do any of it manually.

Cc: Vinod Koul <vkoul@kernel.org>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
…utes

There's no need to special-case the dp0 sysfs attributes, the
is_visible() callback in the attribute group can handle that for us, so
add that and add it to the attribute group list making the logic simpler
overall.

This is a step on the way to moving all of the sysfs attribute handling
into the default driver core attribute group logic so that the soundwire
core does not have to do any of it manually.

Cc: Vinod Koul <vkoul@kernel.org>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
…ice groups

The driver core supports the ability to handle the creation and removal
of device-specific sysfs files in a race-free manner.  Take advantage of
that by converting this driver to use this by moving the sysfs
attributes into a group and assigning the dev_groups pointer to it.

Cc: Vinod Koul <vkoul@kernel.org>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Now that sdw_slave_sysfs_init() only calls sdw_slave_sysfs_dpn_init(),
just do that instead and remove sdw_slave_sysfs_init() to get it out of
the way to save a bit of logic and code size.

Cc: Vinod Koul <vkoul@kernel.org>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Now that we manually created our own attribute group list, the outdated
ATTRIBUTE_GROUPS() comments can be removed as they are not needed at
all.

Cc: Vinod Koul <vkoul@kernel.org>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
@plbossart
Copy link
Copy Markdown
Member Author

The first patch in this series seems to prevent LunarLake devices from booting to SSH, even with the sof-pci-lnl driver blacklisted. IOW something non-audio is going boink. We would need to test with a direct device access, testing remotely is impossible.

@djbw
Copy link
Copy Markdown

djbw commented Feb 16, 2024

@plbossart any update on the debug?

I posted a debug patch to get more info here

@plbossart
Copy link
Copy Markdown
Member Author

@plbossart any update on the debug?

I posted a debug patch to get more info here

Sorry, we've been busy fixing bugs while most of our team was on CNY vacation. @marc-hb is looking into this today.

@plbossart
Copy link
Copy Markdown
Member Author

@djbw the results are the same, the boot process is stopped while dealing with the initramfs. I'll have to leave you in the capable hands of JF-based @marc-hb, it's likely that LNL has some sort of sysfs tree snafu that is exposed by your patch.

@djbw
Copy link
Copy Markdown

djbw commented Feb 16, 2024

@djbw the results are the same, the boot process is stopped while dealing with the initramfs. I'll have to leave you in the capable hands of JF-based @marc-hb, it's likely that LNL has some sort of sysfs tree snafu that is exposed by your patch.

Sounds good, I was not expecting the patch to help, but hopefully give more info of which is_visible() callback might have been problematic, but if you don't even get a console / log out of the machine then not much to work with.

@marc-hb
Copy link
Copy Markdown
Collaborator

marc-hb commented Feb 17, 2024

Dan's commit "sysfs: Introduce a mechanism to hide static attribute_groups" is definitely the trigger. In addition to comparing the base versus first commit of this PR, I also cherry picked it over v6.8-rc4 with the very same results: v6.8-rc4 alone works fine; hard hang and no logs at all with the cherry-pick on top.

What this patch triggers is a super hard hang while or immediately after loading the initramfs. So there is absolutely ZERO kernel logs on the eDP panel.

I tried the following kernel params: debug break=top. They work fine without the trigger, the system stops at the start of the initramfs. With the commit, the system crashes too early for these to have any effect.

Without Dan's commit, Ctrl-alt-del and SysRq work fine after break=top. With it, these key strokes have no effect while the kernel is locked up. Using the reset button on the front panel is required.

I changed the initramfs compression in the odd chance. No difference.

https://lore.kernel.org/all/65baa2c754e8d_37ad2941f@dwillia2-xfh.jf.intel.com.notmuch/raw didn't apply, it seems to have spaces instead of tabs.
Pierre fixed that patch for me and shared it in this PR. I added it but it made not difference. I never tried the other, later commits in this PR.

For complete disclosure these ACPI error show up every time the system boots:

Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.BGNV], AE_ALREADY_EXISTS (20230331/dswload2-326)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20230331/psobject-220)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.BGMA], AE_ALREADY_EXISTS (20230331/dsfield-637)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.BGMS], AE_ALREADY_EXISTS (20230331/dsfield-637)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.BGIA], AE_ALREADY_EXISTS (20230331/dsfield-637)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.PC00.PTMA], AE_ALREADY_EXISTS (20230331/dswload2-326)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20230331/psobject-220)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.PC00.PTMS], AE_ALREADY_EXISTS (20230331/dswload2-326)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20230331/psobject-220)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.PC00.PTIA], AE_ALREADY_EXISTS (20230331/dswload2-326)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20230331/psobject-220)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI Error: Cannot assign type [Device] to [Integer] (must be type Int/Str/Buf) (20230331/exstoren-90)
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI: \: Can't tag data node
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI: \: Can't tag data node
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI: \: Can't tag data node
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI: \: Can't tag data node
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: ACPI: \: Can't tag data node
Feb 17 00:00:46 jf-lnlm-rvp-nocodec-1 kernel: i8042: Can't read CTR while initializing i8042
Feb 17 00:00:50 jf-lnlm-rvp-nocodec-1 kernel: ucsi_acpi USBC000:00: failed to reset PPM!
Feb 17 00:00:50 jf-lnlm-rvp-nocodec-1 kernel: ucsi_acpi USBC000:00: error -ETIMEDOUT: PPM init failed

The next steps could/should be:

  • Split Dan's commit into even smaller parts and try to isolate which part makes a difference
  • Find a serial port and try earlyprintk

@marc-hb
Copy link
Copy Markdown
Collaborator

marc-hb commented Feb 17, 2024

@marc-hb
Copy link
Copy Markdown
Collaborator

marc-hb commented Feb 22, 2024

I found how to use a serial connection to this board. Crashes in perf_event_sysfs_init every time:

.
.
.
[    5.747097] pci 0000:00:15.1: Adding to iommu group 13
[    5.752857] pci 0000:00:15.2: Adding to iommu group 13
[    5.758619] pci 0000:00:15.3: Adding to iommu group 13
[    5.764395] pci 0000:00:16.0: Adding to iommu group 14
[    5.770246] pci 0000:00:1c.0: Adding to iommu group 15
[    5.776040] pci 0000:00:1f.0: Adding to iommu group 16
[    5.781803] pci 0000:00:1f.3: Adding to iommu group 16
[    5.787568] pci 0000:00:1f.4: Adding to iommu group 16
[    5.793325] pci 0000:00:1f.5: Adding to iommu group 16
[    5.799186] pci 0000:7f:00.0: Adding to iommu group 17
[    5.805494] DMAR: Intel(R) Virtualization Technology for Direg for IO (SWIOTLB)
[    5.819731] software IO TLB: mapped [mem [    5.828831] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x28680fa287f, max_idle_ns: 440795281151 ns
[    5.839895] clocksource: Switched to clocksource tsc
[    5.845484] platform rtc_cmos: registered platform RTC device[    5.857089] BUG: kernel NULL pointer dereference, address: 00rnel mode
[    5.857658] #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
[    5.857658] CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
[    5.857658] Code: 00 00 0 5.857658] RSP: 0000:ffffaa1d400f7dd0 EFLAGS: 00010206
[    5.8 R08: fffffffffff742c3 R09: ffff9daec26c0000
[    5.857658] R10ffff9db22ec00000(0000) knlGS:0000000000000000
[    5.857658] CS2: 0000000000000000
[    5.857658] DR3: 0000000000000000 DR6: 0x181/0x490
[    5.857658]  ? exc_page_fault+0x68/0x190
[    5.5.857658]  internal_create_groups+0x42/0xa0
[    5.857658]  pmu_dev_alloc+0xc0/0xe0
[    5.857658]  perf_event_sysfs_init+0x580000000000 ]---
[    5.857658] RIP: 0010:exra_is_visible+0x14/0 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 0f 1f 44 00 00 31 c0 83   5.857658] RBP: 0000000000000001 R08: fffffffffff742c3 R09: fff000000001 R12: ffff9da
ec355f800
[    5.857658] R13: ffffffffab80000000080050033
[    5.857658] CR2: 0000000000000008 CR3: 0000000400
[    5.857658] PKRU: 55555554
[    5.857658] note: swap[    6.235716] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
[    6.236701] Kernel Offset: 0x28c00000

@djbw
Copy link
Copy Markdown

djbw commented Feb 22, 2024

I think this is the fixup, I did not expect empty attribute arrays, but that seems to be standard practice for perf pmu.

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index ccb275cdabcb..8c63ba3cfc47 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -33,10 +33,10 @@ static void remove_files(struct kernfs_node *parent,
 
 static umode_t __first_visible(const struct attribute_group *grp, struct kobject *kobj)
 {
-	if (grp->attrs && grp->is_visible)
+	if (grp->attrs && grp->attrs[0] && grp->is_visible)
 		return grp->is_visible(kobj, grp->attrs[0], 0);
 
-	if (grp->bin_attrs && grp->is_bin_visible)
+	if (grp->bin_attrs && grp->bin_attrs[0] && grp->is_bin_visible)
 		return grp->is_bin_visible(kobj, grp->bin_attrs[0], 0);
 
 	return 0;
-- 
2.43.0

marc-hb added a commit to marc-hb/kconfig that referenced this pull request Feb 22, 2024
As no one ever wanted to boot from a microphone, it's very rare that we
have to use the serial console to debug very early boot issues. But it
can happen, see for instance
thesofproject/linux#4799

In such case it's very convenient to use another test device to collect
logs on the serial console.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Feb 22, 2024
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
@marc-hb
Copy link
Copy Markdown
Collaborator

marc-hb commented Feb 22, 2024

I think this is the fixup, I did not expect empty attribute arrays, but that seems to be standard practice for perf pmu.

This fixup works. System boots and nothing suspicious in the logs.

plbossart pushed a commit to thesofproject/kconfig that referenced this pull request Feb 23, 2024
As no one ever wanted to boot from a microphone, it's very rare that we
have to use the serial console to debug very early boot issues. But it
can happen, see for instance
thesofproject/linux#4799

In such case it's very convenient to use another test device to collect
logs on the serial console.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@plbossart
Copy link
Copy Markdown
Member Author

closing since there are no issues remaining

@plbossart plbossart closed this Feb 23, 2024
mj22226 pushed a commit to mj22226/linux that referenced this pull request Mar 4, 2024
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
github-actions Bot pushed a commit to ctrliq/kernel-src-tree that referenced this pull request Sep 22, 2025
JIRA: https://issues.redhat.com/browse/RHEL-102859

commit cd69fed
Author: Dan Williams <dan.j.williams@intel.com>
Date:   Thu Feb 22 12:40:54 2024 -0800

    sysfs: Fix crash on empty group attributes array

    It turns out that arch/x86/events/intel/core.c makes use of "empty"
    attributes.

            static struct attribute *empty_attrs;

            __init int intel_pmu_init(void)
            {
                    struct attribute **extra_skl_attr = &empty_attrs;
                    struct attribute **extra_attr = &empty_attrs;
                    struct attribute **td_attr    = &empty_attrs;
                    struct attribute **mem_attr   = &empty_attrs;
                    struct attribute **tsx_attr   = &empty_attrs;
                    ...

    That breaks the assumption __first_visible() that expects that if
    grp->attrs is set then grp->attrs[0] must also be set and results in
    backtraces like:

        BUG: kernel NULL pointer dereference, address: 00rnel mode
        #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
        CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
         ? exc_page_fault+0x68/0x190
         internal_create_groups+0x42/0xa0
         pmu_dev_alloc+0xc0/0xe0
         perf_event_sysfs_init+0x580000000000 ]---
        RIP: 0010:exra_is_visible+0x14/0

    Check for non-empty attributes array before calling is_visible().

    Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
    Closes: thesofproject/linux#4799 (comment)
    Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
    Cc: Marc Herbert <marc.herbert@intel.com>
    Cc: Rafael J. Wysocki <rafael@kernel.org>
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Tested-by: Marc Herbert <marc.herbert@intel.com>
    Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: David Arcari <darcari@redhat.com>
zhang-rui pushed a commit to openvelinux/kernel-intel that referenced this pull request Jan 22, 2026
commit cd69fed upstream.

It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Intel-SIG: commit cd69fed sysfs: Fix crash on empty group attributes array
Backport PMT spec 3.0 support (Discovery driver and preparation for PMT AET)

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
zhang-rui pushed a commit to openvelinux/kernel-intel that referenced this pull request Jan 22, 2026
commit cd69fed upstream.

It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Intel-SIG: commit cd69fed sysfs: Fix crash on empty group attributes array
Backport PMT spec 3.0 support (Discovery driver and preparation for PMT AET)

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
zhang-rui pushed a commit to openvelinux/kernel-intel that referenced this pull request Jan 26, 2026
commit cd69fed upstream.

It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Intel-SIG: commit cd69fed sysfs: Fix crash on empty group attributes array
Backport PMT spec 3.0 support (Discovery driver and preparation for PMT AET)

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
xmzzz pushed a commit to RVCK-Project/rvck-olk that referenced this pull request Feb 8, 2026
mainline inclusion
from mainline-v6.9-rc1
commit cd69fedf58f8ab1ab511f7c6ac1969cebf1c935f
category: feature
bugzilla: https://atomgit.com/openeuler/intel-kernel/issues/186
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cd69fedf58f8ab1ab511f7c6ac1969cebf1c935f

-------------------------------------------------

Intel-SIG: commit cd69fedf58f8 sysfs: Fix crash on empty group attributes array
Backport PMT spec 3.0 support (Discovery driver and preparation for PMT AET)

It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd24b41 ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
x56Jason pushed a commit to openvelinux/kernel-intel that referenced this pull request Feb 9, 2026
commit cd69fed upstream.

It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Intel-SIG: commit cd69fed sysfs: Fix crash on empty group attributes array
Backport PMT spec 3.0 support (Discovery driver and preparation for PMT AET)

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
PvsNarasimha pushed a commit to PvsNarasimha/kernel that referenced this pull request Feb 20, 2026
commit cd69fed upstream.

It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: PvsNarasimha <PVS.NarasimhaRao@amd.com>
guojinhui-liam pushed a commit to openvelinux/kernel that referenced this pull request Mar 3, 2026
commit cd69fed upstream.

It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com>
sync-agent-neo Bot pushed a commit to aosp-mirror-neo/kernel_common that referenced this pull request Mar 30, 2026
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 492018312
Change-Id: Ie71f5ccbe84589db9b803bc376c129bdba20b1ef
(cherry picked from commit cd69fed)
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
sync-agent-neo Bot pushed a commit to aosp-mirror-neo/kernel_superproject that referenced this pull request Mar 30, 2026
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd24b41 ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 492018312
Change-Id: Ie71f5ccbe84589db9b803bc376c129bdba20b1ef
(cherry picked from commit cd69fedf58f8ab1ab511f7c6ac1969cebf1c935f)
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
sync-agent-neo Bot pushed a commit to aosp-mirror-neo/kernel_common that referenced this pull request Mar 31, 2026
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 492018312
Change-Id: Ie71f5ccbe84589db9b803bc376c129bdba20b1ef
(cherry picked from commit cd69fed)
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
sync-agent-neo Bot pushed a commit to aosp-mirror-neo/kernel_superproject that referenced this pull request Mar 31, 2026
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd24b41 ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 492018312
Change-Id: Ie71f5ccbe84589db9b803bc376c129bdba20b1ef
(cherry picked from commit cd69fedf58f8ab1ab511f7c6ac1969cebf1c935f)
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
sync-agent-neo Bot pushed a commit to aosp-mirror-neo/kernel_superproject that referenced this pull request Apr 2, 2026
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd24b41 ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 492018312
Change-Id: Ie71f5ccbe84589db9b803bc376c129bdba20b1ef
(cherry picked from commit cd69fedf58f8ab1ab511f7c6ac1969cebf1c935f)
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
sync-agent-neo Bot pushed a commit to aosp-mirror-neo/kernel_superproject that referenced this pull request Apr 2, 2026
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd24b41 ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 492018312
Change-Id: Ie71f5ccbe84589db9b803bc376c129bdba20b1ef
(cherry picked from commit cd69fedf58f8ab1ab511f7c6ac1969cebf1c935f)
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
sync-agent-neo Bot pushed a commit to aosp-mirror-neo/kernel_superproject that referenced this pull request Apr 2, 2026
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd24b41 ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 492018312
Change-Id: Ie71f5ccbe84589db9b803bc376c129bdba20b1ef
(cherry picked from commit cd69fedf58f8ab1ab511f7c6ac1969cebf1c935f)
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
sync-agent-neo Bot pushed a commit to aosp-mirror-neo/kernel_hikey-linaro that referenced this pull request Apr 2, 2026
It turns out that arch/x86/events/intel/core.c makes use of "empty"
attributes.

	static struct attribute *empty_attrs;

	__init int intel_pmu_init(void)
	{
	        struct attribute **extra_skl_attr = &empty_attrs;
	        struct attribute **extra_attr = &empty_attrs;
	        struct attribute **td_attr    = &empty_attrs;
	        struct attribute **mem_attr   = &empty_attrs;
	        struct attribute **tsx_attr   = &empty_attrs;
		...

That breaks the assumption __first_visible() that expects that if
grp->attrs is set then grp->attrs[0] must also be set and results in
backtraces like:

    BUG: kernel NULL pointer dereference, address: 00rnel mode
    #PF: error_code(0x0000) - not-present ] PREEMPT SMP NOPTI
    CPU: 1 PID: 1 Comm: swapper/IP: 0010:exra_is_visible+0x14/0x20
     ? exc_page_fault+0x68/0x190
     internal_create_groups+0x42/0xa0
     pmu_dev_alloc+0xc0/0xe0
     perf_event_sysfs_init+0x580000000000 ]---
    RIP: 0010:exra_is_visible+0x14/0

Check for non-empty attributes array before calling is_visible().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Closes: thesofproject/linux#4799 (comment)
Fixes: 70317fd24b41 ("sysfs: Introduce a mechanism to hide static attribute_groups")
Cc: Marc Herbert <marc.herbert@intel.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Marc Herbert <marc.herbert@intel.com>
Link: https://lore.kernel.org/r/170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 492018312
Change-Id: Ie71f5ccbe84589db9b803bc376c129bdba20b1ef
(cherry picked from commit cd69fedf58f8ab1ab511f7c6ac1969cebf1c935f)
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants