target-arm queue
A largish pull request: the big things are Richard's PAuth work and Aaron's PMU emulation improvements.
thanks
-- PMM
The following changes since commit 681d61362d3f766a00806b89d6581869041f73cb:
Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into staging (2019-01-17 12:48:42 +0000)
are available in the Git repository at:
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190118
for you to fetch changes up to 2a0ed2804e2c77a1c4e255f05ab739618e05c85d:
tests/libqtest: Introduce qtest_init_with_serial() (2019-01-18 14:17:38 +0000)
----------------------------------------------------------------
target-arm queue:
* hw/char/stm32f2xx_usart: Do not update data register when device is disabled
* hw/arm/virt-acpi-build: Set COHACC override flag in IORT SMMUv3 node
* target/arm: Allow Aarch32 exception return to switch from Mon->Hyp
* ftgmac100: implement the new MDIO interface on Aspeed SoC
* implement the ARMv8.3-PAuth extension
* improve emulation of the ARM PMU
----------------------------------------------------------------
Aaron Lindsay (13):
migration: Add post_save function to VMStateDescription target/arm: Reorganize PMCCNTR accesses
target/arm: Swap PMU values before/after migrations target/arm: Filter cycle counter based on PMCCFILTR_EL0 target/arm: Allow AArch32 access for PMCCFILTR
target/arm: Implement PMOVSSET
target/arm: Define FIELDs for ID_DFR0
target/arm: Make PMCEID[01]_EL0 64 bit registers, add PMCEID[23] target/arm: Add array for supported PMU events, generate PMCEID[01]_EL0 target/arm: Finish implementation of PM[X]EVCNTR and PM[X]EVTYPER target/arm: PMU: Add instruction and cycle events target/arm: PMU: Set PMCR.N to 4
target/arm: Implement PMSWINC
Alexander Graf (1):
target/arm: Allow Aarch32 exception return to switch from Mon->Hyp
Cédric Le Goater (1):
ftgmac100: implement the new MDIO interface on Aspeed SoC
Eric Auger (1):
hw/arm/virt-acpi-build: Set COHACC override flag in IORT SMMUv3 node
Julia Suvorova (1):
tests/libqtest: Introduce qtest_init_with_serial()
Philippe Mathieu-Daudé (1):
hw/char/stm32f2xx_usart: Do not update data register when device is disabled
Richard Henderson (31):
target/arm: Add state for the ARMv8.3-PAuth extension target/arm: Add SCTLR bits through ARMv8.5 target/arm: Add PAuth active bit to tbflags target/arm: Introduce raise_exception_ra target/arm: Add PAuth helpers
target/arm: Decode PAuth within system hint space target/arm: Rearrange decode in disas_data_proc_1src target/arm: Decode PAuth within disas_data_proc_1src target/arm: Decode PAuth within disas_data_proc_2src target/arm: Move helper_exception_return to helper-a64.c target/arm: Add new_pc argument to helper_exception_return target/arm: Rearrange decode in disas_uncond_b_reg target/arm: Decode PAuth within disas_uncond_b_reg target/arm: Decode Load/store register (pac) target/arm: Move cpu_mmu_index out of line target/arm: Introduce arm_mmu_idx
target/arm: Introduce arm_stage1_mmu_idx target/arm: Create ARMVAParameters and helpers target/arm: Merge TBFLAG_AA_TB{0, 1} to TBII target/arm: Export aa64_va_parameters to internals.h target/arm: Add aa64_va_parameters_both target/arm: Decode TBID from TCR
target/arm: Reuse aa64_va_parameters for setting tbflags target/arm: Implement pauth_strip
target/arm: Implement pauth_auth
target/arm: Implement pauth_addpac
target/arm: Implement pauth_computepac target/arm: Add PAuth system registers target/arm: Enable PAuth for -cpu max target/arm: Enable PAuth for user-only target/arm: Tidy TBI handling in gen_a64_set_pc
target/arm/Makefile.objs | 1 + include/hw/acpi/acpi-defs.h | 2 + include/migration/vmstate.h | 1 + target/arm/cpu.h | 244 +++++---- target/arm/helper-a64.h | 14 + target/arm/helper.h | 1 - target/arm/internals.h | 77 +++ target/arm/translate.h | 5 +- tests/libqtest.h | 11 + hw/arm/virt-acpi-build.c | 1 + hw/char/stm32f2xx_usart.c | 3 +- hw/net/ftgmac100.c | 80 ++- migration/vmstate.c | 13 +- target/arm/cpu.c | 19 +- target/arm/cpu64.c | 68 ++- target/arm/helper-a64.c | 155 ++++++ target/arm/helper.c | 1222 +++++++++++++++++++++++++++++++++---------- target/arm/machine.c | 24 + target/arm/op_helper.c | 174 +----- target/arm/pauth_helper.c | 497 ++++++++++++++++++ target/arm/translate-a64.c | 537 ++++++++++++++++--- tests/libqtest.c | 26 + docs/devel/migration.rst | 9 +- 23 files changed, 2552 insertions(+), 632 deletions(-) create mode 100644 target/arm/pauth_helper.c
[Qemu-devel] [PULL 01/49] hw/char/stm32f2xx_usart: Do not update data register when device is disabled
From: Philippe Mathieu-Daudé <[email protected]>
When the device is disabled, the internal circuitry keeps the data register loaded and doesn't update it.
Message-id: [email protected]
--- hw/char/stm32f2xx_usart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/char/stm32f2xx_usart.c +1 -2
@@ -53,14 +53,13 @@ static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size) {STM32F2XXUsartState *s = opaque; - s->usart_dr = *buf; -if (!(s->usart_cr1 &USART_CR1_UE && s->usart_cr1 &USART_CR1_RE )) {/* USART not enabled - drop the chars */ DB_PRINT ("Dropping the chars\n" );return ; } + s->usart_dr = *buf; s->usart_sr |=USART_SR_RXNE ;if (s->usart_cr1 &USART_CR1_RXNEIE ) {
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 02/49] hw/arm/virt-acpi-build: Set COHACC override flag in IORT SMMUv3 node
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
Let's report IO-coherent access is supported for translation table walks, descriptor fetches and queues by setting the COHACC override flag. Without that, we observe wrong command opcodes. The DT description also advertises the dma coherency.
Fixes a703b4f6c1ee ("hw/arm/virt-acpi-build: Add smmuv3 node in IORT table")
Message-id: [email protected]
--- include/hw/acpi/acpi-defs.h | 2 ++ hw/arm/virt-acpi-build.c | 1 + 2 files changed, 3 insertions(+)
include/hw/acpi/acpi-defs.h +2 -0
@@ -623,6 +623,8 @@ struct AcpiIortItsGroup { }QEMU_PACKED ;typedef struct AcpiIortItsGroup AcpiIortItsGroup ; +#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE 1 +struct AcpiIortSmmu3 {ACPI_IORT_NODE_HEADER_DEF uint64_t base_address;
hw/arm/virt-acpi-build.c +1 -0
@@ -418,6 +418,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) smmu->mapping_count =cpu_to_le32 (1 ); smmu->mapping_offset =cpu_to_le32 (sizeof (*smmu)); smmu->base_address =cpu_to_le64 (vms->memmap[VIRT_SMMU ].base); + smmu->flags =cpu_to_le32 (ACPI_IORT_SMMU_V3_COHACC_OVERRIDE ); smmu->event_gsiv =cpu_to_le32 (irq); smmu->pri_gsiv =cpu_to_le32 (irq +1 ); smmu->gerr_gsiv =cpu_to_le32 (irq +2 );
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 04/49] ftgmac100: implement the new MDIO interface on Aspeed SoC
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
The PHY behind the MAC of an Aspeed SoC can be controlled using two different MDC/MDIO interfaces. The same registers PHYCR (MAC60) and PHYDATA (MAC64) are involved but they have a different layout.
BIT31 of the Feature Register (MAC40) controls which MDC/MDIO interface is active.
Message-id: [email protected]
--- hw/net/ftgmac100.c | 80 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 12 deletions(-)
hw/net/ftgmac100.c +68 -12
@@ -89,6 +89,18 @@#define FTGMAC100_PHYDATA_MIIWDATA (x) ((x) & 0xffff)#define FTGMAC100_PHYDATA_MIIRDATA (x) (((x) >> 16) & 0xffff) +/* +* PHY control register - New MDC/MDIO interface +*/ +#define FTGMAC100_PHYCR_NEW_DATA (x) (((x) >> 16) & 0xffff) +#define FTGMAC100_PHYCR_NEW_FIRE (1 << 15) +#define FTGMAC100_PHYCR_NEW_ST_22 (1 << 12) +#define FTGMAC100_PHYCR_NEW_OP (x) (((x) >> 10) & 3) +#define FTGMAC100_PHYCR_NEW_OP_WRITE 0x1 +#define FTGMAC100_PHYCR_NEW_OP_READ 0x2 +#define FTGMAC100_PHYCR_NEW_DEV (x) (((x) >> 5) & 0x1f) +#define FTGMAC100_PHYCR_NEW_REG (x) ((x) & 0x1f) +/* * Feature Register */
@@ -269,9 +281,9 @@ static void phy_reset(FTGMAC100State *s) s->phy_int =0 ; } -static uint32_t do_phy_read (FTGMAC100State *s,int reg) +static uint16_t do_phy_read (FTGMAC100State *s,uint8_t reg) { -uint32_t val; +uint16_t val;switch (reg) {case MII_BMCR :/* Basic Control */
@@ -336,7 +348,7 @@ static uint32_t do_phy_read(FTGMAC100State *s, int reg) MII_BMCR_FD | MII_BMCR_CTST)#define MII_ANAR_MASK 0x2d7f -static void do_phy_write (FTGMAC100State *s,int reg,uint32_t val) +static void do_phy_write (FTGMAC100State *s,uint8_t reg,uint16_t val) {switch (reg) {case MII_BMCR :/* Basic Control */
@@ -373,6 +385,55 @@ static void do_phy_write(FTGMAC100State *s, int reg, uint32_t val) } } +static void do_phy_new_ctl (FTGMAC100State *s) +{ +uint8_t reg; +uint16_t data; + +if (!(s->phycr &FTGMAC100_PHYCR_NEW_ST_22 )) { +qemu_log_mask (LOG_UNIMP ,"%s: unsupported ST code\n" , __func__); +return ; + } + +/* Nothing to do */ +if (!(s->phycr &FTGMAC100_PHYCR_NEW_FIRE )) { +return ; + } + + reg =FTGMAC100_PHYCR_NEW_REG (s->phycr); + data =FTGMAC100_PHYCR_NEW_DATA (s->phycr); + +switch (FTGMAC100_PHYCR_NEW_OP (s->phycr)) { +case FTGMAC100_PHYCR_NEW_OP_WRITE : +do_phy_write (s, reg, data); +break ; +case FTGMAC100_PHYCR_NEW_OP_READ : + s->phydata =do_phy_read (s, reg) &0xffff ; +break ; +default : +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid OP code %08x\n" , + __func__, s->phycr); + } + + s->phycr &= ~FTGMAC100_PHYCR_NEW_FIRE ; +} + +static void do_phy_ctl (FTGMAC100State *s) +{ +uint8_t reg =FTGMAC100_PHYCR_REG (s->phycr); + +if (s->phycr &FTGMAC100_PHYCR_MIIWR ) { +do_phy_write (s, reg, s->phydata &0xffff ); + s->phycr &= ~FTGMAC100_PHYCR_MIIWR ; + }else if (s->phycr &FTGMAC100_PHYCR_MIIRD ) { + s->phydata =do_phy_read (s, reg) <<16 ; + s->phycr &= ~FTGMAC100_PHYCR_MIIRD ; + }else { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: no OP code %08x\n" , + __func__, s->phycr); + } +} +static int ftgmac100_read_bd (FTGMAC100Desc *bd,dma_addr_t addr) {if (dma_memory_read (&address_space_memory, addr, bd,sizeof (*bd))) {
@@ -628,7 +689,6 @@ static void ftgmac100_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) {FTGMAC100State *s =FTGMAC100 (opaque); -int reg;switch (addr &0xff ) {case FTGMAC100_ISR :/* Interrupt status */
@@ -711,14 +771,11 @@ static void ftgmac100_write(void *opaque, hwaddr addr,break ;case FTGMAC100_PHYCR :/* PHY Device control */ - reg =FTGMAC100_PHYCR_REG (value); s->phycr = value; -if (value &FTGMAC100_PHYCR_MIIWR ) { -do_phy_write (s, reg, s->phydata &0xffff ); - s->phycr &= ~FTGMAC100_PHYCR_MIIWR ; +if (s->revr &FTGMAC100_REVR_NEW_MDIO_INTERFACE ) { +do_phy_new_ctl (s); }else { - s->phydata =do_phy_read (s, reg) <<16 ; - s->phycr &= ~FTGMAC100_PHYCR_MIIRD ; +do_phy_ctl (s); }break ;case FTGMAC100_PHYDATA :
@@ -728,8 +785,7 @@ static void ftgmac100_write(void *opaque, hwaddr addr, s->dblac = value;break ;case FTGMAC100_REVR :/* Feature Register */ -/* TODO: Only Old MDIO interface is supported */ - s->revr = value & ~FTGMAC100_REVR_NEW_MDIO_INTERFACE ; + s->revr = value;break ;case FTGMAC100_FEAR1 :/* Feature Register 1 */ s->fear1 = value;
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 03/49] target/arm: Allow Aarch32 exception return to switch from Mon->Hyp
In reply to Peter MaydellFrom: Alexander Graf <[email protected]>
In U-boot, we switch from S-SVC -> Mon -> Hyp mode when we want to enter Hyp mode. The change into Hyp mode is done by doing an exception return from Mon. This doesn't work with current QEMU.
The problem is that in bad_mode_switch() we refuse to allow the change of mode.
Note that bad_mode_switch() is used to do validation for two situations:
(1) changes to mode by instructions writing to CPSR.M (ie not exception take/return) -- this corresponds to the Armv8 Arm ARM pseudocode Arch32.WriteModeByInstr
(2) changes to mode by exception return
Attempting to enter or leave Hyp mode via case (1) is forbidden in v8 and UNPREDICTABLE in v7, and QEMU is correct to disallow it there. However, we're already doing that check at the top of the bad_mode_switch() function, so if that passes then we should allow the case (2) exception return mode changes to switch into Hyp mode.
We want to test whether we're trying to return to the nonexistent "secure Hyp" mode, so we need to look at arm_is_secure_below_el3() rather than arm_is_secure(), since the latter is always true if we're in Mon (EL3).
Message-id: [email protected]
--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +1 -1
@@ -6297,7 +6297,7 @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type)return 0 ;case ARM_CPU_MODE_HYP :return !arm_feature (env,ARM_FEATURE_EL2 ) - ||arm_current_el (env) <2 ||arm_is_secure (env); + ||arm_current_el (env) <2 ||arm_is_secure_below_el3 (env);case ARM_CPU_MODE_MON :return arm_current_el (env) <3 ;default :
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 05/49] target/arm: Add state for the ARMv8.3-PAuth extension
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Add storage space for the 5 encryption keys.
Message-id: [email protected]
--- target/arm/cpu.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
target/arm/cpu.h +29 -1
@@ -201,11 +201,16 @@ typedef struct ARMVectorReg { uint64_t d[2 * ARM_MAX_VQ] QEMU_ALIGNED(16); } ARMVectorReg; -/* In AArch32 mode, predicate registers do not exist at all. */ #ifdef TARGET_AARCH64 +/* In AArch32 mode, predicate registers do not exist at all. */ typedef struct ARMPredicateReg { uint64_t p[2 * ARM_MAX_VQ / 8] QEMU_ALIGNED(16); }ARMPredicateReg ; + +/* In AArch32 mode, PAC keys do not exist at all. */ +typedef struct ARMPACKey { +uint64_t lo, hi; +}ARMPACKey ;#endif
@@ -605,6 +610,14 @@ typedef struct CPUARMState {uint32_t cregs[16 ]; } iwmmxt; +#ifdef TARGET_AARCH64 +ARMPACKey apia_key; +ARMPACKey apib_key; +ARMPACKey apda_key; +ARMPACKey apdb_key; +ARMPACKey apga_key; +#endif +#if defined(CONFIG_USER_ONLY )/* For usermode syscall translation. */ int eabi;
@@ -3264,6 +3277,21 @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,FCMA ) !=0 ; } +static inline bool isar_feature_aa64_pauth (const ARMISARegisters *id) +{ +/* +* Note that while QEMU will only implement the architected algorithm +* QARMA, and thus APA+GPA, the host cpu for kvm may use implementation +* defined algorithms, and thus API+GPI, and this predicate controls +* migration of the 128-bit keys. +*/ +return (id->id_aa64isar1 & + (FIELD_DP64 (0 ,ID_AA64ISAR1 ,APA ,-1 ) | +FIELD_DP64 (0 ,ID_AA64ISAR1 ,API ,-1 ) | +FIELD_DP64 (0 ,ID_AA64ISAR1 ,GPA ,-1 ) | +FIELD_DP64 (0 ,ID_AA64ISAR1 ,GPI ,-1 ))) !=0 ; +} +static inline bool isar_feature_aa64_fp16 (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically wrt FP16. */
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 06/49] target/arm: Add SCTLR bits through ARMv8.5
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Post v8.4 bits taken from SysReg_v85_xml-00bet8.
Message-id: [email protected]
--- target/arm/cpu.h | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-)
target/arm/cpu.h +33 -12
@@ -991,12 +991,15 @@ void pmccntr_sync(CPUARMState *env);#define SCTLR_A (1U << 1)#define SCTLR_C (1U << 2)#define SCTLR_W (1U << 3)/* up to v6; RAO in v7 */ -#define SCTLR_SA (1U << 3) +#define SCTLR_nTLSMD_32 (1U << 3)/* v8.2-LSMAOC, AArch32 only */ +#define SCTLR_SA (1U << 3)/* AArch64 only */ #define SCTLR_P (1U << 4)/* up to v5; RAO in v6 and v7 */ +#define SCTLR_LSMAOE_32 (1U << 4)/* v8.2-LSMAOC, AArch32 only */ #define SCTLR_SA0 (1U << 4)/* v8 onward, AArch64 only */ #define SCTLR_D (1U << 5)/* up to v5; RAO in v6 */ #define SCTLR_CP15BEN (1U << 5)/* v7 onward */ #define SCTLR_L (1U << 6)/* up to v5; RAO in v6 and v7; RAZ in v8 */ +#define SCTLR_nAA (1U << 6)/* when v8.4-LSE is implemented */ #define SCTLR_B (1U << 7)/* up to v6; RAZ in v7 */ #define SCTLR_ITD (1U << 7)/* v8 onward */ #define SCTLR_S (1U << 8)/* up to v6; RAZ in v7 */
@@ -1004,35 +1007,53 @@ void pmccntr_sync(CPUARMState *env);#define SCTLR_R (1U << 9)/* up to v6; RAZ in v7 */ #define SCTLR_UMA (1U << 9)/* v8 onward, AArch64 only */ #define SCTLR_F (1U << 10)/* up to v6 */ -#define SCTLR_SW (1U << 10)/* v7 onward */ -#define SCTLR_Z (1U << 11) +#define SCTLR_SW (1U << 10)/* v7, RES0 in v8 */ +#define SCTLR_Z (1U << 11)/* in v7, RES1 in v8 */ +#define SCTLR_EOS (1U << 11)/* v8.5-ExS */ #define SCTLR_I (1U << 12) -#define SCTLR_V (1U << 13) +#define SCTLR_V (1U << 13)/* AArch32 only */ +#define SCTLR_EnDB (1U << 13)/* v8.3, AArch64 only */ #define SCTLR_RR (1U << 14)/* up to v7 */ #define SCTLR_DZE (1U << 14)/* v8 onward, AArch64 only */ #define SCTLR_L4 (1U << 15)/* up to v6; RAZ in v7 */ #define SCTLR_UCT (1U << 15)/* v8 onward, AArch64 only */ #define SCTLR_DT (1U << 16)/* up to ??, RAO in v6 and v7 */ #define SCTLR_nTWI (1U << 16)/* v8 onward */ -#define SCTLR_HA (1U << 17) +#define SCTLR_HA (1U << 17)/* up to v7, RES0 in v8 */ #define SCTLR_BR (1U << 17)/* PMSA only */ #define SCTLR_IT (1U << 18)/* up to ??, RAO in v6 and v7 */ #define SCTLR_nTWE (1U << 18)/* v8 onward */ #define SCTLR_WXN (1U << 19)#define SCTLR_ST (1U << 20)/* up to ??, RAZ in v6 */ -#define SCTLR_UWXN (1U << 20)/* v7 onward */ -#define SCTLR_FI (1U << 21) -#define SCTLR_U (1U << 22) +#define SCTLR_UWXN (1U << 20)/* v7 onward, AArch32 only */ +#define SCTLR_FI (1U << 21)/* up to v7, v8 RES0 */ +#define SCTLR_IESB (1U << 21)/* v8.2-IESB, AArch64 only */ +#define SCTLR_U (1U << 22)/* up to v6, RAO in v7 */ +#define SCTLR_EIS (1U << 22)/* v8.5-ExS */ #define SCTLR_XP (1U << 23)/* up to v6; v7 onward RAO */ +#define SCTLR_SPAN (1U << 23)/* v8.1-PAN */ #define SCTLR_VE (1U << 24)/* up to v7 */ #define SCTLR_E0E (1U << 24)/* v8 onward, AArch64 only */ #define SCTLR_EE (1U << 25)#define SCTLR_L2 (1U << 26)/* up to v6, RAZ in v7 */ #define SCTLR_UCI (1U << 26)/* v8 onward, AArch64 only */ -#define SCTLR_NMFI (1U << 27) -#define SCTLR_TRE (1U << 28) -#define SCTLR_AFE (1U << 29) -#define SCTLR_TE (1U << 30) +#define SCTLR_NMFI (1U << 27)/* up to v7, RAZ in v7VE and v8 */ +#define SCTLR_EnDA (1U << 27)/* v8.3, AArch64 only */ +#define SCTLR_TRE (1U << 28)/* AArch32 only */ +#define SCTLR_nTLSMD_64 (1U << 28)/* v8.2-LSMAOC, AArch64 only */ +#define SCTLR_AFE (1U << 29)/* AArch32 only */ +#define SCTLR_LSMAOE_64 (1U << 29)/* v8.2-LSMAOC, AArch64 only */ +#define SCTLR_TE (1U << 30)/* AArch32 only */ +#define SCTLR_EnIB (1U << 30)/* v8.3, AArch64 only */ +#define SCTLR_EnIA (1U << 31)/* v8.3, AArch64 only */ +#define SCTLR_BT0 (1ULL << 35)/* v8.5-BTI */ +#define SCTLR_BT1 (1ULL << 36)/* v8.5-BTI */ +#define SCTLR_ITFSB (1ULL << 37)/* v8.5-MemTag */ +#define SCTLR_TCF0 (3ULL << 38)/* v8.5-MemTag */ +#define SCTLR_TCF (3ULL << 40)/* v8.5-MemTag */ +#define SCTLR_ATA0 (1ULL << 42)/* v8.5-MemTag */ +#define SCTLR_ATA (1ULL << 43)/* v8.5-MemTag */ +#define SCTLR_DSSBS (1ULL << 44)/* v8.5 */ #define CPTR_TCPAC (1U << 31)#define CPTR_TTA (1U << 20)
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 07/49] target/arm: Add PAuth active bit to tbflags
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
There are 5 bits of state that could be added, but to save space within tbflags, add only a single enable bit. Helpers will determine the rest of the state at runtime.
Message-id: [email protected]
--- target/arm/cpu.h | 1 + target/arm/translate.h | 2 ++ target/arm/helper.c | 19 +++++++++++++++++++ target/arm/translate-a64.c | 1 + 4 files changed, 23 insertions(+)
target/arm/cpu.h +1 -0
@@ -3014,6 +3014,7 @@ FIELD(TBFLAG_A64, TBI0, 0, 1) FIELD(TBFLAG_A64, TBI1, 1, 1) FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) +FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1)static inline bool bswap_code (bool sctlr_b) {
target/arm/translate.h +2 -0
@@ -68,6 +68,8 @@ typedef struct DisasContext {bool is_ldex;/* True if a single-step exception will be taken to the current EL */ bool ss_same_el; +/* True if v8.3-PAuth is active. */ +bool pauth_active;/* Bottom two bits of XScale c15_cpar coprocessor access control reg */ int c15_cpar;/* TCG op of the current insn_start. */
target/arm/helper.c +19 -0
@@ -12983,6 +12983,25 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags =FIELD_DP32 (flags,TBFLAG_A64 ,SVEEXC_EL , sve_el); flags =FIELD_DP32 (flags,TBFLAG_A64 ,ZCR_LEN , zcr_len); } + +if (cpu_isar_feature (aa64_pauth, cpu)) { +/* +* In order to save space in flags, we record only whether +* pauth is "inactive", meaning all insns are implemented as +* a nop, or "active" when some action must be performed. +* The decision of which action to take is left to a helper. +*/ +uint64_t sctlr; +if (current_el ==0 ) { +/* FIXME: ARMv8.1-VHE S2 translation regime. */ + sctlr = env->cp15.sctlr_el[1 ]; + }else { + sctlr = env->cp15.sctlr_el[current_el]; + } +if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { + flags =FIELD_DP32 (flags,TBFLAG_A64 ,PAUTH_ACTIVE ,1 ); + } + } }else { *pc = env->regs[15 ]; flags =FIELD_DP32 (flags,TBFLAG_A32 ,THUMB , env->thumb);
target/arm/translate-a64.c +1 -0
@@ -13409,6 +13409,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->fp_excp_el =FIELD_EX32 (tb_flags,TBFLAG_ANY ,FPEXC_EL ); dc->sve_excp_el =FIELD_EX32 (tb_flags,TBFLAG_A64 ,SVEEXC_EL ); dc->sve_len = (FIELD_EX32 (tb_flags,TBFLAG_A64 ,ZCR_LEN ) +1 ) *16 ; + dc->pauth_active =FIELD_EX32 (tb_flags,TBFLAG_A64 ,PAUTH_ACTIVE ); dc->vec_len =0 ; dc->vec_stride =0 ; dc->cp_regs = arm_cpu->cp_regs;
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 08/49] target/arm: Introduce raise_exception_ra
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
This path uses cpu_loop_exit_restore to unwind current processor state.
Message-id: [email protected]
--- target/arm/internals.h | 7 +++++++ target/arm/op_helper.c | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-)
target/arm/internals.h +7 -0
@@ -103,6 +103,13 @@ FIELD(V7M_EXCRET, RES1, 7, 25) /* including the must-be-1 prefix */ void QEMU_NORETURN raise_exception(CPUARMState *env, uint32_t excp,uint32_t syndrome,uint32_t target_el); +/* +* Similarly, but also use unwinding to restore cpu state. +*/ +void QEMU_NORETURN raise_exception_ra(CPUARMState *env, uint32_t excp, +uint32_t syndrome,uint32_t target_el, +uintptr_t ra); +/* * For AArch64, map a given EL to an index in the banked_spsr array. * Note that this mapping and the AArch32 mapping defined in bank_number()
target/arm/op_helper.c +17 -2
@@ -28,8 +28,8 @@#define SIGNBIT (uint32_t)0x80000000#define SIGNBIT64 ((uint64_t)1 << 63) -void raise_exception (CPUARMState *env,uint32_t excp, -uint32_t syndrome,uint32_t target_el) +static CPUState *do_raise_exception (CPUARMState *env,uint32_t excp, +uint32_t syndrome,uint32_t target_el) {CPUState *cs =CPU (arm_env_get_cpu (env));
@@ -50,9 +50,24 @@ void raise_exception(CPUARMState *env, uint32_t excp, cs->exception_index = excp; env->exception.syndrome = syndrome; env->exception.target_el = target_el; + +return cs; +} + +void raise_exception (CPUARMState *env,uint32_t excp, +uint32_t syndrome,uint32_t target_el) +{ +CPUState *cs =do_raise_exception (env, excp, syndrome, target_el);cpu_loop_exit (cs); } +void raise_exception_ra (CPUARMState *env,uint32_t excp,uint32_t syndrome, +uint32_t target_el,uintptr_t ra) +{ +CPUState *cs =do_raise_exception (env, excp, syndrome, target_el); +cpu_loop_exit_restore (cs, ra); +} +static int exception_target_el (CPUARMState *env) {int target_el =MAX (1 ,arm_current_el (env));
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 21/49] target/arm: Introduce arm_stage1_mmu_idx
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
While we could expose stage_1_mmu_idx, the combination is probably going to be more useful.
Message-id: [email protected]
--- target/arm/internals.h | 15 +++++++++++++++ target/arm/helper.c | 7 +++++++ 2 files changed, 22 insertions(+)
target/arm/internals.h +15 -0
@@ -927,4 +927,19 @@ void arm_cpu_update_vfiq(ARMCPU *cpu);*/ ARMMMUIdx arm_mmu_idx (CPUARMState *env); +/** +* arm_stage1_mmu_idx: +* @env: The cpu environment +* +* Return the ARMMMUIdx for the stage1 traversal for the current regime. +*/ +#ifdef CONFIG_USER_ONLY +static inline ARMMMUIdx arm_stage1_mmu_idx (CPUARMState *env) +{ +return ARMMMUIdx_S1NSE0; +} +#else +ARMMMUIdx arm_stage1_mmu_idx (CPUARMState *env); +#endif +#endif
target/arm/helper.c +7 -0
@@ -12998,6 +12998,13 @@ int cpu_mmu_index(CPUARMState *env, bool ifetch)return arm_to_core_mmu_idx (arm_mmu_idx (env)); } +#ifndef CONFIG_USER_ONLY +ARMMMUIdx arm_stage1_mmu_idx (CPUARMState *env) +{ +return stage_1_mmu_idx (arm_mmu_idx (env)); +} +#endif +void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *pflags) {
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 11/49] target/arm: Rearrange decode in disas_data_proc_1src
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Now properly signals unallocated for REV64 with SF=0. Allows for the opcode2 field to be decoded shortly.
Message-id: [email protected]
--- target/arm/translate-a64.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-)
target/arm/translate-a64.c +22 -9
@@ -4563,38 +4563,51 @@ static void handle_rev16(DisasContext *s, unsigned int sf,*/ static void disas_data_proc_1src (DisasContext *s,uint32_t insn) { -unsigned int sf, opcode, rn, rd; +unsigned int sf, opcode, opcode2, rn, rd; -if (extract32 (insn,29 ,1 ) ||extract32 (insn,16 ,5 )) { +if (extract32 (insn,29 ,1 )) {unallocated_encoding (s);return ; } sf =extract32 (insn,31 ,1 ); opcode =extract32 (insn,10 ,6 ); + opcode2 =extract32 (insn,16 ,5 ); rn =extract32 (insn,5 ,5 ); rd =extract32 (insn,0 ,5 ); -switch (opcode) { -case 0 :/* RBIT */ +#define MAP (SF ,O2 ,O1 ) ((SF) | (O1 << 1) | (O2 << 7)) + +switch (MAP (sf, opcode2, opcode)) { +case MAP (0 ,0x00 ,0x00 ):/* RBIT */ +case MAP (1 ,0x00 ,0x00 ):handle_rbit (s, sf, rn, rd);break ; -case 1 :/* REV16 */ +case MAP (0 ,0x00 ,0x01 ):/* REV16 */ +case MAP (1 ,0x00 ,0x01 ):handle_rev16 (s, sf, rn, rd);break ; -case 2 :/* REV32 */ +case MAP (0 ,0x00 ,0x02 ):/* REV/REV32 */ +case MAP (1 ,0x00 ,0x02 ):handle_rev32 (s, sf, rn, rd);break ; -case 3 :/* REV64 */ +case MAP (1 ,0x00 ,0x03 ):/* REV64 */ handle_rev64 (s, sf, rn, rd);break ; -case 4 :/* CLZ */ +case MAP (0 ,0x00 ,0x04 ):/* CLZ */ +case MAP (1 ,0x00 ,0x04 ):handle_clz (s, sf, rn, rd);break ; -case 5 :/* CLS */ +case MAP (0 ,0x00 ,0x05 ):/* CLS */ +case MAP (1 ,0x00 ,0x05 ):handle_cls (s, sf, rn, rd);break ; +default : +unallocated_encoding (s); +break ; } + +#undef MAP } static void handle_div(DisasContext *s, bool is_signed, unsigned int sf,
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 13/49] target/arm: Decode PAuth within disas_data_proc_2src
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/translate-a64.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target/arm/translate-a64.c +8 -0
@@ -4884,6 +4884,13 @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn)case 11 :/* RORV */ handle_shift_reg (s,A64_SHIFT_TYPE_ROR , sf, rm, rn, rd);break ; +case 12 :/* PACGA */ +if (sf ==0 || !dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +gen_helper_pacga (cpu_reg (s, rd), cpu_env, +cpu_reg (s, rn),cpu_reg_sp (s, rm)); +break ;case 16 :case 17 :case 18 :
@@ -4899,6 +4906,7 @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn)break ; }default : + do_unallocated:unallocated_encoding (s);break ; }
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 15/49] target/arm: Add new_pc argument to helper_exception_return
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/helper-a64.h | 2 +- target/arm/helper-a64.c | 10 +++++----- target/arm/translate-a64.c | 7 ++++++- 3 files changed, 12 insertions(+), 7 deletions(-)
target/arm/helper-a64.h +1 -1
@@ -86,7 +86,7 @@ DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) DEF_HELPER_2(sqrt_f16, f16, f16, ptr) -DEF_HELPER_1(exception_return, void, env) +DEF_HELPER_2(exception_return, void, env, i64) DEF_HELPER_FLAGS_3(pacia, TCG_CALL_NO_WG, i64, env, i64, i64)DEF_HELPER_FLAGS_3 (pacib,TCG_CALL_NO_WG , i64, env, i64, i64)
target/arm/helper-a64.c +5 -5
@@ -925,7 +925,7 @@ static int el_from_spsr(uint32_t spsr) } } -void HELPER (exception_return )(CPUARMState *env) +void HELPER (exception_return )(CPUARMState *env,uint64_t new_pc) {int cur_el =arm_current_el (env);unsigned int spsr_idx =aarch64_banked_spsr_index (cur_el);
@@ -991,9 +991,9 @@ void HELPER(exception_return)(CPUARMState *env)aarch64_sync_64_to_32 (env);if (spsr &CPSR_T ) { - env->regs[15 ] = env->elr_el[cur_el] & ~0x1 ; + env->regs[15 ] = new_pc & ~0x1 ; }else { - env->regs[15 ] = env->elr_el[cur_el] & ~0x3 ; + env->regs[15 ] = new_pc & ~0x3 ; } qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " "AArch32 EL%d PC 0x%" PRIx32 "\n",
@@ -1005,7 +1005,7 @@ void HELPER(exception_return)(CPUARMState *env) env->pstate &= ~PSTATE_SS ; }aarch64_restore_sp (env, new_el); - env->pc = env->elr_el[cur_el]; + env->pc = new_pc;qemu_log_mask (CPU_LOG_INT ,"Exception return from AArch64 EL%d to " "AArch64 EL%d PC 0x%" PRIx64"\n" , cur_el, new_el, env->pc);
@@ -1031,7 +1031,7 @@ illegal_return:* no change to exception level, execution state or stack pointer */ env->pstate |=PSTATE_IL ; - env->pc = env->elr_el[cur_el]; + env->pc = new_pc; spsr &=PSTATE_NZCV |PSTATE_DAIF ; spsr |=pstate_read (env) & ~(PSTATE_NZCV |PSTATE_DAIF );pstate_write (env, spsr);
target/arm/translate-a64.c +6 -1
@@ -1981,6 +1981,7 @@ static void disas_exc(DisasContext *s, uint32_t insn)static void disas_uncond_b_reg (DisasContext *s,uint32_t insn) {unsigned int opc, op2, op3, rn, op4; +TCGv_i64 dst; opc =extract32 (insn,21 ,4 ); op2 =extract32 (insn,16 ,5 );
@@ -2011,7 +2012,11 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)if (tb_cflags (s->base.tb) &CF_USE_ICOUNT ) {gen_io_start (); } -gen_helper_exception_return (cpu_env); + dst =tcg_temp_new_i64 (); +tcg_gen_ld_i64 (dst, cpu_env, + offsetof(CPUARMState, elr_el[s->current_el])); +gen_helper_exception_return (cpu_env, dst); +tcg_temp_free_i64 (dst);if (tb_cflags (s->base.tb) &CF_USE_ICOUNT ) {gen_io_end (); }
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 18/49] target/arm: Decode Load/store register (pac)
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Not that there are any stores involved, but why argue with ARM's naming convention.
Message-id: [email protected]
--- target/arm/translate-a64.c | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
target/arm/translate-a64.c +61 -0
@@ -3146,6 +3146,64 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, s->be_data | size | MO_ALIGN); } +/* +* PAC memory operations +* +* 31 30 27 26 24 22 21 12 11 10 5 0 +* +------+-------+---+-----+-----+---+--------+---+---+----+-----+ +* | size | 1 1 1 | V | 0 0 | M S | 1 | imm9 | W | 1 | Rn | Rt | +* +------+-------+---+-----+-----+---+--------+---+---+----+-----+ +* +* Rt: the result register +* Rn: base address or SP +* V: vector flag (always 0 as of v8.3) +* M: clear for key DA, set for key DB +* W: pre-indexing flag +* S: sign for imm9. +*/ +static void disas_ldst_pac (DisasContext *s,uint32_t insn, +int size,int rt,bool is_vector) +{ +int rn =extract32 (insn,5 ,5 ); +bool is_wback =extract32 (insn,11 ,1 ); +bool use_key_a = !extract32 (insn,23 ,1 ); +int offset; +TCGv_i64 tcg_addr, tcg_rt; + +if (size !=3 || is_vector || !dc_isar_feature (aa64_pauth, s)) { +unallocated_encoding (s); +return ; + } + +if (rn ==31 ) { +gen_check_sp_alignment (s); + } + tcg_addr =read_cpu_reg_sp (s, rn,1 ); + +if (s->pauth_active) { +if (use_key_a) { +gen_helper_autda (tcg_addr, cpu_env, tcg_addr, cpu_X[31 ]); + }else { +gen_helper_autdb (tcg_addr, cpu_env, tcg_addr, cpu_X[31 ]); + } + } + +/* Form the 10-bit signed, scaled offset. */ + offset = (extract32 (insn,22 ,1 ) <<9 ) |extract32 (insn,12 ,9 ); + offset =sextract32 (offset << size,0 ,10 + size); +tcg_gen_addi_i64 (tcg_addr, tcg_addr, offset); + + tcg_rt =cpu_reg (s, rt); + +do_gpr_ld (s, tcg_rt, tcg_addr, size,/* is_signed */ false, +/* extend */ false,/* iss_valid */ !is_wback, +/* iss_srt */ rt,/* iss_sf */ true,/* iss_ar */ false); + +if (is_wback) { +tcg_gen_mov_i64 (cpu_reg_sp (s, rn), tcg_addr); + } +} +/* Load/store register (all forms) */ static void disas_ldst_reg (DisasContext *s,uint32_t insn) {
@@ -3171,6 +3229,9 @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn)case 2 :disas_ldst_reg_roffset (s, insn, opc, size, rt, is_vector);return ; +default : +disas_ldst_pac (s, insn, size, rt, is_vector); +return ; }break ;case 1 :
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 10/49] target/arm: Decode PAuth within system hint space
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/translate-a64.c | 93 +++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 12 deletions(-)
target/arm/translate-a64.c +81 -12
@@ -1471,33 +1471,102 @@ static void handle_hint(DisasContext *s, uint32_t insn, }switch (selector) { -case 0 :/* NOP */ -return ; -case 3 :/* WFI */ +case 0b00000 :/* NOP */ +break ; +case 0b00011 :/* WFI */ s->base.is_jmp =DISAS_WFI ; -return ; +break ; +case 0b00001 :/* YIELD */ /* When running in MTTCG we don't generate jumps to the yield and * WFE helpers as it won't affect the scheduling of other vCPUs. * If we wanted to more completely model WFE/SEV so we don't busy * spin unnecessarily we would need to do something more involved. */ -case 1 :/* YIELD */ if (!(tb_cflags (s->base.tb) &CF_PARALLEL )) { s->base.is_jmp =DISAS_YIELD ; } -return ; -case 2 :/* WFE */ +break ; +case 0b00010 :/* WFE */ if (!(tb_cflags (s->base.tb) &CF_PARALLEL )) { s->base.is_jmp =DISAS_WFE ; } -return ; -case 4 :/* SEV */ -case 5 :/* SEVL */ +break ; +case 0b00100 :/* SEV */ +case 0b00101 :/* SEVL */ /* we treat all as NOP at least for now */ -return ; +break ; +case 0b00111 :/* XPACLRI */ +if (s->pauth_active) { +gen_helper_xpaci (cpu_X[30 ], cpu_env, cpu_X[30 ]); + } +break ; +case 0b01000 :/* PACIA1716 */ +if (s->pauth_active) { +gen_helper_pacia (cpu_X[17 ], cpu_env, cpu_X[17 ], cpu_X[16 ]); + } +break ; +case 0b01010 :/* PACIB1716 */ +if (s->pauth_active) { +gen_helper_pacib (cpu_X[17 ], cpu_env, cpu_X[17 ], cpu_X[16 ]); + } +break ; +case 0b01100 :/* AUTIA1716 */ +if (s->pauth_active) { +gen_helper_autia (cpu_X[17 ], cpu_env, cpu_X[17 ], cpu_X[16 ]); + } +break ; +case 0b01110 :/* AUTIB1716 */ +if (s->pauth_active) { +gen_helper_autib (cpu_X[17 ], cpu_env, cpu_X[17 ], cpu_X[16 ]); + } +break ; +case 0b11000 :/* PACIAZ */ +if (s->pauth_active) { +gen_helper_pacia (cpu_X[30 ], cpu_env, cpu_X[30 ], +new_tmp_a64_zero (s)); + } +break ; +case 0b11001 :/* PACIASP */ +if (s->pauth_active) { +gen_helper_pacia (cpu_X[30 ], cpu_env, cpu_X[30 ], cpu_X[31 ]); + } +break ; +case 0b11010 :/* PACIBZ */ +if (s->pauth_active) { +gen_helper_pacib (cpu_X[30 ], cpu_env, cpu_X[30 ], +new_tmp_a64_zero (s)); + } +break ; +case 0b11011 :/* PACIBSP */ +if (s->pauth_active) { +gen_helper_pacib (cpu_X[30 ], cpu_env, cpu_X[30 ], cpu_X[31 ]); + } +break ; +case 0b11100 :/* AUTIAZ */ +if (s->pauth_active) { +gen_helper_autia (cpu_X[30 ], cpu_env, cpu_X[30 ], +new_tmp_a64_zero (s)); + } +break ; +case 0b11101 :/* AUTIASP */ +if (s->pauth_active) { +gen_helper_autia (cpu_X[30 ], cpu_env, cpu_X[30 ], cpu_X[31 ]); + } +break ; +case 0b11110 :/* AUTIBZ */ +if (s->pauth_active) { +gen_helper_autib (cpu_X[30 ], cpu_env, cpu_X[30 ], +new_tmp_a64_zero (s)); + } +break ; +case 0b11111 :/* AUTIBSP */ +if (s->pauth_active) { +gen_helper_autib (cpu_X[30 ], cpu_env, cpu_X[30 ], cpu_X[31 ]); + } +break ;default :/* default specified as NOP equivalent */ -return ; +break ; } }
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 24/49] target/arm: Export aa64_va_parameters to internals.h
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
We need to reuse this from helper-a64.c. Provide a stub definition for CONFIG_USER_ONLY. This matches the stub definitions that we removed for arm_regime_tbi{0,1} before.
Message-id: [email protected]
--- target/arm/internals.h | 17 +++++++++++++++++ target/arm/helper.c | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-)
target/arm/internals.h +17 -0
@@ -956,4 +956,21 @@ typedef struct ARMVAParameters { bool using64k : 1; } ARMVAParameters; +#ifdef CONFIG_USER_ONLY +static inline ARMVAParameters aa64_va_parameters (CPUARMState *env, +uint64_t va, +ARMMMUIdx mmu_idx,bool data) +{ +return (ARMVAParameters ) { +/* 48-bit address space */ + .tsz =16 , +/* We can't handle tagged addresses properly in user-only mode */ + .tbi = false, + }; +} +#else +ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va, +ARMMMUIdx mmu_idx,bool data); +#endif +#endif
target/arm/helper.c +2 -2
@@ -9744,8 +9744,8 @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs)return (hiattr <<6 ) | (hihint <<4 ) | (loattr <<2 ) | lohint; } -static ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va, -ARMMMUIdx mmu_idx,bool data) +ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va, +ARMMMUIdx mmu_idx,bool data) {uint64_t tcr =regime_tcr (env, mmu_idx)->raw_tcr;uint32_t el =regime_el (env, mmu_idx);
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 25/49] target/arm: Add aa64_va_parameters_both
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
We will want to check TBI for I and D simultaneously.
Message-id: [email protected]
--- target/arm/internals.h | 15 ++++++++++++--- target/arm/helper.c | 10 ++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-)
target/arm/internals.h +12 -3
@@ -957,9 +957,9 @@ typedef struct ARMVAParameters { } ARMVAParameters; #ifdef CONFIG_USER_ONLY -static inline ARMVAParameters aa64_va_parameters(CPUARMState *env, - uint64_t va, - ARMMMUIdx mmu_idx, bool data) +static inline ARMVAParameters aa64_va_parameters_both(CPUARMState *env, + uint64_t va, + ARMMMUIdx mmu_idx) { return (ARMVAParameters) { /* 48-bit address space */
@@ -968,7 +968,16 @@ static inline ARMVAParameters aa64_va_parameters(CPUARMState *env, .tbi = false, }; } + +static inline ARMVAParameters aa64_va_parameters (CPUARMState *env, +uint64_t va, +ARMMMUIdx mmu_idx,bool data) +{ +return aa64_va_parameters_both (env, va, mmu_idx); +}#else +ARMVAParameters aa64_va_parameters_both (CPUARMState *env,uint64_t va, +ARMMMUIdx mmu_idx);ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va,ARMMMUIdx mmu_idx,bool data);#endif
target/arm/helper.c +8 -2
@@ -9744,8 +9744,8 @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs)return (hiattr <<6 ) | (hihint <<4 ) | (loattr <<2 ) | lohint; } -ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va, -ARMMMUIdx mmu_idx,bool data) +ARMVAParameters aa64_va_parameters_both (CPUARMState *env,uint64_t va, +ARMMMUIdx mmu_idx) {uint64_t tcr =regime_tcr (env, mmu_idx)->raw_tcr;uint32_t el =regime_el (env, mmu_idx);
@@ -9800,6 +9800,12 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, }; } +ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va, +ARMMMUIdx mmu_idx,bool data) +{ +return aa64_va_parameters_both (env, va, mmu_idx); +} +static ARMVAParameters aa32_va_parameters (CPUARMState *env,uint32_t va,ARMMMUIdx mmu_idx) {
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 12/49] target/arm: Decode PAuth within disas_data_proc_1src
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/translate-a64.c | 146 +++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+)
target/arm/translate-a64.c +146 -0
@@ -4564,6 +4564,7 @@ static void handle_rev16(DisasContext *s, unsigned int sf,static void disas_data_proc_1src (DisasContext *s,uint32_t insn) {unsigned int sf, opcode, opcode2, rn, rd; +TCGv_i64 tcg_rd;if (extract32 (insn,29 ,1 )) {unallocated_encoding (s);
@@ -4602,7 +4603,152 @@ static void disas_data_proc_1src(DisasContext *s, uint32_t insn)case MAP (1 ,0x00 ,0x05 ):handle_cls (s, sf, rn, rd);break ; +case MAP (1 ,0x01 ,0x00 ):/* PACIA */ +if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_pacia (tcg_rd, cpu_env, tcg_rd,cpu_reg_sp (s, rn)); + }else if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +break ; +case MAP (1 ,0x01 ,0x01 ):/* PACIB */ +if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_pacib (tcg_rd, cpu_env, tcg_rd,cpu_reg_sp (s, rn)); + }else if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +break ; +case MAP (1 ,0x01 ,0x02 ):/* PACDA */ +if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_pacda (tcg_rd, cpu_env, tcg_rd,cpu_reg_sp (s, rn)); + }else if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +break ; +case MAP (1 ,0x01 ,0x03 ):/* PACDB */ +if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_pacdb (tcg_rd, cpu_env, tcg_rd,cpu_reg_sp (s, rn)); + }else if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +break ; +case MAP (1 ,0x01 ,0x04 ):/* AUTIA */ +if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_autia (tcg_rd, cpu_env, tcg_rd,cpu_reg_sp (s, rn)); + }else if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +break ; +case MAP (1 ,0x01 ,0x05 ):/* AUTIB */ +if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_autib (tcg_rd, cpu_env, tcg_rd,cpu_reg_sp (s, rn)); + }else if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +break ; +case MAP (1 ,0x01 ,0x06 ):/* AUTDA */ +if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_autda (tcg_rd, cpu_env, tcg_rd,cpu_reg_sp (s, rn)); + }else if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +break ; +case MAP (1 ,0x01 ,0x07 ):/* AUTDB */ +if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_autdb (tcg_rd, cpu_env, tcg_rd,cpu_reg_sp (s, rn)); + }else if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +break ; +case MAP (1 ,0x01 ,0x08 ):/* PACIZA */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_pacia (tcg_rd, cpu_env, tcg_rd,new_tmp_a64_zero (s)); + } +break ; +case MAP (1 ,0x01 ,0x09 ):/* PACIZB */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_pacib (tcg_rd, cpu_env, tcg_rd,new_tmp_a64_zero (s)); + } +break ; +case MAP (1 ,0x01 ,0x0a ):/* PACDZA */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_pacda (tcg_rd, cpu_env, tcg_rd,new_tmp_a64_zero (s)); + } +break ; +case MAP (1 ,0x01 ,0x0b ):/* PACDZB */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_pacdb (tcg_rd, cpu_env, tcg_rd,new_tmp_a64_zero (s)); + } +break ; +case MAP (1 ,0x01 ,0x0c ):/* AUTIZA */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_autia (tcg_rd, cpu_env, tcg_rd,new_tmp_a64_zero (s)); + } +break ; +case MAP (1 ,0x01 ,0x0d ):/* AUTIZB */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_autib (tcg_rd, cpu_env, tcg_rd,new_tmp_a64_zero (s)); + } +break ; +case MAP (1 ,0x01 ,0x0e ):/* AUTDZA */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_autda (tcg_rd, cpu_env, tcg_rd,new_tmp_a64_zero (s)); + } +break ; +case MAP (1 ,0x01 ,0x0f ):/* AUTDZB */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_autdb (tcg_rd, cpu_env, tcg_rd,new_tmp_a64_zero (s)); + } +break ; +case MAP (1 ,0x01 ,0x10 ):/* XPACI */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_xpaci (tcg_rd, cpu_env, tcg_rd); + } +break ; +case MAP (1 ,0x01 ,0x11 ):/* XPACD */ +if (!dc_isar_feature (aa64_pauth, s) || rn !=31 ) { + goto do_unallocated; + }else if (s->pauth_active) { + tcg_rd =cpu_reg (s, rd); +gen_helper_xpacd (tcg_rd, cpu_env, tcg_rd); + } +break ;default : + do_unallocated:unallocated_encoding (s);break ; }
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 16/49] target/arm: Rearrange decode in disas_uncond_b_reg
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
This will enable PAuth decode in a subsequent patch.
Message-id: [email protected]
--- target/arm/translate-a64.c | 47 +++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-)
target/arm/translate-a64.c +36 -11
@@ -1989,32 +1989,54 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) rn =extract32 (insn,5 ,5 ); op4 =extract32 (insn,0 ,5 ); -if (op4 !=0x0 || op3 !=0x0 || op2 !=0x1f ) { -unallocated_encoding (s); -return ; +if (op2 !=0x1f ) { + goto do_unallocated; }switch (opc) {case 0 :/* BR */ case 1 :/* BLR */ case 2 :/* RET */ -gen_a64_set_pc (s,cpu_reg (s, rn)); +switch (op3) { +case 0 : +if (op4 !=0 ) { + goto do_unallocated; + } + dst =cpu_reg (s, rn); +break ; + +default : + goto do_unallocated; + } + +gen_a64_set_pc (s, dst);/* BLR also needs to load return address */ if (opc ==1 ) {tcg_gen_movi_i64 (cpu_reg (s,30 ), s->pc); }break ; +case 4 :/* ERET */ if (s->current_el ==0 ) { -unallocated_encoding (s); -return ; + goto do_unallocated; + } +switch (op3) { +case 0 : +if (op4 !=0 ) { + goto do_unallocated; + } + dst =tcg_temp_new_i64 (); +tcg_gen_ld_i64 (dst, cpu_env, + offsetof(CPUARMState, elr_el[s->current_el])); +break ; + +default : + goto do_unallocated; }if (tb_cflags (s->base.tb) &CF_USE_ICOUNT ) {gen_io_start (); } - dst =tcg_temp_new_i64 (); -tcg_gen_ld_i64 (dst, cpu_env, - offsetof(CPUARMState, elr_el[s->current_el])); +gen_helper_exception_return (cpu_env, dst);tcg_temp_free_i64 (dst);if (tb_cflags (s->base.tb) &CF_USE_ICOUNT ) {
@@ -2023,14 +2045,17 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)/* Must exit loop to check un-masked IRQs */ s->base.is_jmp =DISAS_EXIT ;return ; +case 5 :/* DRPS */ -if (rn !=0x1f ) { -unallocated_encoding (s); +if (op3 !=0 || op4 !=0 || rn !=0x1f ) { + goto do_unallocated; }else {unsupported_encoding (s, insn); }return ; +default : + do_unallocated:unallocated_encoding (s);return ; }
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 28/49] target/arm: Implement pauth_strip
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Stripping out the authentication data does not require any crypto, it merely requires the virtual address parameters.
Message-id: [email protected]
--- target/arm/pauth_helper.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
target/arm/pauth_helper.c +13 -1
@@ -38,6 +38,15 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,g_assert_not_reached ();/* FIXME */ } +static uint64_t pauth_original_ptr (uint64_t ptr,ARMVAParameters param) +{ +uint64_t extfield = -param.select; +int bot_pac_bit =64 - param.tsz; +int top_pac_bit =64 -8 * param.tbi; + +return deposit64 (ptr, bot_pac_bit, top_pac_bit - bot_pac_bit, extfield); +} +static uint64_t pauth_auth (CPUARMState *env,uint64_t ptr,uint64_t modifier,ARMPACKey *key,bool data,int keynumber) {
@@ -46,7 +55,10 @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,static uint64_t pauth_strip (CPUARMState *env,uint64_t ptr,bool data) { -g_assert_not_reached ();/* FIXME */ +ARMMMUIdx mmu_idx =arm_stage1_mmu_idx (env); +ARMVAParameters param =aa64_va_parameters (env, ptr, mmu_idx, data); + +return pauth_original_ptr (ptr, param); } static void QEMU_NORETURN pauth_trap(CPUARMState *env, int target_el,
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 17/49] target/arm: Decode PAuth within disas_uncond_b_reg
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/translate-a64.c | 82 +++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-)
target/arm/translate-a64.c +81 -1
@@ -1982,6 +1982,7 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) {unsigned int opc, op2, op3, rn, op4;TCGv_i64 dst; +TCGv_i64 modifier; opc =extract32 (insn,21 ,4 ); op2 =extract32 (insn,16 ,5 );
@@ -1999,12 +2000,44 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)case 2 :/* RET */ switch (op3) {case 0 : +/* BR, BLR, RET */ if (op4 !=0 ) { goto do_unallocated; } dst =cpu_reg (s, rn);break ; +case 2 : +case 3 : +if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +if (opc ==2 ) { +/* RETAA, RETAB */ +if (rn !=0x1f || op4 !=0x1f ) { + goto do_unallocated; + } + rn =30 ; + modifier = cpu_X[31 ]; + }else { +/* BRAAZ, BRABZ, BLRAAZ, BLRABZ */ +if (op4 !=0x1f ) { + goto do_unallocated; + } + modifier =new_tmp_a64_zero (s); + } +if (s->pauth_active) { + dst =new_tmp_a64 (s); +if (op3 ==2 ) { +gen_helper_autia (dst, cpu_env,cpu_reg (s, rn), modifier); + }else { +gen_helper_autib (dst, cpu_env,cpu_reg (s, rn), modifier); + } + }else { + dst =cpu_reg (s, rn); + } +break ; +default : goto do_unallocated; }
@@ -2016,12 +2049,38 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) }break ; +case 8 :/* BRAA */ +case 9 :/* BLRAA */ +if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +if (op3 !=2 || op3 !=3 ) { + goto do_unallocated; + } +if (s->pauth_active) { + dst =new_tmp_a64 (s); + modifier =cpu_reg_sp (s, op4); +if (op3 ==2 ) { +gen_helper_autia (dst, cpu_env,cpu_reg (s, rn), modifier); + }else { +gen_helper_autib (dst, cpu_env,cpu_reg (s, rn), modifier); + } + }else { + dst =cpu_reg (s, rn); + } +gen_a64_set_pc (s, dst); +/* BLRAA also needs to load return address */ +if (opc ==9 ) { +tcg_gen_movi_i64 (cpu_reg (s,30 ), s->pc); + } +break ; +case 4 :/* ERET */ if (s->current_el ==0 ) { goto do_unallocated; }switch (op3) { -case 0 : +case 0 :/* ERET */ if (op4 !=0 ) { goto do_unallocated; }
@@ -2030,6 +2089,27 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) offsetof(CPUARMState, elr_el[s->current_el]));break ; +case 2 :/* ERETAA */ +case 3 :/* ERETAB */ +if (!dc_isar_feature (aa64_pauth, s)) { + goto do_unallocated; + } +if (rn !=0x1f || op4 !=0x1f ) { + goto do_unallocated; + } + dst =tcg_temp_new_i64 (); +tcg_gen_ld_i64 (dst, cpu_env, + offsetof(CPUARMState, elr_el[s->current_el])); +if (s->pauth_active) { + modifier = cpu_X[31 ]; +if (op3 ==2 ) { +gen_helper_autia (dst, cpu_env, dst, modifier); + }else { +gen_helper_autib (dst, cpu_env, dst, modifier); + } + } +break ; +default : goto do_unallocated; }
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 20/49] target/arm: Introduce arm_mmu_idx
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
The pattern
ARMMMUIdx mmu_idx = core_to_arm_mmu_idx(env, cpu_mmu_index(env, false));
is computing the full ARMMMUIdx, stripping off the ARM bits, and then putting them back.
Avoid the extra two steps with the appropriate helper function.
Message-id: [email protected]
--- target/arm/cpu.h | 9 ++++++++- target/arm/internals.h | 8 ++++++++ target/arm/helper.c | 27 ++++++++++++++++----------- 3 files changed, 32 insertions(+), 12 deletions(-)
target/arm/cpu.h +8 -1
@@ -2749,7 +2749,14 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,/* Return the MMU index for a v7M CPU in the specified security state */ ARMMMUIdx arm_v7m_mmu_idx_for_secstate (CPUARMState *env,bool secstate); -/* Determine the current mmu_idx to use for normal loads/stores */ +/** +* cpu_mmu_index: +* @env: The cpu environment +* @ifetch: True for code access, false for data access. +* +* Return the core mmu index for the current translation regime. +* This function is used by generic TCG code paths. +*/ int cpu_mmu_index (CPUARMState *env,bool ifetch);/* Indexes used when registering address spaces with cpu_address_space_init */
target/arm/internals.h +8 -0
@@ -919,4 +919,12 @@ void arm_cpu_update_virq(ARMCPU *cpu);*/ void arm_cpu_update_vfiq (ARMCPU *cpu); +/** +* arm_mmu_idx: +* @env: The cpu environment +* +* Return the full ARMMMUIdx for the current translation regime. +*/ +ARMMMUIdx arm_mmu_idx (CPUARMState *env); +#endif
target/arm/helper.c +16 -11
@@ -7117,7 +7117,7 @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, limit = env->v7m.msplim[M_REG_S ]; } }else { - mmu_idx =core_to_arm_mmu_idx (env,cpu_mmu_index (env, false)); + mmu_idx =arm_mmu_idx (env); frame_sp_p = &env->regs[13 ]; limit =v7m_sp_limit (env); }
@@ -7298,7 +7298,7 @@ static bool v7m_push_stack(ARMCPU *cpu)CPUARMState *env = &cpu->env;uint32_t xpsr =xpsr_read (env);uint32_t frameptr = env->regs[13 ]; -ARMMMUIdx mmu_idx =core_to_arm_mmu_idx (env,cpu_mmu_index (env, false)); +ARMMMUIdx mmu_idx =arm_mmu_idx (env);/* Align stack pointer if the guest wants that */ if ((frameptr & 4) &&
@@ -11073,7 +11073,7 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,int prot;bool ret;ARMMMUFaultInfo fi = {}; -ARMMMUIdx mmu_idx =core_to_arm_mmu_idx (env,cpu_mmu_index (env, false)); +ARMMMUIdx mmu_idx =arm_mmu_idx (env); *attrs = (MemTxAttrs ) {};
@@ -12977,26 +12977,31 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)return arm_v7m_mmu_idx_for_secstate_and_priv (env, secstate, priv); } -int cpu_mmu_index (CPUARMState *env,bool ifetch) +ARMMMUIdx arm_mmu_idx (CPUARMState *env) { -int el =arm_current_el (env); +int el;if (arm_feature (env,ARM_FEATURE_M )) { -ARMMMUIdx mmu_idx =arm_v7m_mmu_idx_for_secstate (env, env->v7m.secure); - -return arm_to_core_mmu_idx (mmu_idx); +return arm_v7m_mmu_idx_for_secstate (env, env->v7m.secure); } + el =arm_current_el (env);if (el <2 &&arm_is_secure_below_el3 (env)) { -return arm_to_core_mmu_idx (ARMMMUIdx_S1SE0 + el); +return ARMMMUIdx_S1SE0 + el; + }else { +return ARMMMUIdx_S12NSE0 + el; } -return el; +} + +int cpu_mmu_index (CPUARMState *env,bool ifetch) +{ +return arm_to_core_mmu_idx (arm_mmu_idx (env)); }void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *pflags) { -ARMMMUIdx mmu_idx =core_to_arm_mmu_idx (env,cpu_mmu_index (env, false)); +ARMMMUIdx mmu_idx =arm_mmu_idx (env);int current_el =arm_current_el (env);int fp_el =fp_exception_el (env, current_el);uint32_t flags =0 ;
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 23/49] target/arm: Merge TBFLAG_AA_TB{0, 1} to TBII
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
We will shortly want to talk about TBI as it relates to data. Passing around a pair of variables is less convenient than a single variable.
Message-id: [email protected]
--- target/arm/cpu.h | 3 +-- target/arm/translate.h | 3 +-- target/arm/helper.c | 5 ++--- target/arm/translate-a64.c | 13 +++++++------ 4 files changed, 11 insertions(+), 13 deletions(-)
target/arm/cpu.h +1 -2
@@ -2979,8 +2979,7 @@ FIELD(TBFLAG_A32, HANDLER, 21, 1)FIELD (TBFLAG_A32 ,STACKCHECK ,22 ,1 ) /* Bit usage when in AArch64 state */ -FIELD(TBFLAG_A64, TBI0, 0, 1) -FIELD(TBFLAG_A64, TBI1, 1, 1) +FIELD(TBFLAG_A64, TBII, 0, 2) FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) FIELD(TBFLAG_A64, ZCR_LEN, 4, 4)FIELD (TBFLAG_A64 ,PAUTH_ACTIVE ,8 ,1 )
target/arm/translate.h +1 -2
@@ -26,8 +26,7 @@ typedef struct DisasContext {int user;#endif ARMMMUIdx mmu_idx;/* MMU index to use for normal loads/stores */ -bool tbi0;/* TBI0 for EL0/1 or TBI for EL2/3 */ -bool tbi1;/* TBI1 for EL0/1, not used for EL2/3 */ +uint8_t tbii;/* TBI1|TBI0 for EL0/1 or TBI for EL2/3 */ bool ns;/* Use non-secure CPREG bank on access */ int fp_excp_el;/* FP exception EL or 0 if enabled */ int sve_excp_el;/* SVE exception EL or 0 if enabled */
target/arm/helper.c +2 -3
@@ -13041,10 +13041,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, *pc = env->pc; flags =FIELD_DP32 (flags,TBFLAG_ANY ,AARCH64_STATE ,1 );/* Get control bits for tagged addresses */ - flags =FIELD_DP32 (flags,TBFLAG_A64 ,TBI0 , + flags =FIELD_DP32 (flags,TBFLAG_A64 ,TBII , + (arm_regime_tbi1 (env, mmu_idx) <<1 ) |arm_regime_tbi0 (env, mmu_idx)); - flags =FIELD_DP32 (flags,TBFLAG_A64 ,TBI1 , -arm_regime_tbi1 (env, mmu_idx));if (cpu_isar_feature (aa64_sve, cpu)) {int sve_el =sve_exception_el (env, current_el);
target/arm/translate-a64.c +7 -6
@@ -276,13 +276,15 @@ void gen_a64_set_pc_im(uint64_t val)*/ static void gen_a64_set_pc (DisasContext *s,TCGv_i64 src) { +/* Note that TBII is TBI1:TBI0. */ +int tbi = s->tbii;if (s->current_el <=1 ) {/* Test if NEITHER or BOTH TBI values are set. If so, no need to * examine bit 55 of address, can just generate code. * If mixed, then test via generated code */ -if (s->tbi0 && s->tbi1) { +if (tbi ==3 ) {TCGv_i64 tmp_reg =tcg_temp_new_i64 ();/* Both bits set, sign extension from bit 55 into [63:56] will * cover both cases
@@ -290,7 +292,7 @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src)tcg_gen_shli_i64 (tmp_reg, src,8 );tcg_gen_sari_i64 (cpu_pc, tmp_reg,8 );tcg_temp_free_i64 (tmp_reg); - }else if (!s->tbi0 && !s->tbi1) { + }else if (tbi ==0 ) {/* Neither bit set, just load it as-is */ tcg_gen_mov_i64 (cpu_pc, src); }else {
@@ -300,7 +302,7 @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src)tcg_gen_andi_i64 (tcg_bit55, src, (1ull <<55 )); -if (s->tbi0) { +if (tbi ==1 ) {/* tbi0==1, tbi1==0, so 0-fill upper byte if bit 55 = 0 */ tcg_gen_andi_i64 (tcg_tmpval, src,0x00FFFFFFFFFFFFFFull );
@@ -318,7 +320,7 @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src)tcg_temp_free_i64 (tcg_tmpval); } }else {/* EL > 1 */ -if (s->tbi0) { +if (tbi !=0 ) {/* Force tag byte to all zero */ tcg_gen_andi_i64 (cpu_pc, src,0x00FFFFFFFFFFFFFFull ); }else {
@@ -13807,8 +13809,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->condexec_cond =0 ; core_mmu_idx =FIELD_EX32 (tb_flags,TBFLAG_ANY ,MMUIDX ); dc->mmu_idx =core_to_arm_mmu_idx (env, core_mmu_idx); - dc->tbi0 =FIELD_EX32 (tb_flags,TBFLAG_A64 ,TBI0 ); - dc->tbi1 =FIELD_EX32 (tb_flags,TBFLAG_A64 ,TBI1 ); + dc->tbii =FIELD_EX32 (tb_flags,TBFLAG_A64 ,TBII ); dc->current_el =arm_mmu_idx_to_el (dc->mmu_idx);#if !defined(CONFIG_USER_ONLY ) dc->user = (dc->current_el ==0 );
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 27/49] target/arm: Reuse aa64_va_parameters for setting tbflags
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
The arm_regime_tbi{0,1} functions are replacable with the new function by giving the lowest and highest address.
Message-id: [email protected]
--- target/arm/cpu.h | 35 ----------------------- target/arm/helper.c | 70 ++++++++++++++++----------------------------- 2 files changed, 24 insertions(+), 81 deletions(-)
target/arm/cpu.h +0 -35
@@ -3015,41 +3015,6 @@ static inline bool arm_cpu_bswap_data(CPUARMState *env) }#endif -#ifndef CONFIG_USER_ONLY -/** -* arm_regime_tbi0: -* @env: CPUARMState -* @mmu_idx: MMU index indicating required translation regime -* -* Extracts the TBI0 value from the appropriate TCR for the current EL -* -* Returns: the TBI0 value. -*/ -uint32_t arm_regime_tbi0 (CPUARMState *env,ARMMMUIdx mmu_idx); - -/** -* arm_regime_tbi1: -* @env: CPUARMState -* @mmu_idx: MMU index indicating required translation regime -* -* Extracts the TBI1 value from the appropriate TCR for the current EL -* -* Returns: the TBI1 value. -*/ -uint32_t arm_regime_tbi1 (CPUARMState *env,ARMMMUIdx mmu_idx); -#else -/* We can't handle tagged addresses properly in user-only mode */ -static inline uint32_t arm_regime_tbi0 (CPUARMState *env,ARMMMUIdx mmu_idx) -{ -return 0 ; -} - -static inline uint32_t arm_regime_tbi1 (CPUARMState *env,ARMMMUIdx mmu_idx) -{ -return 0 ; -} -#endif -void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *flags);
target/arm/helper.c +24 -46
82 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 29/49] target/arm: Implement pauth_auth
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
This is not really functional yet, because the crypto is not yet implemented. This, however follows the Auth pseudo function.
Message-id: [email protected]
--- target/arm/pauth_helper.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
target/arm/pauth_helper.c +20 -1
@@ -50,7 +50,26 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param)static uint64_t pauth_auth (CPUARMState *env,uint64_t ptr,uint64_t modifier,ARMPACKey *key,bool data,int keynumber) { -g_assert_not_reached ();/* FIXME */ +ARMMMUIdx mmu_idx =arm_stage1_mmu_idx (env); +ARMVAParameters param =aa64_va_parameters (env, ptr, mmu_idx, data); +int bot_bit, top_bit; +uint64_t pac, orig_ptr, test; + + orig_ptr =pauth_original_ptr (ptr, param); + pac =pauth_computepac (orig_ptr, modifier, *key); + bot_bit =64 - param.tsz; + top_bit =64 -8 * param.tbi; + + test = (pac ^ ptr) & ~MAKE_64BIT_MASK (55 ,1 ); +if (unlikely (extract64 (test, bot_bit, top_bit - bot_bit))) { +int error_code = (keynumber <<1 ) | (keynumber ^1 ); +if (param.tbi) { +return deposit64 (ptr,53 ,2 , error_code); + }else { +return deposit64 (ptr,61 ,2 , error_code); + } + } +return orig_ptr; }static uint64_t pauth_strip (CPUARMState *env,uint64_t ptr,bool data)
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 09/49] target/arm: Add PAuth helpers
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
The cryptographic internals are stubbed out for now, but the enable and trap bits are checked.
Message-id: [email protected]
--- target/arm/Makefile.objs | 1 + target/arm/helper-a64.h | 12 +++ target/arm/internals.h | 6 ++ target/arm/pauth_helper.c | 186 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 205 insertions(+) create mode 100644 target/arm/pauth_helper.c
target/arm/Makefile.objs +1 -0
@@ -8,6 +8,7 @@ obj-y += translate.o op_helper.o helper.o cpu.o obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o obj-y += gdbstub.o obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o +obj-$(TARGET_AARCH64) += pauth_helper.o obj-y += crypto_helper.o obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
target/arm/helper-a64.h +12 -0
@@ -85,3 +85,15 @@ DEF_HELPER_2(advsimd_rinth, f16, f16, ptr) DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) DEF_HELPER_2(sqrt_f16, f16, f16, ptr) + +DEF_HELPER_FLAGS_3(pacia, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(pacib, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(pacda, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(pacdb, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(pacga, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autia, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autib, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autda, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) +DEF_HELPER_FLAGS_2 (xpacd,TCG_CALL_NO_RWG_SE , i64, env, i64)
target/arm/internals.h +6 -0
@@ -266,6 +266,7 @@ enum arm_exception_class {EC_CP14DTTRAP =0x06 ,EC_ADVSIMDFPACCESSTRAP =0x07 ,EC_FPIDTRAP =0x08 , +EC_PACTRAP =0x09 ,EC_CP14RRTTRAP =0x0c ,EC_ILLEGALSTATE =0x0e , EC_AA32_SVC = 0x11,
@@ -433,6 +434,11 @@ static inline uint32_t syn_sve_access_trap(void)return EC_SVEACCESSTRAP <<ARM_EL_EC_SHIFT ; } +static inline uint32_t syn_pactrap (void ) +{ +return EC_PACTRAP <<ARM_EL_EC_SHIFT ; +} +static inline uint32_t syn_insn_abort (int same_el,int ea,int s1ptw,int fsc) {return (EC_INSNABORT <<ARM_EL_EC_SHIFT ) | (same_el <<ARM_EL_EC_SHIFT )
target/arm/pauth_helper.c new file +186 -0
186 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 22/49] target/arm: Create ARMVAParameters and helpers
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Split out functions to extract the virtual address parameters. Let the functions choose T0 or T1 address space half, if present. Extract (most of) the control bits that vary between EL or Tx.
Message-id: [email protected]
--- target/arm/internals.h | 14 +++ target/arm/helper.c | 278 ++++++++++++++++++++++------------------- 2 files changed, 164 insertions(+), 128 deletions(-)
target/arm/internals.h +14 -0
@@ -942,4 +942,18 @@ static inline ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env)ARMMMUIdx arm_stage1_mmu_idx (CPUARMState *env);#endif +/* +* Parameters of a given virtual address, as extracted from the +* translation control register (TCR) for a given regime. +*/ +typedef struct ARMVAParameters { +unsigned tsz :8 ; +unsigned select :1 ; +bool tbi :1 ; +bool epd :1 ; +bool hpd :1 ; +bool using16k :1 ; +bool using64k :1 ; +}ARMVAParameters ; +#endif
target/arm/helper.c +150 -128
336 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 30/49] target/arm: Implement pauth_addpac
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
This is not really functional yet, because the crypto is not yet implemented. This, however follows the AddPAC pseudo function.
Message-id: [email protected]
--- target/arm/pauth_helper.c | 42 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-)
target/arm/pauth_helper.c +41 -1
@@ -35,7 +35,47 @@ static uint64_t pauth_computepac(uint64_t data, uint64_t modifier,static uint64_t pauth_addpac (CPUARMState *env,uint64_t ptr,uint64_t modifier,ARMPACKey *key,bool data) { -g_assert_not_reached ();/* FIXME */ +ARMMMUIdx mmu_idx =arm_stage1_mmu_idx (env); +ARMVAParameters param =aa64_va_parameters (env, ptr, mmu_idx, data); +uint64_t pac, ext_ptr, ext, test; +int bot_bit, top_bit; + +/* If tagged pointers are in use, use ptr<55>, otherwise ptr<63>. */ +if (param.tbi) { + ext =sextract64 (ptr,55 ,1 ); + }else { + ext =sextract64 (ptr,63 ,1 ); + } + +/* Build a pointer with known good extension bits. */ + top_bit =64 -8 * param.tbi; + bot_bit =64 - param.tsz; + ext_ptr =deposit64 (ptr, bot_bit, top_bit - bot_bit, ext); + + pac =pauth_computepac (ext_ptr, modifier, *key); + +/* +* Check if the ptr has good extension bits and corrupt the +* pointer authentication code if not. +*/ + test =sextract64 (ptr, bot_bit, top_bit - bot_bit); +if (test !=0 && test !=-1 ) { + pac ^=MAKE_64BIT_MASK (top_bit -1 ,1 ); + } + +/* +* Preserve the determination between upper and lower at bit 55, +* and insert pointer authentication code. +*/ +if (param.tbi) { + ptr &= ~MAKE_64BIT_MASK (bot_bit,55 - bot_bit +1 ); + pac &=MAKE_64BIT_MASK (bot_bit,54 - bot_bit +1 ); + }else { + ptr &=MAKE_64BIT_MASK (0 , bot_bit); + pac &= ~(MAKE_64BIT_MASK (55 ,1 ) |MAKE_64BIT_MASK (0 , bot_bit)); + } + ext &=MAKE_64BIT_MASK (55 ,1 ); +return pac | ext | ptr; }static uint64_t pauth_original_ptr (uint64_t ptr,ARMVAParameters param)
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 33/49] target/arm: Enable PAuth for -cpu max
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/cpu64.c | 4 ++++ 1 file changed, 4 insertions(+)
target/arm/cpu64.c +4 -0
@@ -316,6 +316,10 @@ static void aarch64_max_initfn(Object *obj) t = cpu->isar.id_aa64isar1; t =FIELD_DP64 (t,ID_AA64ISAR1 ,FCMA ,1 ); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,APA ,1 );/* PAuth, architected only */ + t =FIELD_DP64 (t,ID_AA64ISAR1 ,API ,0 ); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA ,1 ); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI ,0 ); cpu->isar.id_aa64isar1 = t; t = cpu->isar.id_aa64pfr0;
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 14/49] target/arm: Move helper_exception_return to helper-a64.c
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
This function is only used by AArch64. Code movement only.
Message-id: [email protected]
--- target/arm/helper-a64.h | 2 + target/arm/helper.h | 1 - target/arm/helper-a64.c | 155 ++++++++++++++++++++++++++++++++++++++++ target/arm/op_helper.c | 155 ---------------------------------------- 4 files changed, 157 insertions(+), 156 deletions(-)
target/arm/helper-a64.h +2 -0
@@ -86,6 +86,8 @@ DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) DEF_HELPER_2(sqrt_f16, f16, f16, ptr) +DEF_HELPER_1(exception_return, void, env) + DEF_HELPER_FLAGS_3(pacia, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(pacib, TCG_CALL_NO_WG, i64, env, i64, i64)DEF_HELPER_FLAGS_3 (pacda,TCG_CALL_NO_WG , i64, env, i64, i64)
target/arm/helper.h +0 -1
@@ -79,7 +79,6 @@ DEF_HELPER_2(get_cp_reg64, i64, env, ptr) DEF_HELPER_3(msr_i_pstate, void, env, i32, i32) DEF_HELPER_1(clear_pstate_ss, void, env) -DEF_HELPER_1(exception_return, void, env) DEF_HELPER_2(get_r13_banked, i32, env, i32)DEF_HELPER_3 (set_r13_banked, void, env, i32, i32)
target/arm/helper-a64.c +155 -0
161 lines not on this page · raw message
target/arm/op_helper.c +0 -155
161 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 31/49] target/arm: Implement pauth_computepac
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
This is the main crypto routine, an implementation of QARMA. This matches, as much as possible, ARM pseudocode.
Message-id: [email protected]
--- target/arm/pauth_helper.c | 242 +++++++++++++++++++++++++++++++++++++- 1 file changed, 241 insertions(+), 1 deletion(-)
target/arm/pauth_helper.c +241 -1
@@ -26,10 +26,250 @@#include "tcg/tcg-gvec-desc.h" +static uint64_t pac_cell_shuffle (uint64_t i) +{ +uint64_t o =0 ; + + o |=extract64 (i,52 ,4 ); + o |=extract64 (i,24 ,4 ) <<4 ; + o |=extract64 (i,44 ,4 ) <<8 ; + o |=extract64 (i,0 ,4 ) <<12 ; + + o |=extract64 (i,28 ,4 ) <<16 ; + o |=extract64 (i,48 ,4 ) <<20 ; + o |=extract64 (i,4 ,4 ) <<24 ; + o |=extract64 (i,40 ,4 ) <<28 ; + + o |=extract64 (i,32 ,4 ) <<32 ; + o |=extract64 (i,12 ,4 ) <<36 ; + o |=extract64 (i,56 ,4 ) <<40 ; + o |=extract64 (i,20 ,4 ) <<44 ; + + o |=extract64 (i,8 ,4 ) <<48 ; + o |=extract64 (i,36 ,4 ) <<52 ; + o |=extract64 (i,16 ,4 ) <<56 ; + o |=extract64 (i,60 ,4 ) <<60 ; + +return o; +} + +static uint64_t pac_cell_inv_shuffle (uint64_t i) +{ +uint64_t o =0 ; + + o |=extract64 (i,12 ,4 ); + o |=extract64 (i,24 ,4 ) <<4 ; + o |=extract64 (i,48 ,4 ) <<8 ; + o |=extract64 (i,36 ,4 ) <<12 ; + + o |=extract64 (i,56 ,4 ) <<16 ; + o |=extract64 (i,44 ,4 ) <<20 ; + o |=extract64 (i,4 ,4 ) <<24 ; + o |=extract64 (i,16 ,4 ) <<28 ; + + o |= i &MAKE_64BIT_MASK (32 ,4 ); + o |=extract64 (i,52 ,4 ) <<36 ; + o |=extract64 (i,28 ,4 ) <<40 ; + o |=extract64 (i,8 ,4 ) <<44 ; + + o |=extract64 (i,20 ,4 ) <<48 ; + o |=extract64 (i,0 ,4 ) <<52 ; + o |=extract64 (i,40 ,4 ) <<56 ; + o |= i &MAKE_64BIT_MASK (60 ,4 ); + +return o; +} + +static uint64_t pac_sub (uint64_t i) +{ +static const uint8_t sub[16 ] = { +0xb ,0x6 ,0x8 ,0xf ,0xc ,0x0 ,0x9 ,0xe , +0x3 ,0x7 ,0x4 ,0x5 ,0xd ,0x2 ,0x1 ,0xa , + }; +uint64_t o =0 ; +int b; + +for (b =0 ; b <64 ; b +=16 ) { + o |= (uint64_t )sub[(i >> b) &0xf ] << b; + } +return o; +} + +static uint64_t pac_inv_sub (uint64_t i) +{ +static const uint8_t inv_sub[16 ] = { +0x5 ,0xe ,0xd ,0x8 ,0xa ,0xb ,0x1 ,0x9 , +0x2 ,0x6 ,0xf ,0x0 ,0x4 ,0xc ,0x7 ,0x3 , + }; +uint64_t o =0 ; +int b; + +for (b =0 ; b <64 ; b +=16 ) { + o |= (uint64_t )inv_sub[(i >> b) &0xf ] << b; + } +return o; +} + +static int rot_cell (int cell,int n) +{ +/* 4-bit rotate left by n. */ + cell |= cell <<4 ; +return extract32 (cell,4 - n,4 ); +} + +static uint64_t pac_mult (uint64_t i) +{ +uint64_t o =0 ; +int b; + +for (b =0 ; b <4 *4 ; b +=4 ) { +int i0, i4, i8, ic, t0, t1, t2, t3; + + i0 =extract64 (i, b,4 ); + i4 =extract64 (i, b +4 *4 ,4 ); + i8 =extract64 (i, b +8 *4 ,4 ); + ic =extract64 (i, b +12 *4 ,4 ); + + t0 =rot_cell (i8,1 ) ^rot_cell (i4,2 ) ^rot_cell (i0,1 ); + t1 =rot_cell (ic,1 ) ^rot_cell (i4,1 ) ^rot_cell (i0,2 ); + t2 =rot_cell (ic,2 ) ^rot_cell (i8,1 ) ^rot_cell (i0,1 ); + t3 =rot_cell (ic,1 ) ^rot_cell (i8,2 ) ^rot_cell (i4,1 ); + + o |= (uint64_t )t3 << b; + o |= (uint64_t )t2 << (b +4 *4 ); + o |= (uint64_t )t1 << (b +8 *4 ); + o |= (uint64_t )t0 << (b +12 *4 ); + } +return o; +} + +static uint64_t tweak_cell_rot (uint64_t cell) +{ +return (cell >>1 ) | (((cell ^ (cell >>1 )) &1 ) <<3 ); +} + +static uint64_t tweak_shuffle (uint64_t i) +{ +uint64_t o =0 ; + + o |=extract64 (i,16 ,4 ) <<0 ; + o |=extract64 (i,20 ,4 ) <<4 ; + o |=tweak_cell_rot (extract64 (i,24 ,4 )) <<8 ; + o |=extract64 (i,28 ,4 ) <<12 ; + + o |=tweak_cell_rot (extract64 (i,44 ,4 )) <<16 ; + o |=extract64 (i,8 ,4 ) <<20 ; + o |=extract64 (i,12 ,4 ) <<24 ; + o |=tweak_cell_rot (extract64 (i,32 ,4 )) <<28 ; + + o |=extract64 (i,48 ,4 ) <<32 ; + o |=extract64 (i,52 ,4 ) <<36 ; + o |=extract64 (i,56 ,4 ) <<40 ; + o |=tweak_cell_rot (extract64 (i,60 ,4 )) <<44 ; + + o |=tweak_cell_rot (extract64 (i,0 ,4 )) <<48 ; + o |=extract64 (i,4 ,4 ) <<52 ; + o |=tweak_cell_rot (extract64 (i,40 ,4 )) <<56 ; + o |=tweak_cell_rot (extract64 (i,36 ,4 )) <<60 ; + +return o; +} + +static uint64_t tweak_cell_inv_rot (uint64_t cell) +{ +return ((cell <<1 ) &0xf ) | ((cell &1 ) ^ (cell >>3 )); +} + +static uint64_t tweak_inv_shuffle (uint64_t i) +{ +uint64_t o =0 ; + + o |=tweak_cell_inv_rot (extract64 (i,48 ,4 )); + o |=extract64 (i,52 ,4 ) <<4 ; + o |=extract64 (i,20 ,4 ) <<8 ; + o |=extract64 (i,24 ,4 ) <<12 ; + + o |=extract64 (i,0 ,4 ) <<16 ; + o |=extract64 (i,4 ,4 ) <<20 ; + o |=tweak_cell_inv_rot (extract64 (i,8 ,4 )) <<24 ; + o |=extract64 (i,12 ,4 ) <<28 ; + + o |=tweak_cell_inv_rot (extract64 (i,28 ,4 )) <<32 ; + o |=tweak_cell_inv_rot (extract64 (i,60 ,4 )) <<36 ; + o |=tweak_cell_inv_rot (extract64 (i,56 ,4 )) <<40 ; + o |=tweak_cell_inv_rot (extract64 (i,16 ,4 )) <<44 ; + + o |=extract64 (i,32 ,4 ) <<48 ; + o |=extract64 (i,36 ,4 ) <<52 ; + o |=extract64 (i,40 ,4 ) <<56 ; + o |=tweak_cell_inv_rot (extract64 (i,44 ,4 )) <<60 ; + +return o; +} +static uint64_t pauth_computepac (uint64_t data,uint64_t modifier,ARMPACKey key) { -g_assert_not_reached ();/* FIXME */ +static const uint64_t RC [5 ] = { +0x0000000000000000ull , +0x13198A2E03707344ull , +0xA4093822299F31D0ull , +0x082EFA98EC4E6C89ull , +0x452821E638D01377ull , + }; +const uint64_t alpha =0xC0AC29B7C97C50DDull ; +/* +* Note that in the ARM pseudocode, key0 contains bits <127:64> +* and key1 contains bits <63:0> of the 128-bit key. +*/ +uint64_t key0 = key.hi, key1 = key.lo; +uint64_t workingval, runningmod, roundkey, modk0; +int i; + + modk0 = (key0 <<63 ) | ((key0 >>1 ) ^ (key0 >>63 )); + runningmod = modifier; + workingval = data ^ key0; + +for (i =0 ; i <=4 ; ++i) { + roundkey = key1 ^ runningmod; + workingval ^= roundkey; + workingval ^=RC [i]; +if (i >0 ) { + workingval =pac_cell_shuffle (workingval); + workingval =pac_mult (workingval); + } + workingval =pac_sub (workingval); + runningmod =tweak_shuffle (runningmod); + } + roundkey = modk0 ^ runningmod; + workingval ^= roundkey; + workingval =pac_cell_shuffle (workingval); + workingval =pac_mult (workingval); + workingval =pac_sub (workingval); + workingval =pac_cell_shuffle (workingval); + workingval =pac_mult (workingval); + workingval ^= key1; + workingval =pac_cell_inv_shuffle (workingval); + workingval =pac_inv_sub (workingval); + workingval =pac_mult (workingval); + workingval =pac_cell_inv_shuffle (workingval); + workingval ^= key0; + workingval ^= runningmod; +for (i =0 ; i <=4 ; ++i) { + workingval =pac_inv_sub (workingval); +if (i <4 ) { + workingval =pac_mult (workingval); + workingval =pac_cell_inv_shuffle (workingval); + } + runningmod =tweak_inv_shuffle (runningmod); + roundkey = key1 ^ runningmod; + workingval ^=RC [4 - i]; + workingval ^= roundkey; + workingval ^= alpha; + } + workingval ^= modk0; + +return workingval; } static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 32/49] target/arm: Add PAuth system registers
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/helper.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
target/arm/helper.c +70 -0
@@ -5061,6 +5061,70 @@ static CPAccessResult access_lor_other(CPUARMState *env,return access_lor_ns (env); } +#ifdef TARGET_AARCH64 +static CPAccessResult access_pauth (CPUARMState *env,const ARMCPRegInfo *ri, +bool isread) +{ +int el =arm_current_el (env); + +if (el <2 && +arm_feature (env,ARM_FEATURE_EL2 ) && + !(arm_hcr_el2_eff (env) &HCR_APK )) { +return CP_ACCESS_TRAP_EL2 ; + } +if (el <3 && +arm_feature (env,ARM_FEATURE_EL3 ) && + !(env->cp15.scr_el3 &SCR_APK )) { +return CP_ACCESS_TRAP_EL3 ; + } +return CP_ACCESS_OK ; +} + +static const ARMCPRegInfo pauth_reginfo[] = { + { .name ="APDAKEYLO_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =2 , .opc2 =0 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apda_key.lo) }, + { .name ="APDAKEYHI_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =2 , .opc2 =1 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apda_key.hi) }, + { .name ="APDBKEYLO_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =2 , .opc2 =2 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apdb_key.lo) }, + { .name ="APDBKEYHI_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =2 , .opc2 =3 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apdb_key.hi) }, + { .name ="APGAKEYLO_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =3 , .opc2 =0 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apga_key.lo) }, + { .name ="APGAKEYHI_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =3 , .opc2 =1 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apga_key.hi) }, + { .name ="APIAKEYLO_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =1 , .opc2 =0 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apia_key.lo) }, + { .name ="APIAKEYHI_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =1 , .opc2 =1 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apia_key.hi) }, + { .name ="APIBKEYLO_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =1 , .opc2 =2 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apib_key.lo) }, + { .name ="APIBKEYHI_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =2 , .crm =1 , .opc2 =3 , + .access =PL1_RW , .accessfn = access_pauth, + .fieldoffset = offsetof(CPUARMState, apib_key.hi) }, +REGINFO_SENTINEL +}; +#endif +void register_cp_regs_for_features (ARMCPU *cpu) {/* Register all the coprocessor registers based on feature bits */
@@ -5845,6 +5909,12 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_one_arm_cp_reg (cpu, &zcr_el3_reginfo); } } + +#ifdef TARGET_AARCH64 +if (cpu_isar_feature (aa64_pauth, cpu)) { +define_arm_cp_regs (cpu, pauth_reginfo); + } +#endif }void arm_cpu_register_gdb_regs_for_features (ARMCPU *cpu)
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 26/49] target/arm: Decode TBID from TCR
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Use TBID in aa64_va_parameters depending on the data parameter. This automatically updates all existing users of the function.
Message-id: [email protected]
--- target/arm/internals.h | 1 + target/arm/helper.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
target/arm/internals.h +1 -0
@@ -950,6 +950,7 @@ typedef struct ARMVAParameters { unsigned tsz : 8; unsigned select : 1; bool tbi : 1; + bool tbid : 1; bool epd : 1; bool hpd : 1; bool using16k : 1;
target/arm/helper.c +11 -3
@@ -9749,7 +9749,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, {uint64_t tcr =regime_tcr (env, mmu_idx)->raw_tcr;uint32_t el =regime_el (env, mmu_idx); -bool tbi, epd, hpd, using16k, using64k; +bool tbi, tbid, epd, hpd, using16k, using64k;int select, tsz;/*
@@ -9764,10 +9764,11 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, using16k =extract32 (tcr,15 ,1 );if (mmu_idx == ARMMMUIdx_S2NS) {/* VTCR_EL2 */ - tbi = hpd = false; + tbi = tbid = hpd = false; }else { tbi =extract32 (tcr,20 ,1 ); hpd =extract32 (tcr,24 ,1 ); + tbid =extract32 (tcr,29 ,1 ); } epd = false; }else if (!select) {
@@ -9777,6 +9778,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, using16k =extract32 (tcr,15 ,1 ); tbi =extract64 (tcr,37 ,1 ); hpd =extract64 (tcr,41 ,1 ); + tbid =extract64 (tcr,51 ,1 ); }else {int tg =extract32 (tcr,30 ,2 ); using16k = tg ==1 ;
@@ -9785,6 +9787,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, epd =extract32 (tcr,23 ,1 ); tbi =extract64 (tcr,38 ,1 ); hpd =extract64 (tcr,42 ,1 ); + tbid =extract64 (tcr,52 ,1 ); } tsz =MIN (tsz,39 );/* TODO: ARMv8.4-TTST */ tsz =MAX (tsz,16 );/* TODO: ARMv8.2-LVA */
@@ -9793,6 +9796,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, .tsz = tsz, .select = select, .tbi = tbi, + .tbid = tbid, .epd = epd, .hpd = hpd, .using16k = using16k,
@@ -9803,7 +9807,11 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va,ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va,ARMMMUIdx mmu_idx,bool data) { -return aa64_va_parameters_both (env, va, mmu_idx); +ARMVAParameters ret =aa64_va_parameters_both (env, va, mmu_idx); + +/* Present TBI as a composite with TBID. */ + ret.tbi &= (data || !ret.tbid); +return ret; } static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va,
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 34/49] target/arm: Enable PAuth for user-only
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Add 4 attributes that controls the EL1 enable bits, as we may not always want to turn on pointer authentication with -cpu max. However, by default they are enabled.
Message-id: [email protected]
--- target/arm/cpu.c | 3 +++ target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
target/arm/cpu.c +3 -0
@@ -162,6 +162,9 @@ static void arm_cpu_reset(CPUState *s) env->pstate = PSTATE_MODE_EL0t;/* Userspace expects access to DC ZVA, CTL_EL0 and the cache ops */ env->cp15.sctlr_el[1 ] |=SCTLR_UCT |SCTLR_UCI |SCTLR_DZE ; +/* Enable all PAC instructions */ + env->cp15.hcr_el2 |=HCR_API ; + env->cp15.scr_el3 |=SCR_API ;/* and to the FP/Neon instructions */ env->cp15.cpacr_el1 =deposit64 (env->cp15.cpacr_el1,20 ,2 ,3 );/* and to the SVE instructions */
target/arm/cpu64.c +60 -0
72 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 19/49] target/arm: Move cpu_mmu_index out of line
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
This function is, or will shortly become, too big to inline.
Message-id: [email protected]
--- target/arm/cpu.h | 48 +++++---------------------------------------- target/arm/helper.c | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 43 deletions(-)
target/arm/cpu.h +5 -43
@@ -2741,54 +2741,16 @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) }/* Return the MMU index for a v7M CPU in the specified security and -* privilege state +* privilege state. */ -static inline ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv (CPUARMState *env, -bool secstate, -bool priv) -{ -ARMMMUIdx mmu_idx =ARM_MMU_IDX_M ; - -if (priv) { - mmu_idx |=ARM_MMU_IDX_M_PRIV ; - } - -if (armv7m_nvic_neg_prio_requested (env->nvic, secstate)) { - mmu_idx |=ARM_MMU_IDX_M_NEGPRI ; - } - -if (secstate) { - mmu_idx |=ARM_MMU_IDX_M_S ; - } - -return mmu_idx; -} +ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv (CPUARMState *env, +bool secstate,bool priv);/* Return the MMU index for a v7M CPU in the specified security state */ -static inline ARMMMUIdx arm_v7m_mmu_idx_for_secstate (CPUARMState *env, -bool secstate) -{ -bool priv =arm_current_el (env) !=0 ; - -return arm_v7m_mmu_idx_for_secstate_and_priv (env, secstate, priv); -} +ARMMMUIdx arm_v7m_mmu_idx_for_secstate (CPUARMState *env,bool secstate);/* Determine the current mmu_idx to use for normal loads/stores */ -static inline int cpu_mmu_index (CPUARMState *env,bool ifetch) -{ -int el =arm_current_el (env); - -if (arm_feature (env,ARM_FEATURE_M )) { -ARMMMUIdx mmu_idx =arm_v7m_mmu_idx_for_secstate (env, env->v7m.secure); - -return arm_to_core_mmu_idx (mmu_idx); - } - -if (el <2 &&arm_is_secure_below_el3 (env)) { -return arm_to_core_mmu_idx (ARMMMUIdx_S1SE0 + el); - } -return el; -} +int cpu_mmu_index (CPUARMState *env,bool ifetch);/* Indexes used when registering address spaces with cpu_address_space_init */ typedef enum ARMASIdx {
target/arm/helper.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 35/49] target/arm: Tidy TBI handling in gen_a64_set_pc
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
We can perform this with fewer operations.
Message-id: [email protected]
--- target/arm/translate-a64.c | 62 +++++++++++++------------------------- 1 file changed, 21 insertions(+), 41 deletions(-)
target/arm/translate-a64.c +21 -41
@@ -261,7 +261,7 @@ void gen_a64_set_pc_im(uint64_t val)/* Load the PC from a generic TCG variable. * * If address tagging is enabled via the TCR TBI bits, then loading -* an address into the PC will clear out any tag in the it: +* an address into the PC will clear out any tag in it: * + for EL2 and EL3 there is only one TBI bit, and if it is set * then the address is zero-extended, clearing bits [63:56] * + for EL0 and EL1, TBI0 controls addresses with bit 55 == 0
@@ -280,54 +280,34 @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src)int tbi = s->tbii;if (s->current_el <=1 ) { -/* Test if NEITHER or BOTH TBI values are set. If so, no need to -* examine bit 55 of address, can just generate code. -* If mixed, then test via generated code -*/ -if (tbi ==3 ) { -TCGv_i64 tmp_reg =tcg_temp_new_i64 (); -/* Both bits set, sign extension from bit 55 into [63:56] will -* cover both cases -*/ -tcg_gen_shli_i64 (tmp_reg, src,8 ); -tcg_gen_sari_i64 (cpu_pc, tmp_reg,8 ); -tcg_temp_free_i64 (tmp_reg); - }else if (tbi ==0 ) { -/* Neither bit set, just load it as-is */ -tcg_gen_mov_i64 (cpu_pc, src); - }else { -TCGv_i64 tcg_tmpval =tcg_temp_new_i64 (); -TCGv_i64 tcg_bit55 =tcg_temp_new_i64 (); -TCGv_i64 tcg_zero =tcg_const_i64 (0 ); +if (tbi !=0 ) { +/* Sign-extend from bit 55. */ +tcg_gen_sextract_i64 (cpu_pc, src,0 ,56 ); -tcg_gen_andi_i64 (tcg_bit55, src, (1ull <<55 )); +if (tbi !=3 ) { +TCGv_i64 tcg_zero =tcg_const_i64 (0 ); -if (tbi ==1 ) { -/* tbi0==1, tbi1==0, so 0-fill upper byte if bit 55 = 0 */ -tcg_gen_andi_i64 (tcg_tmpval, src, -0x00FFFFFFFFFFFFFFull ); -tcg_gen_movcond_i64 (TCG_COND_EQ , cpu_pc, tcg_bit55, tcg_zero, - tcg_tmpval, src); - }else { -/* tbi0==0, tbi1==1, so 1-fill upper byte if bit 55 = 1 */ -tcg_gen_ori_i64 (tcg_tmpval, src, -0xFF00000000000000ull ); -tcg_gen_movcond_i64 (TCG_COND_NE , cpu_pc, tcg_bit55, tcg_zero, - tcg_tmpval, src); +/* +* The two TBI bits differ. +* If tbi0, then !tbi1: only use the extension if positive. +* if !tbi0, then tbi1: only use the extension if negative. +*/ +tcg_gen_movcond_i64 (tbi ==1 ?TCG_COND_GE :TCG_COND_LT , + cpu_pc, cpu_pc, tcg_zero, cpu_pc, src); +tcg_temp_free_i64 (tcg_zero); } -tcg_temp_free_i64 (tcg_zero); -tcg_temp_free_i64 (tcg_bit55); -tcg_temp_free_i64 (tcg_tmpval); +return ; } - }else {/* EL > 1 */ + }else {if (tbi !=0 ) {/* Force tag byte to all zero */ -tcg_gen_andi_i64 (cpu_pc, src,0x00FFFFFFFFFFFFFFull ); - }else { -/* Load unmodified address */ -tcg_gen_mov_i64 (cpu_pc, src); +tcg_gen_extract_i64 (cpu_pc, src,0 ,56 ); +return ; } } + +/* Load unmodified address */ +tcg_gen_mov_i64 (cpu_pc, src); } typedef struct DisasCompare64 {
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 36/49] migration: Add post_save function to VMStateDescription
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
In some cases it may be helpful to modify state before saving it for migration, and then modify the state back after it has been saved. The existing pre_save function provides half of this functionality. This patch adds a post_save function to provide the second half.
Message-id: [email protected]
--- include/migration/vmstate.h | 1 + migration/vmstate.c | 13 ++++++++++++- docs/devel/migration.rst | 9 +++++++-- 3 files changed, 20 insertions(+), 3 deletions(-)
include/migration/vmstate.h +1 -0
@@ -185,6 +185,7 @@ struct VMStateDescription {int (*pre_load)(void *opaque);int (*post_load)(void *opaque,int version_id);int (*pre_save)(void *opaque); +int (*post_save)(void *opaque);bool (*needed)(void *opaque);const VMStateField *fields;const VMStateDescription **subsections;
migration/vmstate.c +12 -1
@@ -390,6 +390,9 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,if (ret) {error_report ("Save of field %s/%s failed" , vmsd->name, field->name); +if (vmsd->post_save) { + vmsd->post_save (opaque); + }return ret; }
@@ -415,7 +418,15 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,json_end_array (vmdesc); } -return vmstate_subsection_save (f, vmsd, opaque, vmdesc); + ret =vmstate_subsection_save (f, vmsd, opaque, vmdesc); + +if (vmsd->post_save) { +int ps_ret = vmsd->post_save (opaque); +if (!ret) { + ret = ps_ret; + } + } +return ret; } static const VMStateDescription *
docs/devel/migration.rst +7 -2
@@ -419,8 +419,13 @@ The functions to do that are inside a vmstate definition, and are called: This function is called before we save the state of one device. -Example: You can look at hpet.c, that uses the three function to -massage the state that is transferred. +- ``int (*post_save)(void *opaque);`` + + This function is called after we save the state of one device + (even upon failure, unless the call to pre_save returned an error). + +Example: You can look at hpet.c, that uses the first three functions +to massage the state that is transferred. The ``VMSTATE_WITH_TMP`` macro may be useful when the migration data doesn't match the stored device data well; it allows an
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 37/49] target/arm: Reorganize PMCCNTR accesses
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
pmccntr_read and pmccntr_write contained duplicate code that was already being handled by pmccntr_sync. Consolidate the duplicated code into two
functions: pmccntr_op_start and pmccntr_op_finish. Add a companion to c15_ccnt in CPUARMState so that we can simultaneously save both the architectural register value and the last underlying cycle count - this ensures time isn't lost and will also allow us to access the 'old' architectural register value in order to detect overflows in later patches.
Message-id: [email protected]
--- target/arm/cpu.h | 37 +++++++++++--- target/arm/helper.c | 118 ++++++++++++++++++++++++++------------------ 2 files changed, 100 insertions(+), 55 deletions(-)
target/arm/cpu.h +29 -8
@@ -473,10 +473,20 @@ typedef struct CPUARMState {uint64_t oslsr_el1;/* OS Lock Status */ uint64_t mdcr_el2;uint64_t mdcr_el3; -/* If the counter is enabled, this stores the last time the counter -* was reset. Otherwise it stores the counter value +/* Stores the architectural value of the counter *the last time it was +* updated* by pmccntr_op_start. Accesses should always be surrounded +* by pmccntr_op_start/pmccntr_op_finish to guarantee the latest +* architecturally-correct value is being read/set. */ uint64_t c15_ccnt; +/* Stores the delta between the architectural value and the underlying +* cycle count during normal operation. It is used to update c15_ccnt +* to be the correct architectural value before accesses. During +* accesses, c15_ccnt_delta contains the underlying count being used +* for the access, after which it reverts to the delta value in +* pmccntr_op_finish. +*/ +uint64_t c15_ccnt_delta;uint64_t pmccfiltr_el0;/* Performance Monitor Filter Register */ uint64_t vpidr_el2;/* Virtualization Processor ID Register */ uint64_t vmpidr_el2;/* Virtualization Multiprocessor ID Register */
@@ -971,15 +981,26 @@ int cpu_arm_signal_handler(int host_signum, void *pinfo, void *puc);/** -* pmccntr_sync +* pmccntr_op_start/finish * @env: CPUARMState * -* Synchronises the counter in the PMCCNTR. This must always be called twice, -* once before any action that might affect the timer and again afterwards. -* The function is used to swap the state of the register if required. -* This only happens when not in user mode (!CONFIG_USER_ONLY) +* Convert the counter in the PMCCNTR between its delta form (the typical mode +* when it's enabled) and the guest-visible value. These two calls must always +* surround any action which might affect the counter. */ -void pmccntr_sync (CPUARMState *env); +void pmccntr_op_start (CPUARMState *env); +void pmccntr_op_finish (CPUARMState *env); + +/** +* pmu_op_start/finish +* @env: CPUARMState +* +* Convert all PMU counters between their delta form (the typical mode when +* they are enabled) and the guest-visible values. These two calls must +* surround any action which might affect the counters. +*/ +void pmu_op_start (CPUARMState *env); +void pmu_op_finish (CPUARMState *env);/* SCTLR bit meanings. Several bits have been reused in newer * versions of the architecture; in that case we define constants
target/arm/helper.c +71 -47
163 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 38/49] target/arm: Swap PMU values before/after migrations
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
Because of the PMU's design, many register accesses have side effects which are inter-related, meaning that the normal method of saving CP registers can result in inconsistent state. These side-effects are largely handled in pmu_op_start/finish functions which can be called before and after the state is saved/restored. By doing this and adding raw read/write functions for the affected registers, we avoid migration-related inconsistencies.
Message-id: [email protected]
--- target/arm/helper.c | 6 ++++-- target/arm/machine.c | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-)
target/arm/helper.c +4 -2
@@ -1459,11 +1459,13 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 0, .access = PL0_RW, .accessfn = pmreg_access_ccntr, .type = ARM_CP_IO, - .readfn = pmccntr_read, .writefn = pmccntr_write, }, + .fieldoffset = offsetof(CPUARMState, cp15.c15_ccnt), + .readfn = pmccntr_read, .writefn = pmccntr_write, + .raw_readfn = raw_read, .raw_writefn = raw_write, },#endif { .name = "PMCCFILTR_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 15, .opc2 = 7, - .writefn = pmccfiltr_write, + .writefn = pmccfiltr_write, .raw_writefn = raw_write, .access = PL0_RW, .accessfn = pmreg_access, .type = ARM_CP_IO, .fieldoffset = offsetof(CPUARMState, cp15.pmccfiltr_el0),
target/arm/machine.c +24 -0
@@ -620,6 +620,10 @@ static int cpu_pre_save(void *opaque) {ARMCPU *cpu = opaque; +if (!kvm_enabled ()) { +pmu_op_start (&cpu->env); + } +if (kvm_enabled ()) {if (!write_kvmstate_to_list (cpu)) {/* This should never fail */
@@ -641,6 +645,17 @@ static int cpu_pre_save(void *opaque)return 0 ; } +static int cpu_post_save (void *opaque) +{ +ARMCPU *cpu = opaque; + +if (!kvm_enabled ()) { +pmu_op_finish (&cpu->env); + } + +return 0 ; +} +static int cpu_pre_load (void *opaque) {ARMCPU *cpu = opaque;
@@ -653,6 +668,10 @@ static int cpu_pre_load(void *opaque)*/ env->irq_line_state =UINT32_MAX ; +if (!kvm_enabled ()) { +pmu_op_start (&cpu->env); + } +return 0 ; }
@@ -721,6 +740,10 @@ static int cpu_post_load(void *opaque, int version_id)hw_breakpoint_update_all (cpu);hw_watchpoint_update_all (cpu); +if (!kvm_enabled ()) { +pmu_op_finish (&cpu->env); + } +return 0 ; }
@@ -729,6 +752,7 @@ const VMStateDescription vmstate_arm_cpu = { .version_id = 22, .minimum_version_id = 22, .pre_save = cpu_pre_save, + .post_save = cpu_post_save, .pre_load = cpu_pre_load, .post_load = cpu_post_load, .fields = (VMStateField []) {
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 40/49] target/arm: Allow AArch32 access for PMCCFILTR
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
Message-id: [email protected]
--- target/arm/helper.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
target/arm/helper.c +26 -1
@@ -994,6 +994,10 @@ static const ARMCPRegInfo v6_cp_reginfo[] = { PMXEVTYPER_M | PMXEVTYPER_MT | \ PMXEVTYPER_EVTCOUNT) +#define PMCCFILTR 0xf8000000 +#define PMCCFILTR_M PMXEVTYPER_M +#define PMCCFILTR_EL0 (PMCCFILTR | PMCCFILTR_M) +static inline uint32_t pmu_num_counters (CPUARMState *env) {return (env->cp15.c9_pmcr &PMCRN_MASK ) >>PMCRN_SHIFT ;
@@ -1297,10 +1301,26 @@ static void pmccfiltr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) {pmccntr_op_start (env); - env->cp15.pmccfiltr_el0 = value &0xfc000000 ; + env->cp15.pmccfiltr_el0 = value &PMCCFILTR_EL0 ;pmccntr_op_finish (env); } +static void pmccfiltr_write_a32 (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +pmccntr_op_start (env); +/* M is not accessible from AArch32 */ + env->cp15.pmccfiltr_el0 = (env->cp15.pmccfiltr_el0 &PMCCFILTR_M ) | + (value &PMCCFILTR ); +pmccntr_op_finish (env); +} + +static uint64_t pmccfiltr_read_a32 (CPUARMState *env,const ARMCPRegInfo *ri) +{ +/* M is not visible in AArch32 */ +return env->cp15.pmccfiltr_el0 &PMCCFILTR ; +} +static void pmcntenset_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
@@ -1545,6 +1565,11 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .readfn = pmccntr_read, .writefn = pmccntr_write, .raw_readfn = raw_read, .raw_writefn = raw_write, },#endif + { .name = "PMCCFILTR", .cp = 15, .opc1 = 0, .crn = 14, .crm = 15, .opc2 = 7, + .writefn = pmccfiltr_write_a32, .readfn = pmccfiltr_read_a32, + .access = PL0_RW, .accessfn = pmreg_access, + .type = ARM_CP_ALIAS | ARM_CP_IO, + .resetvalue = 0, }, { .name = "PMCCFILTR_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 15, .opc2 = 7, .writefn = pmccfiltr_write, .raw_writefn = raw_write,
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 42/49] target/arm: Define FIELDs for ID_DFR0
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
This is immediately necessary for the PMUv3 implementation to check ID_DFR0.PerfMon to enable/disable specific features, but defines the full complement of fields for possible future use elsewhere.
Message-id: [email protected]
--- target/arm/cpu.h | 9 +++++++++ 1 file changed, 9 insertions(+)
target/arm/cpu.h +9 -0
@@ -1681,6 +1681,15 @@ FIELD(ID_AA64MMFR1, PAN, 20, 4) FIELD(ID_AA64MMFR1, SPECSEI, 24, 4) FIELD(ID_AA64MMFR1, XNX, 28, 4) +FIELD(ID_DFR0, COPDBG, 0, 4) +FIELD(ID_DFR0, COPSDBG, 4, 4) +FIELD(ID_DFR0, MMAPDBG, 8, 4) +FIELD(ID_DFR0, COPTRC, 12, 4) +FIELD(ID_DFR0, MMAPTRC, 16, 4) +FIELD(ID_DFR0, MPROFDBG, 20, 4) +FIELD(ID_DFR0, PERFMON, 24, 4) +FIELD(ID_DFR0, TRACEFILT, 28, 4) +QEMU_BUILD_BUG_ON (ARRAY_SIZE (((ARMCPU *)0 )->ccsidr) <=R_V7M_CSSELR_INDEX_MASK );/* If adding a feature bit which corresponds to a Linux ELF
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 39/49] target/arm: Filter cycle counter based on PMCCFILTR_EL0
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
Rename arm_ccnt_enabled to pmu_counter_enabled, and add logic to only return 'true' if the specified counter is enabled and neither prohibited or filtered.
Message-id: [email protected]
--- target/arm/cpu.h | 10 ++++- target/arm/cpu.c | 3 ++ target/arm/helper.c | 96 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 101 insertions(+), 8 deletions(-)
target/arm/cpu.h +9 -1
@@ -1002,6 +1002,12 @@ void pmccntr_op_finish(CPUARMState *env);void pmu_op_start (CPUARMState *env);void pmu_op_finish (CPUARMState *env); +/** +* Functions to register as EL change hooks for PMU mode filtering +*/ +void pmu_pre_el_change (ARMCPU *cpu,void *ignored); +void pmu_post_el_change (ARMCPU *cpu,void *ignored); +/* SCTLR bit meanings. Several bits have been reused in newer * versions of the architecture; in that case we define constants * for both old and new bit meanings. Code which tests against those
@@ -1084,7 +1090,8 @@ void pmu_op_finish(CPUARMState *env);#define MDCR_EPMAD (1U << 21)#define MDCR_EDAD (1U << 20) -#define MDCR_SPME (1U << 17) +#define MDCR_SPME (1U << 17)/* MDCR_EL3 */ +#define MDCR_HPMD (1U << 17)/* MDCR_EL2 */ #define MDCR_SDD (1U << 16)#define MDCR_SPD (3U << 14)#define MDCR_TDRA (1U << 11)
@@ -1094,6 +1101,7 @@ void pmu_op_finish(CPUARMState *env);#define MDCR_HPME (1U << 7)#define MDCR_TPM (1U << 6)#define MDCR_TPMCR (1U << 5) +#define MDCR_HPMN (0x1fU)/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ #define SDCR_VALID_MASK (MDCR_EPMAD | MDCR_EDAD | MDCR_SPME | MDCR_SPD)
target/arm/cpu.c +3 -0
@@ -1038,6 +1038,9 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)if (!cpu->has_pmu) {unset_feature (env,ARM_FEATURE_PMU ); cpu->id_aa64dfr0 &= ~0xf00 ; + }else if (!kvm_enabled ()) { +arm_register_pre_el_change_hook (cpu, &pmu_pre_el_change,0 ); +arm_register_el_change_hook (cpu, &pmu_post_el_change,0 ); }if (!arm_feature (env,ARM_FEATURE_EL2 )) {
target/arm/helper.c +89 -7
141 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PULL 39/49] target/arm: Filter cycle counter based on PMCCFILTR_EL0
Quoted 7 lines · Peter Maydell
From: Aaron Lindsay <[email protected]>
Rename
arm_ccnt_enabledtopmu_counter_enabled, and add logic to only return 'true' if the specified counter is enabled and neither prohibited or filtered.
Quoted 6 lines
Signed-off-by Aaron Lindsay <[email protected]>Signed-off-by Aaron Lindsay <[email protected]>Reviewed-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-id: [email protected]
Signed-off-by Peter Maydell <[email protected]>
Hi Aaron; I've just had somebody report what seems like a bug in this code from last year:
Quoted 22 lines
target/arm/helper.c +17
-3+/* Returns true if the counter (pass 31 for PMCCNTR) should count events using +* the current EL, security state, and register configuration. +*/ +static bool pmu_counter_enabled (CPUARMState *env,uint8_t counter) { -/* This does not support checking PMCCFILTR_EL0 register */ +uint64_t filter; +bool e, p, u, nsk, nsu, nsh, m; +bool enabled, prohibited, filtered; +bool secure =arm_is_secure (env); +int el =arm_current_el (env); +uint8_t hpmn = env->cp15.mdcr_el2 &MDCR_HPMN ; -if (!(env->cp15.c9_pmcr &PMCRE ) || !(env->cp15.c9_pmcnten & (1 <<31 ))) { -return false; +if (!arm_feature (env,ARM_FEATURE_EL2 ) || + (counter < hpmn || counter ==31 )) { + e = env->cp15.c9_pmcr &PMCRE ; + }else { + e = env->cp15.mdcr_el2 &MDCR_HPME ; + } + enabled = e && (env->cp15.c9_pmcnten & (1 << counter));
target/arm/helper.c static CPAccessResult pmreg_access_ccntr(CPUARMState *env, · line 1120
Quoted 10 lines
target/arm/helper.c +10
-0+ +if (!secure) { +if (el ==2 && (counter < hpmn || counter ==31 )) { + prohibited = env->cp15.mdcr_el2 &MDCR_HPMD ; + }else { + prohibited = false; + } + }else { + prohibited =arm_feature (env,ARM_FEATURE_EL3 ) && + (env->cp15.mdcr_el3 &MDCR_SPME );
The Arm ARM says that MDCR.SPME is 0 to prohibit secure-state event counting, and 1 to enable it. So shouldn't this test be "!(env->cp15.mdcr_el3 & MDCR_SPME)" ?
(compare also the AArch32.CountEvents pseudocode, which has a test "HaveEL3(EL3) && ISSecure() && spme == '0' &&...")
thanks
-- PMM
PATCH 1/1 target/arm: Count PMU events when MDCR.SPME is set
This check was backwards when introduced in commit 033614c47de78409ad3fb39bb7bd1483b71c6789:
target/arm: Filter cycle counter based on PMCCFILTR_EL0
--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +1 -1
@@ -1452,7 +1452,7 @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) } }else { prohibited =arm_feature (env,ARM_FEATURE_EL3 ) && - (env->cp15.mdcr_el3 &MDCR_SPME ); + !(env->cp15.mdcr_el3 &MDCR_SPME ); }if (prohibited && counter ==31 ) {
Signature · 1 line
2.17.1
Peter Maydell
AppliedRe: [PATCH] target/arm: Count PMU events when MDCR.SPME is set
Quoted 16 lines · Aaron Lindsay
This check was backwards when introduced in commit
033614c47de78409ad3fb39bb7bd1483b71c6789:target/arm: Filter cycle counter based on
PMCCFILTR_EL0Signed-off-by Aaron Lindsay <[email protected]>--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/arm/helper.c +0
-0
target/arm/helper.c static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) · line 1458
Quoted 8 lines
target/arm/helper.c +1
-1@@ -1452,7 +1452,7 @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) } }else { prohibited =arm_feature (env,ARM_FEATURE_EL3 ) && - (env->cp15.mdcr_el3 &MDCR_SPME ); + !(env->cp15.mdcr_el3 &MDCR_SPME ); }if (prohibited && counter ==31 ) {
Applied to target-arm.next, thanks.
-- PMM
Re: [PULL 39/49] target/arm: Filter cycle counter based on PMCCFILTR_EL0
In reply to Peter MaydellQuoted 55 lines · Peter Maydell
Quoted 7 lines · Peter Maydell
From: Aaron Lindsay <[email protected]>
Rename
arm_ccnt_enabledtopmu_counter_enabled, and add logic to only return 'true' if the specified counter is enabled and neither prohibited or filtered.Quoted 6 lines
Signed-off-by Aaron Lindsay <[email protected]>Signed-off-by Aaron Lindsay <[email protected]>Reviewed-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-id: [email protected]
Signed-off-by Peter Maydell <[email protected]>Hi Aaron; I've just had somebody report what seems like a bug in this code from last year:
Quoted 22 lines
target/arm/helper.c +17
-3+/* Returns true if the counter (pass 31 for PMCCNTR) should count events using +* the current EL, security state, and register configuration. +*/ +static bool pmu_counter_enabled (CPUARMState *env,uint8_t counter) { -/* This does not support checking PMCCFILTR_EL0 register */ +uint64_t filter; +bool e, p, u, nsk, nsu, nsh, m; +bool enabled, prohibited, filtered; +bool secure =arm_is_secure (env); +int el =arm_current_el (env); +uint8_t hpmn = env->cp15.mdcr_el2 &MDCR_HPMN ; -if (!(env->cp15.c9_pmcr &PMCRE ) || !(env->cp15.c9_pmcnten & (1 <<31 ))) { -return false; +if (!arm_feature (env,ARM_FEATURE_EL2 ) || + (counter < hpmn || counter ==31 )) { + e = env->cp15.c9_pmcr &PMCRE ; + }else { + e = env->cp15.mdcr_el2 &MDCR_HPME ; + } + enabled = e && (env->cp15.c9_pmcnten & (1 << counter));target/arm/helper.c static CPAccessResult pmreg_access_ccntr(CPUARMState *env, · line 1120
Quoted 10 lines
target/arm/helper.c +10
-0+ +if (!secure) { +if (el ==2 && (counter < hpmn || counter ==31 )) { + prohibited = env->cp15.mdcr_el2 &MDCR_HPMD ; + }else { + prohibited = false; + } + }else { + prohibited =arm_feature (env,ARM_FEATURE_EL3 ) && + (env->cp15.mdcr_el3 &MDCR_SPME );The Arm ARM says that MDCR.SPME is 0 to prohibit secure-state event counting, and 1 to enable it. So shouldn't this test be "!(env->cp15.mdcr_el3 &
MDCR_SPME)" ?
Quoted 2 lines
(compare also the AArch32.CountEvents pseudocode, which has a test "HaveEL3(EL3) &&
ISSecure()&& spme == '0' &&...")
I agree my original patch was incorrect. My guess is that I overlooked the trailing D changing to an E and got caught assuming MDCR_HPMD and MDCR_SPME both prohibited counting when set. Sending a fix separately.
-Aaron
[Qemu-devel] [PULL 41/49] target/arm: Implement PMOVSSET
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
Add an array for PMOVSSET so we only define it for v7ve+ platforms
Message-id: [email protected]
--- target/arm/helper.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
target/arm/helper.c +28 -0
@@ -1342,6 +1342,13 @@ static void pmovsr_write(CPUARMState *env, const ARMCPRegInfo *ri, env->cp15.c9_pmovsr &= ~value; } +static void pmovsset_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ + value &=pmu_counter_mask (env); + env->cp15.c9_pmovsr |= value; +} +static void pmxevtyper_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
@@ -1718,6 +1725,24 @@ static const ARMCPRegInfo v7mp_cp_reginfo[] = {REGINFO_SENTINEL }; +static const ARMCPRegInfo pmovsset_cp_reginfo[] = { +/* PMOVSSET is not implemented in v7 before v7ve */ + { .name ="PMOVSSET" , .cp =15 , .opc1 =0 , .crn =9 , .crm =14 , .opc2 =3 , + .access =PL0_RW , .accessfn = pmreg_access, + .type =ARM_CP_ALIAS , + .fieldoffset =offsetoflow32 (CPUARMState, cp15.c9_pmovsr), + .writefn = pmovsset_write, + .raw_writefn = raw_write }, + { .name ="PMOVSSET_EL0" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =3 , .crn =9 , .crm =14 , .opc2 =3 , + .access =PL0_RW , .accessfn = pmreg_access, + .type =ARM_CP_ALIAS , + .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), + .writefn = pmovsset_write, + .raw_writefn = raw_write }, +REGINFO_SENTINEL +}; +static void teecr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
@@ -5360,6 +5385,9 @@ void register_cp_regs_for_features(ARMCPU *cpu) !arm_feature(env, ARM_FEATURE_PMSA)) {define_arm_cp_regs (cpu, v7mp_cp_reginfo); } +if (arm_feature (env,ARM_FEATURE_V7VE )) { +define_arm_cp_regs (cpu, pmovsset_cp_reginfo); + }if (arm_feature (env,ARM_FEATURE_V7 )) {/* v7 performance monitor control register: same implementor * field as main ID register, and we implement only the cycle
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 43/49] target/arm: Make PMCEID[01]_EL0 64 bit registers, add PMCEID[23]
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
Message-id: [email protected]
--- target/arm/cpu.h | 4 ++-- target/arm/helper.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-)
target/arm/cpu.h +2 -2
@@ -852,8 +852,8 @@ struct ARMCPU {uint32_t id_pfr0;uint32_t id_pfr1;uint32_t id_dfr0; -uint32_t pmceid0; -uint32_t pmceid1; +uint64_t pmceid0; +uint64_t pmceid1;uint32_t id_afr0;uint32_t id_mmfr0;uint32_t id_mmfr1;
target/arm/helper.c +17 -2
@@ -5425,6 +5425,21 @@ void register_cp_regs_for_features(ARMCPU *cpu) }else {define_arm_cp_regs (cpu, not_v7_cp_reginfo); } +if (FIELD_EX32 (cpu->id_dfr0,ID_DFR0 ,PERFMON ) >=4 && +FIELD_EX32 (cpu->id_dfr0,ID_DFR0 ,PERFMON ) !=0xf ) { +ARMCPRegInfo v81_pmu_regs[] = { + { .name ="PMCEID2" , .state =ARM_CP_STATE_AA32 , + .cp =15 , .opc1 =0 , .crn =9 , .crm =14 , .opc2 =4 , + .access =PL0_R , .accessfn = pmreg_access, .type =ARM_CP_CONST , + .resetvalue =extract64 (cpu->pmceid0,32 ,32 ) }, + { .name ="PMCEID3" , .state =ARM_CP_STATE_AA32 , + .cp =15 , .opc1 =0 , .crn =9 , .crm =14 , .opc2 =5 , + .access =PL0_R , .accessfn = pmreg_access, .type =ARM_CP_CONST , + .resetvalue =extract64 (cpu->pmceid1,32 ,32 ) }, +REGINFO_SENTINEL + }; +define_arm_cp_regs (cpu, v81_pmu_regs); + }if (arm_feature (env,ARM_FEATURE_V8 )) {/* AArch64 ID registers, which all have impdef reset values. * Note that within the ID register ranges the unused slots
@@ -5601,7 +5616,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name = "PMCEID0", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 6, .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, - .resetvalue = cpu->pmceid0 }, + .resetvalue = extract64(cpu->pmceid0, 0, 32) }, { .name = "PMCEID0_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 6, .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
@@ -5609,7 +5624,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name = "PMCEID1", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 7, .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, - .resetvalue = cpu->pmceid1 }, + .resetvalue = extract64(cpu->pmceid1, 0, 32) }, { .name = "PMCEID1_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7, .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 44/49] target/arm: Add array for supported PMU events, generate PMCEID[01]_EL0
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
This commit doesn't add any supported events, but provides the framework for adding them. We store the pm_event structs in a simple array, and provide the mapping from the event numbers to array indexes in the supported_event_map array. Because the value of PMCEID[01] depends upon which events are supported at runtime, generate it dynamically.
Message-id: [email protected]
--- target/arm/cpu.h | 10 ++++++++ target/arm/cpu.c | 19 +++++++++------ target/arm/cpu64.c | 4 ---- target/arm/helper.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 11 deletions(-)
target/arm/cpu.h +10 -0
@@ -1008,6 +1008,16 @@ void pmu_op_finish(CPUARMState *env);void pmu_pre_el_change (ARMCPU *cpu,void *ignored);void pmu_post_el_change (ARMCPU *cpu,void *ignored); +/* +* get_pmceid +* @env: CPUARMState +* @which: which PMCEID register to return (0 or 1) +* +* Return the PMCEID[01]_EL0 register values corresponding to the counters +* which are supported given the current configuration +*/ +uint64_t get_pmceid (CPUARMState *env,unsigned which); +/* SCTLR bit meanings. Several bits have been reused in newer * versions of the architecture; in that case we define constants * for both old and new bit meanings. Code which tests against those
target/arm/cpu.c +12 -7
@@ -1037,10 +1037,19 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)if (!cpu->has_pmu) {unset_feature (env,ARM_FEATURE_PMU ); + } +if (arm_feature (env,ARM_FEATURE_PMU )) { + cpu->pmceid0 =get_pmceid (&cpu->env,0 ); + cpu->pmceid1 =get_pmceid (&cpu->env,1 ); + +if (!kvm_enabled ()) { +arm_register_pre_el_change_hook (cpu, &pmu_pre_el_change,0 ); +arm_register_el_change_hook (cpu, &pmu_post_el_change,0 ); + } + }else { cpu->id_aa64dfr0 &= ~0xf00 ; - }else if (!kvm_enabled ()) { -arm_register_pre_el_change_hook (cpu, &pmu_pre_el_change,0 ); -arm_register_el_change_hook (cpu, &pmu_post_el_change,0 ); + cpu->pmceid0 =0 ; + cpu->pmceid1 =0 ; }if (!arm_feature (env,ARM_FEATURE_EL2 )) {
@@ -1685,8 +1694,6 @@ static void cortex_a7_initfn(Object *obj) cpu->id_pfr0 =0x00001131 ; cpu->id_pfr1 =0x00011011 ; cpu->id_dfr0 =0x02010555 ; - cpu->pmceid0 =0x00000000 ; - cpu->pmceid1 =0x00000000 ; cpu->id_afr0 =0x00000000 ; cpu->id_mmfr0 =0x10101105 ; cpu->id_mmfr1 =0x40000000 ;
@@ -1732,8 +1739,6 @@ static void cortex_a15_initfn(Object *obj) cpu->id_pfr0 =0x00001131 ; cpu->id_pfr1 =0x00011011 ; cpu->id_dfr0 =0x02010555 ; - cpu->pmceid0 =0x0000000 ; - cpu->pmceid1 =0x00000000 ; cpu->id_afr0 =0x00000000 ; cpu->id_mmfr0 =0x10201105 ; cpu->id_mmfr1 =0x20000000 ;
target/arm/cpu64.c +0 -4
@@ -138,8 +138,6 @@ static void aarch64_a57_initfn(Object *obj) cpu->isar.id_isar6 =0 ; cpu->isar.id_aa64pfr0 =0x00002222 ; cpu->id_aa64dfr0 =0x10305106 ; - cpu->pmceid0 =0x00000000 ; - cpu->pmceid1 =0x00000000 ; cpu->isar.id_aa64isar0 =0x00011120 ; cpu->isar.id_aa64mmfr0 =0x00001124 ; cpu->dbgdidr =0x3516d000 ;
@@ -246,8 +244,6 @@ static void aarch64_a72_initfn(Object *obj) cpu->isar.id_isar5 =0x00011121 ; cpu->isar.id_aa64pfr0 =0x00002222 ; cpu->id_aa64dfr0 =0x10305106 ; - cpu->pmceid0 =0x00000000 ; - cpu->pmceid1 =0x00000000 ; cpu->isar.id_aa64isar0 =0x00011120 ; cpu->isar.id_aa64mmfr0 =0x00001124 ; cpu->dbgdidr =0x3516d000 ;
target/arm/helper.c +57 -0
63 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 46/49] target/arm: PMU: Add instruction and cycle events
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
The instruction event is only enabled when icount is used, cycles are always supported. Always defining get_cycle_count (but altering its behavior depending on CONFIG_USER_ONLY) allows us to remove some CONFIG_USER_ONLY #defines throughout the rest of the code.
Message-id: [email protected]
--- target/arm/helper.c | 90 ++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 46 deletions(-)
target/arm/helper.c +44 -46
@@ -15,6 +15,7 @@#include "arm_ldst.h" #include <zlib.h> /* For crc32 */ #include "exec/semihost.h" +#include "sysemu/cpus.h" #include "sysemu/kvm.h" #include "fpu/softfloat.h" #include "qemu/range.h"
@@ -1021,7 +1022,48 @@ typedef struct pm_event {uint64_t (*get_count)(CPUARMState *); } pm_event; +static bool event_always_supported (CPUARMState *env) +{ +return true; +} + +/* +* Return the underlying cycle count for the PMU cycle counters. If we're in +* usermode, simply return 0. +*/ +static uint64_t cycles_get_count (CPUARMState *env) +{ +#ifndef CONFIG_USER_ONLY +return muldiv64 (qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ), +ARM_CPU_FREQ ,NANOSECONDS_PER_SECOND ); +#else +return cpu_get_host_ticks (); +#endif +} + +#ifndef CONFIG_USER_ONLY +static bool instructions_supported (CPUARMState *env) +{ +return use_icount ==1 /* Precise instruction counting */ ; +} + +static uint64_t instructions_get_count (CPUARMState *env) +{ +return (uint64_t )cpu_get_icount_raw (); +} +#endif +static const pm_event pm_events[] = { +#ifndef CONFIG_USER_ONLY + { .number =0x008 ,/* INST_RETIRED, Instruction architecturally executed */ + .supported = instructions_supported, + .get_count = instructions_get_count, + }, + { .number =0x011 ,/* CPU_CYCLES, Cycle */ + .supported = event_always_supported, + .get_count = cycles_get_count, + } +#endif };/*
@@ -1030,7 +1072,7 @@ static const pm_event pm_events[] = {* should first be updated to something sparse instead of the current * supported_event_map[] array. */ -#define MAX_EVENT_ID 0x0 +#define MAX_EVENT_ID 0x11#define UNSUPPORTED_EVENT UINT16_MAXstatic uint16_t supported_event_map[MAX_EVENT_ID +1 ];
@@ -1131,8 +1173,6 @@ static CPAccessResult pmreg_access_swinc(CPUARMState *env,return pmreg_access (env, ri, isread); } -#ifndef CONFIG_USER_ONLY -static CPAccessResult pmreg_access_selr (CPUARMState *env,const ARMCPRegInfo *ri,bool isread)
@@ -1243,9 +1283,7 @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)*/ void pmccntr_op_start (CPUARMState *env) { -uint64_t cycles =0 ; - cycles =muldiv64 (qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ), -ARM_CPU_FREQ ,NANOSECONDS_PER_SECOND ); +uint64_t cycles =cycles_get_count (env);if (pmu_counter_enabled (env,31 )) {uint64_t eff_cycles = cycles;
@@ -1391,42 +1429,6 @@ static void pmccntr_write32(CPUARMState *env, const ARMCPRegInfo *ri,pmccntr_write (env, ri,deposit64 (cur_val,0 ,32 , value)); } -#else /* CONFIG_USER_ONLY */ - -void pmccntr_op_start (CPUARMState *env) -{ -} - -void pmccntr_op_finish (CPUARMState *env) -{ -} - -void pmevcntr_op_start (CPUARMState *env,uint8_t i) -{ -} - -void pmevcntr_op_finish (CPUARMState *env,uint8_t i) -{ -} - -void pmu_op_start (CPUARMState *env) -{ -} - -void pmu_op_finish (CPUARMState *env) -{ -} - -void pmu_pre_el_change (ARMCPU *cpu,void *ignored) -{ -} - -void pmu_post_el_change (ARMCPU *cpu,void *ignored) -{ -} - -#endif -static void pmccfiltr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
@@ -1823,7 +1825,6 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {/* Unimplemented so WI. */ { .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4, .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NOP }, -#ifndef CONFIG_USER_ONLY { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, .access = PL0_RW, .type = ARM_CP_ALIAS, .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr),
@@ -1845,7 +1846,6 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .fieldoffset = offsetof(CPUARMState, cp15.c15_ccnt), .readfn = pmccntr_read, .writefn = pmccntr_write, .raw_readfn = raw_read, .raw_writefn = raw_write, }, -#endif { .name = "PMCCFILTR", .cp = 15, .opc1 = 0, .crn = 14, .crm = 15, .opc2 = 7, .writefn = pmccfiltr_write_a32, .readfn = pmccfiltr_read_a32, .access = PL0_RW, .accessfn = pmreg_access,
@@ -5675,7 +5675,6 @@ void register_cp_regs_for_features(ARMCPU *cpu)* count register. */ unsigned int i, pmcrn =0 ; -#ifndef CONFIG_USER_ONLY ARMCPRegInfo pmcr = { .name ="PMCR" , .cp =15 , .crn =9 , .crm =12 , .opc1 =0 , .opc2 =0 , .access =PL0_RW ,
@@ -5732,7 +5731,6 @@ void register_cp_regs_for_features(ARMCPU *cpu)g_free (pmevtyper_name);g_free (pmevtyper_el0_name); } -#endif ARMCPRegInfo clidr = { .name ="CLIDR" , .state =ARM_CP_STATE_BOTH , .opc0 =3 , .crn =0 , .crm =0 , .opc1 =1 , .opc2 =1 ,
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 45/49] target/arm: Finish implementation of PM[X]EVCNTR and PM[X]EVTYPER
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
Add arrays to hold the registers, the definitions themselves, access functions, and logic to reset counters when PMCR.P is set. Update filtering code to support counters other than PMCCNTR. Support migration with raw read/write functions.
Message-id: [email protected]
--- target/arm/cpu.h | 3 + target/arm/helper.c | 296 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 282 insertions(+), 17 deletions(-)
target/arm/cpu.h +3 -0
@@ -487,6 +487,9 @@ typedef struct CPUARMState {* pmccntr_op_finish. */ uint64_t c15_ccnt_delta; +uint64_t c14_pmevcntr[31 ]; +uint64_t c14_pmevcntr_delta[31 ]; +uint64_t c14_pmevtyper[31 ];uint64_t pmccfiltr_el0;/* Performance Monitor Filter Register */ uint64_t vpidr_el2;/* Virtualization Processor ID Register */ uint64_t vmpidr_el2;/* Virtualization Multiprocessor ID Register */
target/arm/helper.c +279 -17
397 lines not on this page · raw message
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 49/49] tests/libqtest: Introduce qtest_init_with_serial()
In reply to Peter MaydellFrom: Julia Suvorova <[email protected]>
Run qtest with a socket that connects QEMU chardev and test code.
Message-id: [email protected]
--- tests/libqtest.h | 11 +++++++++++ tests/libqtest.c | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
tests/libqtest.h +11 -0
@@ -62,6 +62,17 @@ QTestState *qtest_init(const char *extra_args);*/ QTestState *qtest_init_without_qmp_handshake (const char *extra_args); +/** +* qtest_init_with_serial: +* @extra_args: other arguments to pass to QEMU. CAUTION: these +* arguments are subject to word splitting and shell evaluation. +* @sock_fd: pointer to store the socket file descriptor for +* connection with serial. +* +* Returns: #QTestState instance. +*/ +QTestState *qtest_init_with_serial (const char *extra_args,int *sock_fd); +/** * qtest_quit: * @s: #QTestState instance to operate on.
tests/libqtest.c +26 -0
@@ -315,6 +315,32 @@ QTestState *qtest_initf(const char *fmt, ...)return s; } +QTestState *qtest_init_with_serial (const char *extra_args,int *sock_fd) +{ +int sock_fd_init; +char *sock_path, sock_dir[] ="/tmp/qtest-serial-XXXXXX" ; +QTestState *qts; + +g_assert (mkdtemp (sock_dir)); + sock_path =g_strdup_printf ("%s/sock" , sock_dir); + + sock_fd_init =init_socket (sock_path); + + qts =qtest_initf ("-chardev socket,id=s0,path=%s,nowait " +"-serial chardev:s0 %s" , + sock_path, extra_args); + + *sock_fd =socket_accept (sock_fd_init); + +unlink (sock_path); +g_free (sock_path); +rmdir (sock_dir); + +g_assert (*sock_fd >=0 ); + +return qts; +} +void qtest_quit (QTestState *s) {g_hook_destroy_link (&abrt_hooks,g_hook_find_data (&abrt_hooks, TRUE, s));
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 47/49] target/arm: PMU: Set PMCR.N to 4
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
This both advertises that we support four counters and enables them because the pmu_num_counters() reads this value from PMCR.
Message-id: [email protected]
--- target/arm/helper.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
target/arm/helper.c +5 -5
@@ -1777,7 +1777,7 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .access = PL1_W, .type = ARM_CP_NOP },/* Performance monitors are implementation defined in v7, * but with an ARM recommended set of registers, which we -* follow (although we don't actually implement any counters) +* follow. * * Performance registers fall into three categories: * (a) always UNDEF in PL0, RW in PL1 (PMINTENSET, PMINTENCLR)
@@ -5671,10 +5671,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) }if (arm_feature (env,ARM_FEATURE_V7 )) {/* v7 performance monitor control register: same implementor -* field as main ID register, and we implement only the cycle -* count register. +* field as main ID register, and we implement four counters in +* addition to the cycle count register. */ -unsigned int i, pmcrn =0 ; +unsigned int i, pmcrn =4 ;ARMCPRegInfo pmcr = { .name ="PMCR" , .cp =15 , .crn =9 , .crm =12 , .opc1 =0 , .opc2 =0 , .access =PL0_RW ,
@@ -5689,7 +5689,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL0_RW, .accessfn = pmreg_access, .type = ARM_CP_IO, .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), - .resetvalue = cpu->midr & 0xff000000, + .resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT), .writefn = pmcr_write, .raw_writefn = raw_write, };define_one_arm_cp_reg (cpu, &pmcr);
Signature · 1 line
2.20.1
[Qemu-devel] [PULL 48/49] target/arm: Implement PMSWINC
In reply to Peter MaydellFrom: Aaron Lindsay <[email protected]>
Message-id: [email protected]
--- target/arm/helper.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)
target/arm/helper.c +37 -2
@@ -1027,6 +1027,15 @@ static bool event_always_supported(CPUARMState *env)return true; } +static uint64_t swinc_get_count (CPUARMState *env) +{ +/* +* SW_INCR events are written directly to the pmevcntr's by writes to +* PMSWINC, so there is no underlying count maintained by the PMU itself +*/ +return 0 ; +} +/* * Return the underlying cycle count for the PMU cycle counters. If we're in * usermode, simply return 0.
@@ -1054,6 +1063,10 @@ static uint64_t instructions_get_count(CPUARMState *env)#endif static const pm_event pm_events[] = { + { .number =0x000 ,/* SW_INCR */ + .supported = event_always_supported, + .get_count = swinc_get_count, + }, #ifndef CONFIG_USER_ONLY { .number =0x008 ,/* INST_RETIRED, Instruction architecturally executed */ .supported = instructions_supported,
@@ -1393,6 +1406,24 @@ static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri,pmu_op_finish (env); } +static void pmswinc_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +unsigned int i; +for (i =0 ; i <pmu_num_counters (env); i++) { +/* Increment a counter's count iff: */ +if ((value & (1 << i)) &&/* counter's bit is set */ +/* counter is enabled and not filtered */ +pmu_counter_enabled (env, i) && +/* counter is SW_INCR */ + (env->cp15.c14_pmevtyper[i] &PMXEVTYPER_EVTCOUNT ) ==0x0 ) { +pmevcntr_op_start (env, i); + env->cp15.c14_pmevcntr[i]++; +pmevcntr_op_finish (env, i); + } + } +} +static uint64_t pmccntr_read (CPUARMState *env,const ARMCPRegInfo *ri) {uint64_t ret;
@@ -1822,9 +1853,13 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), .writefn = pmovsr_write, .raw_writefn = raw_write }, -/* Unimplemented so WI. */ { .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4, - .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NOP }, + .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NO_RAW, + .writefn = pmswinc_write }, + { .name = "PMSWINC_EL0", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 4, + .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NO_RAW, + .writefn = pmswinc_write }, { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, .access = PL0_RW, .type = ARM_CP_ALIAS, .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr),
Signature · 1 line
2.20.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [Qemu-devel] [PULL 00/49] target-arm queue
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'dc264dd9a4 tests/libqtest: Introduce qtest_init_with_serial()00a3d5ff24 target/arm: Implement PMSWINC1367cbdcd9 target/arm: PMU: Set PMCR.N to 4ec6f7cc59a target/arm: PMU: Add instruction and cycle events2d86ff3ae5 target/arm: Finish implementation of PM[X]EVCNTR and PM[X]EVTYPER c231717c50 target/arm: Add array for supported PMU events, generate PMCEID[01]_EL0 9760098cad target/arm: Make PMCEID[01]_EL0 64 bit registers, add PMCEID[23] d29040fb38 target/arm: Define FIELDs for ID_DFR089baa1c6e0 target/arm: Implement PMOVSSETd53dc888d1 target/arm: Allow AArch32 access for PMCCFILTR9638f29e02 target/arm: Filter cycle counter based on PMCCFILTR_EL0 3e0db1e655 target/arm: Swap PMU values before/after migrations5a8ad937a1 target/arm: Reorganize PMCCNTR accesses002e2a459e migration: Add post_save function to VMStateDescription 3c00592eb7 target/arm: Tidy TBI handling in gen_a64_set_pc24e28d6a3a target/arm: Enable PAuth for user-onlyfbf675bf14 target/arm: Enable PAuth for -cpu max789d26ba5d target/arm: Add PAuth system registersfc4ea461df target/arm: Implement pauth_computepac0f4ee384b6 target/arm: Implement pauth_addpac5d622eb1de target/arm: Implement pauth_auth6ef77a0dbf target/arm: Implement pauth_strip4db3223298 target/arm: Reuse aa64_va_parameters for setting tbflags 37911b85ec target/arm: Decode TBID from TCR45ff620692 target/arm: Add aa64_va_parameters_both60da4cfb8e target/arm: Export aa64_va_parameters to internals.h 9f6d40cbc7 target/arm: Merge TBFLAG_AA_TB{0, 1} to TBIId82bb524a6 target/arm: Create ARMVAParameters and helpers1c1d89edb6 target/arm: Introduce arm_stage1_mmu_idxe50f90142a target/arm: Introduce arm_mmu_idx1816b8d727 target/arm: Move cpu_mmu_index out of linea0033e2e8f target/arm: Decode Load/store register (pac)7f26a158f1 target/arm: Decode PAuth within disas_uncond_b_regab96f95f08 target/arm: Rearrange decode in disas_uncond_b_regc6f29a64cb target/arm: Add new_pc argument to helper_exception_return 00505a3d3b target/arm: Move helper_exception_return to helper-a64.c f1cd15ed3d target/arm: Decode PAuth within disas_data_proc_2src 186ce5b0aa target/arm: Decode PAuth within disas_data_proc_1src 6e4cf8f308 target/arm: Rearrange decode in disas_data_proc_1src 1b5190aa4b target/arm: Decode PAuth within system hint space9f6f95c13a target/arm: Add PAuth helpers2ab95bf605 target/arm: Introduce raise_exception_ra7d47196774 target/arm: Add PAuth active bit to tbflagseb274837e8 target/arm: Add SCTLR bits through ARMv8.5c1bb33ecce target/arm: Add state for the ARMv8.3-PAuth extension a5be306757 ftgmac100: implement the new MDIO interface on Aspeed SoC 20c6f95af2 target/arm: Allow Aarch32 exception return to switch from Mon->Hyp 1731fb6c58 hw/arm/virt-acpi-build: Set COHACC override flag in IORT SMMUv3 node f9b569ab06 hw/char/stm32f2xx_usart: Do not update data register when device is disabled
=== OUTPUT BEGIN ===
1/49 Checking commit f9b569ab06af (hw/char/stm32f2xx_usart: Do not update data register when device is disabled) 2/49 Checking commit 1731fb6c5864 (hw/arm/virt-acpi-build: Set COHACC override flag in IORT SMMUv3 node) 3/49 Checking commit 20c6f95af2a0 (target/arm: Allow Aarch32 exception return to switch from Mon->Hyp) 4/49 Checking commit a5be3067572d (ftgmac100: implement the new MDIO interface on Aspeed SoC) 5/49 Checking commit c1bb33ecce31 (target/arm: Add state for the ARMv8.3-PAuth extension)
6/49 Checking commit eb274837e818 (target/arm: Add SCTLR bits through ARMv8.5)
7/49 Checking commit 7d4719677443 (target/arm: Add PAuth active bit to tbflags)
8/49 Checking commit 2ab95bf605bb (target/arm: Introduce raise_exception_ra)
9/49 Checking commit 9f6f95c13a25 (target/arm: Add PAuth helpers)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#73:
new file mode 100644
total: 0 errors, 1 warnings, 226 lines checked
Patch 9/49 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
10/49 Checking commit 1b5190aa4be1 (target/arm: Decode PAuth within system hint space) 11/49 Checking commit 6e4cf8f308e7 (target/arm: Rearrange decode in disas_data_proc_1src) 12/49 Checking commit 186ce5b0aa7c (target/arm: Decode PAuth within disas_data_proc_1src) 13/49 Checking commit f1cd15ed3df3 (target/arm: Decode PAuth within disas_data_proc_2src) 14/49 Checking commit 00505a3d3be5 (target/arm: Move helper_exception_return to helper-a64.c)
WARNING: Block comments use a leading /* on a separate line
#25: FILE: target/arm/helper-a64.c:892:
+ /* Return the exception level that this SPSR is requesting a return to,
WARNING: Block comments use a leading /* on a separate line #42: FILE: target/arm/helper-a64.c:909:
+ /* Returning to Mon from AArch64 is never possible,
WARNING: Block comments use a leading /* on a separate line #73: FILE: target/arm/helper-a64.c:940:
+ /* We must squash the PSTATE.SS bit to zero unless both of the
WARNING: Block comments use a leading /* on a separate line #90: FILE: target/arm/helper-a64.c:957:
+ /* Disallow return to an EL which is unimplemented or higher
WARNING: Block comments use a leading /* on a separate line #116: FILE: target/arm/helper-a64.c:983:
+ /* We do a raw CPSR write because aarch64_sync_64_to_32()
WARNING: Block comments use a leading /* on a separate line #159: FILE: target/arm/helper-a64.c:1026:
+ /* Illegal return events of various kinds have architecturally
total: 0 errors, 6 warnings, 337 lines checked
Patch 14/49 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
15/49 Checking commit c6f29a64cb80 (target/arm: Add new_pc argument to helper_exception_return) 16/49 Checking commit ab96f95f0865 (target/arm: Rearrange decode in disas_uncond_b_reg) 17/49 Checking commit 7f26a158f181 (target/arm: Decode PAuth within disas_uncond_b_reg) 18/49 Checking commit a0033e2e8f58 (target/arm: Decode Load/store register (pac))
WARNING: Block comments use a leading /* on a separate line
#74: FILE: target/arm/translate-a64.c:3198:
+ do_gpr_ld(s, tcg_rt, tcg_addr, size, /* is_signed */ false,
WARNING: Block comments use a leading /* on a separate line #75: FILE: target/arm/translate-a64.c:3199:
+ /* extend */ false, /* iss_valid */ !is_wback,
WARNING: Block comments use a leading /* on a separate line #76: FILE: target/arm/translate-a64.c:3200:
+ /* iss_srt */ rt, /* iss_sf */ true, /* iss_ar */ false);
total: 0 errors, 3 warnings, 73 lines checked
Patch 18/49 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
19/49 Checking commit 1816b8d72764 (target/arm: Move cpu_mmu_index out of line) 20/49 Checking commit e50f90142a9f (target/arm: Introduce arm_mmu_idx)
WARNING: Block comments use a leading /* on a separate line
#31: FILE: target/arm/cpu.h:2752:
+/**
WARNING: Block comments use a leading /* on a separate line #121: FILE: target/arm/internals.h:922:
+/**
total: 0 errors, 2 warnings, 90 lines checked
Patch 20/49 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
21/49 Checking commit 1c1d89edb6b5 (target/arm: Introduce arm_stage1_mmu_idx)
WARNING: Block comments use a leading /* on a separate line
#42: FILE: target/arm/internals.h:930:
+/**
total: 0 errors, 1 warnings, 32 lines checked
Patch 21/49 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
22/49 Checking commit d82bb524a63d (target/arm: Create ARMVAParameters and helpers)
ERROR: spaces prohibited around that ':' (ctx:WxW)
#376: FILE: target/arm/internals.h:950:
+ unsigned tsz : 8;
^ERROR: spaces prohibited around that ':' (ctx:WxW) #377: FILE: target/arm/internals.h:951:
+ unsigned select : 1;
^ERROR: spaces prohibited around that ':' (ctx:WxW) #378: FILE: target/arm/internals.h:952:
+ bool tbi : 1;
^ERROR: spaces prohibited around that ':' (ctx:WxW) #379: FILE: target/arm/internals.h:953:
+ bool epd : 1;
^ERROR: spaces prohibited around that ':' (ctx:WxW) #380: FILE: target/arm/internals.h:954:
+ bool hpd : 1;
^ERROR: spaces prohibited around that ':' (ctx:WxW) #381: FILE: target/arm/internals.h:955:
+ bool using16k : 1;
^ERROR: spaces prohibited around that ':' (ctx:WxW) #382: FILE: target/arm/internals.h:956:
+ bool using64k : 1;
^total: 7 errors, 0 warnings, 354 lines checked
Patch 22/49 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
23/49 Checking commit 9f6d40cbc750 (target/arm: Merge TBFLAG_AA_TB{0, 1} to TBII) 24/49 Checking commit 60da4cfb8e6d (target/arm: Export aa64_va_parameters to internals.h) 25/49 Checking commit 45ff620692b8 (target/arm: Add aa64_va_parameters_both) 26/49 Checking commit 37911b85ec73 (target/arm: Decode TBID from TCR)
ERROR: spaces prohibited around that ':' (ctx:WxW)
#87: FILE: target/arm/internals.h:953:
+ bool tbid : 1;
^total: 1 errors, 0 warnings, 60 lines checked
Patch 26/49 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
27/49 Checking commit 4db3223298d6 (target/arm: Reuse aa64_va_parameters for setting tbflags) 28/49 Checking commit 6ef77a0dbf11 (target/arm: Implement pauth_strip)
29/49 Checking commit 5d622eb1de2d (target/arm: Implement pauth_auth)
30/49 Checking commit 0f4ee384b685 (target/arm: Implement pauth_addpac)
31/49 Checking commit fc4ea461dfc5 (target/arm: Implement pauth_computepac) 32/49 Checking commit 789d26ba5d8a (target/arm: Add PAuth system registers) 33/49 Checking commit fbf675bf14bf (target/arm: Enable PAuth for -cpu max) 34/49 Checking commit 24e28d6a3adf (target/arm: Enable PAuth for user-only) 35/49 Checking commit 3c00592eb7ea (target/arm: Tidy TBI handling in gen_a64_set_pc) 36/49 Checking commit 002e2a459e51 (migration: Add post_save function to VMStateDescription) 37/49 Checking commit 5a8ad937a141 (target/arm: Reorganize PMCCNTR accesses)
WARNING: Block comments use a leading /* on a separate line
#33: FILE: target/arm/cpu.h:476:
+ /* Stores the architectural value of the counter *the last time it was
WARNING: Block comments use a leading /* on a separate line #39: FILE: target/arm/cpu.h:482:
+ /* Stores the delta between the architectural value and the underlying
WARNING: Block comments use a leading /* on a separate line #70: FILE: target/arm/cpu.h:994:
+/**
total: 0 errors, 3 warnings, 217 lines checked
Patch 37/49 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
38/49 Checking commit 3e0db1e65591 (target/arm: Swap PMU values before/after migrations) 39/49 Checking commit 9638f29e02e9 (target/arm: Filter cycle counter based on PMCCFILTR_EL0)
WARNING: Block comments use a leading /* on a separate line
#41: FILE: target/arm/cpu.h:1005:
+/**
WARNING: Block comments use a leading /* on a separate line
#102: FILE: target/arm/helper.c:1092:
+/* Returns true if the counter (pass 31 for PMCCNTR) should count events using
total: 0 errors, 2 warnings, 178 lines checked
Patch 39/49 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
40/49 Checking commit d53dc888d187 (target/arm: Allow AArch32 access for PMCCFILTR)
41/49 Checking commit 89baa1c6e08b (target/arm: Implement PMOVSSET)
42/49 Checking commit d29040fb38b6 (target/arm: Define FIELDs for ID_DFR0)
43/49 Checking commit 9760098cadc2 (target/arm: Make PMCEID[01]_EL0 64 bit registers, add PMCEID[23]) 44/49 Checking commit c231717c50b1 (target/arm: Add array for supported PMU events, generate PMCEID[01]_EL0) 45/49 Checking commit 2d86ff3ae545 (target/arm: Finish implementation of PM[X]EVCNTR and PM[X]EVTYPER)
WARNING: Block comments use a leading /* on a separate line
#307: FILE: target/arm/helper.c:1604:
+ /* We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR
WARNING: Block comments use a trailing */ on a separate line #308: FILE: target/arm/helper.c:1605:
+ * are CONSTRAINED UNPREDICTABLE. */
total: 0 errors, 2 warnings, 406 lines checked
Patch 45/49 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
46/49 Checking commit ec6f7cc59aa3 (target/arm: PMU: Add instruction and cycle events)
WARNING: Block comments use a leading /* on a separate line
#57: FILE: target/arm/helper.c:1047:
+ return use_icount == 1 /* Precise instruction counting */;
total: 0 errors, 1 warnings, 151 lines checked
Patch 46/49 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
47/49 Checking commit 1367cbdcd990 (target/arm: PMU: Set PMCR.N to 4) 48/49 Checking commit 00a3d5ff24fe (target/arm: Implement PMSWINC)
49/49 Checking commit dc264dd9a4ef (tests/libqtest: Introduce qtest_init_with_serial())
WARNING: Block comments use a leading /* on a separate line
#60: FILE: tests/libqtest.h:65:
+/**
total: 0 errors, 1 warnings, 49 lines checked
Patch 49/49 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]