KVM
Functions
sysreg-sr.c File Reference
#include <hyp/sysreg-sr.h>
#include <linux/compiler.h>
#include <linux/kvm_host.h>
#include <asm/kprobes.h>
#include <asm/kvm_asm.h>
#include <asm/kvm_emulate.h>
#include <asm/kvm_hyp.h>
#include <asm/kvm_nested.h>
Include dependency graph for sysreg-sr.c:

Go to the source code of this file.

Functions

void sysreg_save_host_state_vhe (struct kvm_cpu_context *ctxt)
 
 NOKPROBE_SYMBOL (sysreg_save_host_state_vhe)
 
void sysreg_save_guest_state_vhe (struct kvm_cpu_context *ctxt)
 
 NOKPROBE_SYMBOL (sysreg_save_guest_state_vhe)
 
void sysreg_restore_host_state_vhe (struct kvm_cpu_context *ctxt)
 
 NOKPROBE_SYMBOL (sysreg_restore_host_state_vhe)
 
void sysreg_restore_guest_state_vhe (struct kvm_cpu_context *ctxt)
 
 NOKPROBE_SYMBOL (sysreg_restore_guest_state_vhe)
 
void __vcpu_load_switch_sysregs (struct kvm_vcpu *vcpu)
 
void __vcpu_put_switch_sysregs (struct kvm_vcpu *vcpu)
 

Function Documentation

◆ __vcpu_load_switch_sysregs()

void __vcpu_load_switch_sysregs ( struct kvm_vcpu *  vcpu)

__vcpu_load_switch_sysregs - Load guest system registers to the physical CPU

@vcpu: The VCPU pointer

Load system registers that do not affect the host's execution, for example EL1 system registers on a VHE system where the host kernel runs at EL2. This function is called from KVM's vcpu_load() function and loading system register state early avoids having to load them on every entry to the VM.

Definition at line 65 of file sysreg-sr.c.

66 {
67  struct kvm_cpu_context *guest_ctxt = &vcpu->arch.ctxt;
68  struct kvm_cpu_context *host_ctxt;
69 
70  host_ctxt = &this_cpu_ptr(&kvm_host_data)->host_ctxt;
71  __sysreg_save_user_state(host_ctxt);
72 
73  /*
74  * When running a normal EL1 guest, we only load a new vcpu
75  * after a context switch, which imvolves a DSB, so all
76  * speculative EL1&0 walks will have already completed.
77  * If running NV, the vcpu may transition between vEL1 and
78  * vEL2 without a context switch, so make sure we complete
79  * those walks before loading a new context.
80  */
81  if (vcpu_has_nv(vcpu))
82  dsb(nsh);
83 
84  /*
85  * Load guest EL1 and user state
86  *
87  * We must restore the 32-bit state before the sysregs, thanks
88  * to erratum #852523 (Cortex-A57) or #853709 (Cortex-A72).
89  */
91  __sysreg_restore_user_state(guest_ctxt);
92  __sysreg_restore_el1_state(guest_ctxt);
93 
94  vcpu_set_flag(vcpu, SYSREGS_ON_CPU);
95 }
static void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)
Definition: sysreg-sr.h:100
static void __sysreg32_restore_state(struct kvm_vcpu *vcpu)
Definition: sysreg-sr.h:229
static void __sysreg_restore_user_state(struct kvm_cpu_context *ctxt)
Definition: sysreg-sr.h:94
static void __sysreg_save_user_state(struct kvm_cpu_context *ctxt)
Definition: sysreg-sr.h:24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __vcpu_put_switch_sysregs()

void __vcpu_put_switch_sysregs ( struct kvm_vcpu *  vcpu)

__vcpu_put_switch_syregs - Restore host system registers to the physical CPU

@vcpu: The VCPU pointer

Save guest system registers that do not affect the host's execution, for example EL1 system registers on a VHE system where the host kernel runs at EL2. This function is called from KVM's vcpu_put() function and deferring saving system register state until we're no longer running the VCPU avoids having to save them on every exit from the VM.

Definition at line 108 of file sysreg-sr.c.

109 {
110  struct kvm_cpu_context *guest_ctxt = &vcpu->arch.ctxt;
111  struct kvm_cpu_context *host_ctxt;
112 
113  host_ctxt = &this_cpu_ptr(&kvm_host_data)->host_ctxt;
114 
115  __sysreg_save_el1_state(guest_ctxt);
116  __sysreg_save_user_state(guest_ctxt);
117  __sysreg32_save_state(vcpu);
118 
119  /* Restore host user state */
120  __sysreg_restore_user_state(host_ctxt);
121 
122  vcpu_clear_flag(vcpu, SYSREGS_ON_CPU);
123 }
static void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt)
Definition: sysreg-sr.h:40
static void __sysreg32_save_state(struct kvm_vcpu *vcpu)
Definition: sysreg-sr.h:212
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NOKPROBE_SYMBOL() [1/4]

NOKPROBE_SYMBOL ( sysreg_restore_guest_state_vhe  )

◆ NOKPROBE_SYMBOL() [2/4]

NOKPROBE_SYMBOL ( sysreg_restore_host_state_vhe  )

◆ NOKPROBE_SYMBOL() [3/4]

NOKPROBE_SYMBOL ( sysreg_save_guest_state_vhe  )

◆ NOKPROBE_SYMBOL() [4/4]

NOKPROBE_SYMBOL ( sysreg_save_host_state_vhe  )

◆ sysreg_restore_guest_state_vhe()

void sysreg_restore_guest_state_vhe ( struct kvm_cpu_context *  ctxt)

Definition at line 47 of file sysreg-sr.c.

48 {
51 }
static void __sysreg_restore_common_state(struct kvm_cpu_context *ctxt)
Definition: sysreg-sr.h:89
static void __sysreg_restore_el2_return_state(struct kvm_cpu_context *ctxt)
Definition: sysreg-sr.h:186
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysreg_restore_host_state_vhe()

void sysreg_restore_host_state_vhe ( struct kvm_cpu_context *  ctxt)

Definition at line 41 of file sysreg-sr.c.

42 {
44 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysreg_save_guest_state_vhe()

void sysreg_save_guest_state_vhe ( struct kvm_cpu_context *  ctxt)

Definition at line 34 of file sysreg-sr.c.

35 {
38 }
static void __sysreg_save_el2_return_state(struct kvm_cpu_context *ctxt)
Definition: sysreg-sr.h:75
static void __sysreg_save_common_state(struct kvm_cpu_context *ctxt)
Definition: sysreg-sr.h:19
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysreg_save_host_state_vhe()

void sysreg_save_host_state_vhe ( struct kvm_cpu_context *  ctxt)

Definition at line 28 of file sysreg-sr.c.

29 {
31 }
Here is the call graph for this function:
Here is the caller graph for this function: