linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Lan Tianyu <tianyu.lan@intel.com>
Cc: wsa@the-dreams.de, lenb@kernel.org,
	mika.westerberg@linux.intel.com, awilliam@redhat.com,
	robert.moore@intel.com, lv.zheng@intel.com,
	rafael.j.wysocki@intel.com, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	devel@acpica.org
Subject: Re: [PATCH 1/9] ACPICA: Executer: Fix buffer allocation issue for generic_serial_bus region field accesses.
Date: Mon, 21 Apr 2014 23:38:05 +0200	[thread overview]
Message-ID: <5269843.b915ubdT5E@vostro.rjw.lan> (raw)
In-Reply-To: <1397654682-7094-2-git-send-email-tianyu.lan@intel.com>

Hi,

On Wednesday, April 16, 2014 09:24:34 PM Lan Tianyu wrote:
> From: Lv Zheng <lv.zheng@intel.com>
> 
> The size of the buffer allocated for generic_serial_bus region access
> is not correct.  This patch introduces acpi_ex_get_serial_access_length()
> to be invoked to obtain correct data buffer length.  Reported by
> Lan Tianyu, Fixed by Lv Zheng.
> 
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>

I'm queueing up this patch as a fix for 3.15, but can you please resend the
whole series with a CC to linux-acpi?


