All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Stefano Stabellini <sstabellini@kernel.org>, andrew.cooper3@citrix.com
Cc: xen-devel@lists.xenproject.org, julien.grall@arm.com,
	Stefano Stabellini <stefanos@xilinx.com>
Subject: Re: [Xen-devel] [PATCH v4 3/6] xen: extend XEN_DOMCTL_memory_mapping to handle memory policy
Date: Fri, 9 Aug 2019 13:25:19 +0200	[thread overview]
Message-ID: <af45d398-eeea-dd03-95f6-cd7eb065bfaf@suse.com> (raw)
In-Reply-To: <20190807002311.9906-3-sstabellini@kernel.org>

On 07.08.2019 02:23, Stefano Stabellini wrote:
> @@ -950,9 +951,29 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>           if ( add )
>           {
>               printk(XENLOG_G_DEBUG
> -                   "memory_map:add: dom%d gfn=%lx mfn=%lx nr=%lx\n",
> -                   d->domain_id, gfn, mfn, nr_mfns);
> +                   "memory_map:add: dom%d gfn=%lx mfn=%lx nr=%lx policy=%u\n",
> +                   d->domain_id, gfn, mfn, nr_mfns, memory_policy);
>   
> +            switch ( memory_policy )
> +            {
> +#ifdef CONFIG_ARM
> +                case MEMORY_POLICY_ARM_MEM_WB:
> +                    p2mt = p2m_mmio_direct_c;
> +                    break;
> +                case MEMORY_POLICY_ARM_DEV_nGnRE:
> +                    p2mt = p2m_mmio_direct_dev;
> +                    break;
> +#endif
> +#ifdef CONFIG_X86
> +                case MEMORY_POLICY_DEFAULT:
> +                    p2mt = p2m_mmio_direct;
> +                    break;
> +#endif
> +                default:
> +                    domctl_lock_release();
> +                    ret = -EINVAL;
> +                    goto domctl_out_unlock_domonly;
> +            }

Indentation is wrong here: The case labels ought to align with their
switch(). Also please have blank lines between case blocks. For the
Arm part it would be nice if the case being MEMORY_POLICY_DEFAULT
would gain a respective comment, perhaps in the form of a commented
out case label.

> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -571,12 +571,30 @@ struct xen_domctl_bind_pt_irq {
>   */
>   #define DPCI_ADD_MAPPING         1
>   #define DPCI_REMOVE_MAPPING      0
> +/*
> + * Default memory policy. Corresponds to:
> + * Arm: MEMORY_POLICY_ARM_DEV_nGnRE
> + * x86: Memory type UNCACHABLE
> + */

I continue to be unhappy about the imprecise "uncachable" here
for x86: In shadow mode and on AMD/NPT we produce UC- mappings,
while the way EPT works it further depends on host and guest
MTRR settings.  Andrew - do you have any thoughts how to best
describe this here without growing the text too large, but also
without producing an overly imprecise description?

> +#define MEMORY_POLICY_DEFAULT         0
> +#if defined(__arm__) || defined (__aarch64__)
> +/* Arm only. Outer Shareable, Device-nGnRE memory (Device Memory on Armv7) */
> +# define MEMORY_POLICY_ARM_DEV_nGnRE      0
> +/* Arm only. Outer Shareable, Outer/Inner Write-Back Cacheable memory */
> +# define MEMORY_POLICY_ARM_MEM_WB         1
> +/*
> + * On Arm, MEMORY_POLICY selects the stage-2 memory attributes, but note
> + * that the resulting memory attributes will be a combination of stage-2
> + * and stage-1 memory attributes: it will be the strongest between the 2
> + * stages attributes.
> + */
> +#endif
>   struct xen_domctl_memory_mapping {
>       uint64_aligned_t first_gfn; /* first page (hvm guest phys page) in range */
>       uint64_aligned_t first_mfn; /* first page (machine page) in range */
>       uint64_aligned_t nr_mfns;   /* number of pages in range (>0) */
>       uint32_t add_mapping;       /* add or remove mapping */
> -    uint32_t padding;           /* padding for 64-bit aligned structure */
> +    uint32_t memory_policy;      /* cacheability of the memory mapping */

The comment looks to start one column too far to the right.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-08-09 11:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07  0:23 [Xen-devel] [PATCH v4 0/6] iomem memory policy Stefano Stabellini
2019-08-07  0:23 ` [Xen-devel] [PATCH v4 1/6] xen/arm: introduce p2m_is_mmio Stefano Stabellini
2019-08-09 10:05   ` Julien Grall
2019-08-07  0:23 ` [Xen-devel] [PATCH v4 2/6] xen: add a p2mt parameter to map_mmio_regions Stefano Stabellini
2019-08-09 10:23   ` Julien Grall
2019-08-09 10:37     ` Jan Beulich
2019-08-09 10:51       ` Julien Grall
2019-08-09 11:07         ` Jan Beulich
2019-08-09 11:10   ` Jan Beulich
2019-08-07  0:23 ` [Xen-devel] [PATCH v4 3/6] xen: extend XEN_DOMCTL_memory_mapping to handle memory policy Stefano Stabellini
2019-08-09 11:25   ` Jan Beulich [this message]
2019-08-09 17:25   ` Julien Grall
2019-08-07  0:23 ` [Xen-devel] [PATCH v4 4/6] libxc: introduce xc_domain_mem_map_policy Stefano Stabellini
2019-08-07  0:23 ` [Xen-devel] [PATCH v4 5/6] libxl/xl: add memory policy option to iomem Stefano Stabellini
2019-08-09 17:23   ` Julien Grall
2019-08-07  0:23 ` [Xen-devel] [PATCH v4 6/6] xen/arm: clarify the support status of iomem configurations Stefano Stabellini
2019-08-07  9:08   ` Julien Grall
2019-08-07  9:16     ` Julien Grall

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=af45d398-eeea-dd03-95f6-cd7eb065bfaf@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=stefanos@xilinx.com \
    --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.