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

Re: [PATCH for-4.22(?) v2] gnttab: simplify (really: drop) gnttab_set_frame_gfn()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Mon, 18 May 2026 20:00:09 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s3KZXaEvl/iWr8NiuIWntoPtBXfNjIoGDvr8DD4eLN4=; b=KTlWmN7VHEWk8/dlP6RzB91TP4AHlil7QuulZ6lEd6Kfi5sqrkB2nNiK903nyOeQgX97kN6RTHxTOPpx/SDy5kZtJ73jYktJbsTs3FvXU52xS76ImRZigfHkfaIrvk1T1vW57R9b5tZfqYQaO9/0dbTmJqUNzry7B+PQ/PJ/+eh0egEHMHeiDm7s1CLHip7GTJF9rJ5ayOlNpMf+4pKimlD3Q/mS1e9HO5cAonghdn7aaMvF+tB2kwYhvMms3b0pOHsZGtDeZ0/xCG+VzLWw/W+MEiQvgemYNXKblcphM7LJvsVymJPxMX+S5xCWhNCsGVamjJIQu2fJNsYIPkzVqA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VjaDPc1IDKbNvn7Lf5dBLOyA5RwRDqB9h4NejAp3IHd98is7Im75WDRRLxnaS+KcY5GWf64Q9zTHsv0TNMrfFT581vC8OA8nj8w58DYPHV8DqNhQxEZnZA/4M5+SCYFLr9byj9pUvHtMPIjkohjyN7fCAOuOlG6dU8X0fwTSLDniPoWHvM6PV/HRN4dUhrxuHFgJVFS++4zydR5s/5FO9LnDBejZnUZzSLO+5wxzFqdmhJHOP1nc6lCxZKHRSeSq3EU+xNd211V24FI/VYjPInNaJrcMjC/zvqOiFiBwdsKu0s5QsFj12YklNcaYuQKcTwFDwOxuflsccPKx8ueAxg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Rafal Wojtczuk <rafal.wojtczuk@xxxxxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • Delivery-date: Mon, 18 May 2026 18:00:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 12-May-26 16:46, Jan Beulich wrote:
> It's not really doing anything for valid GFNs, which renders its one use
> site pretty pointless. The other isn't so much about setting anything, but
> rather about clearing.
> 
> The main point here, however, is about Rafal spotting the double
> fetching of the GFN (first in gnttab_unpopulate_status_frames(), then
> again in gnttab_set_frame_gfn()). Re-purpose the macro parameter to pass
> in the already fetched GFN, while dropping the no longer used parameters.
> 
> As the result is a mere wrapper around guest_physmap_remove_page(), drop
> the hook altogether.
> 
> Suggested-by: Rafal Wojtczuk <rafal.wojtczuk@xxxxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> v2: Drop hook altogether.
> 
> --- a/xen/arch/arm/include/asm/grant_table.h
> +++ b/xen/arch/arm/include/asm/grant_table.h
> @@ -50,13 +50,6 @@ int replace_grant_host_mapping(uint64_t
>  #define gnttab_dom0_frames()                                             \
>      min_t(unsigned int, opt_max_grant_frames, PFN_DOWN(_etext - _stext))
>  
> -#define gnttab_set_frame_gfn(gt, st, idx, gfn, mfn)                      \
> -    (gfn_eq(gfn, INVALID_GFN)                                            \
> -     ? guest_physmap_remove_page((gt)->domain,                           \
> -                                 gnttab_get_frame_gfn(gt, st, idx),      \
> -                                 mfn, 0)                                 \
> -     : 0)
> -
>  #define gnttab_get_frame_gfn(gt, st, idx) ({                             \
>     (st) ? gnttab_status_gfn(NULL, gt, idx)                               \
>          : gnttab_shared_gfn(NULL, gt, idx);                              \
> --- a/xen/arch/x86/include/asm/grant_table.h
> +++ b/xen/arch/x86/include/asm/grant_table.h
> @@ -32,12 +32,6 @@ static inline int replace_grant_host_map
>      return replace_grant_pv_mapping(addr, frame, new_addr, flags);
>  }
>  
> -#define gnttab_set_frame_gfn(gt, st, idx, gfn, mfn)                      \
> -    (gfn_eq(gfn, INVALID_GFN)                                            \
> -     ? guest_physmap_remove_page((gt)->domain,                           \
> -                                 gnttab_get_frame_gfn(gt, st, idx),      \
> -                                 mfn, 0)                                 \
> -     : 0 /* Handled in add_to_physmap_one(). */)
>  #define gnttab_get_frame_gfn(gt, st, idx) ({                             \
>      mfn_t mfn_ = (st) ? gnttab_status_mfn(gt, idx)                       \
>                        : gnttab_shared_mfn(gt, idx);                      \
> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -1844,8 +1844,7 @@ gnttab_unpopulate_status_frames(struct d
>          {
>              int rc = gfn_eq(gfn, INVALID_GFN)
>                       ? 0
> -                     : gnttab_set_frame_gfn(gt, true, i, INVALID_GFN,
> -                                            page_to_mfn(pg));
> +                     : guest_physmap_remove_page(d, gfn, page_to_mfn(pg), 0);
>  
>              if ( rc )
>              {
> @@ -4285,8 +4284,6 @@ int gnttab_map_frame_begin(
>           */
>          if ( !get_page(pg, d) )
>              rc = -EBUSY;
> -        else if ( (rc = gnttab_set_frame_gfn(gt, status, idx, gfn, *mfn)) )
status is now a variable that is set but never read. Remove it.
With that:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal



 


Rackspace

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