Skip to content

Commit 84b4328

Browse files
committed
ACPICA: Validate GPE blocks at init time
Some of the checks done by acpi_hw_read() and acpi_hw_write(), which are used for accessing GPE registers, are redundant in the specific case of GPE registers and the ones that are not redundant can be done upfront at the initialization time so as to fail the initialization if they are not passed instead of failing every access to the affected GPE registers going forward (including accesses from the SCI interrupt handler). Modify the GPE blocks initialization code accordingly. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent f75aef3 commit 84b4328

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

drivers/acpi/acpica/achware.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width);
7373

7474
acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
7575

76+
acpi_status acpi_hw_validate_io_block(u64 address, u32 bit_width, u32 count);
77+
7678
/*
7779
* hwgpe - GPE support
7880
*/

drivers/acpi/acpica/evgpeblk.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,23 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
317317
return_ACPI_STATUS(AE_OK);
318318
}
319319

320+
/* Validate the space_ID */
321+
322+
if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
323+
(space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
324+
ACPI_ERROR((AE_INFO,
325+
"Unsupported address space: 0x%X", space_id));
326+
return_ACPI_STATUS(AE_SUPPORT);
327+
}
328+
329+
if (space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
330+
status = acpi_hw_validate_io_block(address,
331+
ACPI_GPE_REGISTER_WIDTH,
332+
register_count);
333+
if (ACPI_FAILURE(status))
334+
return_ACPI_STATUS(status);
335+
}
336+
320337
/* Allocate a new GPE block */
321338

322339
gpe_block = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_block_info));

drivers/acpi/acpica/hwvalid.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,33 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width)
292292

293293
return (AE_OK);
294294
}
295+
296+
/******************************************************************************
297+
*
298+
* FUNCTION: acpi_hw_validate_io_block
299+
*
300+
* PARAMETERS: Address Address of I/O port/register blobk
301+
* bit_width Number of bits (8,16,32) in each register
302+
* count Number of registers in the block
303+
*
304+
* RETURN: Status
305+
*
306+
* DESCRIPTION: Validates a block of I/O ports/registers.
307+
*
308+
******************************************************************************/
309+
310+
acpi_status acpi_hw_validate_io_block(u64 address, u32 bit_width, u32 count)
311+
{
312+
acpi_status status;
313+
314+
while (count--) {
315+
status = acpi_hw_validate_io_request((acpi_io_address)address,
316+
bit_width);
317+
if (ACPI_FAILURE(status))
318+
return_ACPI_STATUS(status);
319+
320+
address += ACPI_DIV_8(bit_width);
321+
}
322+
323+
return_ACPI_STATUS(AE_OK);
324+
}

0 commit comments

Comments
 (0)