On 31/10/2023 23:49, Sean Christopherson wrote:
On Mon, Oct 02, 2023, Paul Durrant wrote:
diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h
index 6f4737d5046a..d49946ee7ae3 100644
--- a/include/linux/kvm_types.h
+++ b/include/linux/kvm_types.h
@@ -64,7 +64,7 @@ struct gfn_to_hva_cache {
struct gfn_to_pfn_cache {
u64 generation;
- gpa_t gpa;
+ u64 addr;
Holy moly, we have unions for exactly this reason.
union {
gpa_t gpa;
unsigned long addr;
};
But that's also weird and silly because it's basically the exact same thing as
"uhva". If "uhva" stores the full address instead of the page-aligned address,
then I don't see a need for unionizing the gpa and uhva.
Ok, I think that'll be more invasive but I'll see how it looks.
kvm_xen_vcpu_get_attr() should darn well explicitly check that the gpc stores
the correct type and not bleed ABI into the gfn_to_pfn_cache implementation.
I guess if we leave gpa alone and make it INVALID_GPA for caches
initialized using an HVA then that can be checked. Is that what you mean
here?
If there's a true need for a union, the helpers should WARN.
+unsigned long kvm_gpc_hva(struct gfn_to_pfn_cache *gpc)
+{
+ return !gpc->addr_is_gpa ? gpc->addr : 0;
'0' is a perfectly valid address. Yeah, practically speaking '0' can't be used
these days, but we already have KVM_HVA_ERR_BAD. If y'all want to use the for the
Xen ABI, then so be it. But the common helpers need to use a sane value.
Ok.
Paul