Skip to content
/ linux Public

Commit 61103a8

Browse files
Wer-WolfSasha Levin
authored andcommitted
ACPICA: Abort AML bytecode execution when executing AML_FATAL_OP
[ Upstream commit 026ad37 ] The ACPI specification states that when executing AML_FATAL_OP, the OS should log the fatal error event and shutdown in a timely fashion. Windows complies with this requirement by immediatly entering a Bso_d, effectively aborting the execution of the AML bytecode in question. ACPICA however might continue with the AML bytecode execution should acpi_os_signal() simply return AE_OK. This will cause issues because ACPI BIOS implementations might assume that the Fatal() operator does not return. Fix this by aborting the AML bytecode execution in such a case by returning AE_ERROR. Also turn struct acpi_signal_fatal_info into a local variable because of its small size (12 bytes) and to ensure that acpi_os_signal() always receives valid information about the fatal ACPI BIOS error. Link: acpica/acpica@d516c7758ba6 Signed-off-by: Armin Wolf <W_Armin@gmx.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3325491.5fSG56mABF@rafael.j.wysocki Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5e7c8b5 commit 61103a8

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

drivers/acpi/acpica/exoparg3.c

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <acpi/acpi.h>
1111
#include "accommon.h"
1212
#include "acinterp.h"
13+
#include <acpi/acoutput.h>
1314
#include "acparser.h"
1415
#include "amlcode.h"
1516

@@ -51,37 +52,31 @@ ACPI_MODULE_NAME("exoparg3")
5152
acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state)
5253
{
5354
union acpi_operand_object **operand = &walk_state->operands[0];
54-
struct acpi_signal_fatal_info *fatal;
55-
acpi_status status = AE_OK;
55+
struct acpi_signal_fatal_info fatal;
5656

5757
ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_0T_0R,
5858
acpi_ps_get_opcode_name(walk_state->opcode));
5959

6060
switch (walk_state->opcode) {
6161
case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */
6262

63-
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
64-
"FatalOp: Type %X Code %X Arg %X "
65-
"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
66-
(u32)operand[0]->integer.value,
67-
(u32)operand[1]->integer.value,
68-
(u32)operand[2]->integer.value));
69-
70-
fatal = ACPI_ALLOCATE(sizeof(struct acpi_signal_fatal_info));
71-
if (fatal) {
72-
fatal->type = (u32) operand[0]->integer.value;
73-
fatal->code = (u32) operand[1]->integer.value;
74-
fatal->argument = (u32) operand[2]->integer.value;
75-
}
63+
fatal.type = (u32)operand[0]->integer.value;
64+
fatal.code = (u32)operand[1]->integer.value;
65+
fatal.argument = (u32)operand[2]->integer.value;
7666

77-
/* Always signal the OS! */
67+
ACPI_BIOS_ERROR((AE_INFO,
68+
"Fatal ACPI BIOS error (Type 0x%X Code 0x%X Arg 0x%X)\n",
69+
fatal.type, fatal.code, fatal.argument));
7870

79-
status = acpi_os_signal(ACPI_SIGNAL_FATAL, fatal);
71+
/* Always signal the OS! */
8072

81-
/* Might return while OS is shutting down, just continue */
73+
acpi_os_signal(ACPI_SIGNAL_FATAL, &fatal);
8274

83-
ACPI_FREE(fatal);
84-
goto cleanup;
75+
/*
76+
* Might return while OS is shutting down, so abort the AML execution
77+
* by returning an error.
78+
*/
79+
return_ACPI_STATUS(AE_ERROR);
8580

8681
case AML_EXTERNAL_OP:
8782
/*
@@ -93,21 +88,16 @@ acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state)
9388
* wrong if an external opcode ever gets here.
9489
*/
9590
ACPI_ERROR((AE_INFO, "Executed External Op"));
96-
status = AE_OK;
97-
goto cleanup;
91+
92+
return_ACPI_STATUS(AE_OK);
9893

9994
default:
10095

10196
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
10297
walk_state->opcode));
10398

104-
status = AE_AML_BAD_OPCODE;
105-
goto cleanup;
99+
return_ACPI_STATUS(AE_AML_BAD_OPCODE);
106100
}
107-
108-
cleanup:
109-
110-
return_ACPI_STATUS(status);
111101
}
112102

113103
/*******************************************************************************

0 commit comments

Comments
 (0)