> ---
>  drivers/acpi/acpica/exfield.c | 104 +++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 97 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
> index 68d9744..12878e1 100644
> --- a/drivers/acpi/acpica/exfield.c
> +++ b/drivers/acpi/acpica/exfield.c
> @@ -45,10 +45,71 @@
>  #include "accommon.h"
>  #include "acdispat.h"
>  #include "acinterp.h"
> +#include "amlcode.h"
>  
>  #define _COMPONENT          ACPI_EXECUTER
>  ACPI_MODULE_NAME("exfield")
>  
> +/* Local prototypes */
> +static u32
> +acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length);
> +
> +/*******************************************************************************
> + *
> + * FUNCTION:    acpi_get_serial_access_bytes
> + *
> + * PARAMETERS:  accessor_type   - The type of the protocol indicated by region
> + *                                field access attributes
> + *              access_length   - The access length of the region field
> + *
> + * RETURN:      Decoded access length
> + *
> + * DESCRIPTION: This routine returns the length of the generic_serial_bus
> + *              protocol bytes
> + *
> + ******************************************************************************/
> +
> +static u32
> +acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length)
> +{
> +	u32 length;
> +
> +	switch (accessor_type) {
> +	case AML_FIELD_ATTRIB_QUICK:
> +
> +		length = 0;
> +		break;
> +
> +	case AML_FIELD_ATTRIB_SEND_RCV:
> +	case AML_FIELD_ATTRIB_BYTE:
> +
> +		length = 1;
> +		break;
> +
> +	case AML_FIELD_ATTRIB_WORD:
> +	case AML_FIELD_ATTRIB_WORD_CALL:
> +
> +		length = 2;
> +		break;
> +
> +	case AML_FIELD_ATTRIB_MULTIBYTE:
> +	case AML_FIELD_ATTRIB_RAW_BYTES:
> +	case AML_FIELD_ATTRIB_RAW_PROCESS:
> +
> +		length = access_length;
> +		break;
> +
> +	case AML_FIELD_ATTRIB_BLOCK:
> +	case AML_FIELD_ATTRIB_BLOCK_CALL:
> +	default:
> +
> +		length = ACPI_GSBUS_BUFFER_SIZE;
> +		break;
> +	}
> +
> +	return (length);
> +}
> +
>  /*******************************************************************************
>   *
>   * FUNCTION:    acpi_ex_read_data_from_field
> @@ -63,8 +124,9 @@ ACPI_MODULE_NAME("exfield")
>   *              Buffer, depending on the size of the field.
>   *
>   ******************************************************************************/
> +
>  acpi_status
> -acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
> +acpi_ex_read_data_from_field(struct acpi_walk_state * walk_state,
>  			     union acpi_operand_object *obj_desc,
>  			     union acpi_operand_object **ret_buffer_desc)
>  {
> @@ -73,6 +135,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
>  	acpi_size length;
>  	void *buffer;
>  	u32 function;
> +	u16 accessor_type;
>  
>  	ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc);
>  
> @@ -116,9 +179,22 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
>  			    ACPI_READ | (obj_desc->field.attribute << 16);
>  		} else if (obj_desc->field.region_obj->region.space_id ==
>  			   ACPI_ADR_SPACE_GSBUS) {
> -			length = ACPI_GSBUS_BUFFER_SIZE;
> -			function =
> -			    ACPI_READ | (obj_desc->field.attribute << 16);
> +			accessor_type = obj_desc->field.attribute;
> +			length = acpi_ex_get_serial_access_length(accessor_type,
> +								  obj_desc->
> +								  field.
> +								  access_length);
> +
> +			/*
> +			 * Add additional 2 bytes for modeled generic_serial_bus data buffer:
> +			 * typedef struct {
> +			 *     BYTEStatus; // Byte 0 of the data buffer
> +			 *     BYTELength; // Byte 1 of the data buffer
> +			 *     BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer,
> +			 * }
> +			 */
> +			length += 2;
> +			function = ACPI_READ | (accessor_type << 16);
>  		} else {	/* IPMI */
>  
>  			length = ACPI_IPMI_BUFFER_SIZE;
> @@ -231,6 +307,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
>  	void *buffer;
>  	union acpi_operand_object *buffer_desc;
>  	u32 function;
> +	u16 accessor_type;
>  
>  	ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc);
>  
> @@ -284,9 +361,22 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
>  			    ACPI_WRITE | (obj_desc->field.attribute << 16);
>  		} else if (obj_desc->field.region_obj->region.space_id ==
>  			   ACPI_ADR_SPACE_GSBUS) {
> -			length = ACPI_GSBUS_BUFFER_SIZE;
> -			function =
> -			    ACPI_WRITE | (obj_desc->field.attribute << 16);
> +			accessor_type = obj_desc->field.attribute;
> +			length = acpi_ex_get_serial_access_length(accessor_type,
> +								  obj_desc->
> +								  field.
> +								  access_length);
> +
> +			/*
> +			 * Add additional 2 bytes for modeled generic_serial_bus data buffer:
> +			 * typedef struct {
> +			 *     BYTEStatus; // Byte 0 of the data buffer
> +			 *     BYTELength; // Byte 1 of the data buffer
> +			 *     BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer,
> +			 * }
> +			 */
> +			length += 2;
> +			function = ACPI_WRITE | (accessor_type << 16);
>  		} else {	/* IPMI */
>  
>  			length = ACPI_IPMI_BUFFER_SIZE;
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

  reply	other threads:[~2014-04-21 21:21 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-16 13:24 [PATCH 0/9] I2C ACPI operation region handler support Lan Tianyu
2014-04-16 13:24 ` [PATCH 1/9] ACPICA: Executer: Fix buffer allocation issue for generic_serial_bus region field accesses Lan Tianyu
2014-04-21 21:38   ` Rafael J. Wysocki [this message]
2014-04-22  1:14     ` Lan Tianyu
2014-04-16 13:24 ` [PATCH 2/9] ACPICA: Export acpi_buffer_to_resource symbol Lan Tianyu
2014-04-16 13:24 ` [PATCH 3/9] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
2014-04-16 13:24 ` [PATCH 4/9] ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private data Lan Tianyu
2014-04-16 13:24 ` [PATCH 5/9] I2C: Add smbus quick read/write helper function Lan Tianyu
2014-04-16 13:24 ` [PATCH 6/9] I2C: Add smbus word/block process call " Lan Tianyu
2014-04-16 13:24 ` [PATCH 7/9] I2C/ACPI: Add i2c ACPI operation region support Lan Tianyu
2014-04-16 13:24 ` [PATCH 8/9] I2C/ACPI: Move ACPI related code to i2c-acpi.c Lan Tianyu
2014-04-16 13:24 ` [PATCH 9/9] I2C/ACPI: Add CONFIG_I2C_ACPI config Lan Tianyu
2014-04-16 13:33 ` [PATCH 0/9] I2C ACPI operation region handler support Lan Tianyu
2014-04-16 16:35 ` Adam Williamson
2014-04-22  6:24 ` [Resend Patch " Lan Tianyu
2014-04-22  6:24   ` [Resend Patch 1/9] ACPICA: Executer: Fix buffer allocation issue for generic_serial_bus region field accesses Lan Tianyu
2014-04-22 11:21     ` Mika Westerberg
2014-04-22  6:24   ` [Resend Patch 2/9] ACPICA: Export acpi_buffer_to_resource symbol Lan Tianyu
2014-04-22 11:21     ` Mika Westerberg
2014-04-22  6:24   ` [Resend Patch 3/9] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
2014-04-22 11:23     ` Mika Westerberg
2014-04-22  6:24   ` [Resend Patch 4/9] ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private data Lan Tianyu
2014-04-22 11:24     ` Mika Westerberg
2014-04-22  6:24   ` [Resend Patch 5/9] I2C: Add smbus quick read/write helper function Lan Tianyu
2014-04-22 11:24     ` Mika Westerberg
2014-04-22  6:24   ` [Resend Patch 6/9] I2C: Add smbus word/block process call " Lan Tianyu
2014-04-22 11:26     ` Mika Westerberg
2014-04-22  6:24   ` [Resend Patch 7/9] I2C/ACPI: Add i2c ACPI operation region support Lan Tianyu
2014-04-22 11:36     ` Mika Westerberg
2014-04-23  1:53       ` Lan Tianyu
2014-04-23  7:28         ` Mika Westerberg
2014-04-23  7:17           ` Lan Tianyu
2014-04-22  6:24   ` [Resend Patch 8/9] I2C/ACPI: Move ACPI related code to i2c-acpi.c Lan Tianyu
2014-04-22 11:38     ` Mika Westerberg
2014-04-22  6:24   ` [Resend Patch 9/9] I2C/ACPI: Add CONFIG_I2C_ACPI config Lan Tianyu
2014-04-22 11:45     ` Mika Westerberg
2014-04-23  5:39       ` Lan Tianyu
2014-04-23  6:47         ` Zheng, Lv
2014-04-23  7:40           ` Mika Westerberg
2014-04-23 23:03   ` [Resend Patch 0/9] I2C ACPI operation region handler support Adam Williamson
2014-04-28 14:27   ` [Patch V2 " Lan Tianyu
2014-04-28 14:27     ` [Patch V2 1/9] ACPICA: Executer: Fix buffer allocation issue for generic_serial_bus region field accesses Lan Tianyu
2014-04-28 17:52       ` Adam Williamson
2014-04-28 18:08         ` Adam Williamson
2014-04-28 22:50           ` Rafael J. Wysocki
2014-04-29 11:31             ` Wolfram Sang
2014-04-29 21:37               ` Rafael J. Wysocki
2014-04-28 14:27     ` [Patch V2 2/9] ACPICA: Export acpi_buffer_to_resource symbol Lan Tianyu
2014-04-28 14:27     ` [Patch V2 3/9] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
2014-04-28 14:27     ` [Patch V2 4/9] ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private data Lan Tianyu
2014-04-28 14:27     ` [Patch V2 5/9] I2C: Add smbus quick read/write helper function Lan Tianyu
2014-05-17  9:41       ` Wolfram Sang
2014-05-17 13:13         ` Lan Tianyu
2014-05-17 17:15           ` Wolfram Sang
2014-04-28 14:27     ` [Patch V2 6/9] I2C: Add smbus word/block process call " Lan Tianyu
2014-05-17 10:21       ` Wolfram Sang
2014-05-17 13:59         ` Lan Tianyu
2014-05-17 17:17           ` Wolfram Sang
2014-05-19  9:23             ` Lan Tianyu
2014-04-28 14:27     ` [Patch V2 7/9] I2C/ACPI: Add i2c ACPI operation region support Lan Tianyu
2014-04-29  8:02       ` Mika Westerberg
2014-04-28 14:27     ` [Patch V2 8/9] I2C/ACPI: Move ACPI related code to i2c-acpi.c Lan Tianyu
2014-04-28 14:27     ` [Patch V2 9/9] I2C/ACPI: Add CONFIG_I2C_ACPI config Lan Tianyu
2014-04-29  8:16       ` Mika Westerberg
2014-05-17 17:48         ` Wolfram Sang
2014-05-19  8:49           ` Mika Westerberg
2014-05-19  9:44             ` Lan Tianyu
2014-05-19 20:23               ` Rafael J. Wysocki
2014-04-28 22:51     ` [Patch V2 0/9] I2C ACPI operation region handler support Rafael J. Wysocki
2014-04-29  1:54       ` Lan Tianyu
2014-04-29 15:47         ` Rafael J. Wysocki
2014-05-13 13:09     ` Rolf Eike Beer
2014-05-13 14:06       ` Lan Tianyu
2014-05-15  7:50         ` Rolf Eike Beer
2014-05-15 14:49           ` Lan Tianyu
2014-05-16  8:43             ` Rolf Eike Beer
2014-05-20 14:17           ` Rolf Eike Beer
2014-05-22 15:14             ` Lan Tianyu
2014-05-23  6:55               ` Rolf Eike Beer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5269843.b915ubdT5E@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=awilliam@redhat.com \
    --cc=devel@acpica.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lv.zheng@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.com \
    --cc=tianyu.lan@intel.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).