@@ -2438,22 +2438,28 @@ static void prepare_vmcs02_rare(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
2438
2438
2439
2439
/*
2440
2440
* Whether page-faults are trapped is determined by a combination of
2441
- * 3 settings: PFEC_MASK, PFEC_MATCH and EXCEPTION_BITMAP.PF.
2442
- * If enable_ept, L0 doesn't care about page faults and we should
2443
- * set all of these to L1's desires. However, if !enable_ept, L0 does
2444
- * care about (at least some) page faults, and because it is not easy
2445
- * (if at all possible?) to merge L0 and L1's desires, we simply ask
2446
- * to exit on each and every L2 page fault. This is done by setting
2447
- * MASK=MATCH=0 and (see below) EB.PF=1.
2441
+ * 3 settings: PFEC_MASK, PFEC_MATCH and EXCEPTION_BITMAP.PF. If L0
2442
+ * doesn't care about page faults then we should set all of these to
2443
+ * L1's desires. However, if L0 does care about (some) page faults, it
2444
+ * is not easy (if at all possible?) to merge L0 and L1's desires, we
2445
+ * simply ask to exit on each and every L2 page fault. This is done by
2446
+ * setting MASK=MATCH=0 and (see below) EB.PF=1.
2448
2447
* Note that below we don't need special code to set EB.PF beyond the
2449
2448
* "or"ing of the EB of vmcs01 and vmcs12, because when enable_ept,
2450
2449
* vmcs01's EB.PF is 0 so the "or" will take vmcs12's value, and when
2451
2450
* !enable_ept, EB.PF is 1, so the "or" will always be 1.
2452
2451
*/
2453
- vmcs_write32 (PAGE_FAULT_ERROR_CODE_MASK ,
2454
- enable_ept ? vmcs12 -> page_fault_error_code_mask : 0 );
2455
- vmcs_write32 (PAGE_FAULT_ERROR_CODE_MATCH ,
2456
- enable_ept ? vmcs12 -> page_fault_error_code_match : 0 );
2452
+ if (vmx_need_pf_intercept (& vmx -> vcpu )) {
2453
+ /*
2454
+ * TODO: if both L0 and L1 need the same MASK and MATCH,
2455
+ * go ahead and use it?
2456
+ */
2457
+ vmcs_write32 (PAGE_FAULT_ERROR_CODE_MASK , 0 );
2458
+ vmcs_write32 (PAGE_FAULT_ERROR_CODE_MATCH , 0 );
2459
+ } else {
2460
+ vmcs_write32 (PAGE_FAULT_ERROR_CODE_MASK , vmcs12 -> page_fault_error_code_mask );
2461
+ vmcs_write32 (PAGE_FAULT_ERROR_CODE_MATCH , vmcs12 -> page_fault_error_code_match );
2462
+ }
2457
2463
2458
2464
if (cpu_has_vmx_apicv ()) {
2459
2465
vmcs_write64 (EOI_EXIT_BITMAP0 , vmcs12 -> eoi_exit_bitmap0 );
0 commit comments