aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu_audit.c
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>2011-11-30 04:43:24 -0500
committerAvi Kivity <avi@redhat.com>2011-12-27 04:22:12 -0500
commite37fa7853c276403da2fea8792c579e8bfd75042 (patch)
tree2ada19688af6ef30bba12b011d38e0166976170d /arch/x86/kvm/mmu_audit.c
parentd750ea28865dbff6a73444358d189dd811c68c50 (diff)
KVM: MMU: audit: inline audit function
inline audit function and little cleanup Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu_audit.c')
-rw-r--r--arch/x86/kvm/mmu_audit.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c
index 5df6736a5afb..fe15dcc07a6b 100644
--- a/arch/x86/kvm/mmu_audit.c
+++ b/arch/x86/kvm/mmu_audit.c
@@ -19,6 +19,15 @@
19 19
20#include <linux/ratelimit.h> 20#include <linux/ratelimit.h>
21 21
22char const *audit_point_name[] = {
23 "pre page fault",
24 "post page fault",
25 "pre pte write",
26 "post pte write",
27 "pre sync",
28 "post sync"
29};
30
22#define audit_printk(kvm, fmt, args...) \ 31#define audit_printk(kvm, fmt, args...) \
23 printk(KERN_ERR "audit: (%s) error: " \ 32 printk(KERN_ERR "audit: (%s) error: " \
24 fmt, audit_point_name[kvm->arch.audit_point], ##args) 33 fmt, audit_point_name[kvm->arch.audit_point], ##args)
@@ -227,18 +236,22 @@ static void audit_vcpu_spte(struct kvm_vcpu *vcpu)
227static bool mmu_audit; 236static bool mmu_audit;
228static struct jump_label_key mmu_audit_key; 237static struct jump_label_key mmu_audit_key;
229 238
230static void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point) 239static void __kvm_mmu_audit(struct kvm_vcpu *vcpu, int point)
231{ 240{
232 static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 10); 241 static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 10);
233 242
234 if (static_branch((&mmu_audit_key))) { 243 if (!__ratelimit(&ratelimit_state))
235 if (!__ratelimit(&ratelimit_state)) 244 return;
236 return;
237 245
238 vcpu->kvm->arch.audit_point = point; 246 vcpu->kvm->arch.audit_point = point;
239 audit_all_active_sps(vcpu->kvm); 247 audit_all_active_sps(vcpu->kvm);
240 audit_vcpu_spte(vcpu); 248 audit_vcpu_spte(vcpu);
241 } 249}
250
251static inline void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point)
252{
253 if (static_branch((&mmu_audit_key)))
254 __kvm_mmu_audit(vcpu, point);
242} 255}
243 256
244static void mmu_audit_enable(void) 257static void mmu_audit_enable(void)