Re: [RFC PATCH v5 033/104] KVM: x86: Add infrastructure for stolen GPA bits

From: Paolo Bonzini
Date: Tue Apr 05 2022 - 21:34:32 EST


On 4/1/22 04:34, Isaku Yamahata wrote:
Sure, this patch heavily changed from the original patch Now. One suggestion
is that private/shared is characteristic to kvm page fault, not gpa/gfn.
It's TDX specific.

- Add a helper function to check if KVM MMU is TD or VM. Right now
kvm_gfn_stolen_mask() is used. Probably kvm_mmu_has_private_bit().
(any better name?)

I think use of kvm_gfn_stolen_mask() should be minimized anyway. I would rename it to to kvm_{gfn,gpa}_private_mask and not return bool.

- Let's keep address conversion functions: address => unalias/shared/private

unalias is the same as private. It doesn't seem to have a lot of uses. I would just inline "x & ~gfn_private_mask", or "x & ~kvm_gfn_private_mask(kvm)"; or the same with gpa of course.

The shared and private conversion functions should remain.

- Add struct kvm_page_fault.is_private
see how kvm_is_private_{gpa, gfn}() can be removed (or reduced).

Agreed.

Paolo