diff mbox

ACPICA: Check whether ACPI is disabled before getting a table

Message ID 20170821132054.mwhdxkcka4ocp6h5@pd.tnic (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Borislav Petkov Aug. 21, 2017, 1:20 p.m. UTC
Borislav Petkov <bp@suse.de>

... and save us the splrinking of this test around in the callers.

No functionality change.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 drivers/acpi/acpica/tbxface.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Rafael J. Wysocki Aug. 21, 2017, 1:30 p.m. UTC | #1
On Mon, Aug 21, 2017 at 3:20 PM, Borislav Petkov <bp@alien8.de> wrote:
> Borislav Petkov <bp@suse.de>
>
> ... and save us the splrinking of this test around in the callers.
>
> No functionality change.
>
> Signed-off-by: Borislav Petkov <bp@suse.de>
> ---
>  drivers/acpi/acpica/tbxface.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
> index 010b1c43df92..881b0d5b2838 100644
> --- a/drivers/acpi/acpica/tbxface.c
> +++ b/drivers/acpi/acpica/tbxface.c
> @@ -226,6 +226,9 @@ acpi_get_table_header(char *signature,
>         u32 j;
>         struct acpi_table_header *header;
>
> +       if (acpi_disabled)
> +               return (AE_ERROR);
> +
>         /* Parameter validation */
>
>         if (!signature || !out_table_header) {
> --

Is acpi_disabled an ACPICA variable?  If not, this cannot go upstream.
Not a big deal I guess, but somewhat yucky.
--
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
Borislav Petkov Aug. 21, 2017, 3:34 p.m. UTC | #2
On Mon, Aug 21, 2017 at 03:30:47PM +0200, Rafael J. Wysocki wrote:
> Is acpi_disabled an ACPICA variable?

Doesn't look like it: it is defined in arch/x86/kernel/acpi/boot.c

> If not, this cannot go upstream. Not a big deal I guess, but somewhat
> yucky.

Uff, there's that "sync" of keeping ACPICA code and its version in the
kernel the same. Yuck.

Oh well.
kernel test robot Sept. 3, 2017, 12:43 a.m. UTC | #3
Hi Borislav,

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.13-rc7 next-20170901]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Borislav-Petkov/ACPICA-Check-whether-ACPI-is-disabled-before-getting-a-table/20170823-041359
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All errors (new ones prefixed by >>):

   drivers/acpi/acpica/tbxface.c: In function 'acpi_get_table_header':
>> drivers/acpi/acpica/tbxface.c:254:6: error: 'acpi_disabled' undeclared (first use in this function)
     if (acpi_disabled)
         ^~~~~~~~~~~~~
   drivers/acpi/acpica/tbxface.c:254:6: note: each undeclared identifier is reported only once for each function it appears in

vim +/acpi_disabled +254 drivers/acpi/acpica/tbxface.c

   229	
   230	/*******************************************************************************
   231	 *
   232	 * FUNCTION:    acpi_get_table_header
   233	 *
   234	 * PARAMETERS:  signature           - ACPI signature of needed table
   235	 *              instance            - Which instance (for SSDTs)
   236	 *              out_table_header    - The pointer to the table header to fill
   237	 *
   238	 * RETURN:      Status and pointer to mapped table header
   239	 *
   240	 * DESCRIPTION: Finds an ACPI table header.
   241	 *
   242	 * NOTE:        Caller is responsible in unmapping the header with
   243	 *              acpi_os_unmap_memory
   244	 *
   245	 ******************************************************************************/
   246	acpi_status
   247	acpi_get_table_header(char *signature,
   248			      u32 instance, struct acpi_table_header *out_table_header)
   249	{
   250		u32 i;
   251		u32 j;
   252		struct acpi_table_header *header;
   253	
 > 254		if (acpi_disabled)
   255			return (AE_ERROR);
   256	
   257		/* Parameter validation */
   258	
   259		if (!signature || !out_table_header) {
   260			return (AE_BAD_PARAMETER);
   261		}
   262	
   263		/* Walk the root table list */
   264	
   265		for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count;
   266		     i++) {
   267			if (!ACPI_COMPARE_NAME
   268			    (&(acpi_gbl_root_table_list.tables[i].signature),
   269			     signature)) {
   270				continue;
   271			}
   272	
   273			if (++j < instance) {
   274				continue;
   275			}
   276	
   277			if (!acpi_gbl_root_table_list.tables[i].pointer) {
   278				if ((acpi_gbl_root_table_list.tables[i].flags &
   279				     ACPI_TABLE_ORIGIN_MASK) ==
   280				    ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) {
   281					header =
   282					    acpi_os_map_memory(acpi_gbl_root_table_list.
   283							       tables[i].address,
   284							       sizeof(struct
   285								      acpi_table_header));
   286					if (!header) {
   287						return (AE_NO_MEMORY);
   288					}
   289	
   290					memcpy(out_table_header, header,
   291					       sizeof(struct acpi_table_header));
   292					acpi_os_unmap_memory(header,
   293							     sizeof(struct
   294								    acpi_table_header));
   295				} else {
   296					return (AE_NOT_FOUND);
   297				}
   298			} else {
   299				memcpy(out_table_header,
   300				       acpi_gbl_root_table_list.tables[i].pointer,
   301				       sizeof(struct acpi_table_header));
   302			}
   303			return (AE_OK);
   304		}
   305	
   306		return (AE_NOT_FOUND);
   307	}
   308	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index 010b1c43df92..881b0d5b2838 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -226,6 +226,9 @@  acpi_get_table_header(char *signature,
 	u32 j;
 	struct acpi_table_header *header;
 
+	if (acpi_disabled)
+		return (AE_ERROR);
+
 	/* Parameter validation */
 
 	if (!signature || !out_table_header) {