From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27AE537D128 for ; Tue, 14 Jul 2026 11:08:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784027323; cv=none; b=Q0cXU50lquMRJn1EjEJhMQs+mJzg/G9i9wK2GENnVM8x77bjIQQncY9xpEFraIaRibXB1h+F0IdVQjKWfPqaiW6B1LKPnU+z7ra/LYAReVVqITjnIn3GZk4ishxzns8z7c70YG7/74WXTLLJQl39mwp8RV2KrNTSnB2NDHK9dZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784027323; c=relaxed/simple; bh=w7ra1oZoLsoSUtZm1rl35A/GKCnTGB1TkkeeRr1zxQQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lQ17Kiab1LfGWlbzD7nPZO4E68ciRC7RbC/XzPqfE952AHFT1MOFmuqoHy7PAURpw5XHjdmQLTnVhhMycmf2LUCgPvSYLnFh+grBUnK4v2oW2+dUDtTEG4jwMXx/R8eTZqi2txYNI4b6mT3gqnNd0EL3NsPTl6u0infZbdyZA/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=bYNJCJhG; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=LBqM0GYy; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="bYNJCJhG"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="LBqM0GYy" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66E6SRVm3912767 for ; Tue, 14 Jul 2026 11:08:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= OOV3Jx708g/F9ZxMn2phCG4uyQ912gSuTvQXRh31bc8=; b=bYNJCJhGvyTYhsjQ 1SNBQmlWoOnnCleso1MB3Le/RIuHFhygtaRwYuSresQHpziCoxumQ32k0rjx1/wn umpZ7O0AY67V09m43W6A+mg99pJSdHDXkNIh8wm+3foYc+qG/FVPC4pmaVtHY300 pQ3XXP3xY3hqNfUZSBZRthu3RhC4O4dcUsNoPSgubVw696U8W+P494cmCQHeQCXd X57fIRG2jW9mCnleXjh62OkSV+At37QVFr64+rEMU/RayruHLsKkR55Eu4Xnch3T SBq6Te9xMNT51PFIOsek8DUqS0cXmxAddG3euT84l0BUQXbx7AQAwX1z8wCwYWXK OwRW7g== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fdeu4hahm-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 14 Jul 2026 11:08:41 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2ca5d2474c7so21901355ad.2 for ; Tue, 14 Jul 2026 04:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784027321; x=1784632121; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OOV3Jx708g/F9ZxMn2phCG4uyQ912gSuTvQXRh31bc8=; b=LBqM0GYyw9KXUZd3kjA06yA4gyL+CaBoV4FsPu4tGQ4PcuJafQnp40vI5Zaus6E+gw 8Slq4knmroxI5QXm93FdFa5CmLyv17zsNn+laTvgcoPSIyPpMHcI8/CU0b4JilMB1jgC U56DKRc7VVGpx+m+QiZH74ex7EMbMD73yTKNx84WdpXILF2/yebdiG6Xm/bQR5hlU695 WGuRDVLGNvfi8wJk7OYKTTjfdv37hhO3SSgNmoTgG04iCQVuiE5KdGkfY+/ff+S8sGjx QtY1k8MHFnQr9o4MVnDKr0sJ9djIVpBktU8aE1UwhMN6N/6bCYqa82XaVQUJaEdIK2ZA 4Liw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784027321; x=1784632121; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OOV3Jx708g/F9ZxMn2phCG4uyQ912gSuTvQXRh31bc8=; b=ej+rYoBoH53I4m3fh/XclhAZFMg/NxGkuz0q44e/L6EAtXrApOmqP5wXzuV0/Sp3Rm Gg90Zad+qAaW5R9gFdadyLVpZFTNe3v9scbZgFQrbj0iUrlKlJXFqSLsPwofdm81lxKq 72abiCI2U5HFxQ06TVqf7ff1sQYbFNKEc04jW0YPaF4S5qEJ6i4VpGvdqSXZtib3jIRc FFCIn0ryoGanx2rX5Jq+F23m9eLsmtSvwGtgVDx8eFmfYVfiP2Ca7IUfAWyZv4k9SBbs o1XNgeQGoRt4WjllQiNOAm2wwwyaxyFlFn0qaurX81h7KImMssHFIAOO64D3UYgYyyU+ Acsw== X-Forwarded-Encrypted: i=1; AHgh+Ro8xsCbE3KT+/C6imYrq0Og68YUNBnfOYhbKVW0xAlO49rgBLYO6KsNcOvHxyWtwc0PKEthL7XO/GTS820=@vger.kernel.org X-Gm-Message-State: AOJu0YxcfTlU8lvOmxu1cw5uUsKzMx6++q/WHcjlF6Ue33oc38cCpuyU AsaHFUbYEz7h4KCdLc8tB/7/8trtlYW+wr8d86ez4KPQB8RyFNjEjKN+6ODX5Kuu/LqOpSOjD42 leF9CBUzXGsP1nK168SdbQfKFGI5z+pDWHjlmBBdFTJdgFhZZg4YSj93w1HCQv+rKgdCRNhHlWI Q= X-Gm-Gg: AfdE7cmqGSjRw2N4wFYBCCEPNxPKx97evxEDOglSl5DbZ0cJ+E2XlduDQk8oxkLNUiY jlhgB8l9MTHZxqMKi0Vv6JrEOAAqeX8FXvrskJa3dQx2cqpXDm4KoU8Kf9tKVUvx9Kj3M72plMR eNfHQh6bxrBCk/JXOpbHTwzIOC1rSlR9T04G0T/KHkM7eNoCU/jyjyX6Hej4J106aY8D4Nzwyw5 3MyegEYaf0RTlTBHLn52Djrq3k/wewxLOA6pDwoXibgSqUb/uj2hAKskNA1IS1o2uxQorNSZEfm lDCUr+kKfABwgy3zz+GTobLLkqm9f3Otj9FNxGCXl56ErhjVIQW21U4Vu9TUrMXnXBcwriMAZFr VkE065dDcCm/erHY1T19T2PzyRroSmBIGfdpQRla3KZf3HFkm8R+Va75uydTeBn08cRPDnQwT9m VRclWh2A== X-Received: by 2002:a17:903:4b2d:b0:2c9:ceb9:865b with SMTP id d9443c01a7336-2ce9eab3aeemr110971855ad.21.1784027320695; Tue, 14 Jul 2026 04:08:40 -0700 (PDT) X-Received: by 2002:a17:903:4b2d:b0:2c9:ceb9:865b with SMTP id d9443c01a7336-2ce9eab3aeemr110971565ad.21.1784027320167; Tue, 14 Jul 2026 04:08:40 -0700 (PDT) Received: from [10.133.33.88] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc99cc5aasm114996965ad.0.2026.07.14.04.08.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jul 2026 04:08:39 -0700 (PDT) Message-ID: <21f0957d-a8de-4262-a353-0e19fdac5481@oss.qualcomm.com> Date: Tue, 14 Jul 2026 19:08:34 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] cpufreq: amd-pstate-ut: fix null pointer dereference To: Qianheng Peng , kprateek.nayak@amd.com Cc: li.meng@amd.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, mario.limonciello@amd.com, perry.yuan@amd.com, rafael@kernel.org, ray.huang@amd.com, skhan@linuxfoundation.org, viresh.kumar@linaro.org, wangxb12@chinatelecom.cn, xiongl24@chinatelecom.cn, zhangar@chinatelecom.cn, zhongqiu.han@oss.qualcomm.com References: <1784024553-16448-1-git-send-email-pengqh1@chinatelecom.cn> Content-Language: en-US From: Zhongqiu Han In-Reply-To: <1784024553-16448-1-git-send-email-pengqh1@chinatelecom.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: 8Xl0XJRJ06iM6OW247QWatRkGNxjuEFb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE0MDExNSBTYWx0ZWRfX+ZEsmb8dDU/W sG6IKXJk1vnv2R3vDWYd2ehAQlmarndVHT7AXS+XPQwOyzGc/lmlC6qlhXHQrgvhtTLxe4S5guY Ql+FHWvtwDMQM1kFZKwpWY+UI6i0Y1zWH8oLS9+NyXlqKT3CiYOLNQMKcFU0aIB0kGujstO96XD Ga0h9NjKjFE5O9r5wdVmDMAXhLrrtskHDG3AhOsmAQfOyKFKVrEYqdfmN8bkwTTYUA5PYVLPAI9 2QfvgxK7LulYGrRlfqjKvMC5/jl/UJLxmyGKP0wsED29tRIoTPi9dUIM6NvqiM/8nTkFBgDX1JS BxOqna5tbgzLIKYks6ErSCxZgpOfMksvZCZDya/t/N4fycKR1Kb7doJvUUWk4X0q3YMvdVST+rB FKM0cMh2X1hnZGzXAHZry+aV8sb5AIO5Wbevk1V9RPQZCiaNjZdX2t1DDumQrcKFNalwAvPIipc Uq9gqStUSQcyZ6RjIZA== X-Proofpoint-GUID: 8Xl0XJRJ06iM6OW247QWatRkGNxjuEFb X-Authority-Analysis: v=2.4 cv=cN3QdFeN c=1 sm=1 tr=0 ts=6a5618b9 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=tzYFbmKReUxiKNdrr1oA:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE0MDExNSBTYWx0ZWRfXwbvXuemQU3uZ AVQlA3AsZf1g/gA+QqlL7pEUgrGrMXBV5qOxnvgS4hmHZik57QTFX3ms2EqwdD4V0skQzJgIHca VGbJ4R5nMc+bIWxDpq2Mn1avK2HdEw4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-14_02,2026-07-10_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607140115 Hi Qianheng, On 7/14/2026 6:22 PM, Qianheng Peng wrote: > Hello K Prateek, > Thanks for questions. > > On 7/14/2026 14:39, K Prateek Nayak wrote: >> On 7/14/2026 1:29 PM, Qianheng Peng wrote: >>> The crash issue may occur when insmod amd_pstate_ut modules. >>> >>> amd_pstate_ut: 1 amd_pstate_ut_acpi_cpc_valid success! >>> amd_pstate_ut: 2 amd_pstate_ut_check_enabled success! >>> BUG: kernel NULL pointer dereference, address: 0000000000000080 >>> #PF: supervisor read access in kernel mode >>> #PF: error_code(0x0000) - not-present page >>> PGD 0 P4D 0 >>> Oops: 0000 [#1] SMP NOPTI >>> CPU: 0 PID: 20300 Comm: modprobe >>> Kdump: loaded Tainted: G O 6.6.0-0010.rc1.ctl4.x86_64 #1 >>> Hardware name: FiberHome R2200 V5/Xeon Boards, BIOS 3.1a 02/24/2020 >> >> Is this an AMD platform? > No, it's Intel(R) Xeon(R) Gold 5128. > >>> RIP: 0010:amd_pstate_ut_check_perf+0x141/0x280 [amd_pstate_ut] >>> Call Trace: >>> >>> amd_pstate_ut_init+0x1b/0xff0 [amd_pstate_ut] >>> ? __pfx_amd_pstate_ut_init+0x10/0x10 [amd_pstate_ut] >>> do_one_initcall+0x42/0x2e0 >>> ? kmalloc_trace+0x26/0x90 >>> do_init_module+0x60/0x240 >>> __se_sys_init_module+0x185/0x1c0 >>> do_syscall_64+0x62/0x190 >>> entry_SYSCALL_64_after_hwframe+0x76/0x7e >>> >>> >>> Add invalidation check of cpudata in amd_pstate_ut_check_perf() and >>> amd_pstate_ut_check_freq() to avoid unpredicated null pointer dereference. >>> >>> Fixes: 14eb1c96e3a3 ("cpufreq: amd-pstate: Add test module for amd-pstate driver") >>> Suggested-by: Li Xiong >>> Suggested-by: Xibo Wang >>> Signed-off-by: Qianheng Peng >>> --- >>> drivers/cpufreq/amd-pstate-ut.c | 8 ++++++++ >>> 1 file changed, 8 insertions(+) >>> >>> diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c >>> index 735b29f..3b24260 100644 >>> --- a/drivers/cpufreq/amd-pstate-ut.c >>> +++ b/drivers/cpufreq/amd-pstate-ut.c >>> @@ -157,6 +157,10 @@ static int amd_pstate_ut_check_perf(u32 index) >>> if (!policy) >>> continue; >>> cpudata = policy->driver_data; >>> + if (!cpudata) { >>> + pr_err("%s driver_data of %s is empty!\n", __func__, policy->kobj.name); >>> + return -EINVAL; >>> + } >>> >>> if (get_shared_mem()) { >>> ret = cppc_get_perf_caps(cpu, &cppc_perf); >>> @@ -229,6 +233,10 @@ static int amd_pstate_ut_check_freq(u32 index) >>> if (!policy) >>> continue; >>> cpudata = policy->driver_data; >>> + if (!cpudata) { >>> + pr_err("%s driver_data of %s is empty!\n", __func__, policy->kobj.name); >>> + return -EINVAL; >>> + } >> >> The only time I think this can happen is when the amd-pstate-ut races with a >> the amd_pstate.*_cpu_exit() (probably as a result of concurrent mode switch) >> or if you are running this without running amd-pstate as the cpufreq driver >> (which the ut doesn't check for beforehand) >> >> My setup fails at this exact same point when I have the driver unloaded. >> What is the output of following before you run into this issue: >> >> cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver >> cat /sys/devices/system/cpu/amd_pstate/status >> >> Are you doing any concurrent hotplug / mode switch? >> >>> >>> if (!((policy->cpuinfo.max_freq >= cpudata->nominal_freq) && >>> (cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) && > In this machine, I got output as follow: > ====================================================================================== > [root@ ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver > intel_cpufreq > [root@ ~]# cat /sys/devices/system/cpu/amd_pstate/status > cat: /sys/devices/system/cpu/amd_pstate/status: No such file or directory (os error 2) > ====================================================================================== > Otherwise,I didn't do any concurrent hotplug / mode switch, just modprobe amd_pstate_ut. > It may be worth adding driver name detection to this ut driver, for example via cpufreq_get_current_driver(). -- Thx and BRs, Zhongqiu Han