linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI/Processor: Fix failure of loading acpi-cpufreq driver
@ 2014-04-30  3:10 Lan Tianyu
  2014-04-30  5:08 ` Jiang Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Lan Tianyu @ 2014-04-30  3:10 UTC (permalink / raw)
  To: rjw, lenb, katoh, smf.linux; +Cc: Lan Tianyu, linux-acpi, linux-kernel

According commit d640113fe(ACPI: processor: fix acpi_get_cpuid for UP
processor),  Bios may not provide _MAT or MADT tables and acpi_get_apicid()
always returns -1. For these cases, original code will pass apic_id with
vaule of -1 to acpi_map_cpuid() and it will check the acpi_id. If acpi_id
is equal to zero, ignores apic_id and return zero for CPU0.

Commit b981513(ACPI / scan: bail out early if failed to parse APIC
ID for CPU) changed the behavior. Return ENODEV when find apic_id is
less than zero after calling acpi_get_apicid(). This causes acpi-cpufreq
driver fails to be loaded on some machines. This patch is to fix it.

Reference:https://bugzilla.kernel.org/show_bug.cgi?id=73781
Cc: stable@vger.kernel.org v3.14
Reported-and-tested-by: KATO Hiroshi <katoh@mikage.ne.jp>
Reported-and-tested-by: Stuart Foster <smf.linux@ntlworld.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 drivers/acpi/acpi_processor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index c29c2c3..d55b603 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -260,10 +260,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
 	}
 
 	apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
-	if (apic_id < 0) {
+	if (apic_id < 0)
 		acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n");
-		return -ENODEV;
-	}
 	pr->apic_id = apic_id;
 
 	cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
-- 
1.8.4.rc0.1.g8f6a3e5.dirty


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI/Processor: Fix failure of loading acpi-cpufreq driver
  2014-04-30  3:10 [PATCH] ACPI/Processor: Fix failure of loading acpi-cpufreq driver Lan Tianyu
@ 2014-04-30  5:08 ` Jiang Liu
  2014-04-30  5:16   ` Jiang Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Jiang Liu @ 2014-04-30  5:08 UTC (permalink / raw)
  To: Lan Tianyu, rjw, lenb, katoh, smf.linux; +Cc: linux-acpi, linux-kernel

Hi Tianyu,
	With the suggested fix, we still need to protect
acpi_processor_hotadd_init() when pr->apic_id is -1,
otherwise it may cause invalid memory access.

Best Regards!
Gerry

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index c29c2c3ec0ad..e17befc54c34 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -170,6 +170,9 @@ static int acpi_processor_hotadd_init(struct
acpi_processor *pr)
        acpi_status status;
        int ret;

+       if (pr->apic_id < 0)
+               return -ENODEV;
+
        status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
        if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
                return -ENODEV;


On 2014/4/30 11:10, Lan Tianyu wrote:
> According commit d640113fe(ACPI: processor: fix acpi_get_cpuid for UP
> processor),  Bios may not provide _MAT or MADT tables and acpi_get_apicid()
> always returns -1. For these cases, original code will pass apic_id with
> vaule of -1 to acpi_map_cpuid() and it will check the acpi_id. If acpi_id
> is equal to zero, ignores apic_id and return zero for CPU0.
> 
> Commit b981513(ACPI / scan: bail out early if failed to parse APIC
> ID for CPU) changed the behavior. Return ENODEV when find apic_id is
> less than zero after calling acpi_get_apicid(). This causes acpi-cpufreq
> driver fails to be loaded on some machines. This patch is to fix it.
> 
> Reference:https://bugzilla.kernel.org/show_bug.cgi?id=73781
> Cc: stable@vger.kernel.org v3.14
> Reported-and-tested-by: KATO Hiroshi <katoh@mikage.ne.jp>
> Reported-and-tested-by: Stuart Foster <smf.linux@ntlworld.com>
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> ---
>  drivers/acpi/acpi_processor.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
> index c29c2c3..d55b603 100644
> --- a/drivers/acpi/acpi_processor.c
> +++ b/drivers/acpi/acpi_processor.c
> @@ -260,10 +260,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
>  	}
>  
>  	apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
> -	if (apic_id < 0) {
> +	if (apic_id < 0)
>  		acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n");
> -		return -ENODEV;
> -	}
>  	pr->apic_id = apic_id;
>  
>  	cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
> 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI/Processor: Fix failure of loading acpi-cpufreq driver
  2014-04-30  5:08 ` Jiang Liu
@ 2014-04-30  5:16   ` Jiang Liu
  2014-04-30  6:27     ` Lan Tianyu
  0 siblings, 1 reply; 4+ messages in thread
From: Jiang Liu @ 2014-04-30  5:16 UTC (permalink / raw)
  To: Lan Tianyu, rjw, lenb, katoh, smf.linux; +Cc: linux-acpi, linux-kernel

Hi Tianyu,
	Found another issue at the second glance.
In case of x2apic, "if (apic_id < 0)" should be replaced
by "if (apic_id == -1)" for safety.
Best Regards!
Gerry

On 2014/4/30 13:08, Jiang Liu wrote:
> Hi Tianyu,
> 	With the suggested fix, we still need to protect
> acpi_processor_hotadd_init() when pr->apic_id is -1,
> otherwise it may cause invalid memory access.
> 
> Best Regards!
> Gerry
> 
> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
> index c29c2c3ec0ad..e17befc54c34 100644
> --- a/drivers/acpi/acpi_processor.c
> +++ b/drivers/acpi/acpi_processor.c
> @@ -170,6 +170,9 @@ static int acpi_processor_hotadd_init(struct
> acpi_processor *pr)
>         acpi_status status;
>         int ret;
> 
> +       if (pr->apic_id < 0)
> +               return -ENODEV;
> +
>         status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
>         if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
>                 return -ENODEV;
> 
> 
> On 2014/4/30 11:10, Lan Tianyu wrote:
>> According commit d640113fe(ACPI: processor: fix acpi_get_cpuid for UP
>> processor),  Bios may not provide _MAT or MADT tables and acpi_get_apicid()
>> always returns -1. For these cases, original code will pass apic_id with
>> vaule of -1 to acpi_map_cpuid() and it will check the acpi_id. If acpi_id
>> is equal to zero, ignores apic_id and return zero for CPU0.
>>
>> Commit b981513(ACPI / scan: bail out early if failed to parse APIC
>> ID for CPU) changed the behavior. Return ENODEV when find apic_id is
>> less than zero after calling acpi_get_apicid(). This causes acpi-cpufreq
>> driver fails to be loaded on some machines. This patch is to fix it.
>>
>> Reference:https://bugzilla.kernel.org/show_bug.cgi?id=73781
>> Cc: stable@vger.kernel.org v3.14
>> Reported-and-tested-by: KATO Hiroshi <katoh@mikage.ne.jp>
>> Reported-and-tested-by: Stuart Foster <smf.linux@ntlworld.com>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>> ---
>>  drivers/acpi/acpi_processor.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
>> index c29c2c3..d55b603 100644
>> --- a/drivers/acpi/acpi_processor.c
>> +++ b/drivers/acpi/acpi_processor.c
>> @@ -260,10 +260,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
>>  	}
>>  
>>  	apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
>> -	if (apic_id < 0) {
>> +	if (apic_id < 0)
>>  		acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n");
>> -		return -ENODEV;
>> -	}
>>  	pr->apic_id = apic_id;
>>  
>>  	cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI/Processor: Fix failure of loading acpi-cpufreq driver
  2014-04-30  5:16   ` Jiang Liu
@ 2014-04-30  6:27     ` Lan Tianyu
  0 siblings, 0 replies; 4+ messages in thread
From: Lan Tianyu @ 2014-04-30  6:27 UTC (permalink / raw)
  To: Jiang Liu; +Cc: rjw, lenb, katoh, smf.linux, linux-acpi, linux-kernel

On 2014年04月30日 13:16, Jiang Liu wrote:
> Hi Tianyu,
> 	Found another issue at the second glance.
> In case of x2apic, "if (apic_id < 0)" should be replaced
> by "if (apic_id == -1)" for safety.

Hi Jiang:
	Thanks for suggestion. I will update soon.
	

> Best Regards!
> Gerry
> 
> On 2014/4/30 13:08, Jiang Liu wrote:
>> Hi Tianyu,
>> 	With the suggested fix, we still need to protect
>> acpi_processor_hotadd_init() when pr->apic_id is -1,
>> otherwise it may cause invalid memory access.
>>
>> Best Regards!
>> Gerry
>>
>> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
>> index c29c2c3ec0ad..e17befc54c34 100644
>> --- a/drivers/acpi/acpi_processor.c
>> +++ b/drivers/acpi/acpi_processor.c
>> @@ -170,6 +170,9 @@ static int acpi_processor_hotadd_init(struct
>> acpi_processor *pr)
>>         acpi_status status;
>>         int ret;
>>
>> +       if (pr->apic_id < 0)
>> +               return -ENODEV;
>> +
>>         status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
>>         if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
>>                 return -ENODEV;
>>
>>
>> On 2014/4/30 11:10, Lan Tianyu wrote:
>>> According commit d640113fe(ACPI: processor: fix acpi_get_cpuid for UP
>>> processor),  Bios may not provide _MAT or MADT tables and acpi_get_apicid()
>>> always returns -1. For these cases, original code will pass apic_id with
>>> vaule of -1 to acpi_map_cpuid() and it will check the acpi_id. If acpi_id
>>> is equal to zero, ignores apic_id and return zero for CPU0.
>>>
>>> Commit b981513(ACPI / scan: bail out early if failed to parse APIC
>>> ID for CPU) changed the behavior. Return ENODEV when find apic_id is
>>> less than zero after calling acpi_get_apicid(). This causes acpi-cpufreq
>>> driver fails to be loaded on some machines. This patch is to fix it.
>>>
>>> Reference:https://bugzilla.kernel.org/show_bug.cgi?id=73781
>>> Cc: stable@vger.kernel.org v3.14
>>> Reported-and-tested-by: KATO Hiroshi <katoh@mikage.ne.jp>
>>> Reported-and-tested-by: Stuart Foster <smf.linux@ntlworld.com>
>>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>>> ---
>>>  drivers/acpi/acpi_processor.c | 4 +---
>>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
>>> index c29c2c3..d55b603 100644
>>> --- a/drivers/acpi/acpi_processor.c
>>> +++ b/drivers/acpi/acpi_processor.c
>>> @@ -260,10 +260,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
>>>  	}
>>>  
>>>  	apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
>>> -	if (apic_id < 0) {
>>> +	if (apic_id < 0)
>>>  		acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n");
>>> -		return -ENODEV;
>>> -	}
>>>  	pr->apic_id = apic_id;
>>>  
>>>  	cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>


-- 
Best regards
Tianyu Lan
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-30  6:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30  3:10 [PATCH] ACPI/Processor: Fix failure of loading acpi-cpufreq driver Lan Tianyu
2014-04-30  5:08 ` Jiang Liu
2014-04-30  5:16   ` Jiang Liu
2014-04-30  6:27     ` Lan Tianyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).