linux/arch
Anshuman Khandual d7567e9b9b KVM: arm64: nvhe: Disable branch generation in nVHE guests
While BRBE can record branches within guests, the host recording
branches in guests is not supported by perf (though events are).
Support for BRBE in guests will supported by providing direct access
to BRBE within the guests. That is how x86 LBR works for guests.
Therefore, BRBE needs to be disabled on guest entry and restored on
exit.

For nVHE, this requires explicit handling for guests. Before
entering a guest, save the BRBE state and disable the it. When
returning to the host, restore the state.

For VHE, it is not necessary. We initialize
BRBCR_EL1.{E1BRE,E0BRE}=={0,0} at boot time, and HCR_EL2.TGE==1 while
running in the host. We configure BRBCR_EL2.{E2BRE,E0HBRE} to enable
branch recording in the host. When entering the guest, we set
HCR_EL2.TGE==0 which means BRBCR_EL1 is used instead of BRBCR_EL2.
Consequently for VHE, BRBE recording is disabled at EL1 and EL0 when
running a guest.

Should recording in guests (by the host) ever be desired, the perf ABI
will need to be extended to distinguish guest addresses (struct
perf_branch_entry.priv) for starters. BRBE records would also need to be
invalidated on guest entry/exit as guest/host EL1 and EL0 records can't
be distinguished.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Co-developed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Tested-by: James Clark <james.clark@linaro.org>
Reviewed-by: Leo Yan <leo.yan@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20250611-arm-brbe-v19-v23-3-e7775563036e@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
2025-07-08 16:11:27 +01:00
..
alpha treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
arc Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
arm Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
arm64 KVM: arm64: nvhe: Disable branch generation in nVHE guests 2025-07-08 16:11:27 +01:00
csky Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
hexagon Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
loongarch Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
m68k Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
microblaze Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
mips Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
nios2 Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
openrisc Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
parisc Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
powerpc treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
riscv Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
s390 Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
sh treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
sparc treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
um treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
x86 The delayed from_timer() API cleanup: 2025-06-08 11:33:00 -07:00
xtensa treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
.gitignore
Kconfig fs/resctrl: Add boiler plate for external resctrl code 2025-05-16 11:05:40 +02:00