Re: [RFC PATCH v2 3/6] KVM: x86/mmu: Pass round full 64-bit error code for the KVM page fault

From: Isaku Yamahata
Date: Thu Jun 22 2023 - 22:54:37 EST


On Thu, Jun 22, 2023 at 11:28:22PM +0000,
"Huang, Kai" <kai.huang@xxxxxxxxx> wrote:

> On Thu, 2023-06-22 at 16:16 -0700, Yamahata, Isaku wrote:
> > The upper 32 bits of error code are discarded at kvm_mmu_page_fault()
> > by lower_32_bits().  Now it's passed down as full 64 bits.
> > Because only FNAME(page_fault) depends on it, move lower_32_bits() into
> > FNAME(page_fault).
>
> I haven't looked into the code yet, but the last sentence around
> FNAME(page_fault) doesn't make a lot sense IIUC?
>
> For instance, we can have a shadow EPT table when EPT is enabled in L0 and
> exposed to L1. If we want to pass 64-bit error code to the handler, how can
> FRAME(page_fault)() depend on the lower 32-bit value?

Probably "depend" was too strong. In short, I wanted to not change the value
passed down as error_code from FNAME(page_fault).

FNAME(page_fault) calls helper function to walk page tables. Some check
PFERR_IMPLICIT_ACCESS_MASK(48 bit). If we don't mask lower_32_bits(), it can
pass accidentally the bit. Maybe we can audit the code carefully to check if
IMPLICIT_ACCESS bit doesn't matter or fix it. But I don't want to do it with
this patch series.
--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>