From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>, Kevin Lampis <kevin.lampis@citrix.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Teddy Astie" <teddy.astie@vates.tech>,
"Roger Pau Monné" <roger@xenproject.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH 1/4] x86: extend update_intpte() to support atomic get-and-update
Date: Thu, 13 Aug 2026 13:22:25 +0100 [thread overview]
Message-ID: <4d9931dd-9369-4b87-9064-aa484ef5a570@citrix.com> (raw)
In-Reply-To: <6166e2ac-3b8b-4702-ac15-357d1c1a4c56@suse.com>
On 13/08/2026 1:01 pm, Jan Beulich wrote:
> On 27.07.2026 17:06, Kevin Lampis wrote:
>> --- a/xen/arch/x86/pv/mm.h
>> +++ b/xen/arch/x86/pv/mm.h
>> @@ -66,13 +66,14 @@ static inline intpte_t paging_cmpxchg_guest_entry(
>> * How to write an entry to the guest pagetables.
>> * Returns false for failure (pointer not valid), true for success.
>> */
>> -static inline bool update_intpte(intpte_t *p, intpte_t old, intpte_t new,
>> - mfn_t mfn, struct vcpu *v, bool preserve_ad)
>> +static inline bool update_intpte(intpte_t *p, intpte_t *old, intpte_t new,
>> + mfn_t mfn, struct vcpu *v, bool preserve_ad,
>> + bool use_cmpxchg)
> No 2nd boolean parameter, please. (use_cmpxchg also doesn't look to be an
> overly good name; "swap" maybe?)
This is half of a patch that's been in the XenServer queue for decades
for other purposes. (TLB-flush avoidance based on A/D being clear, for
which you must use some form of atomic, but it relies on dom0 being
trusted not to clear the A/D bits in isolation.)
I agree that we don't want more booleans. Your flags proposal looks
like the right way to go.
XenServer's pre-existing usecase could get away with XCHG. I think it
was wired into CMPXCHG simply because that already existed. This new
usecase probably wants to be XCHG too. I don't think "please preserve
AD while swapping X for Y and also tell the the old value you found"
makes much sense at the hypercall level at least.
Furthermore, now that the return value is unused, we could return the
actual old value to anyone who cares, which avoids turning the input
"old" value into a pointer.
~Andrew
P.S. looking at the preserve_ad logic, I think it ought to be tightened
to only permit A/D becoming set, because that's the only direction that
hardware will move the bits. A/D becoming clear is a race against
something which is not the pagewalker.
next prev parent reply other threads:[~2026-08-13 12:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 15:06 [PATCH 0/4] unmap_page_range optimisation Kevin Lampis
2026-07-27 15:06 ` [PATCH 1/4] x86: extend update_intpte() to support atomic get-and-update Kevin Lampis
2026-08-13 12:01 ` Jan Beulich
2026-08-13 12:22 ` Andrew Cooper [this message]
2026-07-27 15:06 ` [PATCH 2/4] x86: extend mod_l1_entry() to optionally return the old PTE value Kevin Lampis
2026-07-27 15:06 ` [PATCH 3/4] x86: extend do_mmu_update() to support returning " Kevin Lampis
2026-08-13 12:51 ` Jan Beulich
2026-07-27 15:06 ` [PATCH 4/4] x86: add new pte_get_and_clear hypercall Kevin Lampis
2026-08-04 10:30 ` Teddy Astie
2026-08-13 12:55 ` Jan Beulich
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=4d9931dd-9369-4b87-9064-aa484ef5a570@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=kevin.lampis@citrix.com \
--cc=roger@xenproject.org \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.