[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/29] target/i386/tcg: Fix masking of real-mode addresses with A2
From: |
Paolo Bonzini |
Subject: |
[PULL 01/29] target/i386/tcg: Fix masking of real-mode addresses with A20 bit |
Date: |
Mon, 6 Jun 2022 16:36:16 +0200 |
From: Stephen Michael Jothen <sjothen@gmail.com>
The correct A20 masking is done if paging is enabled (protected mode) but it
seems to have been forgotten in real mode. For example from the AMD64 APM Vol. 2
section 1.2.4:
> If the sum of the segment base and effective address carries over into bit 20,
> that bit can be optionally truncated to mimic the 20-bit address wrapping of
> the
> 8086 processor by using the A20M# input signal to mask the A20 address bit.
Most BIOSes will enable the A20 line on boot, but I found by disabling the A20
line
afterwards, the correct wrapping wasn't taking place.
`handle_mmu_fault' in target/i386/tcg/sysemu/excp_helper.c seems to be the
culprit.
In real mode, it fills the TLB with the raw unmasked address. However, for the
protected mode, the `mmu_translate' function does the correct A20 masking.
The fix then should be to just apply the A20 mask in the first branch of the if
statement.
Signed-off-by: Stephen Michael Jothen <sjothen@gmail.com>
Message-Id: <Yo5MUMSz80jXtvt9@air-old.local>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/tcg/sysemu/excp_helper.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/i386/tcg/sysemu/excp_helper.c
b/target/i386/tcg/sysemu/excp_helper.c
index e1b6d88683..48feba7e75 100644
--- a/target/i386/tcg/sysemu/excp_helper.c
+++ b/target/i386/tcg/sysemu/excp_helper.c
@@ -359,6 +359,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int
size,
CPUX86State *env = &cpu->env;
int error_code = PG_ERROR_OK;
int pg_mode, prot, page_size;
+ int32_t a20_mask;
hwaddr paddr;
hwaddr vaddr;
@@ -368,7 +369,8 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int
size,
#endif
if (!(env->cr[0] & CR0_PG_MASK)) {
- paddr = addr;
+ a20_mask = x86_get_a20_mask(env);
+ paddr = addr & a20_mask;
#ifdef TARGET_X86_64
if (!(env->hflags & HF_LMA_MASK)) {
/* Without long mode we can only address 32bits in real mode */
--
2.36.1
- [PULL 06/29] replay: fix event queue flush for qemu shutdown, (continued)
- [PULL 06/29] replay: fix event queue flush for qemu shutdown, Paolo Bonzini, 2022/06/06
- [PULL 10/29] docs: convert docs/devel/replay page to rst, Paolo Bonzini, 2022/06/06
- [PULL 13/29] tests/avocado: add replay Linux tests for virtio machine, Paolo Bonzini, 2022/06/06
- [PULL 14/29] tests/avocado: add replay Linux test for Aarch64 machines, Paolo Bonzini, 2022/06/06
- [PULL 03/29] target/i386: Fix wrong count setting, Paolo Bonzini, 2022/06/06
- [PULL 05/29] modules: generates per-target modinfo, Paolo Bonzini, 2022/06/06
- [PULL 04/29] modules: introduces module_kconfig directive, Paolo Bonzini, 2022/06/06
- [PULL 09/29] replay: simplify async event processing, Paolo Bonzini, 2022/06/06
- [PULL 17/29] x86: cpu: fixup number of addressable IDs for logical processors sharing cache, Paolo Bonzini, 2022/06/06
- [PULL 18/29] python: update for mypy 0.950, Paolo Bonzini, 2022/06/06
- [PULL 01/29] target/i386/tcg: Fix masking of real-mode addresses with A20 bit,
Paolo Bonzini <=
- [PULL 08/29] replay: rewrite async event handling, Paolo Bonzini, 2022/06/06
- [PULL 15/29] tests/Makefile.include: Fix 'make check-help' output, Paolo Bonzini, 2022/06/06
- [PULL 20/29] tests: use python3 as the python executable name, Paolo Bonzini, 2022/06/06
- [PULL 19/29] tests: add "TESTS_PYTHON" variable to Makefile, Paolo Bonzini, 2022/06/06
- [PULL 11/29] docs: move replay docs to docs/system/replay.rst, Paolo Bonzini, 2022/06/06
- [PULL 22/29] tests: add quiet-venv-pip macro, Paolo Bonzini, 2022/06/06
- [PULL 23/29] tests: install "qemu" namespace package into venv, Paolo Bonzini, 2022/06/06
- [PULL 24/29] tests: use tests/venv to run basevm.py-based scripts, Paolo Bonzini, 2022/06/06
- [PULL 26/29] tests: run 'device-crash-test' from tests/venv, Paolo Bonzini, 2022/06/06
- [PULL 21/29] tests: silence pip upgrade warnings during venv creation, Paolo Bonzini, 2022/06/06