Commit graph

1649 commits

Author SHA1 Message Date
Richard Henderson ebacc7febd target/arm: Update sve reduction vs simd_desc
With the reduction operations, we intentionally increase maxsz to
the next power of 2, so as to fill out the reduction tree correctly.
Since e2e7168a214b, oprsz must equal maxsz, with exceptions for small
vectors, so this triggers an assertion for vector sizes > 32 that are
not themselves a power of 2.

Pass the power-of-two value in the simd_data field instead.

Backports c648c9b7e1ccff94b51ecbebe86a206952c47e75
2021-03-30 14:44:53 -04:00
Richard Henderson 1b05fd82b7 target/arm: Update WHILE for PREDDESC
Since b64ee454a4a0, all predicate operations should be
using these field macros for predicates.

Backports e610906c56f98c76888d45beb7f579935dd61a70
2021-03-30 14:42:40 -04:00
Richard Henderson c374bdc9ca target/arm: Update CNTP for PREDDESC
Since b64ee454a4a0, all predicate operations should be
using these field macros for predicates.

Backports f556a201b5bbeb59841b37247969fcfc1ab7bd5d
2021-03-30 14:41:01 -04:00
Richard Henderson 7e26827ea5 target/arm: Update BRKA, BRKB, BRKN for PREDDESC
Since b64ee454a4a0, all predicate operations should be
using these field macros for predicates.

Backports 04c774a25da78eb07d505ee5923167c2010b9f8c
2021-03-30 14:38:02 -04:00
Richard Henderson 452891c530 target/arm: Update find_last_active for PREDDESC
Since b64ee454a4a0, all predicate operations should be
using these field macros for predicates.

Backports 2acbfbe4313daf43b6653ee5d82bcaeaa155e895
2021-03-30 14:34:12 -04:00
Richard Henderson e7cec52fac target/arm: Fix sve_punpk_p vs odd vector lengths
Wrote too much with punpk1 with vl % 512 != 0.

Backports fd911a21414b5a17663fa2b97f1059fb11cee99d
2021-03-30 14:32:44 -04:00
Richard Henderson 78c016ef83 target/arm: Fix sve_zip_p vs odd vector lengths
Wrote too much with low-half zip (zip1) with vl % 512 != 0.

Adjust all of the x + (y << s) to x | (y << s) as a style fix.

We only ever have exact overlap between D, M, and N. Therefore
we only need a single temporary, and we do not need to check for
partial overlap.

Backports 8e7fefed1bdcc0f7e722ccf2a2fc2b4f79fe725e
2021-03-30 14:29:33 -04:00
Richard Henderson 1aed8cee64 target/arm: Fix sve_uzp_p vs odd vector lengths
Missed out on compressing the second half of a predicate
with length vl % 512 > 256.

Adjust all of the x + (y << s) to x | (y << s) as a
general style fix. Drop the extract64 because the input
uint64_t are known to be already zero-extended from the
current size of the predicate.

Backports 226e6c046c0fce8da32575aad020ca56a5a8064d
2021-03-30 14:27:58 -04:00
Stefan Hajnoczi 320b59ddb9 qemu/atomic.h: rename atomic_ to qatomic_
clang's C11 atomic_fetch_*() functions only take a C11 atomic type
pointer argument. QEMU uses direct types (int, etc) and this causes a
compiler error when a QEMU code calls these functions in a source file
that also included <stdatomic.h> via a system header file:

$ CC=clang CXX=clang++ ./configure ... && make
../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)

Avoid using atomic_*() names in QEMU's atomic.h since that namespace is
used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h
and <stdatomic.h> can co-exist. I checked /usr/include on my machine and
searched GitHub for existing "qatomic_" users but there seem to be none.

This patch was generated using:

$ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \
sort -u >/tmp/changed_identifiers
$ for identifier in $(</tmp/changed_identifiers); do
sed -i "s%\<$identifier\>%q$identifier%g" \
$(git grep -I -l "\<$identifier\>")
done

I manually fixed line-wrap issues and misaligned rST tables.

Backports d73415a315471ac0b127ed3fad45c8ec5d711de1
2021-03-08 14:34:35 -05:00
Philippe Mathieu-Daudé 798ce750d5 target/arm/cpu: Update coding style to make checkpatch.pl happy
Backports dddc200dcddd1a4e44c32e2b0f5a3cb248c506a6
2021-03-08 11:35:28 -05:00
Peter Collingbourne de7bcbae57 target/arm: Use TCF0 and TFSRE0 for unprivileged tag checks
Section D6.7 of the ARM ARM states:

For the purpose of determining Tag Check Fault handling, unprivileged
load and store instructions are treated as if executed at EL0 when
executed at either:
- EL1, when the Effective value of PSTATE.UAO is 0.
- EL2, when both the Effective value of HCR_EL2.{E2H, TGE} is {1, 1}
and the Effective value of PSTATE.UAO is 0.

ARM has confirmed a defect in the pseudocode function
AArch64.TagCheckFault that makes it inconsistent with the above
wording. The remedy is to adjust references to PSTATE.EL in that
function to instead refer to AArch64.AccessUsesEL(acctype), so
that unprivileged instructions use SCTLR_EL1.TCF0 and TFSRE0_EL1.
The exception type for synchronous tag check faults remains unchanged.

This patch implements the described change by partially reverting
commits 50244cc76abc and cc97b0019bb5.

Backports 2d928adf8a9148510e1b2041145b8a873f4d26df
2021-03-08 11:34:03 -05:00
Richard Henderson 03c8d3ff00 target/arm: Speed up aarch64 TBL/TBX
Always perform one call instead of two for 16-byte operands.
Use byte loads/stores directly into the vector register file
instead of extractions and deposits to a 64-bit local variable.

In order to easily receive pointers into the vector register file,
convert the helper to the gvec out-of-line signature. Move the
helper into vec_helper.c, where it can make use of H1 and clear_tail.

Backports 519183d3fee58e52f7b51cf146c9dc9edc565059
2021-03-08 11:31:24 -05:00
Rebecca Cran 2e508af5d5 target/arm: Set ID_PFR2.SSBS to 1 for max 32-bit CPU
Enable FEAT_SSBS for the "max" 32-bit CPU.

Backports ed84a60ca80c403749c1fc1bab27c85d8edba39d
2021-03-08 11:27:02 -05:00
Rebecca Cran 0f7620f7cc target/arm: Enable FEAT_SSBS for max AARCH64 CPU
Set ID_AA64PFR1_EL1.SSBS to 2 and ID_PFR2.SSBS to 1.

Backports 89455d1ba6ed190e840cb732e63958755ea42a07
2021-03-08 11:26:20 -05:00
Rebecca Cran 01105515c7 target/arm: Add support for FEAT_SSBS, Speculative Store Bypass Safe
Add support for FEAT_SSBS. SSBS (Speculative Store Bypass Safe) is an
optional feature in ARMv8.0, and mandatory in ARMv8.5.

Backports f2f68a78b793808b84367bc708d632969d4440aa
2021-03-08 11:23:50 -05:00
Richard Henderson d044062b26 target/arm: Enable MTE for user-only
Backports e32328645ed6fc4f20f0164dfc9ce1bf7e667cc4
2021-03-04 18:46:47 -05:00
Richard Henderson c588c150e4 target/arm: Add allocation tag storage for user mode
Use the now-saved PAGE_ANON and PAGE_MTE bits,
and the per-page saved data.

Backports a11d3830d96ad8077440ce4e0aa60608f1f12dde
2021-03-04 18:46:13 -05:00
Richard Henderson f03656b5c3 target/arm: Split out syndrome.h from internals.h
Move everything related to syndromes to a new file,
which can be shared with linux-user.

Backports 1fe27859427bd377a45708310947de54c687d9ff
2021-03-04 18:44:07 -05:00
Richard Henderson 84368d2d6d target/arm: Use the proper TBI settings for linux-user
We were fudging TBI1 enabled to speed up the generated code.
Now that we've improved the code generation, remove this.
Also, tidy the comment to reflect the current code.

The pauth test was testing a kernel address (-1) and making
incorrect assumptions about TBI1; stick to userland addresses.

Backports 16c849784873d10d0da257d698e391fddea1f0e4
2021-03-04 18:41:49 -05:00
Richard Henderson de982a8346 target/arm: Improve gen_top_byte_ignore
Use simple arithmetic instead of a conditional
move when tbi0 != tbi1.

Backports 2169b5c6f7a791ef9c43c72412efaafae3245114
2021-03-04 18:39:43 -05:00
Daniel Müller 642a683d7a target/arm: Correctly initialize MDCR_EL2.HPMN
When working with performance monitoring counters, we look at
MDCR_EL2.HPMN as part of the check whether a counter is enabled. This
check fails, because MDCR_EL2.HPMN is reset to 0, meaning that no
counters are "enabled" for < EL2.
That's in violation of the Arm specification, which states that

> On a Warm reset, this field [MDCR_EL2.HPMN] resets to the value in
> PMCR_EL0.N

That's also what a comment in the code acknowledges, but the necessary
adjustment seems to have been forgotten when support for more counters
was added.
This change fixes the issue by setting the reset value to PMCR.N, which
is four.

Backports d3c1183ffeb71ca3a783eae3d7e1c51e71e8a621
2021-03-04 18:34:06 -05:00
Rebecca Cran 93b0428f48 target/arm: Set ID_PFR0.DIT to 1 for max 32-bit CPU
Enable FEAT_DIT for the "max" 32-bit CPU.

Backports 5385320c2b3183f2e18dbc55c23ecba9272500c2
2021-03-04 18:31:36 -05:00
Rebecca Cran 66d96057a4 target/arm: Set ID_AA64PFR0.DIT and ID_PFR0.DIT to 1 for max AA64 CPU
Enable FEAT_DIT for the "max" AARCH64 CPU.

Backports 2bf1eff9e9125a3d73901991dcfb9cb2ace03be1
2021-03-04 18:30:59 -05:00
Rebecca Cran f7424d89e2 target/arm: Support AA32 DIT by moving PSTATE_SS from cpsr into env->pstate
cpsr has been treated as being the same as spsr, but it isn't.
Since PSTATE_SS isn't in cpsr, remove it and move it into env->pstate.

This allows us to add support for CPSR_DIT, adding helper functions
to merge SPSR_ELx to and from CPSR.

Backports f944a854ce4007000accf7c191b5b52916947198
2021-03-04 18:24:57 -05:00
Rebecca Cran d8458f14af target/arm: Add support for FEAT_DIT, Data Independent Timing
Add support for FEAT_DIT. DIT (Data Independent Timing) is a required
feature for ARMv8.4. Since virtual machine execution is largely
nondeterministic and TCG is outside of the security domain, it's
implemented as a NOP.

Backports dc8b18534ea1dcc90d80ad9a61a3b0aa7eb312fb
2021-03-04 18:19:32 -05:00
Mike Nawrocki 4e482764e2 target/arm: Fix SCR RES1 handling
The FW and AW bits of SCR_EL3 are RES1 only in some contexts. Force them
to 1 only when there is no support for AArch32 at EL1 or above.

The reset value will be 0x30 only if the CPU is AArch64-only; if there
is support for AArch32 at EL1 or above, it will be reset to 0.

Also adds helper function isar_feature_aa64_aa32_el1 to check if AArch32
is supported at EL1 or above.

Backports 10d0ef3e6cfe228df4b2d3e27325f1b0e2b71fd5
2021-03-04 18:15:39 -05:00
Claudio Fontana 18100d1a3b cpu: move debug_check_watchpoint to tcg_ops
commit 568496c0c0f1 ("cpu: Add callback to check architectural") and
commit 3826121d9298 ("target-arm: Implement checking of fired")
introduced an ARM-specific hack for cpu_check_watchpoint.

Make debug_check_watchpoint optional, and move it to tcg_ops.

Backports c73bdb35a91fb6b17c2c93b1ba381fc88a406f8d
2021-03-04 17:30:20 -05:00
Claudio Fontana 7b0c98c236 cpu: move adjust_watchpoint_address to tcg_ops
commit 40612000599e ("arm: Correctly handle watchpoints for BE32 CPUs")

