From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Ackerley Tng <ackerleytng@google.com>,
"David Hildenbrand (Arm)" <david@kernel.org>,
"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
KVM <kvm@vger.kernel.org>
Cc: amit@infradead.org, aneeshkumar.kizhakeveetil@arm.com,
ashish.kalra@amd.com, dwmw2@infradead.org, eberman@quicinc.com,
fvdl@google.com, gshan@redhat.com, jackmanb@google.com,
jackyli@google.com, jthoughton@google.com, kalyazin@amazon.com,
kas@kernel.org, kevinloughlin@google.com, liruxin@google.com,
michael.day@amd.com, michael.roth@amd.com,
mike.rapoport@gmail.com, mvaralar@redhat.com,
pankaj.gupta@amd.com, papaluri@amd.com, patrick.roy@linux.dev,
Peter Xu <peterx@redhat.com>,
pheragu@quicinc.com, pkondeti@qti.qualcomm.com, prty@google.com,
psalian@google.com, qinkun@google.com, seanjc@google.com,
shan.gavin@gmail.com, shivankg@amd.com, sidtelang@google.com,
tabba@google.com, tatashin@google.com, vannapurve@google.com,
vbabka@suse.com, wyihan@google.com
Subject: Re: [Invitation] bi-weekly guest_memfd upstream call on 2026-09-17
Date: Sun, 20 Sep 2026 12:22:37 +0100 [thread overview]
Message-ID: <629e51dc-75ad-4727-b584-293a4081e7c9@arm.com> (raw)
In-Reply-To: <CAEvNRgFAL6qtSiJpQuga_TxWBr2pK=9LoiON+ZARMp0xFA8rPA@mail.gmail.com>
Hi Ackerley,
On 18/09/2026 17:21, Ackerley Tng wrote:
> Suzuki K Poulose <suzuki.poulose@arm.com> writes:
>
>>
>> [...snip...]
>>
>>>
>>> RMI_RTT_SET_RIPAS() is actually saying "host permits the conversion from
>>> base to top", it's not telling the RMM what to set it to, this is also
>>> different from SNP.
>>
>> As mentioned above, host knows the requested "RIPAS" from VCPU exit.
>> RMM knows the "RIPAS" from the VCPU object.
>>
>> Now: Privates vs Shared is translated to RIPAS_RAM vs RIPAS_EMPTY
>> in the CCA (well, roughly)
>>
>> RIPAS_RAM implies, the GPA can be mapped into the private address
>> space of the Realm and it is integrity protected. Host cannot
>> replace the GPA with another content (it can unmap and DESTROY
>> the GPA mapping. But unless the Realm consents to replace the
>> GPA, again via SET_RIPAS request).
>>
>>
>>>
>>> Interestingly RMI_RTT_SET_RIPAS() also errors out if the current
>>> shared/private state is different from the one tracked in the vCPU
>>> object in the RMM? Did I get that right? I'm looking at the base_align
>>
>> Correct.
>>
>>> Failure condition, where it says ripas_pre != rec.ripas_value.
>>
>> Please note that, in such cases, RMM needs a deeper page table level
>> and the error is RMI_ERROR_RTT, indicating to the host that:
>> Look I need a deeper level table to satisfy the request.
>>
>> e.g., base = 4K, but walk.level = 2, and ripas_pre="private"
>>
>> i.e. the requested base is mapped at L2 as block with "private" ripas.
>> If you want to convert the "base" to shared, it needs L3 table. The host
>> would follow up with RMI_RTT_CREATE and then retry the request.
>>
>>
>>> If two vCPUs race to convert the same range to shared, both vCPUs would
>>> have rec.ripas_value = private. The first conversion would be fine, but
>>
>> nit: rec.ripas_value = empty (shared)
>>
>
> Sorry that was a bad mixture of pseudocode and constants on my part.
>
>>> the second one woul see ripas_pre = shared but rec.ripas_value = private
>>> and would definitely get an error?
>>
>> rec.ripas_value == empty (shared) as per the guest request. And the RMM
>> will find the state is already "shared" and would confirm the success
>> back to host.
>>
>
> Oh yes, my bad.
>
> base_align says (rephrased)
>
> if (!AddrIsRttLevelAligned(base, walk.level) &&
> ripas_pre != rec.ripas_value)
> return RMI_ERROR_RTT
>
> Is the alignment check to do with another vCPU splitting the record in
> the table?
Nope. The Host doesn't keep track of the levels at which the S2 mapping
is created nor does it track the "RIPAS" of the regions. That check is
making sure that we don't unnecessarily break down "block" mappings.
e.g., Before boot, the host might set RIPAS for certain regions (e.g.,
populated contents.) The Guest (firmware) could at boot then convert
all of the "DRAM" regions to RIPAS_RAM without checking what was
populated (this is anyway available in the Measurement). Thus a
conversion request may encounter regions that are already in the
requested state (RIPAS_RAM in the above case). And thus RMM
can report SUCCESS if it is already in the state.
Otherwise, we now need to split the block mapping to a deeper level
to apply the "state" change to a subset of the "block" range. This
is why we return RMI_ERROR_RTT when the requested RIPAS doesn't
match the "ripas_pre"
Does that help ? Remember that we don't have the concept of "ACCEPT"
in CCA.
Cheers
Suzuki
>
> Why compare ripas_pre and rec.ripas_value when the level is not aligned?
>
>>
>>>
>>> And there's no "accept" step in the guest after conversions, which makes
>>> it different from TDX and SNP.
>>
>> Correct, the guest "permitted" the GPA to be made private with unknown
>> contents anyway. RMM guarantees that the "data" is scrubbed when the
>> GPA is made valid. The advantage with this approach is, once the
>> Guest sets the RIPAS_RAM, the host can lazily donate pages at
>> fault time
>>
>>>
>>> Difficulty in using current gmem hooks that SNP uses:
>>>
>>> * .gmem_make_shared() called from conversions doesn't have the vCPU
>>> context, finding the right vCPU context is expensive.
>>> * Sean, don't we already iterate vCPUs to find VMSA pages to kick
>>> the right vCPUs?
>>
>> We could keep a list of VCPUs with pending set-ripas request for e.g.
>> Or before the vCPU enter, we check the state of the region and
>> do the sync with RMM.
>>
>>> * .gmem_make_private at fault time is too late
>>> * At the next vCPU enter, the RMM would already read it's state to
>>> report success/failure, and there's no fault in-between for the
>>> .gmem_make_private to happen.
>>>
>>> At the call Sean suggested mirroring the RMM's tracking in KVM, but that
>>> sounds quite arch-specific and it's like doing arch-specific validation
>>> within KVM.
>>
>> Suzuki
>>
>>
>>>
>>> p.s. Fuad, for pKVM you also mentioned that you'll need to check if the
>>> guest had requested for conversion first? This might be the same/similar
>>> problem.
next prev parent reply other threads:[~2026-09-20 11:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 15:11 [Invitation] bi-weekly guest_memfd upstream call on 2026-09-16 David Hildenbrand (Arm)
2026-09-16 15:16 ` [Invitation] bi-weekly guest_memfd upstream call on 2026-09-17 David Hildenbrand (Arm)
2026-09-17 18:41 ` Ackerley Tng
2026-09-17 19:30 ` Sean Christopherson
2026-09-18 16:56 ` Ackerley Tng
2026-09-18 9:28 ` Suzuki K Poulose
2026-09-18 16:21 ` Ackerley Tng
2026-09-20 11:22 ` Suzuki K Poulose [this message]
2026-09-25 8:40 ` Fuad Tabba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=629e51dc-75ad-4727-b584-293a4081e7c9@arm.com \
--to=suzuki.poulose@arm.com \
--cc=ackerleytng@google.com \
--cc=amit@infradead.org \
--cc=aneeshkumar.kizhakeveetil@arm.com \
--cc=ashish.kalra@amd.com \
--cc=david@kernel.org \
--cc=dwmw2@infradead.org \
--cc=eberman@quicinc.com \
--cc=fvdl@google.com \
--cc=gshan@redhat.com \
--cc=jackmanb@google.com \
--cc=jackyli@google.com \
--cc=jthoughton@google.com \
--cc=kalyazin@amazon.com \
--cc=kas@kernel.org \
--cc=kevinloughlin@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-mm@kvack.org \
--cc=liruxin@google.com \
--cc=michael.day@amd.com \
--cc=michael.roth@amd.com \
--cc=mike.rapoport@gmail.com \
--cc=mvaralar@redhat.com \
--cc=pankaj.gupta@amd.com \
--cc=papaluri@amd.com \
--cc=patrick.roy@linux.dev \
--cc=peterx@redhat.com \
--cc=pheragu@quicinc.com \
--cc=pkondeti@qti.qualcomm.com \
--cc=prty@google.com \
--cc=psalian@google.com \
--cc=qinkun@google.com \
--cc=seanjc@google.com \
--cc=shan.gavin@gmail.com \
--cc=shivankg@amd.com \
--cc=sidtelang@google.com \
--cc=tabba@google.com \
--cc=tatashin@google.com \
--cc=vannapurve@google.com \
--cc=vbabka@suse.com \
--cc=wyihan@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox