Re: [PATCH RFC v3 87/88] QUESTION: KVM: guest_memfd: Disallow private mappings of shared-only PFNs

From: Aneesh Kumar K . V

Date: Mon Nov 09 2026 - 00:37:30 EST


Ackerley Tng via B4 Relay <devnull+ackerleytng.google.com@xxxxxxxxxx>
writes:

> From: Ackerley Tng <ackerleytng@xxxxxxxxxx>
>
> Host kernel drivers directly write to the PCI MSI-X vector table to
> program and mask interrupts. On confidential computing platforms, allowing
> hardware protection tables (such as RMP, Secure-EPT, or GPT) to mark MSI-X
> pages private causes subsequent host kernel interrupt updates to trigger
> fatal hardware protection faults.
>
> I see 2 options here:
>
> 1. Prevent it at conversion time, and require INIT_SHARED
> 2. Let guest_memfd track all conversions to private as per normal, but
> block setting the MSI-X range as private at the platform level by
> blocking platform config for SNP, ARM CCA at fault time, and by blocking
> faults for TDX.
>
> Implement (2) partially by introducing a PFN attribute bit indicating that
> a physical frame cannot be mapped or populated as private, reporting that
> attribute from VFIO PCI whenever a BAR page overlaps the MSI-X vector
> table.
>

For the TDISP flow, we could initially treat all MMIO BARs as shared.
The guest could then request that a specific BAR range be trusted
through an mmio_validate request. The validation operation could call
set_memory_attribute() to convert only the guest-requested range. This
would allow the guest to control whether the MSI-X table and PBA ranges
are trusted.

Before reporting that the mmio_validate request succeeded, we would also
need to ensure that the BAR range had been marked private and mapped
into the guest VM.This is required for the device to transition to the
RUN state. This also means we should not get a gmem fault on private
device PFN. In my series, I enforce this in the architecture fault
handler.

The host must also be prevented from modifying the BAR attributes
afterward, as that would cause an attested device to transition from
TDISP RUN to the error state. An earlier discussion also considered
whether the guest driver should be allowed to manage BME/MSE. VFIO
currently emulates these, and the conclusion was that the VMM must not
pass it through. Once the device is in the TDISP RUN state, the guest
TSM manages the power state and BME/MSE changes.

-aneesh