<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/acpi/platform_profile.c, branch v6.12.80</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2025-04-20T08:16:00+00:00</updated>
<entry>
<title>ACPI: platform-profile: Fix CFI violation when accessing sysfs files</title>
<updated>2025-04-20T08:16:00+00:00</updated>
<author>
<name>Nathan Chancellor</name>
<email>nathan@kernel.org</email>
</author>
<published>2025-02-11T02:28:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7005fdceff205c7c92b4d1b616bb778e12db14a5'/>
<id>urn:sha1:7005fdceff205c7c92b4d1b616bb778e12db14a5</id>
<content type='text'>
commit dd4f730b557ce701a2cd4f604bf1e57667bd8b6e upstream.

When an attribute group is created with sysfs_create_group(), the
-&gt;sysfs_ops() callback is set to kobj_sysfs_ops, which sets the -&gt;show()
and -&gt;store() callbacks to kobj_attr_show() and kobj_attr_store()
respectively. These functions use container_of() to get the respective
callback from the passed attribute, meaning that these callbacks need to
be of the same type as the callbacks in 'struct kobj_attribute'.

However, -&gt;show() and -&gt;store() in the platform_profile driver are
defined for struct device_attribute with the help of DEVICE_ATTR_RO()
and DEVICE_ATTR_RW(), which results in a CFI violation when accessing
platform_profile or platform_profile_choices under /sys/firmware/acpi
because the types do not match:

  CFI failure at kobj_attr_show+0x19/0x30 (target: platform_profile_choices_show+0x0/0x140; expected type: 0x7a69590c)

There is no functional issue from the type mismatch because the layout
of 'struct kobj_attribute' and 'struct device_attribute' are the same,
so the container_of() cast does not break anything aside from CFI.

Change the type of platform_profile_choices_show() and
platform_profile_{show,store}() to match the callbacks in
'struct kobj_attribute' and update the attribute variables to
match, which resolves the CFI violation.

Cc: All applicable &lt;stable@vger.kernel.org&gt;
Fixes: a2ff95e018f1 ("ACPI: platform: Add platform profile support")
Reported-by: John Rowley &lt;lkml@johnrowley.me&gt;
Closes: https://github.com/ClangBuiltLinux/linux/issues/2047
Tested-by: John Rowley &lt;lkml@johnrowley.me&gt;
Reviewed-by: Sami Tolvanen &lt;samitolvanen@google.com&gt;
Signed-off-by: Nathan Chancellor &lt;nathan@kernel.org&gt;
Acked-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Reviewed-by: Mark Pearson &lt;mpearson-lenovo@squebb.ca&gt;
Tested-by: Mark Pearson &lt;mpearson-lenovo@squebb.ca&gt;
Link: https://patch.msgid.link/20250210-acpi-platform_profile-fix-cfi-violation-v3-1-ed9e9901c33a@kernel.org
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
[nathan: Fix conflicts in older stable branches]
Signed-off-by: Nathan Chancellor &lt;nathan@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>ACPI: add missing MODULE_DESCRIPTION() macros</title>
<updated>2024-06-13T19:06:30+00:00</updated>
<author>
<name>Jeff Johnson</name>
<email>quic_jjohnson@quicinc.com</email>
</author>
<published>2024-06-03T14:29:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=abba7f922d8b7d39d5dd6c1ee3e79fcd9f56aa6e'/>
<id>urn:sha1:abba7f922d8b7d39d5dd6c1ee3e79fcd9f56aa6e</id>
<content type='text'>
make allmodconfig &amp;&amp; make W=1 C=1 reports:
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/acpi/acpi_tad.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/acpi/platform_profile.o

Add the missing invocations of the MODULE_DESCRIPTION() macro.

Signed-off-by: Jeff Johnson &lt;quic_jjohnson@quicinc.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI: platform-profile: add platform_profile_cycle()</title>
<updated>2024-04-15T13:46:56+00:00</updated>
<author>
<name>Gergo Koteles</name>
<email>soyer@irl.hu</email>
</author>
<published>2024-04-08T17:35:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ba95eb44676d68049490af617049a7bf68946527'/>
<id>urn:sha1:ba95eb44676d68049490af617049a7bf68946527</id>
<content type='text'>
Some laptops have a key to switch platform profiles.

Add a platform_profile_cycle() function to cycle between the enabled
profiles.

Signed-off-by: Gergo Koteles &lt;soyer@irl.hu&gt;
Acked-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Link: https://lore.kernel.org/r/5a97deddf72aa5e764d881eb39a7ba35c01a903e.1712597199.git.soyer@irl.hu
Reviewed-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
</content>
</entry>
<entry>
<title>ACPI: platform-profile: call sysfs_notify() from platform_profile_store()</title>
<updated>2021-08-16T16:32:02+00:00</updated>
<author>
<name>Hans de Goede</name>
<email>hdegoede@redhat.com</email>
</author>
<published>2021-08-16T11:30:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b25d5a1cd19896bb87b399d6e24896cf6f854d44'/>
<id>urn:sha1:b25d5a1cd19896bb87b399d6e24896cf6f854d44</id>
<content type='text'>
Drivers like thinkpad_acpi and ideapad_laptop call the
platform_profile_notify() helper when the profile is changed by hardware
(the embedded-controller/EC) in response to an EC handled hotkey.

This allows userspace to monitor for such changes by polling for POLLPRI
on the platform_profile sysfs file. But the profile can also be changed
underneath a userspace program monitoring it by anonther userspace program
storing a new value.

Add a sysfs_notify() call to platform_profile_store(), so that userspace
programs monitoring for changes also get notified in this case.

