File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed
Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -172,11 +172,31 @@ impl<T: ConfigRegionAccess> PciDevice<T> {
172172
173173 pub fn get_irq ( & self ) -> Option < InterruptLine > {
174174 let header = self . header ( ) ;
175- if let Some ( endpoint) = EndpointHeader :: from_header ( header, & self . access ) {
176- let ( _pin, line) = endpoint. interrupt ( & self . access ) ;
177- Some ( line)
178- } else {
179- None
175+ let endpoint = EndpointHeader :: from_header ( header, & self . access ) ?;
176+ let ( pin, line) = endpoint. interrupt ( & self . access ) ;
177+ // PCIe specification v5 section 7.5.1.1.13 (Interrupt Pin Register)
178+ match pin {
179+ 0 => {
180+ warn ! ( "The function uses no legacy interrupt message(s)." ) ;
181+ None
182+ }
183+ 1 ..=4 => {
184+ // PCI specification v3 footnote 43
185+ #[ cfg( target_arch = "x86_64" ) ]
186+ if matches ! ( line, 16 ..254 ) {
187+ error ! ( "Reserved IRQ number" ) ;
188+ return None ;
189+ } else if line == 255 {
190+ error ! ( "Unknown IRQ line or no connection to the interrupt controller" ) ;
191+ return None ;
192+ }
193+
194+ Some ( line)
195+ }
196+ 5 .. => {
197+ error ! ( "Reserved interrupt pin value returned." ) ;
198+ None
199+ }
180200 }
181201 }
182202
You can’t perform that action at this time.
0 commit comments