Hi Sean,
On 7/20/21 1:02 PM, Sean Christopherson wrote:
IMO, the CPU behavior is a bug, even if the behavior is working as intended for
the microarchitecture. I.e. this should be treated as an erratum.
I agreed with your comment that it should be treated as an erratum. I
now have agreement from the hardware team to publish this as an erratum
with explanation and recommendation. This will certainly help in
documenting on "why" we are making the page split.
...
- apic->regs = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT);
+ if (kvm_x86_ops.alloc_apic_backing_page)
+ apic->regs = kvm_x86_ops.alloc_apic_backing_page(vcpu);
This can be a static_call().
Noted.
This isn't "finding" anything, it's identifying which of the two pages is
_guaranteed_ to be unaligned. The whole function needs a much bigger comment to
explain what's going on.
Let me add more comment to clarify it.
+ pfn = page_to_pfn(p);
+ if (IS_ALIGNED(__pfn_to_phys(pfn), PMD_SIZE)) {
+ pfn++;
+ __free_page(p);
+ } else {
+ __free_page(pfn_to_page(pfn + 1));
+ }
+
+ return pfn_to_page(pfn);
+}
thanks