xref: /OK3568_Linux_fs/kernel/Documentation/firmware-guide/acpi/apei/einj.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun====================
4*4882a593SmuzhiyunAPEI Error INJection
5*4882a593Smuzhiyun====================
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunEINJ provides a hardware error injection mechanism. It is very useful
8*4882a593Smuzhiyunfor debugging and testing APEI and RAS features in general.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunYou need to check whether your BIOS supports EINJ first. For that, look
11*4882a593Smuzhiyunfor early boot messages similar to this one::
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun  ACPI: EINJ 0x000000007370A000 000150 (v01 INTEL           00000001 INTL 00000001)
14*4882a593Smuzhiyun
15*4882a593Smuzhiyunwhich shows that the BIOS is exposing an EINJ table - it is the
16*4882a593Smuzhiyunmechanism through which the injection is done.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunAlternatively, look in /sys/firmware/acpi/tables for an "EINJ" file,
19*4882a593Smuzhiyunwhich is a different representation of the same thing.
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunIt doesn't necessarily mean that EINJ is not supported if those above
22*4882a593Smuzhiyundon't exist: before you give up, go into BIOS setup to see if the BIOS
23*4882a593Smuzhiyunhas an option to enable error injection. Look for something called WHEA
24*4882a593Smuzhiyunor similar. Often, you need to enable an ACPI5 support option prior, in
25*4882a593Smuzhiyunorder to see the APEI,EINJ,... functionality supported and exposed by
26*4882a593Smuzhiyunthe BIOS menu.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunTo use EINJ, make sure the following are options enabled in your kernel
29*4882a593Smuzhiyunconfiguration::
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun  CONFIG_DEBUG_FS
32*4882a593Smuzhiyun  CONFIG_ACPI_APEI
33*4882a593Smuzhiyun  CONFIG_ACPI_APEI_EINJ
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunThe EINJ user interface is in <debugfs mount point>/apei/einj.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunThe following files belong to it:
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun- available_error_type
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun  This file shows which error types are supported:
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun  ================  ===================================
44*4882a593Smuzhiyun  Error Type Value	Error Description
45*4882a593Smuzhiyun  ================  ===================================
46*4882a593Smuzhiyun  0x00000001        Processor Correctable
47*4882a593Smuzhiyun  0x00000002        Processor Uncorrectable non-fatal
48*4882a593Smuzhiyun  0x00000004        Processor Uncorrectable fatal
49*4882a593Smuzhiyun  0x00000008        Memory Correctable
50*4882a593Smuzhiyun  0x00000010        Memory Uncorrectable non-fatal
51*4882a593Smuzhiyun  0x00000020        Memory Uncorrectable fatal
52*4882a593Smuzhiyun  0x00000040        PCI Express Correctable
53*4882a593Smuzhiyun  0x00000080        PCI Express Uncorrectable fatal
54*4882a593Smuzhiyun  0x00000100        PCI Express Uncorrectable non-fatal
55*4882a593Smuzhiyun  0x00000200        Platform Correctable
56*4882a593Smuzhiyun  0x00000400        Platform Uncorrectable non-fatal
57*4882a593Smuzhiyun  0x00000800        Platform Uncorrectable fatal
58*4882a593Smuzhiyun  ================  ===================================
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun  The format of the file contents are as above, except present are only
61*4882a593Smuzhiyun  the available error types.
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun- error_type
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun  Set the value of the error type being injected. Possible error types
66*4882a593Smuzhiyun  are defined in the file available_error_type above.
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun- error_inject
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun  Write any integer to this file to trigger the error injection. Make
71*4882a593Smuzhiyun  sure you have specified all necessary error parameters, i.e. this
72*4882a593Smuzhiyun  write should be the last step when injecting errors.
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun- flags
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun  Present for kernel versions 3.13 and above. Used to specify which
77*4882a593Smuzhiyun  of param{1..4} are valid and should be used by the firmware during
78*4882a593Smuzhiyun  injection. Value is a bitmask as specified in ACPI5.0 spec for the
79*4882a593Smuzhiyun  SET_ERROR_TYPE_WITH_ADDRESS data structure:
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun    Bit 0
82*4882a593Smuzhiyun      Processor APIC field valid (see param3 below).
83*4882a593Smuzhiyun    Bit 1
84*4882a593Smuzhiyun      Memory address and mask valid (param1 and param2).
85*4882a593Smuzhiyun    Bit 2
86*4882a593Smuzhiyun      PCIe (seg,bus,dev,fn) valid (see param4 below).
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun  If set to zero, legacy behavior is mimicked where the type of
89*4882a593Smuzhiyun  injection specifies just one bit set, and param1 is multiplexed.
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun- param1
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun  This file is used to set the first error parameter value. Its effect
94*4882a593Smuzhiyun  depends on the error type specified in error_type. For example, if
95*4882a593Smuzhiyun  error type is memory related type, the param1 should be a valid
96*4882a593Smuzhiyun  physical memory address. [Unless "flag" is set - see above]
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun- param2
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun  Same use as param1 above. For example, if error type is of memory
101*4882a593Smuzhiyun  related type, then param2 should be a physical memory address mask.
102*4882a593Smuzhiyun  Linux requires page or narrower granularity, say, 0xfffffffffffff000.
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun- param3
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun  Used when the 0x1 bit is set in "flags" to specify the APIC id
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun- param4
109*4882a593Smuzhiyun  Used when the 0x4 bit is set in "flags" to specify target PCIe device
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun- notrigger
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun  The error injection mechanism is a two-step process. First inject the
114*4882a593Smuzhiyun  error, then perform some actions to trigger it. Setting "notrigger"
115*4882a593Smuzhiyun  to 1 skips the trigger phase, which *may* allow the user to cause the
116*4882a593Smuzhiyun  error in some other context by a simple access to the CPU, memory
117*4882a593Smuzhiyun  location, or device that is the target of the error injection. Whether
118*4882a593Smuzhiyun  this actually works depends on what operations the BIOS actually
119*4882a593Smuzhiyun  includes in the trigger phase.
120*4882a593Smuzhiyun
121*4882a593SmuzhiyunBIOS versions based on the ACPI 4.0 specification have limited options
122*4882a593Smuzhiyunin controlling where the errors are injected. Your BIOS may support an
123*4882a593Smuzhiyunextension (enabled with the param_extension=1 module parameter, or boot
124*4882a593Smuzhiyuncommand line einj.param_extension=1). This allows the address and mask
125*4882a593Smuzhiyunfor memory injections to be specified by the param1 and param2 files in
126*4882a593Smuzhiyunapei/einj.
127*4882a593Smuzhiyun
128*4882a593SmuzhiyunBIOS versions based on the ACPI 5.0 specification have more control over
129*4882a593Smuzhiyunthe target of the injection. For processor-related errors (type 0x1, 0x2
130*4882a593Smuzhiyunand 0x4), you can set flags to 0x3 (param3 for bit 0, and param1 and
131*4882a593Smuzhiyunparam2 for bit 1) so that you have more information added to the error
132*4882a593Smuzhiyunsignature being injected. The actual data passed is this::
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun	memory_address = param1;
135*4882a593Smuzhiyun	memory_address_range = param2;
136*4882a593Smuzhiyun	apicid = param3;
137*4882a593Smuzhiyun	pcie_sbdf = param4;
138*4882a593Smuzhiyun
139*4882a593SmuzhiyunFor memory errors (type 0x8, 0x10 and 0x20) the address is set using
140*4882a593Smuzhiyunparam1 with a mask in param2 (0x0 is equivalent to all ones). For PCI
141*4882a593Smuzhiyunexpress errors (type 0x40, 0x80 and 0x100) the segment, bus, device and
142*4882a593Smuzhiyunfunction are specified using param1::
143*4882a593Smuzhiyun
144*4882a593Smuzhiyun         31     24 23    16 15    11 10      8  7        0
145*4882a593Smuzhiyun	+-------------------------------------------------+
146*4882a593Smuzhiyun	| segment |   bus  | device | function | reserved |
147*4882a593Smuzhiyun	+-------------------------------------------------+
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunAnyway, you get the idea, if there's doubt just take a look at the code
150*4882a593Smuzhiyunin drivers/acpi/apei/einj.c.
151*4882a593Smuzhiyun
152*4882a593SmuzhiyunAn ACPI 5.0 BIOS may also allow vendor-specific errors to be injected.
153*4882a593SmuzhiyunIn this case a file named vendor will contain identifying information
154*4882a593Smuzhiyunfrom the BIOS that hopefully will allow an application wishing to use
155*4882a593Smuzhiyunthe vendor-specific extension to tell that they are running on a BIOS
156*4882a593Smuzhiyunthat supports it. All vendor extensions have the 0x80000000 bit set in
157*4882a593Smuzhiyunerror_type. A file vendor_flags controls the interpretation of param1
158*4882a593Smuzhiyunand param2 (1 = PROCESSOR, 2 = MEMORY, 4 = PCI). See your BIOS vendor
159*4882a593Smuzhiyundocumentation for details (and expect changes to this API if vendors
160*4882a593Smuzhiyuncreativity in using this feature expands beyond our expectations).
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun
163*4882a593SmuzhiyunAn error injection example::
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun  # cd /sys/kernel/debug/apei/einj
166*4882a593Smuzhiyun  # cat available_error_type		# See which errors can be injected
167*4882a593Smuzhiyun  0x00000002	Processor Uncorrectable non-fatal
168*4882a593Smuzhiyun  0x00000008	Memory Correctable
169*4882a593Smuzhiyun  0x00000010	Memory Uncorrectable non-fatal
170*4882a593Smuzhiyun  # echo 0x12345000 > param1		# Set memory address for injection
171*4882a593Smuzhiyun  # echo 0xfffffffffffff000 > param2		# Mask - anywhere in this page
172*4882a593Smuzhiyun  # echo 0x8 > error_type			# Choose correctable memory error
173*4882a593Smuzhiyun  # echo 1 > error_inject			# Inject now
174*4882a593Smuzhiyun
175*4882a593SmuzhiyunYou should see something like this in dmesg::
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun  [22715.830801] EDAC sbridge MC3: HANDLING MCE MEMORY ERROR
178*4882a593Smuzhiyun  [22715.834759] EDAC sbridge MC3: CPU 0: Machine Check Event: 0 Bank 7: 8c00004000010090
179*4882a593Smuzhiyun  [22715.834759] EDAC sbridge MC3: TSC 0
180*4882a593Smuzhiyun  [22715.834759] EDAC sbridge MC3: ADDR 12345000 EDAC sbridge MC3: MISC 144780c86
181*4882a593Smuzhiyun  [22715.834759] EDAC sbridge MC3: PROCESSOR 0:306e7 TIME 1422553404 SOCKET 0 APIC 0
182*4882a593Smuzhiyun  [22716.616173] EDAC MC3: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x12345 offset:0x0 grain:32 syndrome:0x0 -  area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0)
183*4882a593Smuzhiyun
184*4882a593SmuzhiyunFor more information about EINJ, please refer to ACPI specification
185*4882a593Smuzhiyunversion 4.0, section 17.5 and ACPI 5.0, section 18.6.
186