Re: [PATCH v2 00/11] KVM: Support guest MAXPHYADDR < host MAXPHYADDR
From: Paolo Bonzini
Date: Mon Jun 22 2020 - 18:20:36 EST
On 22/06/20 21:14, Tom Lendacky wrote:
>>> I guess I'm trying to understand why RSVD has to be reported to the guest
>>> on a #PF (vs an NPF) when there's no guarantee that it can receive that
>>> error code today even when guest MAXPHYADDR == host MAXPHYADDR. That would
>>> eliminate the need to trap #PF.
>>
>> That's an interesting observation! But do processors exist where either:
>>
>> 1) RSVD doesn't win over all other bits, assuming no race conditions
>
> There may not be any today, but, present bit aside (which is always
> checked), there is no architectural statement that says every error
> condition has to be checked and reported in a #PF error code. So software
> can't rely on RSVD being present when there are other errors present.
> That's why I'm saying I don't think trapping #PF just to check and report
> RSVD should be done.
Fair enough---if I could get rid of the #PF case I would only be happy.
But I'm worried about guests being upset if they see non-RSVD page
faults for a page table entry that has one or more reserved bits set.
>> 2) A/D bits can be clobbered in a page table entry that has reserved
>> bits set?
>
> There is nothing we can do about this one. The APM documents this when
> using nested page tables.
Understood.
> If the guest is using the same MAXPHYADDR as the
> host, then I'm pretty sure this doesn't happen, correct? So it's only when
> the guest is using something less than the host MAXPHYADDR that this occurs.
> I'm not arguing against injecting a #PF with the RSVD on an NPF where it's
> detected that bits are set above the guest MAXPHYADDR, just the #PF trapping.
Got it. My question is: is there an architectural guarantee that the
dirty bit is not set if the instruction raises a page fault? (And what
about the accessed bit?).
If so, the NPF behavior makes it impossible to emulate lower MAXPHYADDR
values from the NPF vmexit handler. It would be incorrect to inject a
#PF with the RSVD error code from the NPF handler, because the guest
would not expect the dirty bits to be set in the page table entry.
Even if there's no such guarantee, I would be reluctant to break it
because software could well be expecting it.
Paolo
> Thanks,
> Tom
>
>>
>> Running the x86/access.flat testcase from kvm-unit-tests on bare metal
>> suggests that all existing processors do neither of the above.
>>
>> In particular, the second would be a showstopper on AMD.
>>
>> Paolo
>>
>