accel/tcg: Fix unaligned stores to s390x low-address-protected lowcore
commitb0f650f0477ae775e0915e3d60ab5110ad5e9157
authorIlya Leoshkevich <iii@linux.ibm.com>
Mon, 11 Jul 2022 18:56:38 +0000 (11 20:56 +0200)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 12 Jul 2022 05:13:33 +0000 (12 10:43 +0530)
treeae709274082e661508bfa4ea9879c702ba6b5d02
parentba8924113ca459d02ee67656a713f7ff494b968e
accel/tcg: Fix unaligned stores to s390x low-address-protected lowcore

If low-address-protection is active, unaligned stores to non-protected
parts of lowcore lead to protection exceptions. The reason is that in
such cases tlb_fill() call in store_helper_unaligned() covers
[0, addr + size) range, which contains the protected portion of
lowcore. This range is too large.

The most straightforward fix would be to make sure we stay within the
original [addr, addr + size) range. However, if an unaligned access
affects a single page, we don't need to call tlb_fill() in
store_helper_unaligned() at all, since it would be identical to
the previous tlb_fill() call in store_helper(), and therefore a no-op.
If an unaligned access covers multiple pages, this situation does not
occur.

Therefore simply skip TLB handling in store_helper_unaligned() if we
are dealing with a single page.

Fixes: 2bcf018340cb ("s390x/tcg: low-address protection support")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20220711185640.3558813-2-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
accel/tcg/cputlb.c