diff options
author | Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> | 2011-11-30 04:43:24 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-12-27 04:22:12 -0500 |
commit | e37fa7853c276403da2fea8792c579e8bfd75042 (patch) | |
tree | 2ada19688af6ef30bba12b011d38e0166976170d /arch/x86 | |
parent | d750ea28865dbff6a73444358d189dd811c68c50 (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')
-rw-r--r-- | arch/x86/kvm/mmu.c | 28 | ||||
-rw-r--r-- | arch/x86/kvm/mmu_audit.c | 29 |
2 files changed, 28 insertions, 29 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index b1178d1bb8f5..7a8e99c6dc81 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -59,21 +59,6 @@ enum { | |||
59 | AUDIT_POST_SYNC | 59 | AUDIT_POST_SYNC |
60 | }; | 60 | }; |
61 | 61 | ||
62 | char *audit_point_name[] = { | ||
63 | "pre page fault", | ||
64 | "post page fault", | ||
65 | "pre pte write", | ||
66 | "post pte write", | ||
67 | "pre sync", | ||
68 | "post sync" | ||
69 | }; | ||
70 | |||
71 | #ifdef CONFIG_KVM_MMU_AUDIT | ||
72 | static void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point); | ||
73 | #else | ||
74 | static void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point) { } | ||
75 | #endif | ||
76 | |||
77 | #undef MMU_DEBUG | 62 | #undef MMU_DEBUG |
78 | 63 | ||
79 | #ifdef MMU_DEBUG | 64 | #ifdef MMU_DEBUG |
@@ -1539,6 +1524,13 @@ static int kvm_sync_page_transient(struct kvm_vcpu *vcpu, | |||
1539 | return ret; | 1524 | return ret; |
1540 | } | 1525 | } |
1541 | 1526 | ||
1527 | #ifdef CONFIG_KVM_MMU_AUDIT | ||
1528 | #include "mmu_audit.c" | ||
1529 | #else | ||
1530 | static void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point) { } | ||
1531 | static void mmu_audit_disable(void) { } | ||
1532 | #endif | ||
1533 | |||
1542 | static int kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, | 1534 | static int kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, |
1543 | struct list_head *invalid_list) | 1535 | struct list_head *invalid_list) |
1544 | { | 1536 | { |
@@ -4035,12 +4027,6 @@ void kvm_mmu_destroy(struct kvm_vcpu *vcpu) | |||
4035 | mmu_free_memory_caches(vcpu); | 4027 | mmu_free_memory_caches(vcpu); |
4036 | } | 4028 | } |
4037 | 4029 | ||
4038 | #ifdef CONFIG_KVM_MMU_AUDIT | ||
4039 | #include "mmu_audit.c" | ||
4040 | #else | ||
4041 | static void mmu_audit_disable(void) { } | ||
4042 | #endif | ||
4043 | |||
4044 | void kvm_mmu_module_exit(void) | 4030 | void kvm_mmu_module_exit(void) |
4045 | { | 4031 | { |
4046 | mmu_destroy_caches(); | 4032 | mmu_destroy_caches(); |
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 | ||
22 | char 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) | |||
227 | static bool mmu_audit; | 236 | static bool mmu_audit; |
228 | static struct jump_label_key mmu_audit_key; | 237 | static struct jump_label_key mmu_audit_key; |
229 | 238 | ||
230 | static void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point) | 239 | static 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 | |||
251 | static 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 | ||
244 | static void mmu_audit_enable(void) | 257 | static void mmu_audit_enable(void) |