[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/26] target/arm/arm-semi: Don't let the guest close stdin/stdout
From: |
Peter Maydell |
Subject: |
[PULL 02/26] target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr |
Date: |
Thu, 30 Jan 2020 16:15:09 +0000 |
The guest can use the semihosting API to open a handle
corresponding to QEMU's own stdin, stdout, or stderr.
When the guest closes this handle, we should not
close the underlying host stdin/stdout/stderr
the way we would do if the handle corresponded to
a host fd we'd opened on behalf of the guest in SYS_OPEN.
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
---
target/arm/arm-semi.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
index 788fe61b51a..8718fd01948 100644
--- a/target/arm/arm-semi.c
+++ b/target/arm/arm-semi.c
@@ -403,6 +403,15 @@ static uint32_t host_closefn(ARMCPU *cpu, GuestFD *gf)
{
CPUARMState *env = &cpu->env;
+ /*
+ * Only close the underlying host fd if it's one we opened on behalf
+ * of the guest in SYS_OPEN.
+ */
+ if (gf->hostfd == STDIN_FILENO ||
+ gf->hostfd == STDOUT_FILENO ||
+ gf->hostfd == STDERR_FILENO) {
+ return 0;
+ }
return set_swi_errno(env, close(gf->hostfd));
}
--
2.20.1
- [PULL 00/26] target-arm queue, Peter Maydell, 2020/01/30
- [PULL 01/26] hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES, Peter Maydell, 2020/01/30
- [PULL 02/26] target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr,
Peter Maydell <=
- [PULL 04/26] hw/arm: ast2600: Wire up the eMMC controller, Peter Maydell, 2020/01/30
- [PULL 03/26] hw/sd: Configure number of slots exposed by the ASPEED SDHCI model, Peter Maydell, 2020/01/30
- [PULL 05/26] ftgmac100: check RX and TX buffer alignment, Peter Maydell, 2020/01/30
- [PULL 06/26] hw/arm/aspeed: add a 'execute-in-place' property to boot directly from CE0, Peter Maydell, 2020/01/30
- [PULL 07/26] misc/pca9552: Add qom set and get, Peter Maydell, 2020/01/30
- [PULL 09/26] add device_legacy_reset function to prepare for reset api change, Peter Maydell, 2020/01/30
- [PULL 08/26] hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus', Peter Maydell, 2020/01/30
- [PULL 10/26] hw/core/qdev: add trace events to help with resettable transition, Peter Maydell, 2020/01/30
- [PULL 12/26] hw/core: add Resettable support to BusClass and DeviceClass, Peter Maydell, 2020/01/30
- [PULL 14/26] hw/core/qdev: handle parent bus change regarding resettable, Peter Maydell, 2020/01/30