-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel.patch
2542 lines (2211 loc) · 84.1 KB
/
kernel.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From ef26bb97d6425204f25f2fb3284bb368777dbb61 Mon Sep 17 00:00:00 2001
From: Jason Marmanis <[email protected]>
Date: Fri, 3 Jul 2020 08:55:26 +0300
Subject: [PATCH] Add paging mode switching capability
Decouple paging mode from global state and add
capability to change paging mode on runtime.
---
arch/x86/include/asm/kvm_host.h | 52 +++-
arch/x86/kvm/cpuid.c | 2 +
arch/x86/kvm/mmu.c | 452 ++++++++++++++++----------------
arch/x86/kvm/mmu.h | 2 +-
arch/x86/kvm/mmu_audit.c | 10 +-
arch/x86/kvm/mtrr.c | 1 +
arch/x86/kvm/paging_tmpl.h | 8 +-
arch/x86/kvm/svm.c | 9 +-
arch/x86/kvm/vmx.c | 360 ++++++++++++++++++-------
arch/x86/kvm/x86.c | 37 ++-
virt/kvm/kvm_main.c | 19 ++
11 files changed, 582 insertions(+), 370 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 3245b95ad..05e099180 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -78,6 +78,8 @@
#define KVM_REQ_HV_STIMER KVM_ARCH_REQ(22)
#define KVM_REQ_LOAD_EOI_EXITMAP KVM_ARCH_REQ(23)
#define KVM_REQ_GET_VMCS12_PAGES KVM_ARCH_REQ(24)
+#define KVM_REQ_PM_SWITCH \
+ KVM_ARCH_REQ_FLAGS(25, KVM_REQUEST_WAIT)
#define CR0_RESERVED_BITS \
(~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
@@ -792,6 +794,33 @@ enum kvm_irqchip_mode {
KVM_IRQCHIP_SPLIT, /* created with KVM_CAP_SPLIT_IRQCHIP */
};
+struct kvm_paging {
+ u8 mode;
+ bool ept_enabled;
+ bool ept_ad_enabled;
+ bool pml_enabled;
+ bool unrestricted_guest_enabled;
+ bool largepages_enabled;
+ u64 shadow_user_mask;
+ u64 shadow_accessed_mask;
+ u64 shadow_dirty_mask;
+ u64 shadow_nx_mask;
+ u64 shadow_x_mask;
+ u64 shadow_present_mask;
+ u64 shadow_acc_track_mask;
+ u64 shadow_me_mask;
+ u64 shadow_mmio_value;
+ u64 shadow_mmio_mask;
+ void (*slot_enable_log_dirty)(struct kvm *kvm,
+ struct kvm_memory_slot *slot);
+ void (*slot_disable_log_dirty)(struct kvm *kvm,
+ struct kvm_memory_slot *slot);
+ void (*flush_log_dirty)(struct kvm *kvm);
+ void (*enable_log_dirty_pt_masked)(struct kvm *kvm,
+ struct kvm_memory_slot *slot,
+ gfn_t offset, unsigned long mask);
+};
+
struct kvm_arch {
unsigned int n_used_mmu_pages;
unsigned int n_requested_mmu_pages;
@@ -874,6 +903,10 @@ struct kvm_arch {
bool x2apic_broadcast_quirk_disabled;
bool guest_can_read_msr_platform_info;
+
+ struct kvm_paging *paging;
+ struct completion switch_barrier;
+ struct mutex switch_lock;
};
struct kvm_vm_stat {
@@ -953,7 +986,7 @@ struct kvm_x86_ops {
struct kvm *(*vm_alloc)(void);
void (*vm_free)(struct kvm *);
- int (*vm_init)(struct kvm *kvm);
+ int (*vm_init)(struct kvm *kvm, unsigned long type);
void (*vm_destroy)(struct kvm *kvm);
/* Create, but do not attach this VCPU */
@@ -1082,14 +1115,6 @@ struct kvm_x86_ops {
* called when reenabling log dirty for the GFNs in the mask after
* corresponding bits are cleared in slot->dirty_bitmap.
*/
- void (*slot_enable_log_dirty)(struct kvm *kvm,
- struct kvm_memory_slot *slot);
- void (*slot_disable_log_dirty)(struct kvm *kvm,
- struct kvm_memory_slot *slot);
- void (*flush_log_dirty)(struct kvm *kvm);
- void (*enable_log_dirty_pt_masked)(struct kvm *kvm,
- struct kvm_memory_slot *slot,
- gfn_t offset, unsigned long mask);
int (*write_log_dirty)(struct kvm_vcpu *vcpu);
/* pmu operations of sub-arch */
@@ -1138,6 +1163,9 @@ struct kvm_x86_ops {
int (*mem_enc_unreg_region)(struct kvm *kvm, struct kvm_enc_region *argp);
int (*get_msr_feature)(struct kvm_msr_entry *entry);
+
+ void (*vcpu_pm_switch)(struct kvm_vcpu *vcpu);
+ void (*kvm_pm_switch)(struct kvm *kvm, u8 val);
};
struct kvm_arch_async_pf {
@@ -1178,7 +1206,7 @@ int kvm_mmu_create(struct kvm_vcpu *vcpu);
void kvm_mmu_setup(struct kvm_vcpu *vcpu);
void kvm_mmu_init_vm(struct kvm *kvm);
void kvm_mmu_uninit_vm(struct kvm *kvm);
-void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask,
+void kvm_mmu_set_mask_ptes(struct kvm_paging *paging, u64 user_mask, u64 accessed_mask,
u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask,
u64 acc_track_mask, u64 me_mask);
@@ -1220,8 +1248,6 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq,
void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
bool mask);
-extern bool tdp_enabled;
-
u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu);
/* control of guest tsc rate supported? */
@@ -1351,7 +1377,7 @@ void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva);
void kvm_mmu_invpcid_gva(struct kvm_vcpu *vcpu, gva_t gva, unsigned long pcid);
void kvm_mmu_new_cr3(struct kvm_vcpu *vcpu, gpa_t new_cr3, bool skip_tlb_flush);
-void kvm_enable_tdp(void);
+void kvm_enable_tdp(struct kvm *kvm);
void kvm_disable_tdp(void);
static inline gpa_t translate_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access,
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index b810102a9..d2e73d266 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -499,6 +499,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
entry->ecx |= f_la57;
entry->ecx |= f_umip;
/* PKU is not yet implemented for shadow paging. */
+ //no kvm context, unconditionally no PKU
+ bool tdp_enabled = false;
if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))
entry->ecx &= ~F(PKU);
entry->edx &= kvm_cpuid_7_0_edx_x86_features;
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index cdc0c4609..4c7202e5e 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -56,8 +56,6 @@
* 2. while doing 1. it walks guest-physical to host-physical
* If the hardware supports that we don't need to do shadow paging.
*/
-bool tdp_enabled = false;
-
enum {
AUDIT_PRE_PAGE_FAULT,
AUDIT_POST_PAGE_FAULT,
@@ -126,8 +124,8 @@ module_param(dbg, bool, 0644);
(PAGE_MASK & ~((1ULL << (PAGE_SHIFT + (((level) - 1) \
* PT32_LEVEL_BITS))) - 1))
-#define PT64_PERM_MASK (PT_PRESENT_MASK | PT_WRITABLE_MASK | shadow_user_mask \
- | shadow_x_mask | shadow_nx_mask | shadow_me_mask)
+#define PT64_PERM_MASK(paging) (PT_PRESENT_MASK | PT_WRITABLE_MASK | paging->shadow_user_mask \
+ | paging->shadow_x_mask | paging->shadow_nx_mask | paging->shadow_me_mask)
#define ACC_EXEC_MASK 1
#define ACC_WRITE_MASK PT_WRITABLE_MASK
@@ -210,22 +208,11 @@ static struct kmem_cache *pte_list_desc_cache;
static struct kmem_cache *mmu_page_header_cache;
static struct percpu_counter kvm_total_used_mmu_pages;
-static u64 __read_mostly shadow_nx_mask;
-static u64 __read_mostly shadow_x_mask; /* mutual exclusive with nx_mask */
-static u64 __read_mostly shadow_user_mask;
-static u64 __read_mostly shadow_accessed_mask;
-static u64 __read_mostly shadow_dirty_mask;
-static u64 __read_mostly shadow_mmio_mask;
-static u64 __read_mostly shadow_mmio_value;
-static u64 __read_mostly shadow_present_mask;
-static u64 __read_mostly shadow_me_mask;
-
/*
* SPTEs used by MMUs without A/D bits are marked with shadow_acc_track_value.
* Non-present SPTEs with shadow_acc_track_value set are in place for access
* tracking.
*/
-static u64 __read_mostly shadow_acc_track_mask;
static const u64 shadow_acc_track_value = SPTE_SPECIAL_MASK;
/*
@@ -260,15 +247,15 @@ static const u64 shadow_nonpresent_or_rsvd_mask_len = 5;
static u64 __read_mostly shadow_nonpresent_or_rsvd_lower_gfn_mask;
-static void mmu_spte_set(u64 *sptep, u64 spte);
+static void mmu_spte_set(struct kvm_paging *paging, u64 *sptep, u64 spte);
static union kvm_mmu_page_role
kvm_mmu_calc_root_page_role(struct kvm_vcpu *vcpu);
-void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask, u64 mmio_value)
+void kvm_mmu_set_mmio_spte_mask(struct kvm_paging *paging, u64 mmio_mask, u64 mmio_value)
{
BUG_ON((mmio_mask & mmio_value) != mmio_value);
- shadow_mmio_value = mmio_value | SPTE_SPECIAL_MASK;
- shadow_mmio_mask = mmio_mask | SPTE_SPECIAL_MASK;
+ paging->shadow_mmio_value = mmio_value | SPTE_SPECIAL_MASK;
+ paging->shadow_mmio_mask = mmio_mask | SPTE_SPECIAL_MASK;
}
EXPORT_SYMBOL_GPL(kvm_mmu_set_mmio_spte_mask);
@@ -277,27 +264,27 @@ static inline bool sp_ad_disabled(struct kvm_mmu_page *sp)
return sp->role.ad_disabled;
}
-static inline bool spte_ad_enabled(u64 spte)
+static inline bool spte_ad_enabled(struct kvm_paging *paging, u64 spte)
{
- MMU_WARN_ON((spte & shadow_mmio_mask) == shadow_mmio_value);
+ MMU_WARN_ON((spte & paging->shadow_mmio_mask) == paging->shadow_mmio_value);
return !(spte & shadow_acc_track_value);
}
-static inline u64 spte_shadow_accessed_mask(u64 spte)
+static inline u64 spte_shadow_accessed_mask(struct kvm_paging *paging, u64 spte)
{
- MMU_WARN_ON((spte & shadow_mmio_mask) == shadow_mmio_value);
- return spte_ad_enabled(spte) ? shadow_accessed_mask : 0;
+ MMU_WARN_ON((spte & paging->shadow_mmio_mask) == paging->shadow_mmio_value);
+ return spte_ad_enabled(paging, spte) ? paging->shadow_accessed_mask : 0;
}
-static inline u64 spte_shadow_dirty_mask(u64 spte)
+static inline u64 spte_shadow_dirty_mask(struct kvm_paging *paging, u64 spte)
{
- MMU_WARN_ON((spte & shadow_mmio_mask) == shadow_mmio_value);
- return spte_ad_enabled(spte) ? shadow_dirty_mask : 0;
+ MMU_WARN_ON((spte & paging->shadow_mmio_mask) == paging->shadow_mmio_value);
+ return spte_ad_enabled(paging, spte) ? paging->shadow_dirty_mask : 0;
}
-static inline bool is_access_track_spte(u64 spte)
+static inline bool is_access_track_spte(struct kvm_paging *paging, u64 spte)
{
- return !spte_ad_enabled(spte) && (spte & shadow_acc_track_mask) == 0;
+ return !spte_ad_enabled(paging, spte) && (spte & paging->shadow_acc_track_mask) == 0;
}
/*
@@ -328,11 +315,11 @@ static u64 generation_mmio_spte_mask(unsigned int gen)
return mask;
}
-static unsigned int get_mmio_spte_generation(u64 spte)
+static unsigned int get_mmio_spte_generation(struct kvm_paging *paging, u64 spte)
{
unsigned int gen;
- spte &= ~shadow_mmio_mask;
+ spte &= ~paging->shadow_mmio_mask;
gen = (spte >> MMIO_SPTE_GEN_LOW_SHIFT) & MMIO_GEN_LOW_MASK;
gen |= (spte >> MMIO_SPTE_GEN_HIGH_SHIFT) << MMIO_GEN_LOW_SHIFT;
@@ -352,18 +339,19 @@ static void mark_mmio_spte(struct kvm_vcpu *vcpu, u64 *sptep, u64 gfn,
u64 gpa = gfn << PAGE_SHIFT;
access &= ACC_WRITE_MASK | ACC_USER_MASK;
- mask |= shadow_mmio_value | access;
+ struct kvm_paging *paging = vcpu->kvm->arch.paging;
+ mask |= paging->shadow_mmio_value | access;
mask |= gpa | shadow_nonpresent_or_rsvd_mask;
mask |= (gpa & shadow_nonpresent_or_rsvd_mask)
<< shadow_nonpresent_or_rsvd_mask_len;
trace_mark_mmio_spte(sptep, gfn, access, gen);
- mmu_spte_set(sptep, mask);
+ mmu_spte_set(paging, sptep, mask);
}
-static bool is_mmio_spte(u64 spte)
+static bool is_mmio_spte(struct kvm_paging *paging, u64 spte)
{
- return (spte & shadow_mmio_mask) == shadow_mmio_value;
+ return (spte & paging->shadow_mmio_mask) == paging->shadow_mmio_value;
}
static gfn_t get_mmio_spte_gfn(u64 spte)
@@ -376,9 +364,9 @@ static gfn_t get_mmio_spte_gfn(u64 spte)
return gpa >> PAGE_SHIFT;
}
-static unsigned get_mmio_spte_access(u64 spte)
+static unsigned get_mmio_spte_access(struct kvm_paging *paging, u64 spte)
{
- u64 mask = generation_mmio_spte_mask(MMIO_GEN_MASK) | shadow_mmio_mask;
+ u64 mask = generation_mmio_spte_mask(MMIO_GEN_MASK) | paging->shadow_mmio_mask;
return (spte & ~mask) & ~PAGE_MASK;
}
@@ -398,7 +386,7 @@ static bool check_mmio_spte(struct kvm_vcpu *vcpu, u64 spte)
unsigned int kvm_gen, spte_gen;
kvm_gen = kvm_current_mmio_generation(vcpu);
- spte_gen = get_mmio_spte_generation(spte);
+ spte_gen = get_mmio_spte_generation(vcpu->kvm->arch.paging, spte);
trace_check_mmio_spte(spte, kvm_gen, spte_gen);
return likely(kvm_gen == spte_gen);
@@ -411,7 +399,7 @@ static bool check_mmio_spte(struct kvm_vcpu *vcpu, u64 spte)
* - Setting either @accessed_mask or @dirty_mask requires setting both
* - At least one of @accessed_mask or @acc_track_mask must be set
*/
-void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask,
+void kvm_mmu_set_mask_ptes(struct kvm_paging *paging, u64 user_mask, u64 accessed_mask,
u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask,
u64 acc_track_mask, u64 me_mask)
{
@@ -419,14 +407,14 @@ void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask,
BUG_ON(!accessed_mask && !acc_track_mask);
BUG_ON(acc_track_mask & shadow_acc_track_value);
- shadow_user_mask = user_mask;
- shadow_accessed_mask = accessed_mask;
- shadow_dirty_mask = dirty_mask;
- shadow_nx_mask = nx_mask;
- shadow_x_mask = x_mask;
- shadow_present_mask = p_mask;
- shadow_acc_track_mask = acc_track_mask;
- shadow_me_mask = me_mask;
+ paging->shadow_user_mask = user_mask;
+ paging->shadow_accessed_mask = accessed_mask;
+ paging->shadow_dirty_mask = dirty_mask;
+ paging->shadow_nx_mask = nx_mask;
+ paging->shadow_x_mask = x_mask;
+ paging->shadow_present_mask = p_mask;
+ paging->shadow_acc_track_mask = acc_track_mask;
+ paging->shadow_me_mask = me_mask;
}
EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes);
@@ -434,15 +422,6 @@ static void kvm_mmu_reset_all_pte_masks(void)
{
u8 low_phys_bits;
- shadow_user_mask = 0;
- shadow_accessed_mask = 0;
- shadow_dirty_mask = 0;
- shadow_nx_mask = 0;
- shadow_x_mask = 0;
- shadow_mmio_mask = 0;
- shadow_present_mask = 0;
- shadow_acc_track_mask = 0;
-
/*
* If the CPU has 46 or less physical address bits, then set an
* appropriate mask to guard against L1TF attacks. Otherwise, it is
@@ -471,9 +450,9 @@ static int is_nx(struct kvm_vcpu *vcpu)
return vcpu->arch.efer & EFER_NX;
}
-static int is_shadow_present_pte(u64 pte)
+static int is_shadow_present_pte(struct kvm_paging *paging, u64 pte)
{
- return (pte != 0) && !is_mmio_spte(pte);
+ return (pte != 0) && !is_mmio_spte(paging, pte);
}
static int is_large_pte(u64 pte)
@@ -490,9 +469,9 @@ static int is_last_spte(u64 pte, int level)
return 0;
}
-static bool is_executable_pte(u64 spte)
+static bool is_executable_pte(struct kvm_paging *paging, u64 spte)
{
- return (spte & (shadow_x_mask | shadow_nx_mask)) == shadow_x_mask;
+ return (spte & (paging->shadow_x_mask | paging->shadow_nx_mask)) == paging->shadow_x_mask;
}
static kvm_pfn_t spte_to_pfn(u64 pte)
@@ -536,11 +515,11 @@ union split_spte {
u64 spte;
};
-static void count_spte_clear(u64 *sptep, u64 spte)
+static void count_spte_clear(struct kvm_paging *paging, u64 *sptep, u64 spte)
{
struct kvm_mmu_page *sp = page_header(__pa(sptep));
- if (is_shadow_present_pte(spte))
+ if (is_shadow_present_pte(paging, spte))
return;
/* Ensure the spte is completely set before we increase the count */
@@ -650,9 +629,9 @@ static bool spte_can_locklessly_be_made_writable(u64 spte)
(SPTE_HOST_WRITEABLE | SPTE_MMU_WRITEABLE);
}
-static bool spte_has_volatile_bits(u64 spte)
+static bool spte_has_volatile_bits(struct kvm_paging *paging, u64 spte)
{
- if (!is_shadow_present_pte(spte))
+ if (!is_shadow_present_pte(paging, spte))
return false;
/*
@@ -662,29 +641,29 @@ static bool spte_has_volatile_bits(u64 spte)
* to ensure tlb flush is not missed.
*/
if (spte_can_locklessly_be_made_writable(spte) ||
- is_access_track_spte(spte))
+ is_access_track_spte(paging, spte))
return true;
- if (spte_ad_enabled(spte)) {
- if ((spte & shadow_accessed_mask) == 0 ||
- (is_writable_pte(spte) && (spte & shadow_dirty_mask) == 0))
+ if (spte_ad_enabled(paging, spte)) {
+ if ((spte & paging->shadow_accessed_mask) == 0 ||
+ (is_writable_pte(spte) && (spte & paging->shadow_dirty_mask) == 0))
return true;
}
return false;
}
-static bool is_accessed_spte(u64 spte)
+static bool is_accessed_spte(struct kvm_paging *paging, u64 spte)
{
- u64 accessed_mask = spte_shadow_accessed_mask(spte);
+ u64 accessed_mask = spte_shadow_accessed_mask(paging, spte);
return accessed_mask ? spte & accessed_mask
- : !is_access_track_spte(spte);
+ : !is_access_track_spte(paging, spte);
}
-static bool is_dirty_spte(u64 spte)
+static bool is_dirty_spte(struct kvm_paging *paging, u64 spte)
{
- u64 dirty_mask = spte_shadow_dirty_mask(spte);
+ u64 dirty_mask = spte_shadow_dirty_mask(paging, spte);
return dirty_mask ? spte & dirty_mask : spte & PT_WRITABLE_MASK;
}
@@ -695,9 +674,9 @@ static bool is_dirty_spte(u64 spte)
* or in a state where the hardware will not attempt to update
* the spte.
*/
-static void mmu_spte_set(u64 *sptep, u64 new_spte)
+static void mmu_spte_set(struct kvm_paging *paging, u64 *sptep, u64 new_spte)
{
- WARN_ON(is_shadow_present_pte(*sptep));
+ WARN_ON(is_shadow_present_pte(paging, *sptep));
__set_spte(sptep, new_spte);
}
@@ -705,18 +684,18 @@ static void mmu_spte_set(u64 *sptep, u64 new_spte)
* Update the SPTE (excluding the PFN), but do not track changes in its
* accessed/dirty status.
*/
-static u64 mmu_spte_update_no_track(u64 *sptep, u64 new_spte)
+static u64 mmu_spte_update_no_track(struct kvm_paging *paging, u64 *sptep, u64 new_spte)
{
u64 old_spte = *sptep;
- WARN_ON(!is_shadow_present_pte(new_spte));
+ WARN_ON(!is_shadow_present_pte(paging, new_spte));
- if (!is_shadow_present_pte(old_spte)) {
- mmu_spte_set(sptep, new_spte);
+ if (!is_shadow_present_pte(paging, old_spte)) {
+ mmu_spte_set(paging, sptep, new_spte);
return old_spte;
}
- if (!spte_has_volatile_bits(old_spte))
+ if (!spte_has_volatile_bits(paging, old_spte))
__update_clear_spte_fast(sptep, new_spte);
else
old_spte = __update_clear_spte_slow(sptep, new_spte);
@@ -737,12 +716,12 @@ static u64 mmu_spte_update_no_track(u64 *sptep, u64 new_spte)
*
* Returns true if the TLB needs to be flushed
*/
-static bool mmu_spte_update(u64 *sptep, u64 new_spte)
+static bool mmu_spte_update(struct kvm_paging *paging, u64 *sptep, u64 new_spte)
{
bool flush = false;
- u64 old_spte = mmu_spte_update_no_track(sptep, new_spte);
+ u64 old_spte = mmu_spte_update_no_track(paging, sptep, new_spte);
- if (!is_shadow_present_pte(old_spte))
+ if (!is_shadow_present_pte(paging, old_spte))
return false;
/*
@@ -759,12 +738,12 @@ static bool mmu_spte_update(u64 *sptep, u64 new_spte)
* to guarantee consistency between TLB and page tables.
*/
- if (is_accessed_spte(old_spte) && !is_accessed_spte(new_spte)) {
+ if (is_accessed_spte(paging, old_spte) && !is_accessed_spte(paging, new_spte)) {
flush = true;
kvm_set_pfn_accessed(spte_to_pfn(old_spte));
}
- if (is_dirty_spte(old_spte) && !is_dirty_spte(new_spte)) {
+ if (is_dirty_spte(paging, old_spte) && !is_dirty_spte(paging, new_spte)) {
flush = true;
kvm_set_pfn_dirty(spte_to_pfn(old_spte));
}
@@ -778,17 +757,17 @@ static bool mmu_spte_update(u64 *sptep, u64 new_spte)
* state bits, it is used to clear the last level sptep.
* Returns non-zero if the PTE was previously valid.
*/
-static int mmu_spte_clear_track_bits(u64 *sptep)
+static int mmu_spte_clear_track_bits(struct kvm_paging *paging, u64 *sptep)
{
kvm_pfn_t pfn;
u64 old_spte = *sptep;
- if (!spte_has_volatile_bits(old_spte))
+ if (!spte_has_volatile_bits(paging, old_spte))
__update_clear_spte_fast(sptep, 0ull);
else
old_spte = __update_clear_spte_slow(sptep, 0ull);
- if (!is_shadow_present_pte(old_spte))
+ if (!is_shadow_present_pte(paging, old_spte))
return 0;
pfn = spte_to_pfn(old_spte);
@@ -800,10 +779,10 @@ static int mmu_spte_clear_track_bits(u64 *sptep)
*/
WARN_ON(!kvm_is_reserved_pfn(pfn) && !page_count(pfn_to_page(pfn)));
- if (is_accessed_spte(old_spte))
+ if (is_accessed_spte(paging, old_spte))
kvm_set_pfn_accessed(pfn);
- if (is_dirty_spte(old_spte))
+ if (is_dirty_spte(paging, old_spte))
kvm_set_pfn_dirty(pfn);
return 1;
@@ -824,12 +803,12 @@ static u64 mmu_spte_get_lockless(u64 *sptep)
return __get_spte_lockless(sptep);
}
-static u64 mark_spte_for_access_track(u64 spte)
+static u64 mark_spte_for_access_track(struct kvm_paging *paging, u64 spte)
{
- if (spte_ad_enabled(spte))
- return spte & ~shadow_accessed_mask;
+ if (spte_ad_enabled(paging, spte))
+ return spte & ~paging->shadow_accessed_mask;
- if (is_access_track_spte(spte))
+ if (is_access_track_spte(paging, spte))
return spte;
/*
@@ -847,22 +826,22 @@ static u64 mark_spte_for_access_track(u64 spte)
spte |= (spte & shadow_acc_track_saved_bits_mask) <<
shadow_acc_track_saved_bits_shift;
- spte &= ~shadow_acc_track_mask;
+ spte &= ~paging->shadow_acc_track_mask;
return spte;
}
/* Restore an acc-track PTE back to a regular PTE */
-static u64 restore_acc_track_spte(u64 spte)
+static u64 restore_acc_track_spte(struct kvm_paging *paging, u64 spte)
{
u64 new_spte = spte;
u64 saved_bits = (spte >> shadow_acc_track_saved_bits_shift)
& shadow_acc_track_saved_bits_mask;
- WARN_ON_ONCE(spte_ad_enabled(spte));
- WARN_ON_ONCE(!is_access_track_spte(spte));
+ WARN_ON_ONCE(spte_ad_enabled(paging, spte));
+ WARN_ON_ONCE(!is_access_track_spte(paging, spte));
- new_spte &= ~shadow_acc_track_mask;
+ new_spte &= ~paging->shadow_acc_track_mask;
new_spte &= ~(shadow_acc_track_saved_bits_mask <<
shadow_acc_track_saved_bits_shift);
new_spte |= saved_bits;
@@ -871,15 +850,15 @@ static u64 restore_acc_track_spte(u64 spte)
}
/* Returns the Accessed status of the PTE and resets it at the same time. */
-static bool mmu_spte_age(u64 *sptep)
+static bool mmu_spte_age(struct kvm_paging *paging, u64 *sptep)
{
u64 spte = mmu_spte_get_lockless(sptep);
- if (!is_accessed_spte(spte))
+ if (!is_accessed_spte(paging, spte))
return false;
- if (spte_ad_enabled(spte)) {
- clear_bit((ffs(shadow_accessed_mask) - 1),
+ if (spte_ad_enabled(paging, spte)) {
+ clear_bit((ffs(paging->shadow_accessed_mask) - 1),
(unsigned long *)sptep);
} else {
/*
@@ -889,8 +868,8 @@ static bool mmu_spte_age(u64 *sptep)
if (is_writable_pte(spte))
kvm_set_pfn_dirty(spte_to_pfn(spte));
- spte = mark_spte_for_access_track(spte);
- mmu_spte_update_no_track(sptep, spte);
+ spte = mark_spte_for_access_track(paging, spte);
+ mmu_spte_update_no_track(paging, sptep, spte);
}
return true;
@@ -1369,7 +1348,7 @@ struct rmap_iterator {
*
* Returns sptep if found, NULL otherwise.
*/
-static u64 *rmap_get_first(struct kvm_rmap_head *rmap_head,
+static u64 *rmap_get_first(struct kvm_paging *paging, struct kvm_rmap_head *rmap_head,
struct rmap_iterator *iter)
{
u64 *sptep;
@@ -1387,7 +1366,7 @@ static u64 *rmap_get_first(struct kvm_rmap_head *rmap_head,
iter->pos = 0;
sptep = iter->desc->sptes[iter->pos];
out:
- BUG_ON(!is_shadow_present_pte(*sptep));
+ BUG_ON(!is_shadow_present_pte(paging, *sptep));
return sptep;
}
@@ -1396,7 +1375,7 @@ static u64 *rmap_get_first(struct kvm_rmap_head *rmap_head,
*
* Returns sptep if found, NULL otherwise.
*/
-static u64 *rmap_get_next(struct rmap_iterator *iter)
+static u64 *rmap_get_next(struct kvm_paging *paging, struct rmap_iterator *iter)
{
u64 *sptep;
@@ -1420,17 +1399,17 @@ static u64 *rmap_get_next(struct rmap_iterator *iter)
return NULL;
out:
- BUG_ON(!is_shadow_present_pte(*sptep));
+ BUG_ON(!is_shadow_present_pte(paging, *sptep));
return sptep;
}
-#define for_each_rmap_spte(_rmap_head_, _iter_, _spte_) \
- for (_spte_ = rmap_get_first(_rmap_head_, _iter_); \
- _spte_; _spte_ = rmap_get_next(_iter_))
+#define for_each_rmap_spte(paging, _rmap_head_, _iter_, _spte_) \
+ for (_spte_ = rmap_get_first(paging, _rmap_head_, _iter_); \
+ _spte_; _spte_ = rmap_get_next(paging, _iter_))
static void drop_spte(struct kvm *kvm, u64 *sptep)
{
- if (mmu_spte_clear_track_bits(sptep))
+ if (mmu_spte_clear_track_bits(kvm->arch.paging, sptep))
rmap_remove(kvm, sptep);
}
@@ -1467,7 +1446,7 @@ static void drop_large_spte(struct kvm_vcpu *vcpu, u64 *sptep)
*
* Return true if tlb need be flushed.
*/
-static bool spte_write_protect(u64 *sptep, bool pt_protect)
+static bool spte_write_protect(struct kvm_paging *paging, u64 *sptep, bool pt_protect)
{
u64 spte = *sptep;
@@ -1481,7 +1460,7 @@ static bool spte_write_protect(u64 *sptep, bool pt_protect)
spte &= ~SPTE_MMU_WRITEABLE;
spte = spte & ~PT_WRITABLE_MASK;
- return mmu_spte_update(sptep, spte);
+ return mmu_spte_update(paging, sptep, spte);
}
static bool __rmap_write_protect(struct kvm *kvm,
@@ -1492,21 +1471,21 @@ static bool __rmap_write_protect(struct kvm *kvm,
struct rmap_iterator iter;
bool flush = false;
- for_each_rmap_spte(rmap_head, &iter, sptep)
- flush |= spte_write_protect(sptep, pt_protect);
+ for_each_rmap_spte(kvm->arch.paging, rmap_head, &iter, sptep)
+ flush |= spte_write_protect(kvm->arch.paging, sptep, pt_protect);
return flush;
}
-static bool spte_clear_dirty(u64 *sptep)
+static bool spte_clear_dirty(struct kvm_paging *paging, u64 *sptep)
{
u64 spte = *sptep;
rmap_printk("rmap_clear_dirty: spte %p %llx\n", sptep, *sptep);
- spte &= ~shadow_dirty_mask;
+ spte &= ~paging->shadow_dirty_mask;
- return mmu_spte_update(sptep, spte);
+ return mmu_spte_update(paging, sptep, spte);
}
static bool wrprot_ad_disabled_spte(u64 *sptep)
@@ -1531,24 +1510,24 @@ static bool __rmap_clear_dirty(struct kvm *kvm, struct kvm_rmap_head *rmap_head)
struct rmap_iterator iter;
bool flush = false;
- for_each_rmap_spte(rmap_head, &iter, sptep)
- if (spte_ad_enabled(*sptep))
- flush |= spte_clear_dirty(sptep);
+ for_each_rmap_spte(kvm->arch.paging, rmap_head, &iter, sptep)
+ if (spte_ad_enabled(kvm->arch.paging, *sptep))
+ flush |= spte_clear_dirty(kvm->arch.paging, sptep);
else
flush |= wrprot_ad_disabled_spte(sptep);
return flush;
}
-static bool spte_set_dirty(u64 *sptep)
+static bool spte_set_dirty(struct kvm_paging *paging, u64 *sptep)
{
u64 spte = *sptep;
rmap_printk("rmap_set_dirty: spte %p %llx\n", sptep, *sptep);
- spte |= shadow_dirty_mask;
+ spte |= paging->shadow_dirty_mask;
- return mmu_spte_update(sptep, spte);
+ return mmu_spte_update(paging, sptep, spte);
}
static bool __rmap_set_dirty(struct kvm *kvm, struct kvm_rmap_head *rmap_head)
@@ -1557,9 +1536,9 @@ static bool __rmap_set_dirty(struct kvm *kvm, struct kvm_rmap_head *rmap_head)
struct rmap_iterator iter;
bool flush = false;
- for_each_rmap_spte(rmap_head, &iter, sptep)
- if (spte_ad_enabled(*sptep))
- flush |= spte_set_dirty(sptep);
+ for_each_rmap_spte(kvm->arch.paging, rmap_head, &iter, sptep)
+ if (spte_ad_enabled(kvm->arch.paging, *sptep))
+ flush |= spte_set_dirty(kvm->arch.paging, sptep);
return flush;
}
@@ -1631,8 +1610,8 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,
struct kvm_memory_slot *slot,
gfn_t gfn_offset, unsigned long mask)
{
- if (kvm_x86_ops->enable_log_dirty_pt_masked)
- kvm_x86_ops->enable_log_dirty_pt_masked(kvm, slot, gfn_offset,
+ if (kvm->arch.paging->enable_log_dirty_pt_masked)
+ kvm->arch.paging->enable_log_dirty_pt_masked(kvm, slot, gfn_offset,
mask);
else
kvm_mmu_write_protect_pt_masked(kvm, slot, gfn_offset, mask);
@@ -1682,7 +1661,7 @@ static bool kvm_zap_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head)
struct rmap_iterator iter;
bool flush = false;
- while ((sptep = rmap_get_first(rmap_head, &iter))) {
+ while ((sptep = rmap_get_first(kvm->arch.paging, rmap_head, &iter))) {
rmap_printk("%s: spte %p %llx.\n", __func__, sptep, *sptep);
drop_spte(kvm, sptep);
@@ -1714,7 +1693,7 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
new_pfn = pte_pfn(*ptep);
restart:
- for_each_rmap_spte(rmap_head, &iter, sptep) {
+ for_each_rmap_spte(kvm->arch.paging, rmap_head, &iter, sptep) {
rmap_printk("kvm_set_pte_rmapp: spte %p %llx gfn %llx (%d)\n",
sptep, *sptep, gfn, level);
@@ -1730,10 +1709,10 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
new_spte &= ~PT_WRITABLE_MASK;
new_spte &= ~SPTE_HOST_WRITEABLE;
- new_spte = mark_spte_for_access_track(new_spte);
+ new_spte = mark_spte_for_access_track(kvm->arch.paging, new_spte);
- mmu_spte_clear_track_bits(sptep);
- mmu_spte_set(sptep, new_spte);
+ mmu_spte_clear_track_bits(kvm->arch.paging, sptep);
+ mmu_spte_set(kvm->arch.paging, sptep, new_spte);
}
}
@@ -1887,8 +1866,8 @@ static int kvm_age_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
struct rmap_iterator uninitialized_var(iter);
int young = 0;
- for_each_rmap_spte(rmap_head, &iter, sptep)
- young |= mmu_spte_age(sptep);
+ for_each_rmap_spte(kvm->arch.paging, rmap_head, &iter, sptep)
+ young |= mmu_spte_age(kvm->arch.paging, sptep);
trace_kvm_age_page(gfn, level, slot, young);
return young;
@@ -1901,8 +1880,8 @@ static int kvm_test_age_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
u64 *sptep;
struct rmap_iterator iter;
- for_each_rmap_spte(rmap_head, &iter, sptep)
- if (is_accessed_spte(*sptep))
+ for_each_rmap_spte(kvm->arch.paging, rmap_head, &iter, sptep)
+ if (is_accessed_spte(kvm->arch.paging, *sptep))
return 1;
return 0;
}
@@ -1933,13 +1912,13 @@ int kvm_test_age_hva(struct kvm *kvm, unsigned long hva)
}
#ifdef MMU_DEBUG
-static int is_empty_shadow_page(u64 *spt)
+static int is_empty_shadow_page(struct kvm_paging *paging, u64 *spt)
{
u64 *pos;
u64 *end;
for (pos = spt, end = pos + PAGE_SIZE / sizeof(u64); pos != end; pos++)
- if (is_shadow_present_pte(*pos)) {
+ if (is_shadow_present_pte(paging, *pos)) {
printk(KERN_ERR "%s: %p %llx\n", __func__,
pos, *pos);
return 0;
@@ -1960,9 +1939,9 @@ static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, int nr)
percpu_counter_add(&kvm_total_used_mmu_pages, nr);
}
-static void kvm_mmu_free_page(struct kvm_mmu_page *sp)
+static void kvm_mmu_free_page(struct kvm_paging *pg, struct kvm_mmu_page *sp)
{
- MMU_WARN_ON(!is_empty_shadow_page(sp->spt));
+ MMU_WARN_ON(!is_empty_shadow_page(pg, sp->spt));
hlist_del(&sp->hash_link);
list_del(&sp->link);
free_page((unsigned long)sp->spt);
@@ -2018,18 +1997,18 @@ static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu, int direct
return sp;
}
-static void mark_unsync(u64 *spte);
-static void kvm_mmu_mark_parents_unsync(struct kvm_mmu_page *sp)
+static void mark_unsync(struct kvm_paging *paging, u64 *spte);
+static void kvm_mmu_mark_parents_unsync(struct kvm_paging *paging, struct kvm_mmu_page *sp)
{
u64 *sptep;
struct rmap_iterator iter;
- for_each_rmap_spte(&sp->parent_ptes, &iter, sptep) {
- mark_unsync(sptep);
+ for_each_rmap_spte(paging, &sp->parent_ptes, &iter, sptep) {
+ mark_unsync(paging, sptep);
}
}
-static void mark_unsync(u64 *spte)
+static void mark_unsync(struct kvm_paging *paging, u64 *spte)
{
struct kvm_mmu_page *sp;
unsigned int index;
@@ -2040,7 +2019,7 @@ static void mark_unsync(u64 *spte)
return;
if (sp->unsync_children++)
return;
- kvm_mmu_mark_parents_unsync(sp);
+ kvm_mmu_mark_parents_unsync(paging, sp);
}
static int nonpaging_sync_page(struct kvm_vcpu *vcpu,
@@ -2093,7 +2072,7 @@ static inline void clear_unsync_child_bit(struct kvm_mmu_page *sp, int idx)
__clear_bit(idx, sp->unsync_child_bitmap);
}
-static int __mmu_unsync_walk(struct kvm_mmu_page *sp,
+static int __mmu_unsync_walk(struct kvm_paging *paging, struct kvm_mmu_page *sp,
struct kvm_mmu_pages *pvec)
{
int i, ret, nr_unsync_leaf = 0;
@@ -2102,7 +2081,7 @@ static int __mmu_unsync_walk(struct kvm_mmu_page *sp,
struct kvm_mmu_page *child;
u64 ent = sp->spt[i];
- if (!is_shadow_present_pte(ent) || is_large_pte(ent)) {
+ if (!is_shadow_present_pte(paging, ent) || is_large_pte(ent)) {
clear_unsync_child_bit(sp, i);
continue;
}
@@ -2113,7 +2092,7 @@ static int __mmu_unsync_walk(struct kvm_mmu_page *sp,
if (mmu_pages_add(pvec, child, i))
return -ENOSPC;
- ret = __mmu_unsync_walk(child, pvec);
+ ret = __mmu_unsync_walk(paging, child, pvec);
if (!ret) {
clear_unsync_child_bit(sp, i);
continue;
@@ -2134,7 +2113,7 @@ static int __mmu_unsync_walk(struct kvm_mmu_page *sp,
#define INVALID_INDEX (-1)
-static int mmu_unsync_walk(struct kvm_mmu_page *sp,
+static int mmu_unsync_walk(struct kvm_paging *paging, struct kvm_mmu_page *sp,
struct kvm_mmu_pages *pvec)
{
pvec->nr = 0;
@@ -2142,7 +2121,7 @@ static int mmu_unsync_walk(struct kvm_mmu_page *sp,
return 0;
mmu_pages_add(pvec, sp, INVALID_INDEX);
- return __mmu_unsync_walk(sp, pvec);
+ return __mmu_unsync_walk(paging, sp, pvec);
}
static void kvm_unlink_unsync_page(struct kvm *kvm, struct kvm_mmu_page *sp)
@@ -2323,7 +2302,7 @@ static void mmu_sync_children(struct kvm_vcpu *vcpu,
LIST_HEAD(invalid_list);
bool flush = false;
- while (mmu_unsync_walk(parent, &pages)) {
+ while (mmu_unsync_walk(vcpu->kvm->arch.paging, parent, &pages)) {
bool protected = false;
for_each_sp(pages, sp, parents, i)
@@ -2521,26 +2500,27 @@ static void link_shadow_page(struct kvm_vcpu *vcpu, u64 *sptep,
BUILD_BUG_ON(VMX_EPT_WRITABLE_MASK != PT_WRITABLE_MASK);
- spte = __pa(sp->spt) | shadow_present_mask | PT_WRITABLE_MASK |
- shadow_user_mask | shadow_x_mask | shadow_me_mask;
+ struct kvm_paging *paging = vcpu->kvm->arch.paging;
+ spte = __pa(sp->spt) | paging->shadow_present_mask | PT_WRITABLE_MASK |
+ paging->shadow_user_mask | paging->shadow_x_mask | paging->shadow_me_mask;
if (sp_ad_disabled(sp))
spte |= shadow_acc_track_value;
else
- spte |= shadow_accessed_mask;
+ spte |= paging->shadow_accessed_mask;
- mmu_spte_set(sptep, spte);
+ mmu_spte_set(paging, sptep, spte);
mmu_page_add_parent_pte(vcpu, sp, sptep);
if (sp->unsync_children || sp->unsync)
- mark_unsync(sptep);
+ mark_unsync(paging, sptep);
}
static void validate_direct_spte(struct kvm_vcpu *vcpu, u64 *sptep,
unsigned direct_access)
{
- if (is_shadow_present_pte(*sptep) && !is_large_pte(*sptep)) {
+ if (is_shadow_present_pte(vcpu->kvm->arch.paging, *sptep) && !is_large_pte(*sptep)) {
struct kvm_mmu_page *child;
/*
@@ -2566,7 +2546,7 @@ static bool mmu_page_zap_pte(struct kvm *kvm, struct kvm_mmu_page *sp,
struct kvm_mmu_page *child;
pte = *spte;
- if (is_shadow_present_pte(pte)) {
+ if (is_shadow_present_pte(kvm->arch.paging, pte)) {
if (is_last_spte(pte, sp->role.level)) {
drop_spte(kvm, spte);
if (is_large_pte(pte))
@@ -2578,7 +2558,7 @@ static bool mmu_page_zap_pte(struct kvm *kvm, struct kvm_mmu_page *sp,
return true;
}
- if (is_mmio_spte(pte))
+ if (is_mmio_spte(kvm->arch.paging, pte))
mmu_spte_clear_no_track(spte);