summaryrefslogtreecommitdiff
path: root/arch/arm64/include
AgeCommit message (Collapse)Author
24 hoursMerge branch 'headers' of git://git.infradead.org/users/willy/pagecache.gitMark Brown
# Conflicts: # drivers/gpu/drm/amd/amdkfd/kfd_migrate.c # net/ceph/osd_client.c
24 hoursMerge branch 'next' of ↵Mark Brown
https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git # Conflicts: # arch/arm64/include/asm/ptrace.h # arch/arm64/include/asm/sysreg.h # arch/arm64/kvm/hyp/nvhe/hyp-main.c
24 hoursMerge branch 'master' of ↵Mark Brown
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git # Conflicts: # Documentation/scheduler/index.rst # arch/arm64/configs/defconfig
26 hoursMerge branch 'for-next/core' of ↵Mark Brown
https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
29 hoursMerge https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git ↵David Hildenbrand (Arm)
mm-unstable into for-next Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> # Conflicts: # mm/sparse-vmemmap.c # Conflict resolution: # # diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c # index 11543f4b6304..5d7e982f94d0 100644 # --- a/mm/sparse-vmemmap.c # +++ b/mm/sparse-vmemmap.c # @@ -36,11 +36,7 @@ # #include "mm_init.h" # #include "sparse.h" # # -<<<<<<< HEAD # -void * __meminit vmemmap_alloc_block(unsigned long size, int node) # -======= # void __ref *vmemmap_alloc_block(unsigned long size, int node) # ->>>>>>> akpm/mm-unstable # { # /* If the main allocator is up use that, fallback to bootmem. */ # if (slab_is_available()) { # @@ -60,11 +56,7 @@ void __ref *vmemmap_alloc_block(unsigned long size, int node) # } # return NULL; # } else # -<<<<<<< HEAD # return memmap_alloc(size, size, __pa(MAX_DMA_ADDRESS), node); # -======= # - return memmap_alloc(size, size, __pa(MAX_DMA_ADDRESS), node, false); # ->>>>>>> akpm/mm-unstable # } # # static void * __meminit altmap_alloc_block_buf(unsigned long size,
30 hoursMerge branch into tip/master: 'sched/core'Ingo Molnar
# New commits in sched/core: 4a3b51aab6e2 ("smpboot: Don't park the thread if work is pending") 40dcc9bdbef3 ("irq_work: Flush lazy work CPU down on PREEMPT_RT") 791b1760accd ("irq_work: Update a comment regarding CPU hotplug invocation") 648d44bda731 ("sched/topology: Add asymmetric SMT packing override") c8fc4136fd3c ("sched/fair: Honor asymmetric SMT priority in idle selection") 53bc5c556b82 ("sched: Set TIF_NEED_RESCHED before calling __trace_set_need_resched()") 4b1f75be23c4 ("sched/core: Fix context analysis errors in non-preferred CPU push") 1fb28c664a19 ("virt/steal_governor: Enable the driver") 27d47ebce4d6 ("virt/steal_governor: Implement steal_governor policy loop") 4b9302d494ff ("virt/steal_governor: Add control knobs for handling steal values") 9a8e740ee9f6 ("virt: Introduce steal governor driver") 68957caaa9c0 ("sched/debug: Add migration stats due to non preferred CPUs") 74699f56ebcf ("sched/core: Push current task from non preferred CPU") 4ee29b029058 ("sched/fair: Load balance only among preferred CPUs") d8a3da0de843 ("sched/core: Try to use a preferred CPU in is_cpu_allowed") 620824516557 ("sysfs: Add preferred CPU file") 518b32bd5bb3 ("cpumask: Introduce cpu_preferred_mask") 06a49ef784ac ("sched/docs: Document cpu_preferred_mask and Preferred CPU concept") cfb463b7172d ("cpumask: Introduce cpumask_intersects_and") a8d0854a76a8 ("sched/cputime: Add kcpustat_field_total helper") be100c77178e ("sched: Add sched_ext hooks for proxy execution") 57c75e3ae38c ("sched: Add helper to block retained proxy donors") a49653d0abeb ("sched/core: Mark wakeups completed through ttwu_runnable()") 8f8c0417e973 ("sched/core: Dequeue waking proxy donors before reset") 313b652837d0 ("sched/core: Drop mutex locks before proxy rescheduling") 627ea30aca3b ("sched/wait: Clarify WF_SYNC wakeup semantics") d2e010082757 ("sched/eevdf: Handle more short slice waking cases") 4bf32ec3327d ("sched/eevdf: Align update_protect_slice to set_protect_slice") aae2a33ea662 ("sched/eevdf: Ensure that vprot will never go above a min slice") c9ce69fc43bd ("sched/fair: Randomize equally shallow slow-path candidates") abe440b3770f ("sched/fair: Drop idle recency from slow-path CPU selection") fbbc63fed0b0 ("sched/core: Remove redundant core_sched_seq") 819224e506bc ("sched/fair: Remove dead code on enqueue_task_fair()") c72945693b90 ("sched: Restart fair hrtick after same-task repicks") a9b3c7570564 ("sched/headers: Replace __ASSEMBLY__ with __ASSEMBLER__ in the <uapi/linux/sched.h> header") e81ee0630837 ("sched/fair: Reset NUMA fault locality after scan period update") ef9293b3b797 ("sched: dynamic: Fix preemption model strings") 879eaa76e608 ("sched: Remove unneeded function type cast in do_balance_callbacks()") f549101187c8 ("sched/deadline: check start_dl_timer expiry with ktime_before()") 2a672daa4b27 ("sched/feat: Use the new static key API for sched_feat") a5576ebce920 ("sched: Convert paravirt_steal to new static key APIs") 9650ce11f2e3 ("sched: dynamic: Simplify preempt model accessors") 5b9a28eeed37 ("sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}") aa4178f63847 ("sched: dynamic: Simplify irqentry_exit_cond_resched()") b9d267b9d632 ("sched: dynamic: Simplify preempt_schedule{,_notrace}()") 88e0b3bb9930 ("sched: dynamic: Simplify {cond,might}_resched()") d3d16750693b ("sched: dynamic: Make PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY") 772d9ffbfd26 ("sched: Migrate whole chain in proxy_migrate_task()") 6b73a09e943f ("sched: Break out core of attach_tasks() helper into sched.h") 1f8805138593 ("sched: Switch rq->next_class in proxy_reset_donor()") 09351db90a28 ("sched/core: Don't proxy-exec unmatched cookie lock owners") 9be817f991e2 ("sched/core: Avoid migrating blocked_on tasks") 3dd95f077371 ("sched/core: Don't steal a proxy-exec donor") Signed-off-by: Ingo Molnar <mingo@kernel.org>
39 hoursarm64/mm: move __check_safe_pte_update()Anshuman Khandual
Patch series "arm64/mm: Standardize printing for pgtable entries", v3. Standardize printing for pgtable entries using recently introduced generic helper ptval_bytes_to_hex_str() in core MM which automatically enables 128 bits entries when added later. But first move __check_safe_pte_update() outside <asm/pgtable.h> to avoid a cyclic dependency while accessing these afore mentioned core MM helpers defined in <linux/pgtable.h>. This replaces the original page table entry print standardisation proposal which was part of the D128 series [1]. This patch (of 2): The page table entry print helpers and related macros which are defined in <linux/pgtable.h> will not be accessible in platform <asm/pgtable.h> which is basically caused by cycling dependency. Move __check_safe_pte_update() inside arch/arm64/mm/mmu.c as a preparation for subsequent usage of the afore mentioned generic MM helpers. While here drop IS_ENABLED(CONFIG_DEBUG_VM), although wrap __check_safe_pte_update() inside #ifdef CONFIG_DEBUG_VM that preserves the current code optimization which is achieved via the static inline functions. This does not cause any functional change. Link: https://lore.kernel.org/20260916044933.2689426-2-anshuman.khandual@arm.com Link: https://lore.kernel.org/linux-mm/20260729122452.3797443-11-anshuman.khandual@arm.com/ [1] Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: David Hildenbrand (Arm) <david@kernel.org> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Mike Rapoport <rppt@kernel.org> Cc: Lorenzo Stoakes <ljs@kernel.org>
46 hoursMerge branch 'for-next/misc' into for-next/coreCatalin Marinas
* for-next/misc: arm64: clear_page[s] using memset
2 daysarm64: clear_page[s] using memsetLinus Walleij
There is no need to try to second-guess the compiler when clearing memory. Just call memset() like everyone else. Since memset() already has an architecture-local MOPS optimization, we do not need to do anything else to preserve the MOPS optimization. While at it, implement the shorthand for directly calling the new prototype clear_pages() for larger page chunks. No performance regressions can be seen, the fastpath benchmarks differences are in the noise. Usama Anjum tested next-20260821 with one warm-up and three repeats in four sessions, for a total of 12 measured runs. The commands were: perf bench mem memset -k 1GB -f default -s 16GB perf bench mem mmap -p 1GB -f demand -s 32GB -l 5 perf bench mem mmap -p 4KB -f demand -s 32GB -l 5 The results were: aws-m7g.metal: Benchmark Base bytes/sec Change with patch memset 1GB 63932542232.12 1.92% mmap 1GB 63272579168.03 -0.57% mmap 4KB 49692830849.48 -1.11% cesw-aarch64-ampereone-1s-a192-32x: Benchmark Base bytes/sec Change with patch memset 1GB 33895562998.71 0.25% mmap 1GB 34338454210.17 1.16% mmap 4KB 25687107580.90 -0.85% Assisted-by: LLM Suggested-by: Will Deacon <will@kernel.org> Tested-by: Usama Anjum <usama.anjum@arm.com> Link: https://lore.kernel.org/linux-arm-kernel/20260303-aarch64-clear-pages-v1-1-ad0c3ee9a555@kernel.org/ Link: https://lore.kernel.org/linux-arm-kernel/67ab6c51-4511-46ab-931b-a4323551147a@arm.com/ Signed-off-by: Linus Walleij <linusw@kernel.org> Reviewed-by: Leonardo Bras <leo.bras@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
3 daysMerge branches 'for-next/misc', 'for-next/be-gone', 'for-next/smccc-bus', ↵Catalin Marinas
'for-next/preemptible-this-cpu', 'for-next/cpu-errata', 'for-next/mpam', 'for-next/kselftest' and 'for-next/efi' into for-next/core * for-next/misc: arm64/sve: Don't zero the SVE state buffer when the SVE state is live arm64/cpufeature: Drop redundant define(ID_AA64MMFR0..._SUPPORTED_LPA2) arm64: Use proper include variant arm64: include: fix repeated word 'to' in comment selftests: arm64: fix typo "hander" in comment arm64: fix typos in comments docs: arm64: Fix typo "initalised" in booting.rst arm64: alternative: Remove 'cfg' parameter arm64: mte-kasan: Use IS_ENABLED() rather than ALTERNATIVE() 'cfg' parameter arm64/cpufeature: Change description for ARM64_HAS_LPA2 * for-next/be-gone: drivers: Kconfig: Simplify dependencies on ARM64 && !CPU_BIG_ENDIAN arm64: Kbuild: Remove vestigial big-endian support gve: Add explicit ARM64 dependency to Kconfig crypto: hisilicon/sec2: Remove check of CONFIG_CPU_LITTLE_ENDIAN arm64: Remove all usage of __AARCH64EB__ arm64: Remove all usage of CONFIG_CPU_BIG_ENDIAN KVM: arm64: Remove support for a big-endian hypervisor object arm64: vdso32: Always build compat vDSO object as little-endian arm64: assembler: Remove endianness helper macros arm64: lib: Assume a little-endian kernel in optimised string routines arm64: lib: Assume a little-endian kernel in custom library routines arm64: crypto: Assume a little-endian kernel arm64: bpf: Remove big-endian support from the JIT compiler selftests/arm64: Remove big-endian support * for-next/smccc-bus: : Switch Arm SMCCC firmware services to an SMCCC bus firmware: smccc: Pass only the required device probe arguments firmware: arm_rmm: Add SPDX and sort the Kconfig and Makefile entries coco: guest: arm64: Remove dummy CCA platform device coco: guest: arm64: Add sysfs ABI for CCA Realm guests firmware: smccc: arm-cca-guest: Bind the TSM provider to an SMCCC device virt: coco: arm-cca-guest: Rename TSM report source file arm64: realm: Move Realm memory encryption ops to RSI code firmware: arm_rmm: Move RSI support out of arch/arm64 firmware: hwrng: arm_smccc_trng: Register as an SMCCC device firmware: smccc: Add an Arm SMCCC bus * for-next/preemptible-this-cpu: : Preemptible this_cpu_*() operations arm64: percpu: Remove _pcp_protect*() wrappers arm64: percpu: Implement preemptible CMPXCHG128 ops arm64: percpu: Implement preemptible CMPXCHG ops arm64: percpu: Implement preemptible XCHG ops arm64: percpu: Implement preemptible return RMW ops arm64: percpu: Implement preemptible void RMW ops arm64: percpu: Implement preemptible read/write ops arm64: percpu: Add infrastructure for preemptible this_cpu_*() ops arm64: entry: sdei: Make 'tsk' available arm64: entry: sdei: Restore all clobberable GPRs arm64: gpr-num: add __GPR_NUM() helper arm64: gpr-num: Add wxN aliases for wN registers arm64: percpu: Factor out percpu offset asm arm64: ptrace: Always inline pt_regs_{read,write}_reg() arm64: preempt: Treat should_resched() as unlikely arm64: preempt: Simplify and optimize __preempt_count_dec_and_test() arm64: cmpxchg128: LSE: Remove redundant operands arm64: cmpxchg: LL/SC: Avoid redundant extension * for-next/cpu-errata: : Various CPU errata workarounds arm64: errata: Add NXP i.MX8QM/8QP workaround for A53 cache coherency issue arm64: cpufeature: Add ARM64_CPUCAP_SOC_ERRATUM for SoC-level errata * for-next/mpam: (30 commits) : MPAM updates arm_mpam: make the mon_sel guard conditional only arm_mpam: On saving mbwu state read the monitors before clearing CFG_MBWU_CTL arm_mpam: detect and enable MPAM-Fb PCC support arm_mpam: change MPAM-Fb error IRQ to use a threaded IRQ handler arm_mpam: add MPAM-Fb MSC firmware access support arm_mpam: prepare mon_sel locking for MPAM-Fb arm_mpam: propagate MSC access errors in mpam_reset_class_locked() arm_mpam: propagate MSC access errors for interrupt control arm_mpam: propagate MSC access errors for mpam_reprogram_ris_partid() arm_mpam: propagate MSC access errors for state saving function arm_mpam: propagate MSC access errors for __ris_msmon_read() arm_mpam: propagate MSC access errors for msmon helpers arm_mpam: propagate MSC access errors for MBWU counters arm_mpam: propagate MSC access errors for hw_probe functions arm_mpam: let low level MSC accessors return an error MAINTAINERS: Use linux-arm-kernel list for the MPAM driver MAINTAINERS: Add mpam.rst to the MPAM DRIVER entry arm_mpam: resctrl: Don't stop early when tearing down a class arm_mpam: Switch to kvzmalloc_objs() for allocation of component cfg arm_mpam: Don't loop forever if there is the maximum possible amount of PARTIDs ... * for-next/kselftest: : arm64 kselftest updates kselftest/arm64/mte: Use MTE safe memory accessors kselftest/arm64/mte: Introduce MTE safe memory accessors kselftest/arm64: Extend gcs-locking to cover cases where enable is unlocked * for-next/efi: : arm64 EFI updates/fixes arm64/efi: Clear PTE_WRITE when applying EFI_MEMORY_RO
3 daysarm64: errata: Add NXP i.MX8QM/8QP workaround for A53 cache coherency issuePeng Fan
According to NXP errata document IMX8_1N94W[1], the i.MX8QuadMax and i.MX8QuadPlus SoCs suffer from a cache coherency issue (ERR050104). The upper bits, above bit 35, of the ARADDR and ACADDR buses within the Arm A53 subsystem have been incorrectly connected. This causes some TLBI and IC maintenance operations exchanged between the A53 and A72 core clusters to be corrupted. The workaround requires: - Downgrading targeted TLBI operations to broadcast-all variants. Instead of patching the low-level __TLBI_1 macro (which causes excessive over-invalidation), redirect high-level TLB flush functions (flush_tlb_mm, __do_flush_tlb_range, flush_tlb_kernel_range, __flush_tlb_kernel_pgtable) to use VMALLE1IS via alternatives. - Upgrading IC IVAU to IC IALLUIS for both kernel (via ALTERNATIVE in invalidate_icache_by_line) and EL0 userspace (via trap-and-upgrade in user_cache_maint_handler with SCTLR_EL1.UCI=0). - Disabling KVM since correct TLB maintenance cannot be guaranteed for guests. - No need to touch SMMU Broadcast TLB Maintenance (BTM) since the arm-smmu driver does not use it. SoC detection uses devicetree compatible string "fsl,imx8qm" or "fsl,imx8qp" since the boot CPU MIDR_EL1 (0x410fd034) and AIDR_EL1 (0) are not unique to these SoCs. [1] https://www.nxp.com/docs/en/errata/IMX8_1N94W.pdf [ Reworked per review feedback from Will Deacon and Mark Rutland: - Move TLBI workaround from __TLBI_1 macro to high-level flush functions to avoid excessive over-invalidation - Add kernel IC IVAU upgrade via ALTERNATIVE in assembler.h - Add cpucap_is_possible() entry for compile-time elimination] Tested-by: Franz Schnyder <franz.schnyder@toradex.com> # Toradex Apalis iMX8QM Co-developed-by: Ivan T. Ivanov <iivanov@suse.de> Signed-off-by: Ivan T. Ivanov <iivanov@suse.de> Signed-off-by: Peng Fan <peng.fan@nxp.com> [catalin.marinas@arm.com: Kconfig and errata text, sysreg_clear_set(), of_machine_compatible_match()] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
3 daysarm64: cpufeature: Add ARM64_CPUCAP_SOC_ERRATUM for SoC-level errataCatalin Marinas
Add a new capability type for SoC-level (not CPU-level) errata. Unlike CPU errata which need to be checked on every CPU, SoC errata are probed once on the boot CPU and the result applies to all CPUs. Secondary and late CPUs skip the matches() check but still get cpu_enable() called. This avoids redundant probing on secondary and late CPUs for errata that are SoC-wide properties, not per-CPU. Convert ARM64_ERRATUM_4311569 from ARM64_CPUCAP_SYSTEM_FEATURE to ARM64_CPUCAP_SOC_ERRATUM since it is a SoC-level property already determined at boot. This changes its scope from SCOPE_SYSTEM to SCOPE_BOOT_CPU, so the workaround is now enabled before the secondary CPUs are brought up. This is safe as the erratum is enabled via an early_param, parsed before the boot CPU capabilities are detected. Co-developed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 daysMerge branch kvm-arm64/cca-7.4 into kvmarm-master/nextMarc Zyngier
* kvm-arm64/cca-7.4: : \ : Preliminary changes that pave the way for CCA in a future revision : of Linux, introducing some required abstractions (vcpu ops, S2 ops) : and making some concepts common with pKVM. : : Patches courtesy of Suzuki Poulose. : / KVM: arm64: Prevent unsupported vcpu features for VM types KVM: arm64: Mandate VGIC v3 for pKVM VMs and Realms KVM: arm64: Abstract out memory abort handling KVM: arm64: Use a local kvm pointer in kvm_handle_guest_abort() KVM: arm64: Add VM specific callback for S2 MMU operations KVM: arm64: Consolidate stage2 unmap range into kvm_stage2_unmap_range KVM: arm64: Add vcpu load/put call backs for flavors KVM: arm64: Refactor the vcpu_load to allow for VM specific callbacks KVM: arm64: Don't call vcpu_set_pauth_traps for pKVM host KVM: arm64: Track the type of VM in kvm_arch KVM: arm64: Avoid including linux/kvm_host.h in kvm_pgtable.h KVM: arm64: Include kvm_emulate.h in kvm/arm_psci.h KVM: arm64: protected VM: Handle user writes to CNTVCT_EL0/CNTPCT_EL0 Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/pkvm-tracing-7.4 into kvmarm-master/nextMarc Zyngier
* kvm-arm64/pkvm-tracing-7.4: : \ : trace_printk() support for pKVM tracing infrastructure. Patches courtesy : of Vincent Donnefort. From the cover letter: : : "This series adds a hypervisor event "hyp_printk" which enables : developers to log pretty much anything into the hypervisor tracing : buffer, just like the kernel function trace_printk()." : / KVM: arm64: Add hyp_printk event to nVHE/pKVM hyp tracing/remotes: Add REMOTE_EVENT_CUSTOM_PRINTK() helper KVM: arm64: Move kvm_define_hypevents.h to arch/arm64/kvm/ KVM: arm64: Allow early calls to pKVM host_share/unshare_hyp Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/pkvm-allocator-7.4 into kvmarm-master/nextMarc Zyngier
* kvm-arm64/pkvm-allocator-7.4: (21 commits) : \ : Dynamic allocator for pKVM, courtesy of Vincent Donnefort. : From the cover letter: : : "pKVM historically lacked a dynamic memory allocator: all hypervisor-side : VM and VCPU structures had to be sized on the host, allocated as : contiguous pages and donated to the hypervisor. : : This design tightly coupled the hypervisor's memory footprint to : host-side constraints, complicated memory reclaim, and severely : restricted VM scalability. : : This patch series introduces a dynamically-mapped custom heap allocator : (hyp_allocator) to the pKVM hypervisor. The initial users are the : pkvm_hyp_vm and pkvm_hyp_vcpu structs, and the hypervisor tracing : metadata." : / KVM: arm64: Fix bpages backing allocation size in hyp_trace KVM: arm64: Prevent 64-bit overflow when computing hyp clock rate KVM: arm64: pkvm: Drop keneldoc markers for the allocator structs KVM: arm64: Alloc simple_buffer_page using pKVM hyp allocator KVM: arm64: Reject hyp trace descriptors with fewer than 3 pages KVM: arm64: Reject hyp trace descriptors with fewer CPUs than hyp_nr_cpus KVM: arm64: Rename vCPU pkvm_memcache to stage2_mc KVM: arm64: Alloc pkvm_hyp_vcpu using pKVM heap allocator KVM: arm64: Alloc pkvm_hyp_vm using pKVM heap allocator KVM: arm64: Move hyp_vm refcount into the structure KVM: arm64: Filter out non-kernel addresses in kern_hyp_va KVM: arm64: Add a shrinker for pKVM KVM: arm64: Add selftests for the pKVM heap allocator KVM: arm64: Add reclaim interface for the pKVM heap alloc KVM: arm64: Add PKVM_HYP_REQ_HYP_ALLOC request KVM: arm64: Add pkvm_hyp_req infrastructure KVM: arm64: Allow kvm_hyp_memcache usage outside of stage-2 KVM: arm64: Add a heap allocator for the pKVM hyp KVM: arm64: Add pkvm_map_private_va_range KVM: arm64: Add pkvm_remove_mappings ... Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/pkvm-state-7.4 into kvmarm-master/nextMarc Zyngier
* kvm-arm64/pkvm-state-7.4: : \ : State protection for protected pKVM guests, finally starting to deliver : on its promises... Patches courtesy of Fuad Tabba. : : "Following the vCPU state-sync series, this series completes the : job for protected VMs: a protected guest's register state stays at : EL2, and the host sees only what handling each exit requires." : / KVM: arm64: Only emulate an SError's entry for vCPUs with NV KVM: arm64: Document the protected VM userspace API KVM: arm64: Advertise the capabilities that protected VMs support KVM: arm64: Reject host power-on of a vCPU that EL2 holds powered off KVM: arm64: Reject host access to protected VM private state KVM: arm64: Add per-EC entry/exit state marshalling for protected guests KVM: arm64: Inject an UNDEF at EL2 for unhandled protected guest exits KVM: arm64: Prevent host PC adjustments for protected vCPUs KVM: arm64: Restrict KVM_ARM_VCPU_INIT and PSCI version for protected VMs KVM: arm64: Handle PSCI calls for protected VMs at EL2 KVM: arm64: Implement HVC handling for protected guests at EL2 KVM: arm64: Add system register reset framework for protected VMs KVM: arm64: Add {flush,sync}_hyp_timer_state() primitives KVM: arm64: Skip fixed-feature state flush for protected vCPUs KVM: arm64: Introduce per-EC entry handlers for pKVM KVM: arm64: Disable steal time for protected VMs KVM: arm64: Pin the host vCPU before adjusting its PC under pKVM KVM: arm64: Validate the host vCPU's VM before reading it under pKVM KVM: arm64: Sync HCR_EL2.VSE back to the host vCPU under pKVM Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/s390-7.4 into kvmarm-master/nextMarc Zyngier
* kvm-arm64/s390-7.4: : \ : Add the first attempt at sharing code with s390 in an effort to support : the arm64-on-s390 effort. This relies on ARM64_S390_COMMON markers in : relevant places. Patches courtesy of Steffen Eiden. : / KVM: arm64: Share arm64 code with s390 arm64: Share arm64 headers with s390 arm64: Prepare sharing arm64 headers with s390 KVM: arm64: Use accessor functions for core regs KVM: arm64: Access elements of vcpu_gp_regs individually arm64: sysreg: Convert SPSR_ELx to automatic register generation arm64: ptrace: Use constants for compat register numbers Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/immutable-idregs-7.4 into kvmarm-master/nextMarc Zyngier
* kvm-arm64/immutable-idregs-7.4: : \ : Make ID registers immutable as soon as a vcpu has had a chance of : running, preventing userspace from altering them from under the guest's : feet. Patches courtesy of Mark Brown, selftest improvements by Fuad Tabba. : / KVM: arm64: selftests: Check ID regs are immutable after a failed run KVM: arm64: Block ID register changes after we rely on the values KVM: arm64: Finalize guest-wide sysregs prior to per-vCPU sysregs Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/pre-faulting into kvmarm-master/nextMarc Zyngier
* kvm-arm64/pre-faulting: : \ : Enable stage-2 pre-faulting in the canonical IPA space, implementing the : KVM_PRE_FAULT_MEMORY API. Patches courtesy of Lorenzo Stoakes, and based : on an initial work by Jack Thomson. : / KVM: selftests: Add nested pre-fault test for arm64 KVM: selftests: Add option for different backing in pre-fault tests KVM: selftests: Enable pre_fault_memory_test for arm64 Documentation: KVM: document arm64 KVM_PRE_FAULT_MEMORY KVM: arm64: Implement KVM_PRE_FAULT_MEMORY KVM: arm64: Pass walk flags to kvm_pgtable_get_leaf() KVM: arm64: Propagate EHWPOISON in kvm_s2_fault_pin_pfn() KVM: arm64: Size the stage-2 memcache from the fault MMU KVM: arm64: Propagate and use kvm_s2_fault_result on S2 fault KVM: arm64: Propagate and use mmu in s2fd when handling guest aborts KVM: arm64: Propagate and use esr in s2fd when handling guest aborts KVM: arm64: Use ESR helpers in guest abort handling arm64: Add ESR fault helpers KVM: Allow architectures to disallow pre-fault Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/s2-rmap into kvmarm-master/nextMarc Zyngier
* kvm-arm64/s2-rmap: (31 commits) : \ : Add a per-shadow stage-2 reverse map tracking infrastructure, : considerably reducing the overhead of MMU notifiers when running L2 : guests. Also fixes issues with the shadow S2 MMU debugfs infrastrtcture. : : Patches courtesy of Wei-Lin Chang. : : This branch drags the kvmarm-fixes-7.3-1 tag, as this series depends : on some of the fixes. : / KVM: arm64: ptdump: Fix shadow ptdump sleep-in-atomic-context problem KVM: arm64: ptdump: Check the page tables aren't freed when accessing KVM: arm64: Refactor kvm_unmap_gfn_range() with common variables KVM: arm64: nv: Drop kvm_s2_mmu pointer from kvm_guest_s2_mapping KVM: arm64: nv: Avoid full shadow stage-2 unmap KVM: arm64: nv: Track guest stage-2 mapping removal KVM: arm64: nv: Track guest stage-2 mapping creation KVM: arm64: nv: Introduce guest stage-2 tracking structures KVM: arm64: Use a variable for the canonical IPA in kvm_s2_fault_map() KVM: arm64: Fix AArch32 DBGBXVR<n> handling KVM: arm64: Fix FGT mapping for HFGITR_EL2.nGCSEPP KVM: selftests: fix steal_time for arm64 with host page size > 4K KVM: arm64: Don't WARN on an unknown VM ioctl in protected mode KVM: arm64: nv: Delay freeing of shadow S2 structures until VM destruction KVM: arm64: nv: Fix life cycle of the nested_mmus array KVM: arm64: Check every private mapping is hyp-owned at pKVM init KVM: arm64: Move the private VA allocation cursor to __io_map_next KVM: arm64: Match hyp text by physical address in fix_host_ownership() KVM: arm64: Transfer the hyp stack pages out of the host stage-2 KVM: arm64: selftests: Test empty SMCCC filter range at base 0 ... Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/gicv5-7.4 into kvmarm-master/nextMarc Zyngier
* kvm-arm64/gicv5-7.4: (52 commits) : \ : GICv5 IRS support, courtesy of Sascha Bischoff. From the cover letter: : : "This series builds on the initial vGICv5 support and adds support : for the GICv5 IRS, as described by the GICv5 (EAC0) specification. : With this, a GICv5 guest is no longer restricted to PPIs, and can make : use of SPIs and LPIs as well." : / KVM: arm64: vgic-v5: Correctly handle host ISTE __le32 conversion KVM: arm64: vgic-v5: Tidy-up programming of vpe descriptor address KVM: arm64: vgic-v5: Correctly reset h_lpi_ist to NULL KVM: arm64: vgic-v5: Drop __iomem attribute from {vmd,vpet}_base KVM: selftests: Add VGICv5 sparse vCPU IDs test KVM: selftests: Add VGICv5 IST save/restore coverage KVM: selftests: Add VGICv5 LPI delivery tests KVM: selftests: Add VGICv5 SPI injection tests KVM: selftests: Add VGICv5 CPU sysreg attribute tests KVM: selftests: Add VGICv5 USERSPACE_PPIS tests KVM: selftests: Add VGICv5 IST attribute tests KVM: selftests: Add VGICv5 IRS_REGS attribute tests KVM: selftests: Add VGICv5 NR_IRQS attribute tests KVM: selftests: Add VGICv5 IRS address attribute tests Documentation: KVM: Add the VGICv5 IRS save/restore sequences Documentation: KVM: Add docs for KVM_DEV_ARM_VGIC_GRP_IST Documentation: KVM: Add KVM_DEV_ARM_VGIC_GRP_IRS_REGS to VGICv5 docs Documentation: KVM: Document KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS for VGICv5 KVM: arm64: gic-v5: Implement save/restore mechanisms for ISTs KVM: arm64: gic-v5: Add VGICv5 IST save/restore UAPI ... Signed-off-by: Marc Zyngier <maz@kernel.org>
4 daysMerge branch kvm-arm64/hyp-type-checking-7.4 into kvmarm-master/nextMarc Zyngier
* kvm-arm64/hyp-type-checking-7.4: : \ : Restore some sanity in the EL2 department by enforcing the type : checking that was lost when converting the KVM internal : interface to SMCCC. Patches courtesy of Fuad Tabba. : : From the cover letter: : : "This series implements that, in plain preprocessor macros rather than : an external generator, in the mold of the syscall wrappers. Each : hypercall's signature is declared once, in kvm_hcall.h: : kvm_call_hyp_nvhe() resolves to a typed nvhe_hvc_##f() stub generated : from the declaration, and the hyp-main.c handlers unmarshal their : arguments through glue that is type-checked against the same : declaration. A mistyped or stale call, or a handler that drifts from : its caller, now fails to compile. On top of that shared declaration, : host-VA parameters gain a __kern sparse address space, so : dereferencing one at EL2 without kern_hyp_va_host() translation is : flagged by sparse. The address space is KVM-private and lives with the : interface it annotates rather than in compiler_types.h, like x86's : __seg_gs in asm/percpu.h. The deeper instances of that bug class, host : VAs reached through struct fields after the boundary, are follow-up : work." : / KVM: arm64: Tag host-VA hypercall parameters __kern KVM: arm64: nVHE: Check hypercall handlers against the declared ABI KVM: arm64: Type-check hypercall arguments at the caller KVM: arm64: Move the host hypercall interface to its own header KVM: arm64: nVHE: Pass host VA arguments as pointers arm64: pi: Run the source checker on the libfdt objects under C=2 KVM: arm64: nVHE: Run the source checker under C=2 KVM: arm64: nVHE: Use NULL to reset the trace buffer backing pointer KVM: arm64: nVHE: Declare the hyp event IDs before defining them KVM: arm64: nVHE: Share the stacktrace per-CPU declarations with EL2 tracing: Include linux/types.h in trace_remote_event.h Signed-off-by: Marc Zyngier <maz@kernel.org>
6 daysMerge tag 'arm64-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux Pull arm64 fixes from Will Deacon: "It finally seems to have calmed down on the arm64 fixes front, so please pull these two straightforward fixes for -rc7. One fixes the EL2 trap configuration for implementation-defined CPU PMU hardware during boot and the other fixes a kcov selftest failure by excluding our softirq early entry code: - Fix PMU EL2 trap configuration for CPUs with an IMPDEF PMU - Fix kcov boot selftest failure by excluding our early IRQ entry code" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: irq: exclude the softirq stack switch from KCOV arm64/boot: Don't set PMUv3p9 FGT2 bits without PMUv3
6 daysKVM: arm64: Prevent unsupported vcpu features for VM typesSuzuki K Poulose
Prevent unsupported VCPU features for the protected VCPUs. Realms and pVMs not support 32bit EL1 or NV yet. pKVM doesn't rely on the host vcpu features for protected VMs and hand picks features while hyp_vcpu is initialised. Block the features early in the vcpu init if we detect incompatible features. Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://patch.msgid.link/20261007073537.2454351-15-suzuki.poulose@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
6 daysKVM: arm64: Mandate VGIC v3 for pKVM VMs and RealmsSuzuki K Poulose
pKVM does not trust the host. Realm VMs follow a similar trust model, with the Realm Management Monitor owning the protected state instead of the host. Add a helper to identify VMs that run under a host-distrusting hypervisor. Use this for blocking ioremap of vgic-v2 into stage2 and prevent creation of VGIC other than v3. Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Gavin Shan <gshan@redhat.com> Tested-by: Gavin Shan <gshan@redhat.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://patch.msgid.link/20261007073537.2454351-14-suzuki.poulose@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
6 daysKVM: arm64: Abstract out memory abort handlingSuzuki K Poulose
Move the memory abort handling under VM specific s2 operation. Tested-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://patch.msgid.link/20261007073537.2454351-13-suzuki.poulose@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
6 daysarm64: mte: make mte_save_tags() and mte_restore_tags() staticTal Zussman
mte_save_tags() and mte_restore_tags() are only used by arch_prepare_to_swap() and arch_swap_restore() in mteswap.c. Make them static and remove their declarations from mte.h. No functional change. Link: https://lore.kernel.org/20260908-folio_swap_entry-v2-6-ee6d01dfa5e1@columbia.edu Signed-off-by: Tal Zussman <tz2294@columbia.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Baoquan He <baoquan.he@linux.dev> Cc: Barry Song <baohua@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chengming Zhou <chengming.zhou@linux.dev> Cc: Chris Li <chrisl@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Harry Yoo <harry@kernel.org> Cc: Jann Horn <jannh@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Kairui Song <kasong@tencent.com> Cc: Kemeng Shi <shikemeng@huaweicloud.com> Cc: Kiryl Shutsemau <kas@kernel.org> Cc: Lance Yang <lance.yang@linux.dev> Cc: Liam R. Howlett <liam@infradead.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Marc Rutland <mark.rutland@arm.com> Cc: Nhat Pham <nphamcs@gmail.com> Cc: Rik van Riel <riel@surriel.com> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: Will Deacon <will@kernel.org> Cc: Zi Yan <ziy@nvidia.com>
8 daysKVM: arm64: Add VM specific callback for S2 MMU operationsSuzuki K Poulose
Add VM type specific S2 MMU operation backends which can be initialized per VM flavor, to keep the handling cleaner. Reviewed-by: Gavin Shan <gshan@redhat.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261007073537.2454351-11-suzuki.poulose@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
8 daysKVM: arm64: Add vcpu load/put call backs for flavorsSuzuki K Poulose
Add VM flavor specific handlers for VCPU load/put, in an effort to make it easier to follow the code. pauth traps were removed from VMs running PKVM as it is a no-op for them. Based on a patch by Marc Zyngier Suggested-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Gavin Shan <gshan@redhat.com> Tested-by: Gavin Shan <gshan@redhat.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261007073537.2454351-9-suzuki.poulose@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
8 daysKVM: arm64: Track the type of VM in kvm_archSuzuki K Poulose
KVM arm64 has different types of VMs with all the different modes in which the hypervisor code can be run. e.g., VHE, nVHE, pKVM etc. Then there is protected VM and normal VMs with pKVM. We might soon add other types, e.g., Arm CCA Realm. So in an effort to make the handling of these different types of VMs a bit more friendly to the eyes, add a VM flavor to the kvm_arch and we could then add handlers for different operations based on the VM type. Keep the flavor initialisation at the beginning to allow for the detection early enough and fail out on any unsupported requests. With that, add wrappers for checking the "type" of a VM and replace the existing users with the new wrappers. Given we already have the construct of "kvm_vm_is_protected" in the core KVM code, use that for all confidential compute guests including Realms that we are about to add. Adds __VM_PROTECTED marker vm flavor to draw the boundary for "protected VMs". In later patches, we would add Realm VMs, which would also be classified as protected. While adding the vm_flavor, move the psci_version around to keep the structure packed. Suggested-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Gavin Shan <gshan@redhat.com> Tested-by: Gavin Shan <gshan@redhat.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://patch.msgid.link/20261007073537.2454351-6-suzuki.poulose@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
8 daysKVM: arm64: Avoid including linux/kvm_host.h in kvm_pgtable.hSteven Price
To avoid future include cycles, drop the linux/kvm_host.h include in kvm_pgtable.h and include the lightweight headers required for the types and inline helpers used there. Additionally provide a forward declaration for struct kvm_s2_mmu as it's only used as a pointer in this file. Both pgtable.c and kvm_pkvm.h relied on the indirect inclusion of kvm_host.h, so make that explicit. Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Gavin Shan <gshan@redhat.com> Signed-off-by: Steven Price <steven.price@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://patch.msgid.link/20261007073537.2454351-5-suzuki.poulose@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
9 daysmm: drop pxd_ERROR()Anshuman Khandual
There are no more users left for any pxd_ERROR() either in generic MM or in the platform MM. Hence all these platform macros along with their generic fallback could be dropped across the tree. Link: https://lore.kernel.org/20260831054331.625505-9-anshuman.khandual@arm.com Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k Acked-by: David Hildenbrand (Arm) <david@kernel.org> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Cc: Helge Deller <deller@gmx.de> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: James Bottomley <james.bottomley@HansenPartnership.com> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Rich Felker <dalias@libc.org> Cc: Samuel Holland <samuel.holland@sifive.com> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
9 daysRevert "arch: introduce set_direct_map_valid_noflush()"Mike Rapoport (Microsoft)
Commit 0c6378a71574 ("arch: introduce set_direct_map_valid_noflush()") added set_direct_map_valid_noflush() to allow updating the direct map for a physically contiguous range in execmem. As Brendan recently pointed out [1], this API is confusing because on arm64 it means that is sets VALID bit in ptes, while on other architectures it is an analog of set_direct_map_default_noflush(). The only user of set_direct_map_valid_noflush() was execmem's ROX cache freeing path and it was switched to utilize VM_FLUSH_RESET_PERMS for resetting permissions of the direct map alias. With the last user gone and with set_direct_map_{invalid,default}_noflush() accepting number of pages as a parameter, set_direct_map_valid_noflush() become a copy of set_memory_valid() on arm64 and a duplicate of set_direct_map_{invalid,default}_noflush() on other architecture, it is safe to remove set_direct_map_valid_noflush(). Also drop a stale comment in arm64::__kernel_map_pages() that Linus bothered to add when merging changes containing set_direct_map_valid_noflush() to his tree. This reverts commit 0c6378a71574daa6cd1534ad42a956e3262756c7. Link: https://lore.kernel.org/20260903-execmem-set-vm-perms-v0-2-v3-6-949b64a9f755@kernel.org Link: https://lore.kernel.org/all/DJ69RCVRBO0Y.3JCYSW50IC4RC@linux.dev [1] Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Brendan Jackman <brendan.jackman@linux.dev> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Andy Lutomirski <luto@kernel.org> Cc: "Borislav Petkov (AMD)" <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Len Brown <lenb@kernel.org> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Will Deacon <will@kernel.org> Cc: Dev Jain <dev.jain@arm.com>
9 daysset_memory: add number of pages parameter to set_direct_map APIsMike Rapoport (Microsoft)
Patch series "arch, mm/execmem: resolve confusion about set_direct_map_valid_noflush()", v3. Recent discussion about implementation of execmem's ROX caches on arm64 revealed a confusion about how set_direct_map_valid_noflush() implemented on different architectures. On arm64 it sets or clears the PTE_VALID bit marking a PTE as present or not present. On other architectures it's a range version of set_direct_map_invalid_noflush() and set_direct_map_default_noflush() Unlike arm64::set_direct_map_valid_noflush(), set_direct_map_default_noflush() not only marks PTE as present, but also sets its default protection mode. Other than that, initial design of execmem ROX caches didn't rely on restoration of large mappings that's now available on x86, but completely removed the memory allocated for the ROX cache from the direct map to ensure that large mappings are not split. This precluded usage of VM_FLUSH_RESET_PERMS for the ROX cache allocations and required execmem to implement manipulation of the direct map alias. Current implementation of ROX caches does not remove the direct map alias but simply calls set_memory_rox() that updates the permissions in both vmalloc address space and the direct map and relies on collapse_large_pages() in x86 CPA to keep large mappings. This allow using VM_FLUSH_RESET_PERMS for execmem ROX cache allocations with small adjustments to set_direct_map APIs and vmalloc::reset_perms() behaviour: adding number of pages parameter to set_direct_map APIs and making resetting of the direct map permissions in vmalloc VMAP_HUGE friendly. Implement these adjustments, make execmem always use VM_FLUSH_RESET_PERMS and revert set_direct_map_valid_noflush() changes. This patch (of 6): When set_direct_map APIs were introduced by the commit d253ca0c3865 ("x86/mm/cpa: Add set_direct_map_*() functions") the single page parameter made sense because the initial callers (vmalloc and hibernation) had sets of unsorted struct pages that required changes of their mappings in the direct map. Since there is an increasing demand for direct map manipulation and it is also desirable to be able to update larger physically contiguous mappings, for example an entire large folio, extend set_direct_map APIs to receive number of pages parameter. As there is still only a handful of callers, change the existing functions directly and update all the call sites rather than adding wrappers for single page case. Link: https://lore.kernel.org/20260903-execmem-set-vm-perms-v0-2-v3-0-949b64a9f755@kernel.org Link: https://lore.kernel.org/20260903-execmem-set-vm-perms-v0-2-v3-1-949b64a9f755@kernel.org Link: https://lore.kernel.org/all/20260611130144.1385343-4-abarnas@google.com [1] Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Andy Lutomirski <luto@kernel.org> Cc: "Borislav Petkov (AMD)" <bp@alien8.de> Cc: Brendan Jackman <brendan.jackman@linux.dev> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Len Brown <lenb@kernel.org> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Will Deacon <will@kernel.org> Cc: Dev Jain <dev.jain@arm.com>
11 daysarm64/boot: Don't set PMUv3p9 FGT2 bits without PMUv3Fuad Tabba
On a CPU with FGT2 and an IMPLEMENTATION DEFINED PMU (PMUVer 0b1111), __init_el2_fgt2 sets the PMUv3p9 bits in HDFGRTR2_EL2 and HDFGWTR2_EL2, which are RES0 there. The macro only checks that PMUVer is at least PMUv3p9, and 0b1111 passes. Exclude 0b1111 before the compare, as __init_el2_debug does. Fixes: 858c7bfcb35e1 ("arm64/boot: Enable EL2 requirements for FEAT_PMUv3p9") Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Bradley Morgan <brads@mainlining.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
12 daysKVM: arm64: Add hyp_printk event to nVHE/pKVM hypVincent Donnefort
Create an event to allow developers to log pretty much anything into the hypervisor tracing buffer with trace_hyp_printk(), just like the kernel tracing has the function trace_printk(). #include <asm/kvm_hypevents.h> trace_hyp_printk("foobar"); trace_hyp_printk("foo=%d", foo); trace_hyp_printk("foo=%d bar=0x%016llx", foo, bar); To ensure writing into the tracing buffer is fast, store the string format into a kernel-accessible ELF section. The hypervisor only has to write into the event the string ID, which is the delta between the hyp_string_fmt and the start of the ELF section. The string format is parsed by the kernel. It is therefore not possible to dereference hypervisor pointers and the format specifier %s is not supported. Also the %p specifiers will fail to find the hypervisor function. To not waste tracing buffer data, use a dynamic size. Each argument is 8 bytes. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <tabba@google.com> Tested-by: Fuad Tabba <tabba@google.com> Link: https://patch.msgid.link/20261001143000.3371786-5-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
12 daysKVM: arm64: Move kvm_define_hypevents.h to arch/arm64/kvm/Vincent Donnefort
kvm_define_hypevents.h is used to define the kernel-side structures for hypervisor events. It doesn't need to be used anywhere else than in hyp_trace.c. Rename and move it to arch/arm64/kvm/ Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <tabba@google.com> Tested-by: Fuad Tabba <tabba@google.com> Link: https://patch.msgid.link/20261001143000.3371786-3-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
12 daysKVM: arm64: Allow early calls to pKVM host_share/unshare_hypVincent Donnefort
The hypervisor tracing for pKVM relies on the __pkvm_host_share_hyp and __pkvm_host_unshare_hyp HVCs. In order to start tracing as early as possible, allow those two HVCs before the host is deprivileged. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <tabba@google.com> Tested-by: Fuad Tabba <tabba@google.com> Link: https://patch.msgid.link/20261001143000.3371786-2-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Rename vCPU pkvm_memcache to stage2_mcVincent Donnefort
With the introduction of the pKVM hyp allocator, the memcache for vCPUs is now only used for carrying pages dedicated to the stage-2 page tables. Rename pkvm_memcache to stage2_mc to reflect its purpose. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-16-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Alloc pkvm_hyp_vcpu using pKVM heap allocatorVincent Donnefort
Transition the allocation of the hypervisor vCPU state structure (pkvm_hyp_vcpu) from the host to the hypervisor using the new pKVM heap allocator (hyp_alloc()). Previously, the host was responsible for calculating the size of, allocating, and donating memory for pkvm_hyp_vcpu during vCPU creation. With the heap allocator in place, the hypervisor now allocates this structure dynamically at EL2. Use the pkvm_call_hyp_req() wrapper in the host to invoke __pkvm_create_hyp_vcpu, which automatically handles any top-up requests if the hypervisor runs out of heap memory during allocation. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-15-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Alloc pkvm_hyp_vm using pKVM heap allocatorVincent Donnefort
Transition the allocation of the hypervisor VM state structure (pkvm_hyp_vm) from the host to the hypervisor using the new pKVM heap allocator (hyp_alloc()). Previously, the host was responsible for calculating the size of, allocating, and donating memory for pkvm_hyp_vm during VM creation. With the heap allocator in place, the hypervisor now allocates this structure dynamically at EL2. Use the pkvm_call_hyp_req() wrapper in the host to invoke __pkvm_init_vm, which automatically handles any top-up requests if the hypervisor runs out of heap memory during allocation. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-14-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Filter out non-kernel addresses in kern_hyp_vaVincent Donnefort
kern_hyp_va() is idempotent for the hypervisor linear space. This is handy for nVHE hypervisor callers handling kvm_vcpu or kvm_arch pointers. Those pointers can originate from the hypervisor space (when protected mode is enabled, we don't trust the kernel and the hypervisor uses its own copy) or from the kernel space (we do trust the kernel in "non-protected" nVHE). This idempotence does not hold for addresses within the hypervisor private range, like the ones you get from the pKVM heap allocator (hyp_alloc()). To resolve this, filter out non-kernel addresses based on PAGE_OFFSET. Leave the assembly version untouched as it has no current users. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-12-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Add a shrinker for pKVMVincent Donnefort
Integrate the pKVM memory reclaim interface with the host's memory management subsystem. This allows the host to automatically recover unused memory fom the hypervisor's heap allocator when the host is under memory pressure. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-11-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Add selftests for the pKVM heap allocatorVincent Donnefort
Introduce a comprehensive runtime selftest for the pKVM hypervisor heap allocator, executed during init when CONFIG_NVHE_EL2_DEBUG is enabled. The selftest runs entirely at EL2 and exercises allocator's core mechanisms: * over-sized allocations * basic allocation and alignment * chunk recycling, splitting, merging * memory reclaiming * memory topup Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-10-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Add reclaim interface for the pKVM heap allocVincent Donnefort
Introduce a host interface to reclaim donated memory from the pKVM heap allocator back to the host. It specifically provides two helpers that will make it easier to create a shrinker for pKVM: pkvm_hyp_reclaimable() pkvm_hyp_relaim() Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-9-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Add PKVM_HYP_REQ_HYP_ALLOC requestVincent Donnefort
Introduce a new pkvm_hyp_request type asking the host to top up the pKVM heap allocator. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-8-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Add pkvm_hyp_req infrastructureVincent Donnefort
Introduce a struct pkvm_hyp_req to enable the pKVM hypervisor to request resources from the host. Provide serialisation helpers to transport these requests via SMCCC registers (starting from a2): pkvm_hyp_req_to_smccc() to encode into the SMCCC args. smccc_to_pkvm_hyp_req() to decode them. When the hypervisor raises a request, the host must handle it and retry the HVC. To automate this sequence, introduce the pkvm_call_hyp_req() macro. This intercepts pending requests, invokes the handler and retries the HVC. Additionally, introduce a trace event to track the handling of these requests. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-7-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Allow kvm_hyp_memcache usage outside of stage-2Vincent Donnefort
Although currently limited to guest stage-2 page-table allocations, struct kvm_hyp_memcache is a useful primitive for passing a list of discontiguous pages between host and hypervisor. Introduce init_hyp_memcache() to initialise a generic hyp memcache, and init_hyp_stage2_memcache() for stage-2 specific memcaches. The generic initialiser will be used to top up the upcoming pKVM heap allocator. Note that the generic kvm_hyp_memcache does not account for the allocated memory. This is expected: donations to the heap allocator are shared and recycled, they cannot be accounted for a specific VM. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001142849.3367614-6-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Advertise the capabilities that protected VMs supportFuad Tabba
For a protected VM, kvm_pkvm_ext_allowed() returns false on every capability it doesn't name, so KVM_CHECK_EXTENSION returns 0 for interfaces the VM implements: it denies KVM_CAP_ONE_REG while KVM_{GET,SET}_ONE_REG stage the guest's boot state. Allow the capabilities that work for a protected guest under the restrictions the preceding patches add, the vGIC and the I/O bus being host-managed. Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001135711.1640520-18-fuad.tabba@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>
13 daysKVM: arm64: Reject host power-on of a vCPU that EL2 holds powered offFuad Tabba
A protected vCPU's power state belongs to EL2, which changes it only on the guest's own PSCI calls. KVM_SET_MP_STATE(RUNNABLE) on a vCPU EL2 holds powered off changes the host's copy alone, and the guest's next CPU_ON of that vCPU then fails: mp_state is no longer STOPPED, so the host returns ALREADY_ON, and the guest's retry fails the same way until the VMM stops the vCPU again. SUSPENDED has the same effect. Record a vCPU EL2 holds powered off as KVM_MP_STATE_UNINITIALIZED, an encoding arm64 didn't use: the guest's CPU_OFF writes it, as does hyp vCPU creation for a vCPU that starts STOPPED, and only the guest's CPU_ON writes RUNNABLE over it. RUNNABLE and SUSPENDED from the VMM return -EPERM on it, the VMM can't write the value itself, and KVM_ARM_VCPU_INIT, which would write STOPPED or RUNNABLE over it, is rejected once the vCPU has run. The VMM can still pause and resume a vCPU EL2 has powered on. Neither STOPPED nor kvm_prepare_system_event() overwrites the value: a vCPU at it is already off, and a STOPPED in its place would turn the guest's next CPU_ON into ALREADY_ON, after a SYSTEM_RESET exit the VMM runs on from. kvm_arm_vcpu_stopped() covers it, so the run loop sleeps the vCPU as before. The guest's CPU_ON is gated on the value rather than on STOPPED. A STOPPED written between the target's CPU_OFF exit and the host's power-off of it, which kvm_prepare_system_event() can do from another vCPU's SYSTEM_OFF or SYSTEM_RESET, would otherwise let the CPU_ON through, and the power-off would then record the target powered off while EL2 holds it ON_PENDING, with no way back before VM teardown. Gated on the value, that CPU_ON returns ALREADY_ON and the retry succeeds once the power-off has run. Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261001135711.1640520-17-fuad.tabba@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>