All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH 07/10] mini-os: move x86 specific gnttab coding into arch/x86/gnttab.c
Date: Sun, 12 Dec 2021 01:41:21 +0100	[thread overview]
Message-ID: <20211212004121.27tquytcimfd47b5@begin> (raw)
In-Reply-To: <20211206072337.9517-8-jgross@suse.com>

Juergen Gross, le lun. 06 déc. 2021 08:23:34 +0100, a ecrit:
> Having grant table code in arch/x86/mm.c seems wrong. Move it to the
> new file arch/x86/gnttab.c, especially as the amount of code is
> expected to grow further.
> 
> No functional change.

There is the __pte fix that you'd probably want to mention.

> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  arch/x86/gnttab.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++
>  arch/x86/mm.c     | 47 ----------------------------
>  2 files changed, 78 insertions(+), 47 deletions(-)
>  create mode 100644 arch/x86/gnttab.c
> 
> diff --git a/arch/x86/gnttab.c b/arch/x86/gnttab.c
> new file mode 100644
> index 0000000..56e59d7
> --- /dev/null
> +++ b/arch/x86/gnttab.c
> @@ -0,0 +1,78 @@
> +/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
> + *
> + * (C) 2021 - Juergen Gross, SUSE Software Solutions Germany GmbH
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to
> + * deal in the Software without restriction, including without limitation the
> + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
> + * sell copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include <mini-os/os.h>
> +#include <mini-os/hypervisor.h>
> +#include <mini-os/gnttab.h>
> +#include <mini-os/mm.h>
> +#include <mini-os/types.h>
> +
> +grant_entry_v1_t *arch_init_gnttab(int nr_grant_frames)
> +{
> +    struct gnttab_setup_table setup;
> +    unsigned long frames[nr_grant_frames];
> +
> +    setup.dom = DOMID_SELF;
> +    setup.nr_frames = nr_grant_frames;
> +    set_xen_guest_handle(setup.frame_list, frames);
> +
> +    HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
> +    return map_frames(frames, nr_grant_frames);
> +}
> +
> +void arch_suspend_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frames)
> +{
> +#ifdef CONFIG_PARAVIRT
> +    int i;
> +
> +    for ( i = 0; i < nr_grant_frames; i++ )
> +    {
> +        HYPERVISOR_update_va_mapping((unsigned long)gnttab_table + PAGE_SIZE * i,
> +                __pte(0x0 << PAGE_SHIFT), UVMF_INVLPG);
> +    }
> +#endif
> +    return;
> +}
> +
> +void arch_resume_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frames)
> +{
> +    struct gnttab_setup_table setup;
> +    unsigned long frames[nr_grant_frames];
> +#ifdef CONFIG_PARAVIRT
> +    int i;
> +#endif
> +
> +    setup.dom = DOMID_SELF;
> +    setup.nr_frames = nr_grant_frames;
> +    set_xen_guest_handle(setup.frame_list, frames);
> +
> +    HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
> +
> +#ifdef CONFIG_PARAVIRT
> +    for ( i = 0; i < nr_grant_frames; i++ )
> +    {
> +        HYPERVISOR_update_va_mapping((unsigned long)gnttab_table + PAGE_SIZE * i,
> +                __pte((frames[i] << PAGE_SHIFT) | L1_PROT), UVMF_INVLPG);
> +    }
> +#endif
> +}
> diff --git a/arch/x86/mm.c b/arch/x86/mm.c
> index c30d8bc..220c0b4 100644
> --- a/arch/x86/mm.c
> +++ b/arch/x86/mm.c
> @@ -837,53 +837,6 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)
>  #endif
>  }
>  
> -grant_entry_v1_t *arch_init_gnttab(int nr_grant_frames)
> -{
> -    struct gnttab_setup_table setup;
> -    unsigned long frames[nr_grant_frames];
> -
> -    setup.dom = DOMID_SELF;
> -    setup.nr_frames = nr_grant_frames;
> -    set_xen_guest_handle(setup.frame_list, frames);
> -
> -    HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
> -    return map_frames(frames, nr_grant_frames);
> -}
> -
> -void arch_suspend_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frames)
> -{
> -#ifdef CONFIG_PARAVIRT
> -    int i;
> -
> -    for (i = 0; i < nr_grant_frames; i++) {
> -        HYPERVISOR_update_va_mapping((unsigned long)(((char *)gnttab_table) + PAGE_SIZE * i),
> -                (pte_t){0x0<<PAGE_SHIFT}, UVMF_INVLPG);
> -    }
> -#endif
> -    return;
> -}
> -
> -void arch_resume_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frames)
> -{
> -    struct gnttab_setup_table setup;
> -    unsigned long frames[nr_grant_frames];
> -#ifdef CONFIG_PARAVIRT
> -    int i;
> -#endif
> -    setup.dom = DOMID_SELF;
> -    setup.nr_frames = nr_grant_frames;
> -    set_xen_guest_handle(setup.frame_list, frames);
> -
> -    HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
> -
> -#ifdef CONFIG_PARAVIRT
> -    for (i = 0; i < nr_grant_frames; i++) {
> -        HYPERVISOR_update_va_mapping((unsigned long)(((char *)gnttab_table) + PAGE_SIZE * i),
> -                (pte_t){(frames[i] << PAGE_SHIFT) | L1_PROT}, UVMF_INVLPG);
> -    }
> -#endif
> -}
> -
>  unsigned long alloc_virt_kernel(unsigned n_pages)
>  {
>      unsigned long addr;
> -- 
> 2.26.2
> 

-- 
Samuel
War doesn't prove who's right, just who's left.


  reply	other threads:[~2021-12-12  0:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06  7:23 [PATCH 00/10] mini-os: add missing PVH features Juergen Gross
2021-12-06  7:23 ` [PATCH 01/10] mini-os: split e820 map handling into new source file Juergen Gross
2021-12-11 23:56   ` Samuel Thibault
2021-12-06  7:23 ` [PATCH 02/10] mini-os: sort and sanitize e820 memory map Juergen Gross
2021-12-12  0:05   ` Samuel Thibault
2021-12-13 14:56     ` Juergen Gross
2021-12-13 21:19       ` Samuel Thibault
2021-12-14  6:33         ` Juergen Gross
2021-12-06  7:23 ` [PATCH 03/10] mini-os: don't assume contiguous RAM when initializing in PVH mode Juergen Gross
2021-12-12  0:15   ` Samuel Thibault
2021-12-13 14:58     ` Juergen Gross
2021-12-13 21:22       ` Samuel Thibault
2021-12-14  6:35         ` Juergen Gross
2021-12-14  7:40           ` Samuel Thibault
2021-12-06  7:23 ` [PATCH 04/10] mini-os: respect memory map when ballooning up Juergen Gross
2021-12-12  0:26   ` Samuel Thibault
2021-12-13 15:05     ` Juergen Gross
2021-12-06  7:23 ` [PATCH 05/10] mini-os: don't repeat definition available via header file Juergen Gross
2021-12-12  0:27   ` Samuel Thibault
2021-12-06  7:23 ` [PATCH 06/10] mini-os: add memory map service functions Juergen Gross
2021-12-12  0:37   ` Samuel Thibault
2021-12-06  7:23 ` [PATCH 07/10] mini-os: move x86 specific gnttab coding into arch/x86/gnttab.c Juergen Gross
2021-12-12  0:41   ` Samuel Thibault [this message]
2021-12-06  7:23 ` [PATCH 08/10] mini-os: add proper pvh grant table handling Juergen Gross
2021-12-12  0:43   ` Samuel Thibault
2021-12-06  7:23 ` [PATCH 09/10] mini-os: prepare grantmap entry interface for use by PVH mode Juergen Gross
2021-12-12  0:50   ` Samuel Thibault
2021-12-06  7:23 ` [PATCH 10/10] mini-os: modify grant mappings to work in " Juergen Gross
2021-12-12  0:51   ` Samuel Thibault
2021-12-06 12:46 ` [PATCH] mini-os: support event channel 0 for console Juergen Gross
2021-12-06 13:24   ` Jan Beulich
2021-12-06 13:30     ` Juergen Gross
2021-12-06 14:17     ` Juergen Gross

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=20211212004121.27tquytcimfd47b5@begin \
    --to=samuel.thibault@ens-lyon.org \
    --cc=jgross@suse.com \
    --cc=minios-devel@lists.xenproject.org \
    --cc=wl@xen.org \
    --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.