On 10/11/23 10:20, David Woodhouse wrote:
But __kvm_mmu_refresh_passthrough_bits() only refreshes
role.base.cr0_wp and not the other two. Do we need this?
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -5159,6 +5159,8 @@ void __kvm_mmu_refresh_passthrough_bits(struct kvm_vcpu *vcpu,
return;
mmu->cpu_role.base.cr0_wp = cr0_wp;
+ mmu->cpu_role.base.smep_andnot_wp = mmu->cpu_role.ext.cr4_smep && !cr0_wp;
+ mmu->cpu_role.base.smap_andnot_wp = mmu->cpu_role.ext.cr4_smap && !cr0_wp;
reset_guest_paging_metadata(vcpu, mmu);
}
{smep,smap}_andnot_wp only matter for shadow paging. You can remove
them from this function, and instead assign which is not called for
shadow paging anyway, and set them in the root_role in kvm_init_shadow_mmu.
Paolo