Also update the documentation to document that POLLPRI polling can be
used to watch for changes.

Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI: platform: Add balanced-performance platform profile</title>
<updated>2021-02-24T13:52:41+00:00</updated>
<author>
<name>Maximilian Luz</name>
<email>luzmaximilian@gmail.com</email>
</author>
<published>2021-02-11T20:17:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6c0b5e3fc6b536b125a66dfee103f3bc26d386f6'/>
<id>urn:sha1:6c0b5e3fc6b536b125a66dfee103f3bc26d386f6</id>
<content type='text'>
Some devices, including most Microsoft Surface devices, have a platform
profile somewhere inbetween balanced and performance. More specifically,
adding this profile allows the following mapping on Surface devices:

  Vendor Name           Platform Profile
  ------------------------------------------
  Battery Saver         low-power
  Recommended           balanced
  Better Performance    balanced-performance
  Best Performance      performance

Suggested-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Maximilian Luz &lt;luzmaximilian@gmail.com&gt;
Reviewed-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI: platform-profile: Fix possible deadlock in platform_profile_remove()</title>
<updated>2021-01-27T17:48:12+00:00</updated>
<author>
<name>Hans de Goede</name>
<email>hdegoede@redhat.com</email>
</author>
<published>2021-01-25T19:09:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=041142d7d25294c17d39552ae51c1d8d89434010'/>
<id>urn:sha1:041142d7d25294c17d39552ae51c1d8d89434010</id>
<content type='text'>
After a rmmod thinkpad_acpi, lockdep pointed out this possible deadlock:

Our _show and _store sysfs attr functions get called with the kn-&gt;active
lock held for the sysfs attr and then take the profile_lock.
sysfs_remove_group() also takes the kn-&gt;active lock for the sysfs attr,
so if we call it with the profile_lock held, then we get an ABBA deadlock.

platform_profile_remove() must only be called by drivers which have
first *successfully* called platform_profile_register(). Anything else
is a driver bug. So the check for cur_profile being set before calling
sysfs_remove_group() is not necessary and it can be dropped.

It is safe to call sysfs_remove_group() without holding the profile_lock
since the attr-group group cannot be re-added until after we clear
cur_profile.

Change platform_profile_remove() to only hold the profile_lock while
clearing the cur_profile, fixing the deadlock.

Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI: platform-profile: Introduce object pointers to callbacks</title>
<updated>2021-01-27T17:45:29+00:00</updated>
<author>
<name>Jiaxun Yang</name>
<email>jiaxun.yang@flygoat.com</email>
</author>
<published>2021-01-25T11:59:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=84f9017c37c479c4f70456a645d24d2296ad2208'/>
<id>urn:sha1:84f9017c37c479c4f70456a645d24d2296ad2208</id>
<content type='text'>
Add an object pointer to handler callbacks to avoid the need for
drivers to have a global variable to get to their driver-data
struct.

Link: https://lore.kernel.org/linux-acpi/6a29f338-d9e4-150c-81dd-2ffb54f5bc35@redhat.com/
Link: https://lore.kernel.org/r/20210114073429.176462-3-jiaxun.yang@flygoat.com
Signed-off-by: Jiaxun Yang &lt;jiaxun.yang@flygoat.com&gt;
Suggested-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI: platform-profile: Drop const qualifier for cur_profile</title>
<updated>2021-01-25T16:30:10+00:00</updated>
<author>
<name>Jiaxun Yang</name>
<email>jiaxun.yang@flygoat.com</email>
</author>
<published>2021-01-25T11:59:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9d56653d14cd5e545599cd9e3013daa17df50cd4'/>
<id>urn:sha1:9d56653d14cd5e545599cd9e3013daa17df50cd4</id>
<content type='text'>
Drop the const qualifier from the static global cur_profile
pointer declaration.

This is a preparation patch for passing the cur_profile pointer as
parameter to the profile_get() and profile_set() callbacks so that
drivers dynamically allocating their driver-data struct, with their
platform_profile_handler struct embedded, can use this pointer to
get to their driver-data.

Note this also requires dropping the const from the pprof
platform_profile_register() function argument. Dropping this
const is not a problem, non of the queued up consumers of
platform_profile_register() actually pass in a const pointer.

Link: https://lore.kernel.org/linux-acpi/5e7a4d87-52ef-e487-9cc2-8e7094beaa08@redhat.com/
Link: https://lore.kernel.org/r/20210114073429.176462-2-jiaxun.yang@flygoat.com
Suggested-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Jiaxun Yang &lt;jiaxun.yang@flygoat.com&gt;
[ hdegoede@redhat.com: Also remove const from platform_profile_register() ]
Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI: platform: Add platform profile support</title>
<updated>2020-12-30T17:34:53+00:00</updated>
<author>
<name>Mark Pearson</name>
<email>markpearson@lenovo.com</email>
</author>
<published>2020-12-30T00:18:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a2ff95e018f1d2bc816f3078d5110a655e355f18'/>
<id>urn:sha1:a2ff95e018f1d2bc816f3078d5110a655e355f18</id>
<content type='text'>
This is the initial implementation of the platform-profile feature.
It provides the details discussed and outlined in the
sysfs-platform_profile document.

Many modern systems have the ability to modify the operating profile to
control aspects like fan speed, temperature and power levels. This
module provides a common sysfs interface that platform modules can register
against to control their individual profile options.

Signed-off-by: Mark Pearson &lt;markpearson@lenovo.com&gt;
Reviewed-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
[ rjw: Use full words in enum values names ]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
</feed>
