qemu/target/s390x
David Hildenbrand e19a61eb51 s390x/tcg: Store only the necessary amount of doublewords for STFLE
The PoP (z14, 7-382) says:
    Doublewords to the right of the doubleword in which the
    highest-numbered facility bit is assigned for a model
    may or may not be stored.

However, stack protection in certain binaries can't deal with that.
"gzip" example code:

f1b4:       a7 08 00 03             lhi     %r0,3
f1b8:       b2 b0 f0 a0             stfle   160(%r15)
f1bc:       e3 20 f0 b2 00 90       llgc    %r2,178(%r15)
f1c2:       c0 2b 00 00 00 01       nilf    %r2,1
f1c8:       b2 4f 00 10             ear     %r1,%a0
f1cc:       b9 14 00 22             lgfr    %r2,%r2
f1d0:       eb 11 00 20 00 0d       sllg    %r1,%r1,32
f1d6:       b2 4f 00 11             ear     %r1,%a1
f1da:       d5 07 f0 b8 10 28       clc     184(8,%r15),40(%r1)
f1e0:       a7 74 00 06             jne     f1ec <file_read@@Base+0x1bc>
f1e4:       eb ef f1 30 00 04       lmg     %r14,%r15,304(%r15)
f1ea:       07 fe                   br      %r14
f1ec:       c0 e5 ff ff 9d 6e       brasl   %r14,2cc8 <__stack_chk_fail@plt>

In QEMU, we currently have:
    max_bytes = 24
the code asks for (3 + 1) doublewords == 32 bytes.

If we write 32 bytes instead of only 24, and return "2 + 1" doublewords
("one less than the number of doulewords needed to contain all of the
 facility bits"), the example code detects a stack corruption.

In my opinion, the code is wrong. However, it seems to work fine on
real machines. So let's limit storing to the minimum of the requested
and the maximum doublewords.

Cc: Stefan Liebler <stli@linux.ibm.com>
Cc: Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
2019-06-07 14:53:25 +02:00
..
arch_dump.c s390x: Use uint64_t for vector registers 2019-06-07 14:53:25 +02:00
cc_helper.c s390x/tcg: Implement VECTOR COMPARE * 2019-05-17 10:54:13 +02:00
cpu_features_def.h s390x/cpumodel: add Deflate-conversion facility 2019-05-21 16:59:16 +02:00
cpu_features.c s390x/cpumodel: add Deflate-conversion facility 2019-05-21 16:59:16 +02:00
cpu_features.h s390x/cpumodel: add Deflate-conversion facility 2019-05-21 16:59:16 +02:00
cpu_models.c s390x/cpumodel: wire up 8561 and 8562 as gen15 machines 2019-05-21 16:59:16 +02:00
cpu_models.h s390x/cpumodel: default enable mepoch for z14 and later 2019-02-18 11:25:43 +01:00
cpu-qom.h target/s390x: change CPU type name to "s390x-cpu" 2017-10-30 08:56:28 +01:00
cpu.c target/s390x: Convert to CPUClass::tlb_fill 2019-05-10 11:12:50 -07:00
cpu.h s390x: Use uint64_t for vector registers 2019-06-07 14:53:25 +02:00
crypto_helper.c s390x/tcg: introduce and use s390_program_interrupt() 2017-12-14 17:56:54 +01:00
diag.c s390x: Return specification exception for unimplemented diag 308 subcodes 2019-01-18 11:52:00 +01:00
excp_helper.c s390x: Use uint64_t for vector registers 2019-06-07 14:53:25 +02:00
fpu_helper.c s390x/tcg: Handle all rounding modes overwritten by BFP instructions 2019-03-04 11:49:31 +01:00
gdbstub.c s390x: Use uint64_t for vector registers 2019-06-07 14:53:25 +02:00
gen-features.c s390x/cpumodel: add gen15 defintions 2019-05-21 16:59:16 +02:00
helper.c s390x: Use uint64_t for vector registers 2019-06-07 14:53:25 +02:00
helper.h s390x/tcg: Implement VECTOR STRING RANGE COMPARE 2019-06-07 14:53:25 +02:00
insn-data.def s390x/tcg: Implement VECTOR STRING RANGE COMPARE 2019-06-07 14:53:25 +02:00
insn-format.def s390x/tcg: Define vector instruction formats 2019-03-11 09:31:01 +01:00
int_helper.c target/s390x: Fix LGPL version in the file header comments 2019-01-30 11:04:02 +01:00
internal.h s390x/tcg: Implement VECTOR COMPARE * 2019-05-17 10:54:13 +02:00
interrupt.c s390x: move tcg_s390_program_interrupt() into TCG code and mark it noreturn 2018-10-04 10:32:39 +02:00
ioinst.c s390x: handle exceptions during s390_cpu_virt_mem_rw() correctly (TCG) 2017-12-14 17:56:54 +01:00
kvm_s390x.h s390x/kvm: Configure page size after memory has actually been initialized 2019-04-25 13:47:01 +02:00
kvm-stub.c s390x/kvm: Configure page size after memory has actually been initialized 2019-04-25 13:47:01 +02:00
kvm.c s390x: Use uint64_t for vector registers 2019-06-07 14:53:25 +02:00
machine.c s390x: Use uint64_t for vector registers 2019-06-07 14:53:25 +02:00
Makefile.objs s390x/tcg: Implement VECTOR FIND ANY ELEMENT EQUAL 2019-06-07 14:53:25 +02:00
mem_helper.c target/s390x: Convert to CPUClass::tlb_fill 2019-05-10 11:12:50 -07:00
misc_helper.c s390x/tcg: Store only the necessary amount of doublewords for STFLE 2019-06-07 14:53:25 +02:00
mmu_helper.c Make address_space_access_valid() take a MemTxAttrs argument 2018-05-31 16:32:35 +01:00
s390-tod.h target/s390x: Split out s390-tod.h 2019-02-18 11:25:43 +01:00
sigp.c Make address_space_access_valid() take a MemTxAttrs argument 2018-05-31 16:32:35 +01:00
tcg_s390x.h s390x/tcg: factor out and fix DATA exception injection 2018-10-04 10:32:39 +02:00
tcg-stub.c s390x/tcg: factor out and fix DATA exception injection 2018-10-04 10:32:39 +02:00
trace-events trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
translate_vx.inc.c s390x/tcg: Implement VECTOR STRING RANGE COMPARE 2019-06-07 14:53:25 +02:00
translate.c s390x: Use uint64_t for vector registers 2019-06-07 14:53:25 +02:00
vec_helper.c s390x/tcg: Implement VECTOR STORE WITH LENGTH 2019-03-11 09:31:01 +01:00
vec_int_helper.c s390x/tcg: Implement VECTOR TEST UNDER MASK 2019-05-17 10:54:13 +02:00
vec_string_helper.c s390x/tcg: Implement VECTOR STRING RANGE COMPARE 2019-06-07 14:53:25 +02:00
vec.h s390x/tcg: Implement VECTOR STRING RANGE COMPARE 2019-06-07 14:53:25 +02:00