[PATCH v5 01/15] KVM: arm64: pgtables: Change write bit from S2AP_W to DBM

Tian Zheng zhengtian10 at huawei.com
Thu Oct 29 00:08:27 PDT 2026



On 10/26/2026 11:02 PM, Leonardo Bras wrote:
> On Wed, Sep 30, 2026 at 10:44:26AM +0800, Tian Zheng wrote:
>> On 9/30/2026 8:25 AM, Oliver Upton wrote:
>>> Hmm... I'd actually like to see this structured where the "write" bit
>>> could either be S2AP_W or DBM depending on if the system supports
>>> FEAT_HAFDBS. Look at how HVHE is handled for selecting the right AP
>>> encoding for the hyp stage-1 page tables.
>>>
>>
>> Hi Oliver,
>>
>> Thanks for the suggestion. I missed the case where FEAT_HAFDBS is not
>> supported. Systems without the feature should keep the original
>> encoding, with S2AP[1] as the write permission bit. I'll follow the HVHE
>> pattern to select between the two encodings in the next version.
>>
>> Thanks!
>> Tian
>>
> 
> Hi Oliver, Tian,
> 
> After some digging, I think it would be better if we kept using S2AP[1] as
> a writable bit, while DBM can be treated as "Can promote a non-writable
> page to writable if HAFDBS=on".
> 
> I know it's not that intuitive, as the Arm ARM even introduced the concept
> of Writable-clean an Writable-dirty, but I think it will be the best way of
> referring to what was intended of the bit.
> 
> I wrote down what I mean by that:
> https://lore.kernel.org/all/20261026144413.441566-1-leo.bras@arm.com/
> 
> tl;dr:
> - DBM + S2AP[1] is set on writable entries (KVM_PGTABLE_PROT_W)
> - Writable detection is made only on S2AP[1], so no changes
> - Wrprotect sets S2AP[1]=0 from the PTE, and also DBM=0 if it's a block
> 
> On dirty-tracking:
> - If HAFDBS=0 : no functional change, DBM bit there but unused
> - If HDBSS=1
>    - Pages: writable-clean promoted to writable-dirty on write, HDBSS does
>      the tracking
>    - Blocks: faults on write, splits in pages, pages get DBM=1.
>    	(argh, I think we need a PROT_DBM for that)
> 
> Does that make sense?
> 
> Thanks!
> Leo

Hi Leo,

Got it. I'll wait for the conclusion of your discussion with Oliver
before proceeding.

Thanks,
Tian




More information about the linux-arm-kernel mailing list