introduced this ARM-specific, TCG-specific hack to adjust the address,
before checking it with cpu_check_watchpoint.

Make adjust_watchpoint_address optional and move it to tcg_ops.

Backports 9ea9087bb4a86893e4ac6ff643837937dc9e5849
2021-03-04 17:24:32 -05:00
Claudio Fontana ddfed5f3a6 cpu: move do_unaligned_access to tcg_ops
make it consistently SOFTMMU-only.

Backports 8535dd702dd054a37a85e0c7971cfb43cc7b50e3
2021-03-04 17:20:02 -05:00
Claudio Fontana ec08ac4995 cpu: move cc->transaction_failed to tcg_ops
Backports cbc183d2d9f5b8a33c2a6cf9cb242b04db1e8d5c
2021-03-04 17:16:41 -05:00
Claudio Fontana ee73443c7d cpu: move cc->do_interrupt to tcg_ops
Backports 0545608056a6161e7020cd7b9368d9636fa80051
2021-03-04 17:10:14 -05:00
Eduardo Habkost bc86f4377c cpu: Move debug_excp_handler to tcg_ops
Backports e9ce43e97a19090ae8975ef168b95ba3d29be991
2021-03-04 17:05:57 -05:00
Eduardo Habkost 76a10fa8e0 cpu: Move tlb_fill to tcg_ops
Backports e124536f37377cff5d68925d4976ad604d0ebf3a
2021-03-04 17:01:55 -05:00
Eduardo Habkost 03cc62e39c cpu: Move cpu_exec_* to tcg_ops
Backports 48c1a3e303b5a2cca48679645ad3fbb914db741a
2021-03-04 16:56:55 -05:00
Eduardo Habkost eb38ac1809 cpu: Move synchronize_from_tb() to tcg_ops
Backports ec62595bab1873c48a34849de70011093177e769
2021-03-04 16:48:27 -05:00
Eduardo Habkost b9b711afe3 cpu: Introduce TCGCpuOperations struct
The TCG-specific CPU methods will be moved to a separate struct,
to make it easier to move accel-specific code outside generic CPU
code in the future. Start by moving tcg_initialize().

The new CPUClass.tcg_opts field may eventually become a pointer,
but keep it an embedded struct for now, to make code conversion
easier.

Backports e9e51b7154404efc9af8735ab87c658a9c434cfd
2021-03-04 16:38:25 -05:00
Claudio Fontana 11ae599cb8 target/arm: do not use cc->do_interrupt for KVM directly
cc->do_interrupt is in theory a TCG callback used in accel/tcg only,
to prepare the emulated architecture to take an interrupt as defined
in the hardware specifications,

but in reality the _do_interrupt style of functions in targets are
also occasionally reused by KVM to prepare the architecture state in a
similar way where userspace code has identified that it needs to
deliver an exception to the guest.

In the case of ARM, that includes:

1) the vcpu thread got a SIGBUS indicating a memory error,
and we need to deliver a Synchronous External Abort to the guest to
let it know about the error.
2) the kernel told us about a debug exception (breakpoint, watchpoint)
but it is not for one of QEMU's own gdbstub breakpoints/watchpoints
so it must be a breakpoint the guest itself has set up, therefore
we need to deliver it to the guest.

So in order to reuse code, the same arm_do_interrupt function is used.
This is all fine, but we need to avoid calling it using the callback
registered in CPUClass, since that one is now TCG-only.

Fortunately this is easily solved by replacing calls to
CPUClass::do_interrupt() with explicit calls to arm_do_interrupt().

Backports 853bfef4e6d60244fd131ec55bbf1e7caa52599b. We don't support
KVM, so we just bring the comment addition over.
2021-03-04 16:33:23 -05:00
Philippe Mathieu-Daudé daafb0ba17 target/arm: Replace magic value by MMU_DATA_LOAD definition
cpu_get_phys_page_debug() uses 'DATA LOAD' MMU access type.

Backports a9dd161ff2f54446f0b0547447d8196699aca3e1
2021-03-04 15:43:47 -05:00
Richard Henderson 2c8f7b1fbc target/arm: Conditionalize DBGDIDR
Only define the register if it exists for the cpu.

