target-arm queue
Subsystems (2)
Smaller pullreq this time around; FEAT_IDTE3 plus a scattering of bug fixes.
-- PMM
The following changes since commit 7e8d3c7fc460fe7cd28a3e423d7466fa292bc269:
Merge tag 'pull-aspeed-20261015' of https://github.com/legoater/qemu into staging (2026-10-15 14:58:28 +0200)
are available in the Git repository at:
https://gitlab.com/pm215/qemu.git tags/pull-target-arm-20261015
for you to fetch changes up to c595a87dc3e318532460c654c36dea08e6ac993a:
target/arm/tcg/gicv5-cpuif: Fix typo in ICC_PPI_SPENDR1_EL1 name (2026-10-15 17:38:38 +0100)
----------------------------------------------------------------
target-arm queue:
* fix user-mode emulation of ID_AA64MMFR0_EL1
* Fix handling of 52-bit TTBRs
* Emulate FEAT_IDTE3
* hw/arm/virt: Use TAG_GRANULE when creating tag memory
* hw/timer/stm32f2xx_timer: fix periodic mode and CEN handling
* hw/misc/stm32_rcc: Mirror clock ready and switch status bits
* hw/intc/arm_gicv5: Make IRS_IDR0 reads return actual value, not 0
* target/arm/tcg/gicv5-cpuif: Fix typo in ICC_PPI_SPENDR1_EL1 name
----------------------------------------------------------------
Alex Bennée (1):
target/arm: fix user-mode emulation of ID_AA64MMFR0_EL1
Fuad Tabba (4):
target/arm: Clear TTBR[5:0] from a 52-bit table base address tests/tcg/aarch64: Add a test for a two-entry 52-bit TTBR table target/arm: Use the 52-bit TTBR base address layout when TCR.DS is set tests/tcg/aarch64: Test the TTBR layout with TCR.DS and a 48-bit OA
Gustavo Romero (1):
hw/arm/virt: Use TAG_GRANULE when creating tag memory
Manuele Conti (2):
hw/timer/stm32f2xx_timer: fix periodic mode and CEN handling hw/misc/stm32_rcc: Mirror clock ready and switch status bits
Peter Maydell (2):
hw/intc/arm_gicv5: Make IRS_IDR0 reads return actual value, not 0 target/arm/tcg/gicv5-cpuif: Fix typo in ICC_PPI_SPENDR1_EL1 name
Richard Henderson (6):
target/arm: Rename isar_feature_aa64_idst target/arm: Enable writes to SCR_EL3.TID{3,5} target/arm: Squash accessfn in modify_arm_cp_regs_with_len target/arm: Implement SCR_EL3.TID3
target/arm: Implement SCR_EL3.TID5
target/arm: Enable FEAT_IDTE3 for -cpu max
MAINTAINERS | 1 + docs/system/arm/emulation.rst | 1 + include/hw/timer/stm32f2xx_timer.h | 2 +- target/arm/cpu-features.h | 7 +- target/arm/cpu.h | 2 + hw/arm/virt.c | 6 +- hw/intc/arm_gicv5.c | 1 + hw/misc/stm32_rcc.c | 19 ++++ hw/timer/stm32f2xx_timer.c | 73 +++++++++--- target/arm/helper.c | 51 ++++++++- target/arm/ptw.c | 18 ++- target/arm/tcg/cpu64.c | 4 + target/arm/tcg/gicv5-cpuif.c | 2 +- target/arm/tcg/op_helper.c | 2 +- target/arm/tcg/translate-a64.c | 2 +- tests/qtest/stm32f405-rcc-test.c | 62 ++++++++++ tests/qtest/stm32f405-timer-test.c | 136 ++++++++++++++++++++++ tests/tcg/aarch64/sysregs.c | 31 ++++- tests/tcg/aarch64/system/ttbr-baddr.c | 208 ++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 + tests/tcg/aarch64/system/meson.build | 6 + 21 files changed, 596 insertions(+), 40 deletions(-) create mode 100644 tests/qtest/stm32f405-rcc-test.c create mode 100644 tests/qtest/stm32f405-timer-test.c create mode 100644 tests/tcg/aarch64/system/ttbr-baddr.c
[PULL 10/16] target/arm: Enable writes to SCR_EL3.TID{3,5}
From: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/cpu-features.h | 5 +++++ target/arm/cpu.h | 2 ++ target/arm/helper.c | 3 +++ 3 files changed, 10 insertions(+)
target/arm/cpu-features.h +5 -0
@@ -1408,6 +1408,11 @@ static inline bool isar_feature_aa64_idst(const ARMISARegisters *id)return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,IDS ) !=0 ; } +static inline bool isar_feature_aa64_idte3 (const ARMISARegisters *id) +{ +return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,IDS ) >=2 ; +} +static inline bool isar_feature_aa64_half_evt (const ARMISARegisters *id) {return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,EVT ) >=1 ;
target/arm/cpu.h +2 -0
@@ -1811,6 +1811,8 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)#define SCR_EASE (1ULL << 19)#define SCR_NMEA (1ULL << 20)#define SCR_FIEN (1ULL << 21) +#define SCR_TID3 (1ULL << 22) +#define SCR_TID5 (1ULL << 23)#define SCR_ENSCXT (1ULL << 25)#define SCR_ATA (1ULL << 26)#define SCR_FGTEN (1ULL << 27)
target/arm/helper.c +3 -0
@@ -960,6 +960,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)if (cpu_isar_feature (aa64_rng_trap, cpu)) { valid_mask |=SCR_TRNDR ; } +if (cpu_isar_feature (aa64_idte3, cpu)) { + valid_mask |=SCR_TID5 |SCR_TID3 ; + } }else { valid_mask &= ~(SCR_RW |SCR_ST );if (cpu_isar_feature (aa32_ras, cpu)) {
Signature · 1 line
2.43.0
[PULL 08/16] tests/tcg/aarch64: Test the TTBR layout with TCR.DS and a 48-bit OA
In reply to Peter MaydellFrom: Fuad Tabba <[email protected]>
Extend the TTBR base address test to check that, with TCR.DS or VTCR.DS and a 48-bit OA, setting TTBR[5:2] is a level 0 Address size fault.
Message-id: [email protected]
--- tests/tcg/aarch64/system/ttbr-baddr.c | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
tests/tcg/aarch64/system/ttbr-baddr.c +55 -0
@@ -4,6 +4,8 @@* With a 52-bit OA, walk a two-entry level 0 table through an IPA with * bit 50 set, which stage 2 maps back onto the table, so the walk * succeeds only if TTBR[4] is cleared from bit 4 of the base address. +* With TCR.DS or VTCR.DS and a 48-bit OA, check that setting TTBR[5:2] +* is a level 0 Address size fault. * * Copyright (c) 2026 Google LLC * Author: Fuad Tabba <[email protected]>
@@ -42,10 +44,13 @@* Stage 1: 16KB granule, 48-bit VA, so level 0 has two entries. * Stage 2: 64KB granule, 52-bit IPA, mapping RAM at its own address and * again at HIGH_IPA. +* Stage 2 with VTCR.DS: 16KB granule, 47-bit IPA, mapping RAM flat. */ static uint64_t s1_l0[2048] __attribute__((aligned(16384))); static uint64_t s1_l1[2048] __attribute__((aligned(16384))); static uint64_t s1_l2[2048] __attribute__((aligned(16384))); +static uint64_t s2ds_l1[2048] __attribute__((aligned(16384))); +static uint64_t s2ds_l2[2048] __attribute__((aligned(16384))); static uint64_t s2_l1[1024] __attribute__((aligned(65536))); static uint64_t s2_l2[8192] __attribute__((aligned(65536))); static uint64_t s2_l2_high[8192] __attribute__((aligned(65536)));
@@ -54,20 +59,27 @@ static uint64_t s2_l2_high[8192] __attribute__((aligned(65536)));#define TCR_T1SZ (x) ((uint64_t)(x) << 16)#define TCR_TG0_16K (2UL << 14)#define TCR_TG1_16K (1UL << 30) +#define TCR_IPS_48 (5UL << 32)#define TCR_IPS_52 (6UL << 32)#define TCR_DS (1UL << 59)#define VTCR_T0SZ (x) ((uint64_t)(x) << 0)#define VTCR_SL0_L1 (2UL << 6) +#define VTCR_TG0_16K (2UL << 14)#define VTCR_TG0_64K (1UL << 14) +#define VTCR_PS_48 (5UL << 16)#define VTCR_PS_52 (6UL << 16)#define VTCR_RES1 (1UL << 31) +#define VTCR_DS (1UL << 32)#define HCR_VM (1UL << 0)#define HCR_RW (1UL << 31)#define PAR_F (1UL << 0) +#define PAR_FST (par) (((par) >> 1) & 0x3f)#define PAR_PA (par) ((par) & 0xfffffffff000UL) +#define FST_ADDR_SIZE_L0 0x00 +#define S2_BLOCK ((1 << 10) | (3 << 6) | (0xf << 2) | 1)static void tlb_flush (void )
@@ -86,6 +98,17 @@ static uint64_t at(uint64_t ttbr1)return par; } +static uint64_t at_s1 (uint64_t ttbr1) +{ +uint64_t par; + +write_sysreg (ttbr1_el1, ttbr1); +tlb_flush (); + asmvolatile ("at s1e1r, %1; isb; mrs %0, par_el1" + :"=r" (par) :"r" (TEST_VA )); +return par; +} +static void setup_tables (void ) {/* Stage 1: TEST_VA -> RAM_BASE, 32MB block, AF */
@@ -93,6 +116,10 @@ static void setup_tables(void) s1_l1[0 ] = (uint64_t )s1_l2 |3 ; s1_l2[(RAM_BASE >>25 ) &0x7ff ] =RAM_BASE | (1 <<10 ) |1 ; +/* Stage 2 with VTCR.DS: RAM_BASE -> RAM_BASE, 32MB block, AF, RW */ + s2ds_l1[0 ] = (uint64_t )s2ds_l2 |3 ; + s2ds_l2[(RAM_BASE >>25 ) &0x7ff ] =RAM_BASE |S2_BLOCK ; +/* Stage 2: 512MB blocks at RAM_BASE and HIGH_IPA | RAM_BASE, AF, RW */ s2_l1[0 ] = (uint64_t )s2_l2 |3 ; s2_l1[HIGH_IPA >>42 ] = (uint64_t )s2_l2_high |3 ;
@@ -108,6 +135,15 @@ static int check(const char *name, uint64_t par)return !ok; } +/* A level 0 Address size fault */ +static int check_fault (const char *name,uint64_t par) +{ +int ok = (par &PAR_F ) &&PAR_FST (par) ==FST_ADDR_SIZE_L0 ; + +ml_printf ("%s: PAR_EL1=%lx %s\n" , name, par, ok ?"ok" :"FAIL" ); +return !ok; +} +int main (void ) {uint64_t mmfr0 =read_sysreg (id_aa64mmfr0_el1);
@@ -135,6 +171,25 @@ int main(void)write_sysreg (mair_el1,0xff );write_sysreg (sctlr_el1,read_sysreg (sctlr_el1) |1 ); +/* +* TCR.DS with a 48-bit OA: TTBR[5:2] are base address bits [51:48], +* so setting any of them is a level 0 Address size fault. +*/ +write_sysreg (hcr_el2,HCR_RW ); +write_sysreg (tcr_el1, tcr |TCR_IPS_48 ); + ret |=check ("ips48" ,at_s1 (base)); + ret |=check_fault ("ips48 ttbr[2]" ,at_s1 (base | (1 <<2 ))); + ret |=check_fault ("ips48 ttbr[4]" ,at_s1 (base | (1 <<4 ))); + +/* The same for VTTBR, with VTCR.DS and a 48-bit PS */ +write_sysreg (vtcr_el2,VTCR_T0SZ (17 ) |VTCR_SL0_L1 |VTCR_TG0_16K | +VTCR_PS_48 |VTCR_RES1 |VTCR_DS ); +write_sysreg (hcr_el2,HCR_RW |HCR_VM ); +write_sysreg (vttbr_el2, (uint64_t )s2ds_l1); + ret |=check ("ps48" ,at (base)); +write_sysreg (vttbr_el2, (uint64_t )s2ds_l1 | (1 <<2 )); + ret |=check_fault ("ps48 vttbr[2]" ,at (base)); +/* * 52-bit OA: TTBR[4] is base address bit 50, so with it set the * level 0 table is at IPA HIGH_IPA | s1_l0. Stage 2 maps that IPA
Signature · 1 line
2.43.0
[PULL 11/16] target/arm: Squash accessfn in modify_arm_cp_regs_with_len
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
When reducing permission of ID registers for userspace access for an emulated kernel, drop the access check as well.
Message-id: [email protected]
--- target/arm/helper.c | 2 ++ 1 file changed, 2 insertions(+)
target/arm/helper.c +2 -0
@@ -8406,11 +8406,13 @@ void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len,if (pat &&g_pattern_match_string (pat, r->name)) { r->type =ARM_CP_CONST ; r->access =PL0U_R ; + r->accessfn =NULL ; r->resetvalue =0 ;/* continue */ }else if (strcmp (r->name, m->name) ==0 ) { r->type =ARM_CP_CONST ; r->access =PL0U_R ; + r->accessfn =NULL ; r->resetvalue &= m->exported_bits; r->resetvalue |= m->fixed_bits;break ;
Signature · 1 line
2.43.0
[PULL 06/16] tests/tcg/aarch64: Add a test for a two-entry 52-bit TTBR table
In reply to Peter MaydellFrom: Fuad Tabba <[email protected]>
Add a test checking that, with a 52-bit OA, TTBR[4] of a two-entry level 0 table is taken only as base address bit 50, not also as bit 4.
Message-id: [email protected]
--- tests/tcg/aarch64/system/ttbr-baddr.c | 153 ++++++++++++++++++++++++++ tests/tcg/aarch64/system/meson.build | 6 + 2 files changed, 159 insertions(+) create mode 100644 tests/tcg/aarch64/system/ttbr-baddr.c
tests/tcg/aarch64/system/ttbr-baddr.c new file +153 -0
@@ -0,0 +1,153 @@ +/* +* TTBR base address with a 52-bit layout and a small initial lookup table +* +* With a 52-bit OA, walk a two-entry level 0 table through an IPA with +* bit 50 set, which stage 2 maps back onto the table, so the walk +* succeeds only if TTBR[4] is cleared from bit 4 of the base address. +* +* Copyright (c) 2026 Google LLC +* Author: Fuad Tabba <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include <stdint.h> +#include <minilib.h> + +/* from Linux's include/linux/stringify.h */ +#define __stringify_1(x...) #x +#define __stringify(x...) __stringify_1(x) + +#define read_sysreg (r) ({ \ + uint64_t __val; \ + asm volatile("mrs %0, " __stringify(r) : "=r" (__val)); \ + __val; \ +}) + +#define write_sysreg (r, v) do { \ + uint64_t __val = (uint64_t)(v); \ + asm volatile("msr " __stringify(r) ", %x0" \ + : : "rZ" (__val)); \ +} while (0) + +/* +* kernel.ld links the test at 1GB, so the tables below lie within the +* blocks mapped at RAM_BASE. +*/ +#define RAM_BASE 0x40000000UL +#define HIGH_IPA (1UL << 50) +#define TEST_VA (0xffff000000000000UL | RAM_BASE) + +/* +* Stage 1: 16KB granule, 48-bit VA, so level 0 has two entries. +* Stage 2: 64KB granule, 52-bit IPA, mapping RAM at its own address and +* again at HIGH_IPA. +*/ +static uint64_t s1_l0[2048] __attribute__((aligned(16384))); +static uint64_t s1_l1[2048] __attribute__((aligned(16384))); +static uint64_t s1_l2[2048] __attribute__((aligned(16384))); +static uint64_t s2_l1[1024] __attribute__((aligned(65536))); +static uint64_t s2_l2[8192] __attribute__((aligned(65536))); +static uint64_t s2_l2_high[8192] __attribute__((aligned(65536))); + +#define TCR_T0SZ (x) ((uint64_t)(x) << 0) +#define TCR_T1SZ (x) ((uint64_t)(x) << 16) +#define TCR_TG0_16K (2UL << 14) +#define TCR_TG1_16K (1UL << 30) +#define TCR_IPS_52 (6UL << 32) +#define TCR_DS (1UL << 59) + +#define VTCR_T0SZ (x) ((uint64_t)(x) << 0) +#define VTCR_SL0_L1 (2UL << 6) +#define VTCR_TG0_64K (1UL << 14) +#define VTCR_PS_52 (6UL << 16) +#define VTCR_RES1 (1UL << 31) + +#define HCR_VM (1UL << 0) +#define HCR_RW (1UL << 31) + +#define PAR_F (1UL << 0) +#define PAR_PA (par) ((par) & 0xfffffffff000UL) +#define S2_BLOCK ((1 << 10) | (3 << 6) | (0xf << 2) | 1) + +static void tlb_flush (void ) +{ + asmvolatile ("dsb sy; tlbi alle1; dsb sy; isb" : : :"memory" ); +} + +static uint64_t at (uint64_t ttbr1) +{ +uint64_t par; + +write_sysreg (ttbr1_el1, ttbr1); +tlb_flush (); + asmvolatile ("at s12e1r, %1; isb; mrs %0, par_el1" + :"=r" (par) :"r" (TEST_VA )); +return par; +} + +static void setup_tables (void ) +{ +/* Stage 1: TEST_VA -> RAM_BASE, 32MB block, AF */ + s1_l0[0 ] = (uint64_t )s1_l1 |3 ; + s1_l1[0 ] = (uint64_t )s1_l2 |3 ; + s1_l2[(RAM_BASE >>25 ) &0x7ff ] =RAM_BASE | (1 <<10 ) |1 ; + +/* Stage 2: 512MB blocks at RAM_BASE and HIGH_IPA | RAM_BASE, AF, RW */ + s2_l1[0 ] = (uint64_t )s2_l2 |3 ; + s2_l1[HIGH_IPA >>42 ] = (uint64_t )s2_l2_high |3 ; + s2_l2[RAM_BASE >>29 ] =RAM_BASE |S2_BLOCK ; + s2_l2_high[RAM_BASE >>29 ] =RAM_BASE |S2_BLOCK ; +} + +static int check (const char *name,uint64_t par) +{ +int ok = !(par &PAR_F ) &&PAR_PA (par) ==RAM_BASE ; + +ml_printf ("%s: PAR_EL1=%lx %s\n" , name, par, ok ?"ok" :"FAIL" ); +return !ok; +} + +int main (void ) +{ +uint64_t mmfr0 =read_sysreg (id_aa64mmfr0_el1); +uint64_t tcr =TCR_T0SZ (16 ) |TCR_T1SZ (16 ) |TCR_TG0_16K |TCR_TG1_16K | +TCR_DS ; +uint64_t base = (uint64_t )s1_l0; +int ret =0 ; + +ml_printf ("TTBR base address test\n" ); + +/* +* PARange 52 bits (FEAT_LPA) and TGran16 with 52-bit addresses +* (FEAT_LPA2) +*/ +if ((mmfr0 &0xf ) !=6 || ((mmfr0 >>20 ) &0xf ) !=2 ) { +ml_printf ("SKIP: no 52-bit PA or no FEAT_LPA2 with 16KB\n" ); +return ret; + } + +/* +* The test runs at EL2 (arg=2) and walks the EL1&0 regime with AT, so +* the EL1 MMU settings below only affect those walks. +*/ +setup_tables (); +write_sysreg (mair_el1,0xff ); +write_sysreg (sctlr_el1,read_sysreg (sctlr_el1) |1 ); + +/* +* 52-bit OA: TTBR[4] is base address bit 50, so with it set the +* level 0 table is at IPA HIGH_IPA | s1_l0. Stage 2 maps that IPA +* onto s1_l0 (through s2_l2_high), so the walk succeeds only if +* TTBR[4] does not also offset the two-entry table by 0x10. +*/ +write_sysreg (vtcr_el2,VTCR_T0SZ (12 ) |VTCR_SL0_L1 |VTCR_TG0_64K | +VTCR_PS_52 |VTCR_RES1 ); +write_sysreg (vttbr_el2, (uint64_t )s2_l1); +write_sysreg (hcr_el2,HCR_RW |HCR_VM ); +write_sysreg (tcr_el1, tcr |TCR_IPS_52 ); + ret |=check ("ips52" ,at (base)); + ret |=check ("ips52 ttbr[4]" ,at (base | (1 <<4 ))); + +return ret; +}
tests/tcg/aarch64/system/meson.build +6 -0
@@ -79,6 +79,12 @@ tests += { '-semihosting-config', 'enable=on,arg=2', qemu_base_args] }, + 'ttbr-baddr.c': { + 'cflags': cflags, + 'qemu_args': ['-M', 'virt,virtualization=on', '-cpu', 'max', + '-semihosting-config', 'enable=on,arg=2', + qemu_base_args] + }, } tests += {
Signature · 1 line
2.43.0
[PULL 03/16] hw/timer/stm32f2xx_timer: fix periodic mode and CEN handling
In reply to Peter MaydellFrom: Manuele Conti <[email protected]>
RM0090 timers count from 0 to ARR inclusive, with a period of ARR + 1, including ARR == 0. Wrap CNT while running, arm an absolute expiry, and delete the QEMU timer when CEN is cleared.
Freeze CNT in stopped_cnt while CEN is clear so TIM_CNT writes while stopped are preserved and resume on enable. Return a stopped CNT verbatim even when it is greater than ARR. Reset also deletes any pending event.
Migration compatibility is not required for these machine types, so use version 2 as both the current and minimum VMState version and serialize stopped_cnt directly.
Add qtests covering the timer period, prescaler, stopped CNT, ARR == 0, update generation, and system reset.
--- MAINTAINERS | 1 + include/hw/timer/stm32f2xx_timer.h | 2 +- hw/timer/stm32f2xx_timer.c | 73 ++++++++++++---- tests/qtest/stm32f405-timer-test.c | 136 +++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 + 5 files changed, 195 insertions(+), 19 deletions(-) create mode 100644 tests/qtest/stm32f405-timer-test.c
MAINTAINERS +1 -0
@@ -1216,6 +1216,7 @@ F: hw/misc/stm32f4xx_syscfg.c F: hw/misc/stm32f4xx_exti.c F: hw/misc/stm32_rcc.c F: include/hw/misc/stm32_rcc.h +F: tests/qtest/stm32f405* Netduino 2 M: Alistair Francis <[email protected]>
include/hw/timer/stm32f2xx_timer.h +1 -1
@@ -76,7 +76,6 @@ struct STM32F2XXTimerState {qemu_irq irq;int64_t tick_offset; -uint64_t hit_time;uint64_t freq_hz;uint32_t tim_cr1;
@@ -97,6 +96,7 @@ struct STM32F2XXTimerState {uint32_t tim_dcr;uint32_t tim_dmar;uint32_t tim_or; + uint32_t stopped_cnt; };#endif /* HW_STM32F2XX_TIMER_H */
hw/timer/stm32f2xx_timer.c +55 -18
148 lines not on this page · raw message
tests/qtest/stm32f405-timer-test.c new file +136 -0
136 lines not on this page · raw message
tests/qtest/meson.build +2 -0
@@ -253,6 +253,8 @@ qtests_exynos4210 = \ ['exynos4210_uart_fifo-test'] qtests_arm = \ + (config_all_devices.has_key('CONFIG_OLIMEX_STM32_H405') ? \ + ['stm32f405-timer-test'] : []) + \ (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \ (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \ (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
Signature · 1 line
2.43.0
[PULL 09/16] target/arm: Rename isar_feature_aa64_idst
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Rename from isar_feature_aa64_ids to match the feature name: FEAT_IDST.
Message-id: [email protected]
--- target/arm/cpu-features.h | 2 +- target/arm/tcg/op_helper.c | 2 +- target/arm/tcg/translate-a64.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
target/arm/cpu-features.h +1 -1
@@ -1403,7 +1403,7 @@ static inline bool isar_feature_aa64_fwb(const ARMISARegisters *id)return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,FWB ) !=0 ; } -static inline bool isar_feature_aa64_ids (const ARMISARegisters *id) +static inline bool isar_feature_aa64_idst (const ARMISARegisters *id) {return FIELD_EX64_IDREG (id,ID_AA64MMFR2 ,IDS ) !=0 ; }
target/arm/tcg/op_helper.c +1 -1
@@ -1136,7 +1136,7 @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key,break ;case CP_ACCESS_UNDEFINED :/* CP_ACCESS_UNDEFINED is never direct to a specified EL */ -if (cpu_isar_feature (aa64_ids, cpu) && isread && +if (cpu_isar_feature (aa64_idst, cpu) && isread &&arm_cpreg_in_idspace (ri)) {/* * FEAT_IDST says this should be reported as EC_SYSTEMREGISTERTRAP,
target/arm/tcg/translate-a64.c +1 -1
@@ -2675,7 +2675,7 @@ static void gen_sysreg_undef(DisasContext *s, bool isread,*/ uint32_t syndrome; -if (isread &&dc_isar_feature (aa64_ids, s) && +if (isread &&dc_isar_feature (aa64_idst, s) &&arm_cpreg_encoding_in_idspace (op0, op1, op2, crn, crm)) { syndrome =syn_aa64_sysregtrap (op0, op1, op2, crn, crm, rt, isread); }else {
Signature · 1 line
2.43.0
[PULL 15/16] hw/intc/arm_gicv5: Make IRS_IDR0 reads return actual value, not 0
In reply to Peter MaydellIN the code for handling reads of IRS_IDR0, we carefully construct the correct value starting with cs->irs_idr0 and adjusting it. However, we never actually write the final value into *data, so the guest will always see zero.
We didn't notice this before, because Linux happens to not care about this register value except to check for the presence of virtualization.
Message-id: [email protected]
--- hw/intc/arm_gicv5.c | 1 + 1 file changed, 1 insertion(+)
hw/intc/arm_gicv5.c +1 -0
@@ -1433,6 +1433,7 @@ static bool config_readl(GICv5 *s, GICv5Domain domain, hwaddr offset,/* ...which means VIRT_ONE_N is also RES0 */ v &= ~R_IRS_IDR0_VIRT_ONE_N_MASK ; } + *data = v;return true;case A_IRS_IDR1 :
Signature · 1 line
2.43.0
[PULL 01/16] target/arm: fix user-mode emulation of ID_AA64MMFR0_EL1
In reply to Peter MaydellFrom: Alex Bennée <[email protected]>
Since kernel commit b130a8f70cbbf9 (KVM: arm64: Check advertised Stage-2 page size capability) the relevant Stage 2 have been pegged at 1 f(4KB granule not supported at stage 2) by the kernel. As a result the behaviour of the test differs when run on real HW:
id_aa64mmfr0_el1 : 0x00000111ff000000
!!extra bits!! : 0x0000011100000000
compared to under emulation (neoverse-n1):
id_aa64mmfr0_el1 : 0x00000000ff000000
Update the test with a new helper to explicitly test for fixed bits and update v8_user_idregs to match real systems.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4566
Message-id: [email protected]
--- target/arm/helper.c | 12 ++++++++++-- tests/tcg/aarch64/sysregs.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-)
target/arm/helper.c +10 -2
@@ -7023,8 +7023,16 @@ void register_cp_regs_for_features(ARMCPU *cpu) R_ID_AA64FPFR0_F8CVT_MASK }, { .name = "ID_AA64MMFR0_EL1", .exported_bits = R_ID_AA64MMFR0_ECV_MASK, - .fixed_bits = (0xfu <<R_ID_AA64MMFR0_TGRAN64_SHIFT ) | - (0xfu << R_ID_AA64MMFR0_TGRAN4_SHIFT) }, +/* +* Linux does not expose the TGRAN* fields to userspace and so +* they must read as the "this is not implemented" value for those +* fields (which is 0, 0b0001 or 0b1111 depending on the field) +*/ + .fixed_bits = (0xfULL <<R_ID_AA64MMFR0_TGRAN64_SHIFT ) | + (0xfULL <<R_ID_AA64MMFR0_TGRAN4_SHIFT ) | + (0x1ULL <<R_ID_AA64MMFR0_TGRAN4_2_SHIFT ) | + (0x1ULL <<R_ID_AA64MMFR0_TGRAN64_2_SHIFT ) | + (0x1ULL << R_ID_AA64MMFR0_TGRAN16_2_SHIFT) }, { .name = "ID_AA64MMFR1_EL1", .exported_bits = R_ID_AA64MMFR1_AFP_MASK }, { .name = "ID_AA64MMFR2_EL1",
tests/tcg/aarch64/sysregs.c +28 -3
@@ -54,6 +54,23 @@ int failed_bit_count; } \ }) +/* As above but also check that required fixed bits have expected values */ +#define get_cpu_reg_check_fixed (id, allowed_mask, fixed_mask, expected_val) ({ \ + unsigned long __cval = get_cpu_reg(id); \ + unsigned long __extra = __cval & ~(allowed_mask); \ + if (__extra) { \ + printf("%-20s: 0x%016lx\n", " !!extra bits!!", __extra); \ + failed_bit_count++; \ + } \ + if ((__cval & (fixed_mask)) != (expected_val)) { \ + printf("%-20s: 0x%016llx (expected fixed 0x%016llx)\n", \ + " !!fixed mismatch!!", \ + (unsigned long long)(__cval & (fixed_mask)), \ + (unsigned long long)(expected_val)); \ + failed_bit_count++; \ + } \ +}) +/* As above but check RAZ */ #define get_cpu_reg_check_zero (id) ({ \ unsigned long __val = 0xdeadbeef; \
@@ -127,8 +144,16 @@ int main(void)get_cpu_reg_check_mask (id_aa64isar0_el1,_m (f0ff,ffff,f0ff,fff0));get_cpu_reg_check_mask (id_aa64isar1_el1,_m (00ff ,f0ff,ffff,ffff));get_cpu_reg_check_mask (SYS_ID_AA64ISAR2_EL1 ,_m (00ff ,0000 ,00ff ,ffff)); -/* TGran4 & TGran64 as pegged to -1 */ -get_cpu_reg_check_mask (id_aa64mmfr0_el1,_m (f000,0000 ,ff00,0000 )); +/* +* TGran4 & TGran64 are pegged to -1 (0xf). Stage 2 translation +* granule support (TGran4_2, TGran64_2, TGran16_2) are pegged to +* safe value 1 as exposed by Linux kernel since b130a8f70cbbf9 +* (KVM: arm64: Check advertised Stage-2 page size capability). +*/ +get_cpu_reg_check_fixed (id_aa64mmfr0_el1, +_m (f000,0111 , ff00,0000 ), +_m (0000 ,0111 , ff00,0000 ), +_m (0000 ,0111 , ff00,0000 ));get_cpu_reg_check_mask (id_aa64mmfr1_el1,_m (0000 ,f000,0000 ,0000 ));get_cpu_reg_check_mask (SYS_ID_AA64MMFR2_EL1 ,_m (0000 ,000f ,0000 ,0000 ));/* EL1/EL0 reported as AA64 only */
@@ -179,7 +204,7 @@ int main(void) }if (failed_bit_count >0 ) { -printf ("Extra information leaked to user-space!\n" ); +printf ("Bit check failure or extra info leaked to user-space!\n" );return 1 ; }
Signature · 1 line
2.43.0
[PULL 02/16] hw/arm/virt: Use TAG_GRANULE when creating tag memory
In reply to Peter MaydellFrom: Gustavo Romero <[email protected]>
Use TAG_GRANULE definition when creating the memory region where the FEAT_MTE tags are stored.
Message-id: [email protected]
--- hw/arm/virt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/arm/virt.c +4 -2
@@ -2308,8 +2308,10 @@ static void create_tag_ram(MemoryRegion *tag_sysmem, {MemoryRegion *tagram =g_new (MemoryRegion,1 ); -memory_region_init_ram (tagram,NULL , name, size /32 , &error_fatal); -memory_region_add_subregion (tag_sysmem, base /32 , tagram); +/* We store 2 granules in 1 byte. */ +memory_region_init_ram (tagram,NULL , name, size / (2 *TAG_GRANULE ), + &error_fatal); +memory_region_add_subregion (tag_sysmem, base / (2 *TAG_GRANULE ), tagram); } static void create_secure_ram(VirtMachineState *vms,
Signature · 1 line
2.43.0
[PULL 12/16] target/arm: Implement SCR_EL3.TID3
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/helper.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
target/arm/helper.c +15 -2
@@ -6078,8 +6078,21 @@ static CPAccessResult access_v7a_tid3(CPUARMState *env, const ARMCPRegInfo *ri,* Any other registers in the TID3 trap space should use access_tid3(), * so that they trap on v8 and above, but not on v7. */ -if ((arm_current_el (env) <2 ) && (arm_hcr_el2_eff (env) &HCR_TID3 )) { -return CP_ACCESS_TRAP_EL2 ; +switch (arm_current_el (env)) { +case 1 : +if (arm_hcr_el2_eff (env) &HCR_TID3 ) { +return CP_ACCESS_TRAP_EL2 ; + } +/* fall through */ +case 2 : +if (env->cp15.scr_el3 &SCR_TID3 ) { +return CP_ACCESS_TRAP_EL3 ; + } +break ; +case 3 : +break ; +default : +g_assert_not_reached (); }return CP_ACCESS_OK ;
Signature · 1 line
2.43.0
[PULL 04/16] hw/misc/stm32_rcc: Mirror clock ready and switch status bits
In reply to Peter MaydellFrom: Manuele Conti <[email protected]>
RM0090 7.3.1/7.3.3: oscillator ready bits follow their corresponding enable bits, and SWS follows SW. Upstream stored raw values, so firmware polling for ready or checking SWS never saw the expected state.
Mirror the enable bits into the ready bits on CR writes and SW into SWS on CFGR writes. Clock switching is instantaneous in QEMU. No oscillator startup or PLL lock delay is modelled.
Add qtest coverage for HSION, HSEON, PLLON, PLLI2SON and SW, including clearing the ready bits again when the oscillators are disabled.
--- hw/misc/stm32_rcc.c | 19 ++++++++++ tests/qtest/stm32f405-rcc-test.c | 62 ++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/stm32f405-rcc-test.c
hw/misc/stm32_rcc.c +19 -0
@@ -90,6 +90,25 @@ static void stm32_rcc_write(void *opaque, hwaddr addr, }switch (addr) { +case STM32_RCC_CR : +/* +* Oscillators become ready immediately in QEMU. +* Mirror enable bits into ready bits. See RM0090 7.3.1. +*/ + value =deposit32 (value,1 ,1 ,extract32 (value,0 ,1 )); + value =deposit32 (value,17 ,1 ,extract32 (value,16 ,1 )); + value =deposit32 (value,25 ,1 ,extract32 (value,24 ,1 )); + value =deposit32 (value,27 ,1 ,extract32 (value,26 ,1 )); + s->regs[addr >>2 ] = value; +return ; +case STM32_RCC_CFGR : +/* +* System clock switching is instantaneous in QEMU. +* Mirror SW[1:0] into SWS[3:2]. See RM0090 7.3.3. +*/ + value =deposit32 (value,2 ,2 ,extract32 (value,0 ,2 )); + s->regs[addr >>2 ] = value; +return ; case STM32_RCC_AHB1_RSTR ... STM32_RCC_AHB3_RSTR: case STM32_RCC_APB1_RSTR ... STM32_RCC_APB2_RSTR: prev_value = s->regs[addr /4 ];
tests/qtest/stm32f405-rcc-test.c new file +62 -0
62 lines not on this page · raw message
tests/qtest/meson.build +1 -1
@@ -254,7 +254,7 @@ qtests_exynos4210 = \ qtests_arm = \ (config_all_devices.has_key('CONFIG_OLIMEX_STM32_H405') ? \ - ['stm32f405-timer-test'] : []) + \ + ['stm32f405-timer-test', 'stm32f405-rcc-test'] : []) + \ (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \ (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \ (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
Signature · 1 line
2.43.0
[PULL 07/16] target/arm: Use the 52-bit TTBR base address layout when TCR.DS is set
In reply to Peter MaydellFrom: Fuad Tabba <[email protected]>
With TCR.DS set, TTBR[5:2] hold bits [51:48] of the translation table base address, whatever the OA size. If the effective OA size is below 52 bits, setting any of them is a level 0 Address size fault (AArch64_S1TTBaseAddress(), AArch64_S1Walk()).
get_phys_addr_lpae() uses the 52-bit layout only when the OA size is over 48 bits. With TCR.DS set and an IPS of 48 bits, it takes TTBR[5:2] as base address bits [5:2] instead. A guest that sets them gets no
fault: the walk either succeeds with TTBR[5:2] ignored, or reads its first descriptor from the wrong address. VTTBR walks with VTCR.DS take the same path.
Use the 52-bit layout whenever TCR.DS is set, and check the whole base address against the OA size.
Message-id: [email protected]
--- target/arm/ptw.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
target/arm/ptw.c +11 -8
@@ -2107,18 +2107,21 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr =extract64 (ttbr,0 ,48 );/* -* With a 52-bit OA (FEAT_LPA or FEAT_LPA2), bits [51:48] of descaddr are -* in [5:2] of TTBR, and bits [5:0] of the base address are zero: a table -* under 64 bytes is still 64-byte aligned (R_KBLCR). +* With a 52-bit OA (FEAT_LPA or FEAT_LPA2), or with TCR.DS set at any OA +* size, bits [51:48] of descaddr are in [5:2] of TTBR, and bits [5:0] of +* the base address are zero: a table under 64 bytes is still 64-byte +* aligned (R_KBLCR). * -* Otherwise, if the base address is out of range, raise AddressSizeFault. -* In the pseudocode, this is !IsZero(baseregister<47:outputsize>), -* but we've just cleared the bits above 47, so simplify the test. +* If the base address is out of range, raise AddressSizeFault. +* In the pseudocode, this is !IsZero(address<NUM_PABITS-1:outputsize>) +* in AArch64_OAOutOfRange(), but descaddr has no bits set above 51, +* so simplify the test. */ -if (outputsize >48 ) { +if (outputsize >48 || param.ds) { descaddr &= ~MAKE_64BIT_MASK (0 ,6 ); descaddr |=extract64 (ttbr,2 ,4 ) <<48 ; - }else if (descaddr >> outputsize) { + } +if (descaddr >> outputsize) { level =0 ; fi->type = ARMFault_AddressSize; goto do_fault;
Signature · 1 line
2.43.0
[PULL 05/16] target/arm: Clear TTBR[5:0] from a 52-bit table base address
In reply to Peter MaydellFrom: Fuad Tabba <[email protected]>
get_phys_addr_lpae() can read the first descriptor of a walk from the wrong address. This happens with a 52-bit OA when the initial lookup table has fewer than eight entries and its base address has bit 51 set, or bit 50 for a two-entry table. The walk then faults or translates through whatever that address holds. VTTBR walks for stage 2 take the same path.
For example, the 16KB granule with a 48-bit VA has a two-entry level 0 (FEAT_LPA2). The 64KB granule with a 44-bit VA has a four-entry level 1 (FEAT_LPA). KVM's page_fault_test hangs on this in its 16KB, 52-bit PA guest mode under TCG, as reported on kvmarm.
With a 52-bit OA, TTBR[5:2] hold bits [51:48] of the base address. Such a table is 64-byte aligned (R_KBLCR), so bits [5:0] of the base address are zero. get_phys_addr_lpae() ORs TTBR[5:2] into bits [51:48], but then clears only the bits in indexmask. For these tables indexmask covers fewer than six bits, so TTBR[5] stays in the address, and TTBR[4] too for a two-entry table.
Clear TTBR[5:0] when forming a 52-bit table base address.
Message-id: [email protected]
--- target/arm/ptw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
target/arm/ptw.c +4 -1
@@ -2107,13 +2107,16 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr =extract64 (ttbr,0 ,48 );/* -* For FEAT_LPA and PS=6, bits [51:48] of descaddr are in [5:2] of TTBR. +* With a 52-bit OA (FEAT_LPA or FEAT_LPA2), bits [51:48] of descaddr are +* in [5:2] of TTBR, and bits [5:0] of the base address are zero: a table +* under 64 bytes is still 64-byte aligned (R_KBLCR). * * Otherwise, if the base address is out of range, raise AddressSizeFault. * In the pseudocode, this is !IsZero(baseregister<47:outputsize>), * but we've just cleared the bits above 47, so simplify the test. */ if (outputsize >48 ) { + descaddr &= ~MAKE_64BIT_MASK (0 ,6 ); descaddr |=extract64 (ttbr,2 ,4 ) <<48 ; }else if (descaddr >> outputsize) { level =0 ;
Signature · 1 line
2.43.0
[PULL 16/16] target/arm/tcg/gicv5-cpuif: Fix typo in ICC_PPI_SPENDR1_EL1 name
In reply to Peter MaydellA cut-and-paste error meant that the cpreg for ICC_PPI_SPENDR1_EL1 incorrectly named it SPENDR0; as these regs aren't exposed to gdb the string here is for debug only, so this has no visible consquences, but it's confusing. Fix the error.
Message-id: [email protected]
--- target/arm/tcg/gicv5-cpuif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/tcg/gicv5-cpuif.c +1 -1
@@ -893,7 +893,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] = { .fieldoffset = offsetof(CPUARMState, gicv5_cpuif.ppi_pend[0]), .writefn = gic_ppi_spend_write, }, - { .name = "ICC_PPI_SPENDR0_EL1", .state = ARM_CP_STATE_AA64, + { .name = "ICC_PPI_SPENDR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 13, .opc2 = 7, .access = PL1_RW, .type = ARM_CP_IO | ARM_CP_NO_RAW, .fieldoffset = offsetof(CPUARMState, gicv5_cpuif.ppi_pend[1]),
Signature · 1 line
2.43.0
[PULL 14/16] target/arm: Enable FEAT_IDTE3 for -cpu max
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- docs/system/arm/emulation.rst | 1 + target/arm/tcg/cpu64.c | 4 ++++ 2 files changed, 5 insertions(+)
docs/system/arm/emulation.rst +1 -0
@@ -105,6 +105,7 @@ the following architecture extensions: - FEAT_HPMN0 (Setting of MDCR_EL2.HPMN to zero) - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) - FEAT_IDST (ID space trap handling) +- FEAT_IDTE3 (Trapping ID register accesses to EL3) - FEAT_IESB (Implicit error synchronization event) - FEAT_IVIPT (The IVIPT Extension) - FEAT_JSCVT (JavaScript conversion instructions)
target/arm/tcg/cpu64.c +4 -0
@@ -1461,6 +1461,10 @@ void aarch64_max_v9_tcg_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64PFR2 ,FPMR ,1 );/* v9.2: FEAT_FPMR */ SET_IDREG (isar,ID_AA64PFR2 , t); + t =GET_IDREG (isar,ID_AA64MMFR2 ); + t =FIELD_DP64 (t,ID_AA64MMFR2 ,IDS ,2 );/* v9.0: FEAT_IDTE3 */ +SET_IDREG (isar,ID_AA64MMFR2 , t); + t =GET_IDREG (isar,ID_AA64MMFR3 ); t =FIELD_DP64 (t,ID_AA64MMFR3 ,MEC ,1 );/* v9.2: FEAT_MEC */ SET_IDREG (isar,ID_AA64MMFR3 , t);
Signature · 1 line
2.43.0
[PULL 13/16] target/arm: Implement SCR_EL3.TID5
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/helper.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
target/arm/helper.c +15 -2
@@ -5669,8 +5669,21 @@ static const ARMCPRegInfo dcpodp_reg[] = {static CPAccessResult access_tid5 (CPUARMState *env,const ARMCPRegInfo *ri,bool isread) { -if ((arm_current_el (env) <2 ) && (arm_hcr_el2_eff (env) &HCR_TID5 )) { -return CP_ACCESS_TRAP_EL2 ; +switch (arm_current_el (env)) { +case 1 : +if (arm_hcr_el2_eff (env) &HCR_TID5 ) { +return CP_ACCESS_TRAP_EL2 ; + } +/* fall through */ +case 2 : +if (env->cp15.scr_el3 &SCR_TID5 ) { +return CP_ACCESS_TRAP_EL3 ; + } +break ; +case 3 : +break ; +default : +g_assert_not_reached (); }return CP_ACCESS_OK ;
Signature · 1 line
2.43.0
Richard Henderson
AppliedQuoted 17 lines · Peter Maydell
Smaller pullreq this time around;
FEAT_IDTE3plus a scattering of bug fixes.-- PMM
The following changes since commit
7e8d3c7fc460fe7cd28a3e423d7466fa292bc269:Merge tag 'pull-aspeed-20261015' ofhttps://github.com/legoater/qemu into staging (2026-10-15 14:58:28 +0200)are available in the Git repository at:
https://gitlab.com/pm215/qemu.git tags/pull-target-arm-20261015for you to fetch changes up to
c595a87dc3e318532460c654c36dea08e6ac993a:target/arm/tcg/gicv5-cpuif: Fix typo in ICC_PPI_SPENDR1_EL1 name (2026-10-15 17:38:38 +0100)
Quoted 10 lines
----------------------------------------------------------------
target-arm queue:
* fix user-mode emulation ofID_AA64MMFR0_EL1
* Fix handling of 52-bit TTBRs
* EmulateFEAT_IDTE3
* hw/arm/virt: UseTAG_GRANULEwhen creating tag memory
* hw/timer/stm32f2xx_timer: fix periodic mode and CEN handling
* hw/misc/stm32_rcc: Mirror clock ready and switch status bits
* hw/intc/arm_gicv5: MakeIRS_IDR0reads return actual value, not 0
* target/arm/tcg/gicv5-cpuif: Fix typo inICC_PPI_SPENDR1_EL1name
Applied, thanks.
r~