target-arm queue:
* Enable read access to performance counters from EL0 * Enable SCTLR_EL1.BT0 for aarch64-linux-user * Refactoring of cpreg handling -----BEGIN PGP SIGNATURE----- iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmJzlJYZHHBldGVyLm1h eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3rQXEACqtWhESD9ZJ0T1DfiWh7HX KXZuvB5C4kEdY8KXPJsdFM47KGMB29AI1pfqN5oRvalGG40ROM1HNTO44LSjKgUr b+aEq0bcbOJQuhfc5EPoh3b9wekowxlBYsH3Zq251J6ua6dRd1iqdeGXFIZbn02x RY5lXB2wgWh8LnF+qwoLiIrqJWsJ8PSOolyl0LrKjI3Z22UboK1Y5K0sbJBlavX4 xKEyd4Af1Jq+1GcleSymAjcNF1iO+38w6rrFSgMWj+f3HSjKCk+MHU78rfqVNa88 ESRjBj1x3c8kRzNzy+Q8ntJ5QzREvFDpUYBC9lvnoLKQ6xRJWDvvZQw2YJGsH8sB Xgg8fQ75iYEQdN4SHLWn24OwZpKuzTZ4QYm0d02GiAZCGXgAFEIKG62lBd3UJTAy 6wTUdjuLv/KA+Lc3qdvmFfOVxfPh728VvFl55IoGXZv9FFrxvrluLEgr3TIje9W3 0r1FcjtAuuTHzKiaf8UsmvMW9nR550L1xQ+uMY8GKQvQgSvkf050srVZS05GFItH DqCUv++hsyi0b44J377cUKkAEOdH/rhV20pvvfoJthRgmHLNN5LG61JI9eK9JXzl +AYpbxAC3R6f0dp6/31D0ZRhW7wcC/rt1EVK/iACVKoGo8hZf3lC64y2+3TVoApF DdCadVNnR9eUFWh1inGXKQ== =Q7ra -----END PGP SIGNATURE----- Merge tag 'pull-target-arm-20220505' of https://git.linaro.org/people/pmaydell/qemu-arm into staging target-arm queue: * Enable read access to performance counters from EL0 * Enable SCTLR_EL1.BT0 for aarch64-linux-user * Refactoring of cpreg handling # -----BEGIN PGP SIGNATURE----- # # iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmJzlJYZHHBldGVyLm1h # eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3rQXEACqtWhESD9ZJ0T1DfiWh7HX # KXZuvB5C4kEdY8KXPJsdFM47KGMB29AI1pfqN5oRvalGG40ROM1HNTO44LSjKgUr # b+aEq0bcbOJQuhfc5EPoh3b9wekowxlBYsH3Zq251J6ua6dRd1iqdeGXFIZbn02x # RY5lXB2wgWh8LnF+qwoLiIrqJWsJ8PSOolyl0LrKjI3Z22UboK1Y5K0sbJBlavX4 # xKEyd4Af1Jq+1GcleSymAjcNF1iO+38w6rrFSgMWj+f3HSjKCk+MHU78rfqVNa88 # ESRjBj1x3c8kRzNzy+Q8ntJ5QzREvFDpUYBC9lvnoLKQ6xRJWDvvZQw2YJGsH8sB # Xgg8fQ75iYEQdN4SHLWn24OwZpKuzTZ4QYm0d02GiAZCGXgAFEIKG62lBd3UJTAy # 6wTUdjuLv/KA+Lc3qdvmFfOVxfPh728VvFl55IoGXZv9FFrxvrluLEgr3TIje9W3 # 0r1FcjtAuuTHzKiaf8UsmvMW9nR550L1xQ+uMY8GKQvQgSvkf050srVZS05GFItH # DqCUv++hsyi0b44J377cUKkAEOdH/rhV20pvvfoJthRgmHLNN5LG61JI9eK9JXzl # +AYpbxAC3R6f0dp6/31D0ZRhW7wcC/rt1EVK/iACVKoGo8hZf3lC64y2+3TVoApF # DdCadVNnR9eUFWh1inGXKQ== # =Q7ra # -----END PGP SIGNATURE----- # gpg: Signature made Thu 05 May 2022 04:10:46 AM CDT # gpg: using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE # gpg: issuer "peter.maydell@linaro.org" # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [full] # gpg: aka "Peter Maydell <pmaydell@gmail.com>" [full] # gpg: aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [full] * tag 'pull-target-arm-20220505' of https://git.linaro.org/people/pmaydell/qemu-arm: (23 commits) target/arm: read access to performance counters from EL0 target/arm: Add isar_feature_{aa64,any}_ras target/arm: Add isar predicates for FEAT_Debugv8p2 target/arm: Remove HOST_BIG_ENDIAN ifdef in add_cpreg_to_hashtable target/arm: Reformat comments in add_cpreg_to_hashtable target/arm: Perform override check early in add_cpreg_to_hashtable target/arm: Hoist isbanked computation in add_cpreg_to_hashtable target/arm: Use bool for is64 and ns in add_cpreg_to_hashtable target/arm: Consolidate cpreg updates in add_cpreg_to_hashtable target/arm: Hoist computation of key in add_cpreg_to_hashtable target/arm: Merge allocation of the cpreg and its name target/arm: Store cpregs key in the hash table directly target/arm: Drop always-true test in define_arm_vh_e2h_redirects_aliases target/arm: Name CPSecureState type target/arm: Name CPState type target/arm: Change cpreg access permissions to enum target/arm: Avoid bare abort() or assert(0) target/arm: Reorg ARMCPRegInfo type field bits target/arm: Make some more cpreg data static const target/arm: Replace sentinels with ARRAY_SIZE in cpregs.h ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
commit
e91b899411
@ -30,6 +30,7 @@
|
||||
#include "qemu/cutils.h"
|
||||
#include "qemu/log.h"
|
||||
#include "qom/object.h"
|
||||
#include "target/arm/cpregs.h"
|
||||
|
||||
static struct {
|
||||
hwaddr io_base;
|
||||
@ -383,7 +384,6 @@ static const ARMCPRegInfo pxa_cp_reginfo[] = {
|
||||
{ .name = "PWRMODE", .cp = 14, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 0,
|
||||
.access = PL1_RW, .type = ARM_CP_IO,
|
||||
.readfn = arm_cp_read_zero, .writefn = pxa2xx_pwrmode_write },
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static void pxa2xx_setup_cp14(PXA2xxState *s)
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "hw/sysbus.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "qom/object.h"
|
||||
#include "target/arm/cpregs.h"
|
||||
|
||||
#define ICIP 0x00 /* Interrupt Controller IRQ Pending register */
|
||||
#define ICMR 0x04 /* Interrupt Controller Mask register */
|
||||
@ -256,7 +257,6 @@ static const ARMCPRegInfo pxa_pic_cp_reginfo[] = {
|
||||
REGINFO_FOR_PIC_CP("ICLR2", 8),
|
||||
REGINFO_FOR_PIC_CP("ICFP2", 9),
|
||||
REGINFO_FOR_PIC_CP("ICPR2", 0xa),
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static const MemoryRegionOps pxa2xx_pic_ops = {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "gicv3_internal.h"
|
||||
#include "hw/irq.h"
|
||||
#include "cpu.h"
|
||||
#include "target/arm/cpregs.h"
|
||||
|
||||
/*
|
||||
* Special case return value from hppvi_index(); must be larger than
|
||||
@ -2427,7 +2428,6 @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = {
|
||||
.readfn = icc_igrpen1_el3_read,
|
||||
.writefn = icc_igrpen1_el3_write,
|
||||
},
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
|
||||
@ -2681,7 +2681,6 @@ static const ARMCPRegInfo gicv3_cpuif_hcr_reginfo[] = {
|
||||
.readfn = ich_vmcr_read,
|
||||
.writefn = ich_vmcr_write,
|
||||
},
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = {
|
||||
@ -2699,7 +2698,6 @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = {
|
||||
.readfn = ich_ap_read,
|
||||
.writefn = ich_ap_write,
|
||||
},
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = {
|
||||
@ -2731,7 +2729,6 @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = {
|
||||
.readfn = ich_ap_read,
|
||||
.writefn = ich_ap_write,
|
||||
},
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static void gicv3_cpuif_el_change_hook(ARMCPU *cpu, void *opaque)
|
||||
@ -2806,7 +2803,6 @@ void gicv3_init_cpuif(GICv3State *s)
|
||||
.readfn = ich_lr_read,
|
||||
.writefn = ich_lr_write,
|
||||
},
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
define_arm_cp_regs(cpu, lr_regset);
|
||||
}
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "vgic_common.h"
|
||||
#include "migration/blocker.h"
|
||||
#include "qom/object.h"
|
||||
#include "target/arm/cpregs.h"
|
||||
|
||||
|
||||
#ifdef DEBUG_GICV3_KVM
|
||||
#define DPRINTF(fmt, ...) \
|
||||
@ -733,7 +735,6 @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = {
|
||||
*/
|
||||
.resetfn = arm_gicv3_icc_reset,
|
||||
},
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
/**
|
||||
|
453
target/arm/cpregs.h
Normal file
453
target/arm/cpregs.h
Normal file
@ -0,0 +1,453 @@
|
||||
/*
|
||||
* QEMU ARM CP Register access and descriptions
|
||||
*
|
||||
* Copyright (c) 2022 Linaro Ltd
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see
|
||||
* <http://www.gnu.org/licenses/gpl-2.0.html>
|
||||
*/
|
||||
|
||||
#ifndef TARGET_ARM_CPREGS_H
|
||||
#define TARGET_ARM_CPREGS_H
|
||||
|
||||
/*
|
||||
* ARMCPRegInfo type field bits:
|
||||
*/
|
||||
enum {
|
||||
/*
|
||||
* Register must be handled specially during translation.
|
||||
* The method is one of the values below:
|
||||
*/
|
||||
ARM_CP_SPECIAL_MASK = 0x000f,
|
||||
/* Special: no change to PE state: writes ignored, reads ignored. */
|
||||
ARM_CP_NOP = 0x0001,
|
||||
/* Special: sysreg is WFI, for v5 and v6. */
|
||||
ARM_CP_WFI = 0x0002,
|
||||
/* Special: sysreg is NZCV. */
|
||||
ARM_CP_NZCV = 0x0003,
|
||||
/* Special: sysreg is CURRENTEL. */
|
||||
ARM_CP_CURRENTEL = 0x0004,
|
||||
/* Special: sysreg is DC ZVA or similar. */
|
||||
ARM_CP_DC_ZVA = 0x0005,
|
||||
ARM_CP_DC_GVA = 0x0006,
|
||||
ARM_CP_DC_GZVA = 0x0007,
|
||||
|
||||
/* Flag: reads produce resetvalue; writes ignored. */
|
||||
ARM_CP_CONST = 1 << 4,
|
||||
/* Flag: For ARM_CP_STATE_AA32, sysreg is 64-bit. */
|
||||
ARM_CP_64BIT = 1 << 5,
|
||||
/*
|
||||
* Flag: TB should not be ended after a write to this register
|
||||
* (the default is that the TB ends after cp writes).
|
||||
*/
|
||||
ARM_CP_SUPPRESS_TB_END = 1 << 6,
|
||||
/*
|
||||
* Flag: Permit a register definition to override a previous definition
|
||||
* for the same (cp, is64, crn, crm, opc1, opc2) tuple: either the new
|
||||
* or the old must have the ARM_CP_OVERRIDE bit set.
|
||||
*/
|
||||
ARM_CP_OVERRIDE = 1 << 7,
|
||||
/*
|
||||
* Flag: Register is an alias view of some underlying state which is also
|
||||
* visible via another register, and that the other register is handling
|
||||
* migration and reset; registers marked ARM_CP_ALIAS will not be migrated
|
||||
* but may have their state set by syncing of register state from KVM.
|
||||
*/
|
||||
ARM_CP_ALIAS = 1 << 8,
|
||||
/*
|
||||
* Flag: Register does I/O and therefore its accesses need to be marked
|
||||
* with gen_io_start() and also end the TB. In particular, registers which
|
||||
* implement clocks or timers require this.
|
||||
*/
|
||||
ARM_CP_IO = 1 << 9,
|
||||
/*
|
||||
* Flag: Register has no underlying state and does not support raw access
|
||||
* for state saving/loading; it will not be used for either migration or
|
||||
* KVM state synchronization. Typically this is for "registers" which are
|
||||
* actually used as instructions for cache maintenance and so on.
|
||||
*/
|
||||
ARM_CP_NO_RAW = 1 << 10,
|
||||
/*
|
||||
* Flag: The read or write hook might raise an exception; the generated
|
||||
* code will synchronize the CPU state before calling the hook so that it
|
||||
* is safe for the hook to call raise_exception().
|
||||
*/
|
||||
ARM_CP_RAISES_EXC = 1 << 11,
|
||||
/*
|
||||
* Flag: Writes to the sysreg might change the exception level - typically
|
||||
* on older ARM chips. For those cases we need to re-read the new el when
|
||||
* recomputing the translation flags.
|
||||
*/
|
||||
ARM_CP_NEWEL = 1 << 12,
|
||||
/*
|
||||
* Flag: Access check for this sysreg is identical to accessing FPU state
|
||||
* from an instruction: use translation fp_access_check().
|
||||
*/
|
||||
ARM_CP_FPU = 1 << 13,
|
||||
/*
|
||||
* Flag: Access check for this sysreg is identical to accessing SVE state
|
||||
* from an instruction: use translation sve_access_check().
|
||||
*/
|
||||
ARM_CP_SVE = 1 << 14,
|
||||
/* Flag: Do not expose in gdb sysreg xml. */
|
||||
ARM_CP_NO_GDB = 1 << 15,
|
||||
};
|
||||
|
||||
/*
|
||||
* Valid values for ARMCPRegInfo state field, indicating which of
|
||||
* the AArch32 and AArch64 execution states this register is visible in.
|
||||
* If the reginfo doesn't explicitly specify then it is AArch32 only.
|
||||
* If the reginfo is declared to be visible in both states then a second
|
||||
* reginfo is synthesised for the AArch32 view of the AArch64 register,
|
||||
* such that the AArch32 view is the lower 32 bits of the AArch64 one.
|
||||
* Note that we rely on the values of these enums as we iterate through
|
||||
* the various states in some places.
|
||||
*/
|
||||
typedef enum {
|
||||
ARM_CP_STATE_AA32 = 0,
|
||||
ARM_CP_STATE_AA64 = 1,
|
||||
ARM_CP_STATE_BOTH = 2,
|
||||
} CPState;
|
||||
|
||||
/*
|
||||
* ARM CP register secure state flags. These flags identify security state
|
||||
* attributes for a given CP register entry.
|
||||
* The existence of both or neither secure and non-secure flags indicates that
|
||||
* the register has both a secure and non-secure hash entry. A single one of
|
||||
* these flags causes the register to only be hashed for the specified
|
||||
* security state.
|
||||
* Although definitions may have any combination of the S/NS bits, each
|
||||
* registered entry will only have one to identify whether the entry is secure
|
||||
* or non-secure.
|
||||
*/
|
||||
typedef enum {
|
||||
ARM_CP_SECSTATE_BOTH = 0, /* define one cpreg for each secstate */
|
||||
ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */
|
||||
ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */
|
||||
} CPSecureState;
|
||||
|
||||
/*
|
||||
* Access rights:
|
||||
* We define bits for Read and Write access for what rev C of the v7-AR ARM ARM
|
||||
* defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and
|
||||
* PL2 (hyp). The other level which has Read and Write bits is Secure PL1
|
||||
* (ie any of the privileged modes in Secure state, or Monitor mode).
|
||||
* If a register is accessible in one privilege level it's always accessible
|
||||
* in higher privilege levels too. Since "Secure PL1" also follows this rule
|
||||
* (ie anything visible in PL2 is visible in S-PL1, some things are only
|
||||
* visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the
|
||||
* terminology a little and call this PL3.
|
||||
* In AArch64 things are somewhat simpler as the PLx bits line up exactly
|
||||
* with the ELx exception levels.
|
||||
*
|
||||
* If access permissions for a register are more complex than can be
|
||||
* described with these bits, then use a laxer set of restrictions, and
|
||||
* do the more restrictive/complex check inside a helper function.
|
||||
*/
|
||||
typedef enum {
|
||||
PL3_R = 0x80,
|
||||
PL3_W = 0x40,
|
||||
PL2_R = 0x20 | PL3_R,
|
||||
PL2_W = 0x10 | PL3_W,
|
||||
PL1_R = 0x08 | PL2_R,
|
||||
PL1_W = 0x04 | PL2_W,
|
||||
PL0_R = 0x02 | PL1_R,
|
||||
PL0_W = 0x01 | PL1_W,
|
||||
|
||||
/*
|
||||
* For user-mode some registers are accessible to EL0 via a kernel
|
||||
* trap-and-emulate ABI. In this case we define the read permissions
|
||||
* as actually being PL0_R. However some bits of any given register
|
||||
* may still be masked.
|
||||
*/
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
PL0U_R = PL0_R,
|
||||
#else
|
||||
PL0U_R = PL1_R,
|
||||
#endif
|
||||
|
||||
PL3_RW = PL3_R | PL3_W,
|
||||
PL2_RW = PL2_R | PL2_W,
|
||||
PL1_RW = PL1_R | PL1_W,
|
||||
PL0_RW = PL0_R | PL0_W,
|
||||
} CPAccessRights;
|
||||
|
||||
typedef enum CPAccessResult {
|
||||
/* Access is permitted */
|
||||
CP_ACCESS_OK = 0,
|
||||
|
||||
/*
|
||||
* Combined with one of the following, the low 2 bits indicate the
|
||||
* target exception level. If 0, the exception is taken to the usual
|
||||
* target EL (EL1 or PL1 if in EL0, otherwise to the current EL).
|
||||
*/
|
||||
CP_ACCESS_EL_MASK = 3,
|
||||
|
||||
/*
|
||||
* Access fails due to a configurable trap or enable which would
|
||||
* result in a categorized exception syndrome giving information about
|
||||
* the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6,
|
||||
* 0xc or 0x18).
|
||||
*/
|
||||
CP_ACCESS_TRAP = (1 << 2),
|
||||
CP_ACCESS_TRAP_EL2 = CP_ACCESS_TRAP | 2,
|
||||
CP_ACCESS_TRAP_EL3 = CP_ACCESS_TRAP | 3,
|
||||
|
||||
/*
|
||||
* Access fails and results in an exception syndrome 0x0 ("uncategorized").
|
||||
* Note that this is not a catch-all case -- the set of cases which may
|
||||
* result in this failure is specifically defined by the architecture.
|
||||
*/
|
||||
CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2),
|
||||
CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = CP_ACCESS_TRAP_UNCATEGORIZED | 2,
|
||||
CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = CP_ACCESS_TRAP_UNCATEGORIZED | 3,
|
||||
} CPAccessResult;
|
||||
|
||||
typedef struct ARMCPRegInfo ARMCPRegInfo;
|
||||
|
||||
/*
|
||||
* Access functions for coprocessor registers. These cannot fail and
|
||||
* may not raise exceptions.
|
||||
*/
|
||||
typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque);
|
||||
typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque,
|
||||
uint64_t value);
|
||||
/* Access permission check functions for coprocessor registers. */
|
||||
typedef CPAccessResult CPAccessFn(CPUARMState *env,
|
||||
const ARMCPRegInfo *opaque,
|
||||
bool isread);
|
||||
/* Hook function for register reset */
|
||||
typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque);
|
||||
|
||||
#define CP_ANY 0xff
|
||||
|
||||
/* Definition of an ARM coprocessor register */
|
||||
struct ARMCPRegInfo {
|
||||
/* Name of register (useful mainly for debugging, need not be unique) */
|
||||
const char *name;
|
||||
/*
|
||||
* Location of register: coprocessor number and (crn,crm,opc1,opc2)
|
||||
* tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a
|
||||
* 'wildcard' field -- any value of that field in the MRC/MCR insn
|
||||
* will be decoded to this register. The register read and write
|
||||
* callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2
|
||||
* used by the program, so it is possible to register a wildcard and
|
||||
* then behave differently on read/write if necessary.
|
||||
* For 64 bit registers, only crm and opc1 are relevant; crn and opc2
|
||||
* must both be zero.
|
||||
* For AArch64-visible registers, opc0 is also used.
|
||||
* Since there are no "coprocessors" in AArch64, cp is purely used as a
|
||||
* way to distinguish (for KVM's benefit) guest-visible system registers
|
||||
* from demuxed ones provided to preserve the "no side effects on
|
||||
* KVM register read/write from QEMU" semantics. cp==0x13 is guest
|
||||
* visible (to match KVM's encoding); cp==0 will be converted to
|
||||
* cp==0x13 when the ARMCPRegInfo is registered, for convenience.
|
||||
*/
|
||||
uint8_t cp;
|
||||
uint8_t crn;
|
||||
uint8_t crm;
|
||||
uint8_t opc0;
|
||||
uint8_t opc1;
|
||||
uint8_t opc2;
|
||||
/* Execution state in which this register is visible: ARM_CP_STATE_* */
|
||||
CPState state;
|
||||
/* Register type: ARM_CP_* bits/values */
|
||||
int type;
|
||||
/* Access rights: PL*_[RW] */
|
||||
CPAccessRights access;
|
||||
/* Security state: ARM_CP_SECSTATE_* bits/values */
|
||||
CPSecureState secure;
|
||||
/*
|
||||
* The opaque pointer passed to define_arm_cp_regs_with_opaque() when
|
||||
* this register was defined: can be used to hand data through to the
|
||||
* register read/write functions, since they are passed the ARMCPRegInfo*.
|
||||
*/
|
||||
void *opaque;
|
||||
/*
|
||||
* Value of this register, if it is ARM_CP_CONST. Otherwise, if
|
||||
* fieldoffset is non-zero, the reset value of the register.
|
||||
*/
|
||||
uint64_t resetvalue;
|
||||
/*
|
||||
* Offset of the field in CPUARMState for this register.
|
||||
* This is not needed if either:
|
||||
* 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs
|
||||
* 2. both readfn and writefn are specified
|
||||
*/
|
||||
ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */
|
||||
|
||||
/*
|
||||
* Offsets of the secure and non-secure fields in CPUARMState for the
|
||||
* register if it is banked. These fields are only used during the static
|
||||
* registration of a register. During hashing the bank associated
|
||||
* with a given security state is copied to fieldoffset which is used from
|
||||
* there on out.
|
||||
*
|
||||
* It is expected that register definitions use either fieldoffset or
|
||||
* bank_fieldoffsets in the definition but not both. It is also expected
|
||||
* that both bank offsets are set when defining a banked register. This
|
||||
* use indicates that a register is banked.
|
||||
*/
|
||||
ptrdiff_t bank_fieldoffsets[2];
|
||||
|
||||
/*
|
||||
* Function for making any access checks for this register in addition to
|
||||
* those specified by the 'access' permissions bits. If NULL, no extra
|
||||
* checks required. The access check is performed at runtime, not at
|
||||
* translate time.
|
||||
*/
|
||||
CPAccessFn *accessfn;
|
||||
/*
|
||||
* Function for handling reads of this register. If NULL, then reads
|
||||
* will be done by loading from the offset into CPUARMState specified
|
||||
* by fieldoffset.
|
||||
*/
|
||||
CPReadFn *readfn;
|
||||
/*
|
||||
* Function for handling writes of this register. If NULL, then writes
|
||||
* will be done by writing to the offset into CPUARMState specified
|
||||
* by fieldoffset.
|
||||
*/
|
||||
CPWriteFn *writefn;
|
||||
/*
|
||||
* Function for doing a "raw" read; used when we need to copy
|
||||
* coprocessor state to the kernel for KVM or out for
|
||||
* migration. This only needs to be provided if there is also a
|
||||
* readfn and it has side effects (for instance clear-on-read bits).
|
||||
*/
|
||||
CPReadFn *raw_readfn;
|
||||
/*
|
||||
* Function for doing a "raw" write; used when we need to copy KVM
|
||||
* kernel coprocessor state into userspace, or for inbound
|
||||
* migration. This only needs to be provided if there is also a
|
||||
* writefn and it masks out "unwritable" bits or has write-one-to-clear
|
||||
* or similar behaviour.
|
||||
*/
|
||||
CPWriteFn *raw_writefn;
|
||||
/*
|
||||
* Function for resetting the register. If NULL, then reset will be done
|
||||
* by writing resetvalue to the field specified in fieldoffset. If
|
||||
* fieldoffset is 0 then no reset will be done.
|
||||
*/
|
||||
CPResetFn *resetfn;
|
||||
|
||||
/*
|
||||
* "Original" writefn and readfn.
|
||||
* For ARMv8.1-VHE register aliases, we overwrite the read/write
|
||||
* accessor functions of various EL1/EL0 to perform the runtime
|
||||
* check for which sysreg should actually be modified, and then
|
||||
* forwards the operation. Before overwriting the accessors,
|
||||
* the original function is copied here, so that accesses that
|
||||
* really do go to the EL1/EL0 version proceed normally.
|
||||
* (The corresponding EL2 register is linked via opaque.)
|
||||
*/
|
||||
CPReadFn *orig_readfn;
|
||||
CPWriteFn *orig_writefn;
|
||||
};
|
||||
|
||||
/*
|
||||
* Macros which are lvalues for the field in CPUARMState for the
|
||||
* ARMCPRegInfo *ri.
|
||||
*/
|
||||
#define CPREG_FIELD32(env, ri) \
|
||||
(*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
|
||||
#define CPREG_FIELD64(env, ri) \
|
||||
(*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
|
||||
|
||||
void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *reg,
|
||||
void *opaque);
|
||||
|
||||
static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs)
|
||||
{
|
||||
define_one_arm_cp_reg_with_opaque(cpu, regs, NULL);
|
||||
}
|
||||
|
||||
void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs,
|
||||
void *opaque, size_t len);
|
||||
|
||||
#define define_arm_cp_regs_with_opaque(CPU, REGS, OPAQUE) \
|
||||
do { \
|
||||
QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \
|
||||
define_arm_cp_regs_with_opaque_len(CPU, REGS, OPAQUE, \
|
||||
ARRAY_SIZE(REGS)); \
|
||||
} while (0)
|
||||
|
||||
#define define_arm_cp_regs(CPU, REGS) \
|
||||
define_arm_cp_regs_with_opaque(CPU, REGS, NULL)
|
||||
|
||||
const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp);
|
||||
|
||||
/*
|
||||
* Definition of an ARM co-processor register as viewed from
|
||||
* userspace. This is used for presenting sanitised versions of
|
||||
* registers to userspace when emulating the Linux AArch64 CPU
|
||||
* ID/feature ABI (advertised as HWCAP_CPUID).
|
||||
*/
|
||||
typedef struct ARMCPRegUserSpaceInfo {
|
||||
/* Name of register */
|
||||
const char *name;
|
||||
|
||||
/* Is the name actually a glob pattern */
|
||||
bool is_glob;
|
||||
|
||||
/* Only some bits are exported to user space */
|
||||
uint64_t exported_bits;
|
||||
|
||||
/* Fixed bits are applied after the mask */
|
||||
uint64_t fixed_bits;
|
||||
} ARMCPRegUserSpaceInfo;
|
||||
|
||||
void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len,
|
||||
const ARMCPRegUserSpaceInfo *mods,
|
||||
size_t mods_len);
|
||||
|
||||
#define modify_arm_cp_regs(REGS, MODS) \
|
||||
do { \
|
||||
QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \
|
||||
QEMU_BUILD_BUG_ON(ARRAY_SIZE(MODS) == 0); \
|
||||
modify_arm_cp_regs_with_len(REGS, ARRAY_SIZE(REGS), \
|
||||
MODS, ARRAY_SIZE(MODS)); \
|
||||
} while (0)
|
||||
|
||||
/* CPWriteFn that can be used to implement writes-ignored behaviour */
|
||||
void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
uint64_t value);
|
||||
/* CPReadFn that can be used for read-as-zero behaviour */
|
||||
uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri);
|
||||
|
||||
/*
|
||||
* CPResetFn that does nothing, for use if no reset is required even
|
||||
* if fieldoffset is non zero.
|
||||
*/
|
||||
void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque);
|
||||
|
||||
/*
|
||||
* Return true if this reginfo struct's field in the cpu state struct
|
||||
* is 64 bits wide.
|
||||
*/
|
||||
static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri)
|
||||
{
|
||||
return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT);
|
||||
}
|
||||
|
||||
static inline bool cp_access_ok(int current_el,
|
||||
const ARMCPRegInfo *ri, int isread)
|
||||
{
|
||||
return (ri->access >> ((current_el * 2) + isread)) & 1;
|
||||
}
|
||||
|
||||
/* Raw read of a coprocessor register (as needed for migration, etc) */
|
||||
uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri);
|
||||
|
||||
#endif /* TARGET_ARM_CPREGS_H */
|
@ -43,6 +43,7 @@
|
||||
#include "kvm_arm.h"
|
||||
#include "disas/capstone.h"
|
||||
#include "fpu/softfloat.h"
|
||||
#include "cpregs.h"
|
||||
|
||||
static void arm_cpu_set_pc(CPUState *cs, vaddr value)
|
||||
{
|
||||
@ -116,7 +117,7 @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
|
||||
ARMCPRegInfo *ri = value;
|
||||
ARMCPU *cpu = opaque;
|
||||
|
||||
if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS)) {
|
||||
if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -152,7 +153,7 @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque)
|
||||
ARMCPU *cpu = opaque;
|
||||
uint64_t oldvalue, newvalue;
|
||||
|
||||
if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS | ARM_CP_NO_RAW)) {
|
||||
if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS | ARM_CP_NO_RAW)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -197,6 +198,8 @@ static void arm_cpu_reset(DeviceState *dev)
|
||||
/* Enable all PAC keys. */
|
||||
env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB |
|
||||
SCTLR_EnDA | SCTLR_EnDB);
|
||||
/* Trap on btype=3 for PACIxSP. */
|
||||
env->cp15.sctlr_el[1] |= SCTLR_BT0;
|
||||
/* and to the FP/Neon instructions */
|
||||
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3);
|
||||
/* and to the SVE instructions */
|
||||
@ -1068,27 +1071,13 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz)
|
||||
return (Aff1 << ARM_AFF1_SHIFT) | Aff0;
|
||||
}
|
||||
|
||||
static void cpreg_hashtable_data_destroy(gpointer data)
|
||||
{
|
||||
/*
|
||||
* Destroy function for cpu->cp_regs hashtable data entries.
|
||||
* We must free the name string because it was g_strdup()ed in
|
||||
* add_cpreg_to_hashtable(). It's OK to cast away the 'const'
|
||||
* from r->name because we know we definitely allocated it.
|
||||
*/
|
||||
ARMCPRegInfo *r = data;
|
||||
|
||||
g_free((void *)r->name);
|
||||
g_free(r);
|
||||
}
|
||||
|
||||
static void arm_cpu_initfn(Object *obj)
|
||||
{
|
||||
ARMCPU *cpu = ARM_CPU(obj);
|
||||
|
||||
cpu_set_cpustate_pointers(cpu);
|
||||
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
|
||||
g_free, cpreg_hashtable_data_destroy);
|
||||
cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal,
|
||||
NULL, g_free);
|
||||
|
||||
QLIST_INIT(&cpu->pre_el_change_hooks);
|
||||
QLIST_INIT(&cpu->el_change_hooks);
|
||||
|
393
target/arm/cpu.h
393
target/arm/cpu.h
@ -2595,144 +2595,6 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
|
||||
return kvmid;
|
||||
}
|
||||
|
||||
/* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a
|
||||
* special-behaviour cp reg and bits [11..8] indicate what behaviour
|
||||
* it has. Otherwise it is a simple cp reg, where CONST indicates that
|
||||
* TCG can assume the value to be constant (ie load at translate time)
|
||||
* and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END
|
||||
* indicates that the TB should not be ended after a write to this register
|
||||
* (the default is that the TB ends after cp writes). OVERRIDE permits
|
||||
* a register definition to override a previous definition for the
|
||||
* same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the
|
||||
* old must have the OVERRIDE bit set.
|
||||
* ALIAS indicates that this register is an alias view of some underlying
|
||||
* state which is also visible via another register, and that the other
|
||||
* register is handling migration and reset; registers marked ALIAS will not be
|
||||
* migrated but may have their state set by syncing of register state from KVM.
|
||||
* NO_RAW indicates that this register has no underlying state and does not
|
||||
* support raw access for state saving/loading; it will not be used for either
|
||||
* migration or KVM state synchronization. (Typically this is for "registers"
|
||||
* which are actually used as instructions for cache maintenance and so on.)
|
||||
* IO indicates that this register does I/O and therefore its accesses
|
||||
* need to be marked with gen_io_start() and also end the TB. In particular,
|
||||
* registers which implement clocks or timers require this.
|
||||
* RAISES_EXC is for when the read or write hook might raise an exception;
|
||||
* the generated code will synchronize the CPU state before calling the hook
|
||||
* so that it is safe for the hook to call raise_exception().
|
||||
* NEWEL is for writes to registers that might change the exception
|
||||
* level - typically on older ARM chips. For those cases we need to
|
||||
* re-read the new el when recomputing the translation flags.
|
||||
*/
|
||||
#define ARM_CP_SPECIAL 0x0001
|
||||
#define ARM_CP_CONST 0x0002
|
||||
#define ARM_CP_64BIT 0x0004
|
||||
#define ARM_CP_SUPPRESS_TB_END 0x0008
|
||||
#define ARM_CP_OVERRIDE 0x0010
|
||||
#define ARM_CP_ALIAS 0x0020
|
||||
#define ARM_CP_IO 0x0040
|
||||
#define ARM_CP_NO_RAW 0x0080
|
||||
#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100)
|
||||
#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200)
|
||||
#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300)
|
||||
#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400)
|
||||
#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500)
|
||||
#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600)
|
||||
#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700)
|
||||
#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA
|
||||
#define ARM_CP_FPU 0x1000
|
||||
#define ARM_CP_SVE 0x2000
|
||||
#define ARM_CP_NO_GDB 0x4000
|
||||
#define ARM_CP_RAISES_EXC 0x8000
|
||||
#define ARM_CP_NEWEL 0x10000
|
||||
/* Used only as a terminator for ARMCPRegInfo lists */
|
||||
#define ARM_CP_SENTINEL 0xfffff
|
||||
/* Mask of only the flag bits in a type field */
|
||||
#define ARM_CP_FLAG_MASK 0x1f0ff
|
||||
|
||||
/* Valid values for ARMCPRegInfo state field, indicating which of
|
||||
* the AArch32 and AArch64 execution states this register is visible in.
|
||||
* If the reginfo doesn't explicitly specify then it is AArch32 only.
|
||||
* If the reginfo is declared to be visible in both states then a second
|
||||
* reginfo is synthesised for the AArch32 view of the AArch64 register,
|
||||
* such that the AArch32 view is the lower 32 bits of the AArch64 one.
|
||||
* Note that we rely on the values of these enums as we iterate through
|
||||
* the various states in some places.
|
||||
*/
|
||||
enum {
|
||||
ARM_CP_STATE_AA32 = 0,
|
||||
ARM_CP_STATE_AA64 = 1,
|
||||
ARM_CP_STATE_BOTH = 2,
|
||||
};
|
||||
|
||||
/* ARM CP register secure state flags. These flags identify security state
|
||||
* attributes for a given CP register entry.
|
||||
* The existence of both or neither secure and non-secure flags indicates that
|
||||
* the register has both a secure and non-secure hash entry. A single one of
|
||||
* these flags causes the register to only be hashed for the specified
|
||||
* security state.
|
||||
* Although definitions may have any combination of the S/NS bits, each
|
||||
* registered entry will only have one to identify whether the entry is secure
|
||||
* or non-secure.
|
||||
*/
|
||||
enum {
|
||||
ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */
|
||||
ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */
|
||||
};
|
||||
|
||||
/* Return true if cptype is a valid type field. This is used to try to
|
||||
* catch errors where the sentinel has been accidentally left off the end
|
||||
* of a list of registers.
|
||||
*/
|
||||
static inline bool cptype_valid(int cptype)
|
||||
{
|
||||
return ((cptype & ~ARM_CP_FLAG_MASK) == 0)
|
||||
|| ((cptype & ARM_CP_SPECIAL) &&
|
||||
((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL));
|
||||
}
|
||||
|
||||
/* Access rights:
|
||||
* We define bits for Read and Write access for what rev C of the v7-AR ARM ARM
|
||||
* defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and
|
||||
* PL2 (hyp). The other level which has Read and Write bits is Secure PL1
|
||||
* (ie any of the privileged modes in Secure state, or Monitor mode).
|
||||
* If a register is accessible in one privilege level it's always accessible
|
||||
* in higher privilege levels too. Since "Secure PL1" also follows this rule
|
||||
* (ie anything visible in PL2 is visible in S-PL1, some things are only
|
||||
* visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the
|
||||
* terminology a little and call this PL3.
|
||||
* In AArch64 things are somewhat simpler as the PLx bits line up exactly
|
||||
* with the ELx exception levels.
|
||||
*
|
||||
* If access permissions for a register are more complex than can be
|
||||
* described with these bits, then use a laxer set of restrictions, and
|
||||
* do the more restrictive/complex check inside a helper function.
|
||||
*/
|
||||
#define PL3_R 0x80
|
||||
#define PL3_W 0x40
|
||||
#define PL2_R (0x20 | PL3_R)
|
||||
#define PL2_W (0x10 | PL3_W)
|
||||
#define PL1_R (0x08 | PL2_R)
|
||||
#define PL1_W (0x04 | PL2_W)
|
||||
#define PL0_R (0x02 | PL1_R)
|
||||
#define PL0_W (0x01 | PL1_W)
|
||||
|
||||
/*
|
||||
* For user-mode some registers are accessible to EL0 via a kernel
|
||||
* trap-and-emulate ABI. In this case we define the read permissions
|
||||
* as actually being PL0_R. However some bits of any given register
|
||||
* may still be masked.
|
||||
*/
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
#define PL0U_R PL0_R
|
||||
#else
|
||||
#define PL0U_R PL1_R
|
||||
#endif
|
||||
|
||||
#define PL3_RW (PL3_R | PL3_W)
|
||||
#define PL2_RW (PL2_R | PL2_W)
|
||||
#define PL1_RW (PL1_R | PL1_W)
|
||||
#define PL0_RW (PL0_R | PL0_W)
|
||||
|
||||
/* Return the highest implemented Exception Level */
|
||||
static inline int arm_highest_el(CPUARMState *env)
|
||||
{
|
||||
@ -2784,236 +2646,6 @@ static inline int arm_current_el(CPUARMState *env)
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct ARMCPRegInfo ARMCPRegInfo;
|
||||
|
||||
typedef enum CPAccessResult {
|
||||
/* Access is permitted */
|
||||
CP_ACCESS_OK = 0,
|
||||
/* Access fails due to a configurable trap or enable which would
|
||||
* result in a categorized exception syndrome giving information about
|
||||
* the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6,
|
||||
* 0xc or 0x18). The exception is taken to the usual target EL (EL1 or
|
||||
* PL1 if in EL0, otherwise to the current EL).
|
||||
*/
|
||||
CP_ACCESS_TRAP = 1,
|
||||
/* Access fails and results in an exception syndrome 0x0 ("uncategorized").
|
||||
* Note that this is not a catch-all case -- the set of cases which may
|
||||
* result in this failure is specifically defined by the architecture.
|
||||
*/
|
||||
CP_ACCESS_TRAP_UNCATEGORIZED = 2,
|
||||
/* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */
|
||||
CP_ACCESS_TRAP_EL2 = 3,
|
||||
CP_ACCESS_TRAP_EL3 = 4,
|
||||
/* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */
|
||||
CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5,
|
||||
CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6,
|
||||
} CPAccessResult;
|
||||
|
||||
/* Access functions for coprocessor registers. These cannot fail and
|
||||
* may not raise exceptions.
|
||||
*/
|
||||
typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque);
|
||||
typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque,
|
||||
uint64_t value);
|
||||
/* Access permission check functions for coprocessor registers. */
|
||||
typedef CPAccessResult CPAccessFn(CPUARMState *env,
|
||||
const ARMCPRegInfo *opaque,
|
||||
bool isread);
|
||||
/* Hook function for register reset */
|
||||
typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque);
|
||||
|
||||
#define CP_ANY 0xff
|
||||
|
||||
/* Definition of an ARM coprocessor register */
|
||||
struct ARMCPRegInfo {
|
||||
/* Name of register (useful mainly for debugging, need not be unique) */
|
||||
const char *name;
|
||||
/* Location of register: coprocessor number and (crn,crm,opc1,opc2)
|
||||
* tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a
|
||||
* 'wildcard' field -- any value of that field in the MRC/MCR insn
|
||||
* will be decoded to this register. The register read and write
|
||||
* callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2
|
||||
* used by the program, so it is possible to register a wildcard and
|
||||
* then behave differently on read/write if necessary.
|
||||
* For 64 bit registers, only crm and opc1 are relevant; crn and opc2
|
||||
* must both be zero.
|
||||
* For AArch64-visible registers, opc0 is also used.
|
||||
* Since there are no "coprocessors" in AArch64, cp is purely used as a
|
||||
* way to distinguish (for KVM's benefit) guest-visible system registers
|
||||
* from demuxed ones provided to preserve the "no side effects on
|
||||
* KVM register read/write from QEMU" semantics. cp==0x13 is guest
|
||||
* visible (to match KVM's encoding); cp==0 will be converted to
|
||||
* cp==0x13 when the ARMCPRegInfo is registered, for convenience.
|
||||
*/
|
||||
uint8_t cp;
|
||||
uint8_t crn;
|
||||
uint8_t crm;
|
||||
uint8_t opc0;
|
||||
uint8_t opc1;
|
||||
uint8_t opc2;
|
||||
/* Execution state in which this register is visible: ARM_CP_STATE_* */
|
||||
int state;
|
||||
/* Register type: ARM_CP_* bits/values */
|
||||
int type;
|
||||
/* Access rights: PL*_[RW] */
|
||||
int access;
|
||||
/* Security state: ARM_CP_SECSTATE_* bits/values */
|
||||
int secure;
|
||||
/* The opaque pointer passed to define_arm_cp_regs_with_opaque() when
|
||||
* this register was defined: can be used to hand data through to the
|
||||
* register read/write functions, since they are passed the ARMCPRegInfo*.
|
||||
*/
|
||||
void *opaque;
|
||||
/* Value of this register, if it is ARM_CP_CONST. Otherwise, if
|
||||
* fieldoffset is non-zero, the reset value of the register.
|
||||
*/
|
||||
uint64_t resetvalue;
|
||||
/* Offset of the field in CPUARMState for this register.
|
||||
*
|
||||
* This is not needed if either:
|
||||
* 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs
|
||||
* 2. both readfn and writefn are specified
|
||||
*/
|
||||
ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */
|
||||
|
||||
/* Offsets of the secure and non-secure fields in CPUARMState for the
|
||||
* register if it is banked. These fields are only used during the static
|
||||
* registration of a register. During hashing the bank associated
|
||||
* with a given security state is copied to fieldoffset which is used from
|
||||
* there on out.
|
||||
*
|
||||
* It is expected that register definitions use either fieldoffset or
|
||||
* bank_fieldoffsets in the definition but not both. It is also expected
|
||||
* that both bank offsets are set when defining a banked register. This
|
||||
* use indicates that a register is banked.
|
||||
*/
|
||||
ptrdiff_t bank_fieldoffsets[2];
|
||||
|
||||
/* Function for making any access checks for this register in addition to
|
||||
* those specified by the 'access' permissions bits. If NULL, no extra
|
||||
* checks required. The access check is performed at runtime, not at
|
||||
* translate time.
|
||||
*/
|
||||
CPAccessFn *accessfn;
|
||||
/* Function for handling reads of this register. If NULL, then reads
|
||||
* will be done by loading from the offset into CPUARMState specified
|
||||
* by fieldoffset.
|
||||
*/
|
||||
CPReadFn *readfn;
|
||||
/* Function for handling writes of this register. If NULL, then writes
|
||||
* will be done by writing to the offset into CPUARMState specified
|
||||
* by fieldoffset.
|
||||
*/
|
||||
CPWriteFn *writefn;
|
||||
/* Function for doing a "raw" read; used when we need to copy
|
||||
* coprocessor state to the kernel for KVM or out for
|
||||
* migration. This only needs to be provided if there is also a
|
||||
* readfn and it has side effects (for instance clear-on-read bits).
|
||||
*/
|
||||
CPReadFn *raw_readfn;
|
||||
/* Function for doing a "raw" write; used when we need to copy KVM
|
||||
* kernel coprocessor state into userspace, or for inbound
|
||||
* migration. This only needs to be provided if there is also a
|
||||
* writefn and it masks out "unwritable" bits or has write-one-to-clear
|
||||
* or similar behaviour.
|
||||
*/
|
||||
CPWriteFn *raw_writefn;
|
||||
/* Function for resetting the register. If NULL, then reset will be done
|
||||
* by writing resetvalue to the field specified in fieldoffset. If
|
||||
* fieldoffset is 0 then no reset will be done.
|
||||
*/
|
||||
CPResetFn *resetfn;
|
||||
|
||||
/*
|
||||
* "Original" writefn and readfn.
|
||||
* For ARMv8.1-VHE register aliases, we overwrite the read/write
|
||||
* accessor functions of various EL1/EL0 to perform the runtime
|
||||
* check for which sysreg should actually be modified, and then
|
||||
* forwards the operation. Before overwriting the accessors,
|
||||
* the original function is copied here, so that accesses that
|
||||
* really do go to the EL1/EL0 version proceed normally.
|
||||
* (The corresponding EL2 register is linked via opaque.)
|
||||
*/
|
||||
CPReadFn *orig_readfn;
|
||||
CPWriteFn *orig_writefn;
|
||||
};
|
||||
|
||||
/* Macros which are lvalues for the field in CPUARMState for the
|
||||
* ARMCPRegInfo *ri.
|
||||
*/
|
||||
#define CPREG_FIELD32(env, ri) \
|
||||
(*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
|
||||
#define CPREG_FIELD64(env, ri) \
|
||||
(*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
|
||||
|
||||
#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL }
|
||||
|
||||
void define_arm_cp_regs_with_opaque(ARMCPU *cpu,
|
||||
const ARMCPRegInfo *regs, void *opaque);
|
||||
void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
|
||||
const ARMCPRegInfo *regs, void *opaque);
|
||||
static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs)
|
||||
{
|
||||
define_arm_cp_regs_with_opaque(cpu, regs, 0);
|
||||
}
|
||||
static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs)
|
||||
{
|
||||
define_one_arm_cp_reg_with_opaque(cpu, regs, 0);
|
||||
}
|
||||
const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp);
|
||||
|
||||
/*
|
||||
* Definition of an ARM co-processor register as viewed from
|
||||
* userspace. This is used for presenting sanitised versions of
|
||||
* registers to userspace when emulating the Linux AArch64 CPU
|
||||
* ID/feature ABI (advertised as HWCAP_CPUID).
|
||||
*/
|
||||
typedef struct ARMCPRegUserSpaceInfo {
|
||||
/* Name of register */
|
||||
const char *name;
|
||||
|
||||
/* Is the name actually a glob pattern */
|
||||
bool is_glob;
|
||||
|
||||
/* Only some bits are exported to user space */
|
||||
uint64_t exported_bits;
|
||||
|
||||
/* Fixed bits are applied after the mask */
|
||||
uint64_t fixed_bits;
|
||||
} ARMCPRegUserSpaceInfo;
|
||||
|
||||
#define REGUSERINFO_SENTINEL { .name = NULL }
|
||||
|
||||
void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods);
|
||||
|
||||
/* CPWriteFn that can be used to implement writes-ignored behaviour */
|
||||
void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
uint64_t value);
|
||||
/* CPReadFn that can be used for read-as-zero behaviour */
|
||||
uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri);
|
||||
|
||||
/* CPResetFn that does nothing, for use if no reset is required even
|
||||
* if fieldoffset is non zero.
|
||||
*/
|
||||
void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque);
|
||||
|
||||
/* Return true if this reginfo struct's field in the cpu state struct
|
||||
* is 64 bits wide.
|
||||
*/
|
||||
static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri)
|
||||
{
|
||||
return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT);
|
||||
}
|
||||
|
||||
static inline bool cp_access_ok(int current_el,
|
||||
const ARMCPRegInfo *ri, int isread)
|
||||
{
|
||||
return (ri->access >> ((current_el * 2) + isread)) & 1;
|
||||
}
|
||||
|
||||
/* Raw read of a coprocessor register (as needed for migration, etc) */
|
||||
uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri);
|
||||
|
||||
/**
|
||||
* write_list_to_cpustate
|
||||
* @cpu: ARMCPU
|
||||
@ -4072,6 +3704,11 @@ static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id)
|
||||
return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0;
|
||||
}
|
||||
|
||||
static inline bool isar_feature_aa32_debugv8p2(const ARMISARegisters *id)
|
||||
{
|
||||
return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 8;
|
||||
}
|
||||
|
||||
/*
|
||||
* 64-bit feature tests via id registers.
|
||||
*/
|
||||
@ -4249,6 +3886,11 @@ static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id)
|
||||
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2;
|
||||
}
|
||||
|
||||
static inline bool isar_feature_aa64_ras(const ARMISARegisters *id)
|
||||
{
|
||||
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0;
|
||||
}
|
||||
|
||||
static inline bool isar_feature_aa64_sve(const ARMISARegisters *id)
|
||||
{
|
||||
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0;
|
||||
@ -4378,6 +4020,11 @@ static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id)
|
||||
return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0;
|
||||
}
|
||||
|
||||
static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id)
|
||||
{
|
||||
return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8;
|
||||
}
|
||||
|
||||
static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id)
|
||||
{
|
||||
return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0;
|
||||
@ -4461,6 +4108,16 @@ static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id)
|
||||
return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id);
|
||||
}
|
||||
|
||||
static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id)
|
||||
{
|
||||
return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id);
|
||||
}
|
||||
|
||||
static inline bool isar_feature_any_ras(const ARMISARegisters *id)
|
||||
{
|
||||
return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Forward to the above feature tests given an ARMCPU pointer.
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "hvf_arm.h"
|
||||
#include "qapi/visitor.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "cpregs.h"
|
||||
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
@ -90,7 +91,6 @@ static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = {
|
||||
{ .name = "L2MERRSR",
|
||||
.cp = 15, .opc1 = 3, .crm = 15,
|
||||
.access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static void aarch64_a57_initfn(Object *obj)
|
||||
|
@ -18,6 +18,7 @@
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
#include "hw/boards.h"
|
||||
#endif
|
||||
#include "cpregs.h"
|
||||
|
||||
/* CPU models. These are not needed for the AArch64 linux-user build. */
|
||||
#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
|
||||
@ -263,7 +264,6 @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] = {
|
||||
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
|
||||
{ .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
|
||||
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static void cortex_a8_initfn(Object *obj)
|
||||
@ -331,7 +331,6 @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] = {
|
||||
.access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
|
||||
{ .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2,
|
||||
.access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static void cortex_a9_initfn(Object *obj)
|
||||
@ -397,7 +396,6 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
|
||||
#endif
|
||||
{ .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3,
|
||||
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static void cortex_a7_initfn(Object *obj)
|
||||
@ -685,7 +683,6 @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
|
||||
.access = PL1_RW, .type = ARM_CP_CONST },
|
||||
{ .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5,
|
||||
.opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP },
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static void cortex_r5_initfn(Object *obj)
|
||||
|
@ -19,8 +19,9 @@
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
#include "cpu.h"
|
||||
#include "internals.h"
|
||||
#include "exec/gdbstub.h"
|
||||
#include "internals.h"
|
||||
#include "cpregs.h"
|
||||
|
||||
typedef struct RegisterSysregXmlParam {
|
||||
CPUState *cs;
|
||||
@ -272,7 +273,7 @@ static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml,
|
||||
static void arm_register_sysreg_for_xml(gpointer key, gpointer value,
|
||||
gpointer p)
|
||||
{
|
||||
uint32_t ri_key = *(uint32_t *)key;
|
||||
uint32_t ri_key = (uintptr_t)key;
|
||||
ARMCPRegInfo *ri = value;
|
||||
RegisterSysregXmlParam *param = (RegisterSysregXmlParam *)p;
|
||||
GString *s = param->s;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1200,7 +1200,7 @@ int hvf_vcpu_exec(CPUState *cpu)
|
||||
/* we got kicked, no exit to process */
|
||||
return 0;
|
||||
default:
|
||||
assert(0);
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
hvf_sync_vtimer(cpu);
|
||||
|
@ -15,10 +15,10 @@
|
||||
|
||||
bool write_kvmstate_to_list(ARMCPU *cpu)
|
||||
{
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
bool write_list_to_kvmstate(ARMCPU *cpu, int level)
|
||||
{
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ bool write_kvmstate_to_list(ARMCPU *cpu)
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
if (ret) {
|
||||
ok = false;
|
||||
@ -575,7 +575,7 @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
|
||||
r.addr = (uintptr_t)(cpu->cpreg_values + i);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r);
|
||||
if (ret) {
|
||||
|
@ -661,7 +661,7 @@ static int cpu_pre_save(void *opaque)
|
||||
if (kvm_enabled()) {
|
||||
if (!write_kvmstate_to_list(cpu)) {
|
||||
/* This should never fail */
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -672,7 +672,7 @@ static int cpu_pre_save(void *opaque)
|
||||
} else {
|
||||
if (!write_cpustate_to_list(cpu, false)) {
|
||||
/* This should never fail. */
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "internals.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/cpu_ldst.h"
|
||||
#include "cpregs.h"
|
||||
|
||||
#define SIGNBIT (uint32_t)0x80000000
|
||||
#define SIGNBIT64 ((uint64_t)1 << 63)
|
||||
@ -631,11 +632,13 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
|
||||
uint32_t isread)
|
||||
{
|
||||
const ARMCPRegInfo *ri = rip;
|
||||
CPAccessResult res = CP_ACCESS_OK;
|
||||
int target_el;
|
||||
|
||||
if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14
|
||||
&& extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) {
|
||||
raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env));
|
||||
res = CP_ACCESS_TRAP;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -654,48 +657,46 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
|
||||
mask &= ~((1 << 4) | (1 << 14));
|
||||
|
||||
if (env->cp15.hstr_el2 & mask) {
|
||||
target_el = 2;
|
||||
goto exept;
|
||||
res = CP_ACCESS_TRAP_EL2;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ri->accessfn) {
|
||||
if (ri->accessfn) {
|
||||
res = ri->accessfn(env, ri, isread);
|
||||
}
|
||||
if (likely(res == CP_ACCESS_OK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ri->accessfn(env, ri, isread)) {
|
||||
case CP_ACCESS_OK:
|
||||
return;
|
||||
fail:
|
||||
switch (res & ~CP_ACCESS_EL_MASK) {
|
||||
case CP_ACCESS_TRAP:
|
||||
target_el = exception_target_el(env);
|
||||
break;
|
||||
case CP_ACCESS_TRAP_EL2:
|
||||
/* Requesting a trap to EL2 when we're in EL3 is
|
||||
* a bug in the access function.
|
||||
*/
|
||||
assert(arm_current_el(env) != 3);
|
||||
target_el = 2;
|
||||
break;
|
||||
case CP_ACCESS_TRAP_EL3:
|
||||
target_el = 3;
|
||||
break;
|
||||
case CP_ACCESS_TRAP_UNCATEGORIZED:
|
||||
target_el = exception_target_el(env);
|
||||
syndrome = syn_uncategorized();
|
||||
break;
|
||||
case CP_ACCESS_TRAP_UNCATEGORIZED_EL2:
|
||||
target_el = 2;
|
||||
syndrome = syn_uncategorized();
|
||||
break;
|
||||
case CP_ACCESS_TRAP_UNCATEGORIZED_EL3:
|
||||
target_el = 3;
|
||||
syndrome = syn_uncategorized();
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
exept:
|
||||
target_el = res & CP_ACCESS_EL_MASK;
|
||||
switch (target_el) {
|
||||
case 0:
|
||||
target_el = exception_target_el(env);
|
||||
break;
|
||||
case 2:
|
||||
assert(arm_current_el(env) != 3);
|
||||
assert(arm_is_el2_enabled(env));
|
||||
break;
|
||||
case 3:
|
||||
assert(arm_feature(env, ARM_FEATURE_EL3));
|
||||
break;
|
||||
default:
|
||||
/* No "direct" traps to EL1 */
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
raise_exception(env, EXCP_UDEF, syndrome, target_el);
|
||||
}
|
||||
|
||||
|
@ -27,14 +27,12 @@
|
||||
#include "translate.h"
|
||||
#include "internals.h"
|
||||
#include "qemu/host-utils.h"
|
||||
|
||||
#include "semihosting/semihost.h"
|
||||
#include "exec/gen-icount.h"
|
||||
|
||||
#include "exec/helper-proto.h"
|
||||
#include "exec/helper-gen.h"
|
||||
#include "exec/log.h"
|
||||
|
||||
#include "cpregs.h"
|
||||
#include "translate-a64.h"
|
||||
#include "qemu/atomic128.h"
|
||||
|
||||
@ -1835,7 +1833,9 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
|
||||
}
|
||||
|
||||
/* Handle special cases first */
|
||||
switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) {
|
||||
switch (ri->type & ARM_CP_SPECIAL_MASK) {
|
||||
case 0:
|
||||
break;
|
||||
case ARM_CP_NOP:
|
||||
return;
|
||||
case ARM_CP_NZCV:
|
||||
@ -1910,7 +1910,7 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
g_assert_not_reached();
|
||||
}
|
||||
if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) {
|
||||
return;
|
||||
@ -6151,7 +6151,7 @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn)
|
||||
gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
write_fp_sreg(s, rd, tcg_res);
|
||||
@ -6392,7 +6392,7 @@ static void handle_fp_fcvt(DisasContext *s, int opcode,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -679,7 +679,7 @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
if ((vd + a->stride * (nregs - 1)) > 31) {
|
||||
/*
|
||||
|
@ -30,11 +30,10 @@
|
||||
#include "qemu/bitops.h"
|
||||
#include "arm_ldst.h"
|
||||
#include "semihosting/semihost.h"
|
||||
|
||||
#include "exec/helper-proto.h"
|
||||
#include "exec/helper-gen.h"
|
||||
|
||||
#include "exec/log.h"
|
||||
#include "cpregs.h"
|
||||
|
||||
|
||||
#define ENABLE_ARCH_4T arm_dc_feature(s, ARM_FEATURE_V4T)
|
||||
@ -4745,7 +4744,9 @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
|
||||
}
|
||||
|
||||
/* Handle special cases first */
|
||||
switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) {
|
||||
switch (ri->type & ARM_CP_SPECIAL_MASK) {
|
||||
case 0:
|
||||
break;
|
||||
case ARM_CP_NOP:
|
||||
return;
|
||||
case ARM_CP_WFI:
|
||||
@ -4757,7 +4758,7 @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
|
||||
s->base.is_jmp = DISAS_WFI;
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) {
|
||||
@ -5155,7 +5156,7 @@ static void gen_srs(DisasContext *s,
|
||||
offset = 4;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
tcg_gen_addi_i32(addr, addr, offset);
|
||||
tmp = load_reg(s, 14);
|
||||
@ -5180,7 +5181,7 @@ static void gen_srs(DisasContext *s,
|
||||
offset = 0;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
g_assert_not_reached();
|
||||
}
|
||||
tcg_gen_addi_i32(addr, addr, offset);
|
||||
gen_helper_set_r13_banked(cpu_env, tcg_constant_i32(mode), addr);
|
||||
|
@ -28,9 +28,9 @@ endif
|
||||
# BTI Tests
|
||||
# bti-1 tests the elf notes, so we require special compiler support.
|
||||
ifneq ($(CROSS_CC_HAS_ARMV8_BTI),)
|
||||
AARCH64_TESTS += bti-1
|
||||
bti-1: CFLAGS += -mbranch-protection=standard
|
||||
bti-1: LDFLAGS += -nostdlib
|
||||
AARCH64_TESTS += bti-1 bti-3
|
||||
bti-1 bti-3: CFLAGS += -mbranch-protection=standard
|
||||
bti-1 bti-3: LDFLAGS += -nostdlib
|
||||
endif
|
||||
# bti-2 tests PROT_BTI, so no special compiler support required.
|
||||
AARCH64_TESTS += bti-2
|
||||
|
42
tests/tcg/aarch64/bti-3.c
Normal file
42
tests/tcg/aarch64/bti-3.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* BTI vs PACIASP
|
||||
*/
|
||||
|
||||
#include "bti-crt.inc.c"
|
||||
|
||||
static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc)
|
||||
{
|
||||
uc->uc_mcontext.pc += 8;
|
||||
uc->uc_mcontext.pstate = 1;
|
||||
}
|
||||
|
||||
#define BTYPE_1() \
|
||||
asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \
|
||||
: "=r"(skipped) : : "x16", "x30")
|
||||
|
||||
#define BTYPE_2() \
|
||||
asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \
|
||||
: "=r"(skipped) : : "x16", "x30")
|
||||
|
||||
#define BTYPE_3() \
|
||||
asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \
|
||||
: "=r"(skipped) : : "x15", "x30")
|
||||
|
||||
#define TEST(WHICH, EXPECT) \
|
||||
do { WHICH(); fail += skipped ^ EXPECT; } while (0)
|
||||
|
||||
int main()
|
||||
{
|
||||
int fail = 0;
|
||||
int skipped;
|
||||
|
||||
/* Signal-like with SA_SIGINFO. */
|
||||
signal_info(SIGILL, skip2_sigill);
|
||||
|
||||
/* With SCTLR_EL1.BT0 set, PACIASP is not compatible with type=3. */
|
||||
TEST(BTYPE_1, 0);
|
||||
TEST(BTYPE_2, 0);
|
||||
TEST(BTYPE_3, 1);
|
||||
|
||||
return fail;
|
||||
}
|
Loading…
Reference in New Issue
Block a user