Backports 54a78718be6dd5fc6b6201f84bef8de5ac3b3802
2021-03-04 15:42:03 -05:00
Richard Henderson 073923709f target/arm: Implement ID_PFR2
This was defined at some point before ARMv8.4, and will
shortly be used by new processor descriptions.

Backports 1d51bc96cc4a9b2d31a3f4cb8442ce47753088e2
2021-03-04 15:40:49 -05:00
Philippe Mathieu-Daudé d36a968f8e target/arm/m_helper: Silence GCC 10 maybe-uninitialized error
When building with GCC 10.2 configured with --extra-cflags=-Os, we get:

target/arm/m_helper.c: In function ‘arm_v7m_cpu_do_interrupt’:
target/arm/m_helper.c:1811:16: error: ‘restore_s16_s31’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
1811 | if (restore_s16_s31) {
| ^
target/arm/m_helper.c:1350:10: note: ‘restore_s16_s31’ was declared here
1350 | bool restore_s16_s31;
| ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Initialize the 'restore_s16_s31' variable to silence the warning.

Backports 0ae4f11ee57350dac0e705ba79516310400ff43c
2021-03-04 15:16:55 -05:00
Richard Henderson 0636518de4 target/arm: Update REV, PUNPK for pred_desc
Update all users of do_perm_pred2 for the new
predicate descriptor field definitions.

Backports 70acaafef2e053a312d54c09b6721c730690e72c
2021-03-04 15:15:47 -05:00
Richard Henderson eb315be37e target/arm: Update ZIP, UZP, TRN for pred_desc
Update all users of do_perm_pred3 for the new
predicate descriptor field definitions.

Backports f9b0fcceccfc05cde62ff7577fbf2bc13b842414
2021-03-04 15:15:10 -05:00
Richard Henderson fac4e416c9 target/arm: Update PFIRST, PNEXT for pred_desc
These two were odd, in that do_pfirst_pnext passed the
count of 64-bit words rather than bytes. Change to pass
the standard pred_full_reg_size to avoid confusion.

Backports 86300b5d044064046395ae8ed605cc19e63f2a7c
2021-03-04 15:09:47 -05:00
Richard Henderson 4ef4735cd3 target/arm: Introduce PREDDESC field definitions
SVE predicate operations cannot use the "usual" simd_desc
encoding, because the lengths are not a multiple of 8.
But we were abusing the SIMD_* fields to store values anyway.
This abuse broke when SIMD_OPRSZ_BITS was modified in e2e7168a214.

Introduce a new set of field definitions for exclusive use
of predicates, so that it is obvious what kind of predicate
we are manipulating. To be used in future patches

Backports b64ee454a4a086ed459bcda4c0bbb54e197841e4
2021-03-04 15:08:32 -05:00
Rémi Denis-Courmont 9dfa469976 target/arm: refactor vae1_tlbmask()
Backports bc944d3a8b305029196a5e1406702a92fa0b94cf
2021-03-04 15:05:54 -05:00
Rémi Denis-Courmont 8aeaff9385 target/arm: enable Secure EL2 in max CPU
Backports 24179fea7e34c4952d4878ae1b26108ba65e5933
2021-03-04 15:04:43 -05:00
Rémi Denis-Courmont e6d32dc2e0 target/arm: Implement SCR_EL2.EEL2
This adds handling for the SCR_EL3.EEL2 bit.

Backports 926c1b97895879b78ca14bca2831c08740ed1c38
2021-03-04 15:03:08 -05:00
Rémi Denis-Courmont 9690ed8236 target/arm: revector to run-time pick target EL
On ARMv8-A, accesses by 32-bit secure EL1 to monitor registers trap to
the upper (64-bit) EL. With Secure EL2 support, we can no longer assume
that that is always EL3, so make room for the value to be computed at
run-time.

Backports 6b340aeb48e4f7f983e1c38790de65ae93079840
2021-03-04 14:59:14 -05:00
Rémi Denis-Courmont ce8872709f target/arm: set HPFAR_EL2.NS on secure stage 2 faults
Backport 9861248f637ecf11113b04b0b5c7b13c9aa06f09
2021-03-04 14:54:33 -05:00