[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 03/11] xen/x86: introduce "cpufreq=amd-cppc" xen cmdline
- To: Jan Beulich <jbeulich@xxxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>
- From: Jason Andryuk <jason.andryuk@xxxxxxx>
- Date: Tue, 11 Feb 2025 10:11:22 -0500
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=B3JVTd78im6ZmH7v6neILydXzWSBVLEklfJjgRmabNo=; b=GCVh1bbAx46AH56iUBoc044Z9h8JpK2+tcXLB7dZze2X+hnTTdFvVkLDun95mTqJHzlxxcSOEn/NdXf5Cy86iH0t7z3ITi/k5rWTtu1LvHCtpUR8oKymz0gRqs9XhcQ7QxpE7UtGfAnH2CP0KJD82EGtZTzuDXQNbYtn1Hqw7gPTsrC4XJlc7JDEAOSCim9eMS/05EKcL8gR9tlWuxbzWTVBeM8uqO37GZ/6obQyusWX+PMqmrfds1W/KXJGwNWbGlnZAR+tWHax6/HgsvqzpuGi5VJ/8JxnaXiI/cajZaMGh9/IUkSZp3iz8eWfOTKKcS2WVfwhLOuh1BSzdlsf4g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w199w/E1IzfFYdbIh2wr9lEZ6HjmK/fz35wI1+dyz6slXgJ+WW/Hopi5FuuVg50aqrf70TiFdQhw4NV3t8fxg3mt9kFygJeIOOwVS6QQOTj3TibWucRQVatdnjWswJpuhx2hHBCw7B/lOMU30eUJkeAXI1lLNEhplCKnxnFjsimOlidNKqQGikq9Z8DrITtjlyihiMtmW0awg4VxZWGHKMD+aYWbMO+oAvOpTd0rb6F+NjQkC/y2g1jhjKPl9iwxoiqeTNbR9NgIGLZ33dGtX3EsxB7LuUuEC+1yPvqBnIrpkxfoWL09svhZBCl7XW/pB5EltSgwkCx250fZ0i4ULg==
- Cc: <Ray.Huang@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Anthony PERARD" <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Tue, 11 Feb 2025 15:11:41 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 2025-02-11 07:08, Jan Beulich wrote:
On 06.02.2025 09:32, Penny Zheng wrote:
--- /dev/null
+++ b/xen/arch/x86/acpi/cpufreq/amd-cppc.c
@@ -0,0 +1,64 @@
+static bool __init amd_cppc_handle_option(const char *s, const char *end)
+{
+ int ret;
+
+ ret = parse_boolean("verbose", s, end);
+ if ( ret >= 0 )
+ {
+ cpufreq_verbose = ret;
+ return true;
+ }
+
+ return false;
+}
+
+int __init amd_cppc_cmdline_parse(const char *s, const char *e)
+{
+ do
+ {
+ const char *end = strpbrk(s, ",;");
+
+ if ( !amd_cppc_handle_option(s, end) )
You have an incoming "e" here. What if the comma / semicolon you find
is past where that points? (I understand you've copied that from
hwp_cmdline_parse(), and should have raised the question already there
when reviewing the respective patch. It also looks as if behavior-
wise all would be okay here. It's just that this very much looks like
a buffer overrun on the first and second glance.)
It's been a while since I worked on HWP. I think my assumption was that
you are inside a nul terminated string, and command line option parsing
functions can handle end == NULL, so it would all work out. A too long
string crossing " " or ";" would not match.
+ {
+ printk(XENLOG_WARNING
+ "cpufreq/amd-cppc: option '%.*s' not recognized\n",
+ (int)((end ?: e) - s), s);
+
+ return -EINVAL;
+ }
+
+ s = end ? ++end : end;
The increment is odd here (again inherited from the HWP function), as
"end" is about to go out of scope.
For HWP, I copied from setup_cpufreq_option() which does similar.
You'd prefer:
s = end ? end + 1 : NULL;
That is more explicit which is good. I considered using NULL back when
working on that. I think I when with the current form to match
setup_cpufreq_option().
Regards,
Jason
|