From: Catalin Marinas <catalin.marinas@arm.com>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
kvmarm@lists.linux.dev, kvm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, maz@kernel.org,
will@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com,
yuzenghui@huawei.com, zhukeqian1@huawei.com,
jonathan.cameron@huawei.com, linuxarm@huawei.com
Subject: Re: [RFC PATCH v2 6/8] KVM: arm64: Only write protect selected PTE
Date: Tue, 26 Sep 2023 17:10:05 +0100 [thread overview]
Message-ID: <ZRMCXcf+RoHBEpLS@arm.com> (raw)
In-Reply-To: <ZRL/izqkzWy/lKXM@arm.com>
On Tue, Sep 26, 2023 at 04:58:03PM +0100, Catalin Marinas wrote:
> On Fri, Sep 22, 2023 at 04:59:08PM +0000, Oliver Upton wrote:
> > On Fri, Sep 22, 2023 at 05:00:40PM +0100, Catalin Marinas wrote:
> > > On Fri, Aug 25, 2023 at 10:35:26AM +0100, Shameer Kolothum wrote:
> > > > From: Keqian Zhu <zhukeqian1@huawei.com>
> > > >
> > > > This function write protects all PTEs between the ffs and fls of mask.
> > > > There may be unset bits between this range. It works well under pure
> > > > software dirty log, as software dirty log is not working during this
> > > > process.
> > > >
> > > > But it will unexpectly clear dirty status of PTE when hardware dirty
> > > > log is enabled. So change it to only write protect selected PTE.
> > >
> > > Ah, I did wonder about losing the dirty status. The equivalent to S1
> > > would be for kvm_pgtable_stage2_wrprotect() to set a software dirty bit.
> > >
> > > I'm only superficially familiar with how KVM does dirty tracking for
> > > live migration. Does it need to first write-protect the pages and
> > > disable DBM? Is DBM re-enabled later? Or does stage2_wp_range() with
> > > your patches leave the DBM on? If the latter, the 'wp' aspect is a bit
> > > confusing since DBM basically means writeable (and maybe clean). So
> > > better to have something like stage2_clean_range().
> >
> > KVM has never enabled DBM and we solely rely on write-protection faults
> > for dirty tracking. IOW, we do not have a writable-clean state for
> > stage-2 PTEs (yet).
>
> When I did the stage 2 AF support I left out DBM as it was unlikely
> to be of any use in the real world. Now with dirty tracking for
> migration, we may have a better use for this feature.
>
> What I find confusing with these patches is that stage2_wp_range() is
> supposed to make a stage 2 pte read-only, as the name implies. However,
> if the pte was writeable, it leaves it writeable, clean with DBM
> enabled. Doesn't the change to kvm_pgtable_stage2_wrprotect() in patch 4
> break other uses of stage2_wp_range()? E.g. kvm_mmu_wp_memory_region()?
Ah, that's also used for dirty tracking, so maybe it's ok.
AFAICT KVM doesn't do any form of stage 2 pte change from writeable to
read-only other than dirty tracking (all other cases triggered via MMU
notifier end up unmapping at stage 2).
> Unless I misunderstood, I'd rather change
> kvm_arch_mmu_enable_log_dirty_pt_masked() to call a new function,
> stage2_clean_range(), which clears S2AP[1] together with setting DBM if
> previously writeable. But we should not confuse this with
> write-protecting or change the write-protecting functions to mark a pte
> writeable+clean.
I think it's still good to rename stage2_wp_range() to make it clear
that it's about clean ptes rather than read-only.
--
Catalin
next prev parent reply other threads:[~2023-09-26 16:10 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-25 9:35 [RFC PATCH v2 0/8] KVM: arm64: Implement SW/HW combined dirty log Shameer Kolothum
2023-08-25 9:35 ` [RFC PATCH v2 1/8] arm64: cpufeature: Add API to report system support of HWDBM Shameer Kolothum
2023-08-25 9:35 ` [RFC PATCH v2 2/8] KVM: arm64: Add KVM_PGTABLE_WALK_HW_DBM for HW DBM support Shameer Kolothum
2023-09-15 22:05 ` Oliver Upton
2023-09-18 9:52 ` Shameerali Kolothum Thodi
2023-08-25 9:35 ` [RFC PATCH v2 3/8] KVM: arm64: Add some HW_DBM related pgtable interfaces Shameer Kolothum
2023-09-15 22:22 ` Oliver Upton
2023-09-18 9:53 ` Shameerali Kolothum Thodi
2023-09-22 15:24 ` Catalin Marinas
2023-09-22 17:49 ` Oliver Upton
2023-09-25 8:04 ` Shameerali Kolothum Thodi
2023-09-26 15:20 ` Catalin Marinas
2023-09-26 15:52 ` Shameerali Kolothum Thodi
2023-09-26 16:37 ` Catalin Marinas
2023-08-25 9:35 ` [RFC PATCH v2 4/8] KVM: arm64: Set DBM for previously writeable pages Shameer Kolothum
2023-09-15 22:54 ` Oliver Upton
2023-09-18 9:54 ` Shameerali Kolothum Thodi
2023-09-22 15:40 ` Catalin Marinas
2023-09-25 8:04 ` Shameerali Kolothum Thodi
2023-08-25 9:35 ` [RFC PATCH v2 5/8] KVM: arm64: Add some HW_DBM related mmu interfaces Shameer Kolothum
2023-08-25 9:35 ` [RFC PATCH v2 6/8] KVM: arm64: Only write protect selected PTE Shameer Kolothum
2023-09-22 16:00 ` Catalin Marinas
2023-09-22 16:59 ` Oliver Upton
2023-09-26 15:58 ` Catalin Marinas
2023-09-26 16:10 ` Catalin Marinas [this message]
2023-08-25 9:35 ` [RFC PATCH v2 7/8] KVM: arm64: Add KVM_CAP_ARM_HW_DBM Shameer Kolothum
2023-08-25 9:35 ` [RFC PATCH v2 8/8] KVM: arm64: Start up SW/HW combined dirty log Shameer Kolothum
2023-09-13 17:30 ` [RFC PATCH v2 0/8] KVM: arm64: Implement " Oliver Upton
2023-09-14 9:47 ` Shameerali Kolothum Thodi
2023-09-15 0:36 ` Oliver Upton
2023-09-18 9:55 ` Shameerali Kolothum Thodi
2023-09-20 21:12 ` Oliver Upton
2023-10-12 7:51 ` Shameerali Kolothum Thodi
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=ZRMCXcf+RoHBEpLS@arm.com \
--to=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
--cc=zhukeqian1@huawei.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