diff mbox

[RFC,12/19] ACPI: Enforce stricter checks for address space descriptors

Message ID 1420684386-5975-13-git-send-email-jiang.liu@linux.intel.com
State Changes Requested
Headers show

Commit Message

Jiang Liu Jan. 8, 2015, 2:32 a.m. UTC
Enforce stricter checks for address space descriptors according to
ACPI spec.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
 drivers/acpi/resource.c |    8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Rafael J. Wysocki Jan. 21, 2015, 12:45 a.m. UTC | #1
On Thursday, January 08, 2015 10:32:59 AM Jiang Liu wrote:
> Enforce stricter checks for address space descriptors according to
> ACPI spec.

So is the spec the only reason for doing this?  If so, I'd say don't.

> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> ---
>  drivers/acpi/resource.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
> index 26b47f1da523..e82149e44347 100644
> --- a/drivers/acpi/resource.c
> +++ b/drivers/acpi/resource.c
> @@ -192,6 +192,14 @@ static bool acpi_decode_space(struct resource *res,
>  	bool wp = base->info.mem.write_protect;
>  	u64 len = addr->address_length;
>  
> +	/*
> +	 * Filter out invalid descriptor according to ACPI Spec 5.0, section
> +	 * 6.4.3.5 Address Space Resource Descriptors.
> +	 */
> +	if ((base->min_address_fixed != base->max_address_fixed && len) ||
> +	    (base->min_address_fixed && base->max_address_fixed && !len))
> +		return false;
> +
>  	res->start = addr->minimum;
>  	res->end = addr->maximum;
>  
>
Jiang Liu Jan. 21, 2015, 2:18 a.m. UTC | #2
On 2015/1/21 8:45, Rafael J. Wysocki wrote:
> On Thursday, January 08, 2015 10:32:59 AM Jiang Liu wrote:
>> Enforce stricter checks for address space descriptors according to
>> ACPI spec.
> 
> So is the spec the only reason for doing this?  If so, I'd say don't.
Hi Rafael,
	Yes, it's just for spec. I will drop this patch to avoid
regressions.
Regards!
Gerry

> 
>> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
>> ---
>>  drivers/acpi/resource.c |    8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
>> index 26b47f1da523..e82149e44347 100644
>> --- a/drivers/acpi/resource.c
>> +++ b/drivers/acpi/resource.c
>> @@ -192,6 +192,14 @@ static bool acpi_decode_space(struct resource *res,
>>  	bool wp = base->info.mem.write_protect;
>>  	u64 len = addr->address_length;
>>  
>> +	/*
>> +	 * Filter out invalid descriptor according to ACPI Spec 5.0, section
>> +	 * 6.4.3.5 Address Space Resource Descriptors.
>> +	 */
>> +	if ((base->min_address_fixed != base->max_address_fixed && len) ||
>> +	    (base->min_address_fixed && base->max_address_fixed && !len))
>> +		return false;
>> +
>>  	res->start = addr->minimum;
>>  	res->end = addr->maximum;
>>  
>>
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki Jan. 21, 2015, 3:01 a.m. UTC | #3
On Wednesday, January 21, 2015 10:18:25 AM Jiang Liu wrote:
> On 2015/1/21 8:45, Rafael J. Wysocki wrote:
> > On Thursday, January 08, 2015 10:32:59 AM Jiang Liu wrote:
> >> Enforce stricter checks for address space descriptors according to
> >> ACPI spec.
> > 
> > So is the spec the only reason for doing this?  If so, I'd say don't.
> Hi Rafael,
> 	Yes, it's just for spec. I will drop this patch to avoid
> regressions.

A debug message covering that may be useful, though, in case things don't
work and this is the reason.
diff mbox

Patch

diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 26b47f1da523..e82149e44347 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -192,6 +192,14 @@  static bool acpi_decode_space(struct resource *res,
 	bool wp = base->info.mem.write_protect;
 	u64 len = addr->address_length;
 
+	/*
+	 * Filter out invalid descriptor according to ACPI Spec 5.0, section
+	 * 6.4.3.5 Address Space Resource Descriptors.
+	 */
+	if ((base->min_address_fixed != base->max_address_fixed && len) ||
+	    (base->min_address_fixed && base->max_address_fixed && !len))
+		return false;
+
 	res->start = addr->minimum;
 	res->end = addr->maximum;