~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/kvm/hyp/nvhe/timer-sr.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) 2012-2015 - ARM Ltd
  4  * Author: Marc Zyngier <marc.zyngier@arm.com>
  5  */
  6 
  7 #include <clocksource/arm_arch_timer.h>
  8 #include <linux/compiler.h>
  9 #include <linux/kvm_host.h>
 10 
 11 #include <asm/kvm_hyp.h>
 12 #include <asm/kvm_mmu.h>
 13 
 14 void __kvm_timer_set_cntvoff(u64 cntvoff)
 15 {
 16         write_sysreg(cntvoff, cntvoff_el2);
 17 }
 18 
 19 /*
 20  * Should only be called on non-VHE or hVHE setups.
 21  * VHE systems use EL2 timers and configure EL1 timers in kvm_timer_init_vhe().
 22  */
 23 void __timer_disable_traps(struct kvm_vcpu *vcpu)
 24 {
 25         u64 val, shift = 0;
 26 
 27         if (has_hvhe())
 28                 shift = 10;
 29 
 30         /* Allow physical timer/counter access for the host */
 31         val = read_sysreg(cnthctl_el2);
 32         val |= (CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN) << shift;
 33         write_sysreg(val, cnthctl_el2);
 34 }
 35 
 36 /*
 37  * Should only be called on non-VHE or hVHE setups.
 38  * VHE systems use EL2 timers and configure EL1 timers in kvm_timer_init_vhe().
 39  */
 40 void __timer_enable_traps(struct kvm_vcpu *vcpu)
 41 {
 42         u64 clr = 0, set = 0;
 43 
 44         /*
 45          * Disallow physical timer access for the guest
 46          * Physical counter access is allowed if no offset is enforced
 47          * or running protected (we don't offset anything in this case).
 48          */
 49         clr = CNTHCTL_EL1PCEN;
 50         if (is_protected_kvm_enabled() ||
 51             !kern_hyp_va(vcpu->kvm)->arch.timer_data.poffset)
 52                 set |= CNTHCTL_EL1PCTEN;
 53         else
 54                 clr |= CNTHCTL_EL1PCTEN;
 55 
 56         if (has_hvhe()) {
 57                 clr <<= 10;
 58                 set <<= 10;
 59         }
 60 
 61         sysreg_clear_set(cnthctl_el2, clr, set);
 62 }
 63 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php