{
/*
* CR0.WP is incorporated into the MMU role, but only for non-nested,
- * indirect shadow MMUs. If TDP is enabled, the MMU's metadata needs
- * to be updated, e.g. so that emulating guest translations does the
- * right thing, but there's no need to unload the root as CR0.WP
- * doesn't affect SPTEs.
+ * indirect shadow MMUs. If paging is disabled, no updates are needed
+ * as there are no permission bits to emulate. If TDP is enabled, the
+ * MMU's metadata needs to be updated, e.g. so that emulating guest
+ * translations does the right thing, but there's no need to unload the
+ * root as CR0.WP doesn't affect SPTEs.
*/
- if (tdp_enabled && (cr0 ^ old_cr0) == X86_CR0_WP) {
- kvm_init_mmu(vcpu);
- return;
+ if ((cr0 ^ old_cr0) == X86_CR0_WP) {
+ if (!(cr0 & X86_CR0_PG))
+ return;
+
+ if (tdp_enabled) {
+ kvm_init_mmu(vcpu);
+ return;
+ }
}
if ((cr0 ^ old_cr0) & X86_CR0_PG) {