[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5 4/6] x86: extend do_mmu_update() to support returning the old PTE value


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 13 Nov 2026 08:48:51 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: roger@xxxxxxxxxxxxxx, teddy.astie@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • Delivery-date: Fri, 13 Nov 2026 07:49:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 12.11.2026 17:57, Andrew Cooper wrote:
> On 12/11/2026 2:06 pm, Jan Beulich wrote:
>> On 12.11.2026 11:00, Kevin Lampis wrote:
>>> --- a/xen/arch/x86/mm.c
>>> +++ b/xen/arch/x86/mm.c
>>> @@ -4123,6 +4123,7 @@ long do_mmu_update(
>>>          case MMU_NORMAL_PT_UPDATE:
>>>          case MMU_PT_UPDATE_PRESERVE_AD:
>>>          case MMU_PT_UPDATE_NO_TRANSLATE:
>>> +        case MMU_PT_UPDATE_SWAP:
>>>          {
>>>              p2m_type_t p2mt;
>>>  
>>> @@ -4184,37 +4185,79 @@ long do_mmu_update(
>>>                       update_flags = PTE_UPDATE_PRESERVE_AD;
>>>                  else if ( cmd == MMU_PT_UPDATE_NO_TRANSLATE )
>>>                       update_flags = PTE_UPDATE_NO_TRANSLATE;
>>> +                else if ( cmd == MMU_PT_UPDATE_SWAP )
>>> +                     update_flags = PTE_UPDATE_SWAP;
>>>  
>>>                  switch ( page->u.inuse.type_info & PGT_type_mask )
>>>                  {
>>>                  case PGT_l1_page_table:
>>> +                {
>>> +                    l1_pgentry_t ol1e = {};
>>>                      rc = mod_l1_entry(va, l1e_from_intpte(req.val), mfn,
>>> -                                      update_flags, v, pg_owner, NULL);
>>> -                    break;
>>> +                                      update_flags, v, pg_owner, &ol1e);
>>>  
>>> +                    if ( !rc && cmd == MMU_PT_UPDATE_SWAP )
>>> +                    {
>>> +                        req.val = ol1e.l1;
>> If you didn't open-code l1e_get_intpte() here, it would become more obvious
>> that the INTPTE -> L<n>E done in mod_l<n>_entry() is simply being reversed
>> here. If ol1e was of type intpte_t, doing the update in update_intpte() (and
>> not UPDATE_ENTRY()) would become feasible. Since intpte_t is a mere alias of
>> uint64_t, passing &req.val into mod_l<n>_entry() directly would then also
>> become possible. Less redundancy would be the result.
> 
> Perhaps, but then it would be odd to have mod_l1_entry() require nl1e in
> a typesafe way while passing back ol1e as type unsafe.

If the sole purpose of those parameters is to obtain a type-unsafe intpte_t
(for use here), I'm not convinced this oddity would be overly problematic.

> And there's still the problem of reading ol1e.  We could change the
> indirection of ol?e, but that's invasive both at the source and binary
> level.

I said "passing &req.val" though - no change in indirection.

>  While capable of being inlined, mod_l?_entry() are not due to
> their size.

Yes for mod_l1_entry(), but not for the other three afaics (debug build
with gcc16).

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.