* [PATCH pciutils] libpci: Fix intel_cleanup_io() implementations
@ 2021-12-20 19:28 Pali Rohár
2021-12-26 22:04 ` Martin Mareš
0 siblings, 1 reply; 2+ messages in thread
From: Pali Rohár @ 2021-12-20 19:28 UTC (permalink / raw)
To: Martin Mares, Bjorn Helgaas, Krzysztof Wilczyński,
Matthew Wilcox, linux-pci
Function intel_cleanup_io() should de-initialize I/O port access, e.g. by
calling iopl(0) to reset I/O privilege level to default value.
Caller of intel_cleanup_io() expects that this function returns negative
value on success and positive value on error. Error means that I/O port
access was not de-initialized and is still active. Success means that I/O
port access is not active anymore and intel_setup_io() needs to be called
again to access I/O ports.
Fix Cygwin, Haiku and Linux implementations of intel_cleanup_io() function
to correctly de-initialize I/O port access and fix return value.
---
lib/i386-io-cygwin.h | 2 +-
lib/i386-io-haiku.h | 2 +-
lib/i386-io-linux.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/i386-io-cygwin.h b/lib/i386-io-cygwin.h
index 16022482f268..038b02d00a94 100644
--- a/lib/i386-io-cygwin.h
+++ b/lib/i386-io-cygwin.h
@@ -17,7 +17,7 @@ intel_setup_io(struct pci_access *a UNUSED)
static inline int
intel_cleanup_io(struct pci_access *a UNUSED)
{
- iopl(3);
+ iopl(0);
return -1;
}
diff --git a/lib/i386-io-haiku.h b/lib/i386-io-haiku.h
index 2bbe592672ab..5c724b34e98a 100644
--- a/lib/i386-io-haiku.h
+++ b/lib/i386-io-haiku.h
@@ -72,7 +72,7 @@ static inline int
intel_cleanup_io(struct pci_access *a UNUSED)
{
close(poke_driver_fd);
- return 1;
+ return -1;
}
static inline u8
diff --git a/lib/i386-io-linux.h b/lib/i386-io-linux.h
index b39b4eb8267d..619f8ec11695 100644
--- a/lib/i386-io-linux.h
+++ b/lib/i386-io-linux.h
@@ -17,7 +17,7 @@ intel_setup_io(struct pci_access *a UNUSED)
static inline int
intel_cleanup_io(struct pci_access *a UNUSED)
{
- iopl(3);
+ iopl(0);
return -1;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH pciutils] libpci: Fix intel_cleanup_io() implementations
2021-12-20 19:28 [PATCH pciutils] libpci: Fix intel_cleanup_io() implementations Pali Rohár
@ 2021-12-26 22:04 ` Martin Mareš
0 siblings, 0 replies; 2+ messages in thread
From: Martin Mareš @ 2021-12-26 22:04 UTC (permalink / raw)
To: Pali Rohár
Cc: Bjorn Helgaas, Krzysztof Wilczyński, Matthew Wilcox, linux-pci
Hi!
> Function intel_cleanup_io() should de-initialize I/O port access, e.g. by
> calling iopl(0) to reset I/O privilege level to default value.
>
> Caller of intel_cleanup_io() expects that this function returns negative
> value on success and positive value on error. Error means that I/O port
> access was not de-initialized and is still active. Success means that I/O
> port access is not active anymore and intel_setup_io() needs to be called
> again to access I/O ports.
>
> Fix Cygwin, Haiku and Linux implementations of intel_cleanup_io() function
> to correctly de-initialize I/O port access and fix return value.
Thanks for noticing the problem. I fixed it by removing the return value
of intel_cleanup_io() completely. In fact, only returning -1 made sense ever.
Martin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-26 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 19:28 [PATCH pciutils] libpci: Fix intel_cleanup_io() implementations Pali Rohár
2021-12-26 22:04 ` Martin Mareš
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.