All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Carlo Nonato <carlo.nonato@minervasys.tech>,
	xen-devel@lists.xenproject.org
Cc: andrew.cooper3@citrix.com, george.dunlap@citrix.com,
	jbeulich@suse.com, stefano.stabellini@amd.com, wl@xen.org,
	marco.solieri@unimore.it, andrea.bastoni@minervasys.tech,
	lucmiccio@gmail.com,
	Marco Solieri <marco.solieri@minervasys.tech>
Subject: Re: [PATCH 02/12] xen/arm: add cache coloring initialization for domains
Date: Tue, 25 Oct 2022 12:15:34 +0100	[thread overview]
Message-ID: <9a996e9d-d9ce-f562-122d-1e661d25614c@xen.org> (raw)
In-Reply-To: <CAG+AhRUT75hkaLZi0v0E_ozzyUY9QLHYGTamhXAoKfV2gZMwfg@mail.gmail.com>



On 25/10/2022 11:53, Carlo Nonato wrote:
> Hi Julien,
> 
> On Fri, Oct 21, 2022 at 8:02 PM Julien Grall <julien@xen.org> wrote:
>>
>> Hi Carlo,
>>
>> On 26/08/2022 13:51, Carlo Nonato wrote:
>>> This commit adds array pointers to domains as well as to the hypercall
>>> and configuration structure employed in domain creation. The latter is used
>>> both by the toolstack and by Xen itself to pass configuration data to the
>>> domain creation function, so the XEN_GUEST_HANDLE macro must be adopted to be
>>> able to access guest memory in the first case. This implies special care for
>>> the copy of the configuration data into the domain data, meaning that a
>>> discrimination variable for the two possible code paths (coming from Xen or
>>> from the toolstack) is needed.
>>
>> So this means that a toolstack could set from_guest. I know the
>> toolstack is trusted... However, we should try to limit when the trust
>> when this is possible.
>>
>> In this case, I would consider to modify the prototype of
>> domain_create() to pass internal information.
> 
> Doing as you said isn't a bit too invasive? I should also change all the call
> sites of domain_create() and this means x86 too.

Yes there will be a few calls to modify. But this is better than hacking 
the hypercall interface to cater for internal use.

> Isn't there an easier way to spot a guest address? Maybe just looking at the
> address value... 

HVM/Arm guest have a separate address space. So it is not possible to 
differentiate between guest vs hypervisor address.

> Or maybe adding an internal flag to the do_domctl() path.
IIUC, this flag would indicate whether the XEN_GUEST_HANDLE() is an 
hypervisor or guest address. Is that correct?

If so, I dislike it. I am not sure what the other maintainers think, but 
personally updating domain_create() is my preferred way.

[...]

>>>    void arch_domain_shutdown(struct domain *d)
>>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>>> index 3fd1186b53..4d4cb692fc 100644
>>> --- a/xen/arch/arm/domain_build.c
>>> +++ b/xen/arch/arm/domain_build.c
>>> @@ -33,6 +33,12 @@
>>>    #include <xen/grant_table.h>
>>>    #include <xen/serial.h>
>>>
>>> +#ifdef CONFIG_CACHE_COLORING
>>> +#define XEN_DOM0_CREATE_FLAGS CDF_privileged
>>> +#else
>>> +#define XEN_DOM0_CREATE_FLAGS CDF_privileged | CDF_directmap
>>> +#endif
>>
>> I can't remember if I asked it before and it doesn't seem to written
>> everywhere. This check suggest that it is not possible to use the same
>> Xen binary for coloring and non-coloring.
> 
> If coloring is enabled, all the domains are colored (even if they use
> zero colors
> because of the default selection). This means that they are going to use
> the colored allocator. Since this all-or-nothing design, if coloring is
> enabled, dom0 is assumed to be colored, which implies removing the directmap
> flag. So if what you mean with "same Xen binary for coloring and non-coloring"
> is to have a way to select at runtime if a domain is colored, or if Xen
> itself is colored, the answer is no, we don't have this right now.

[...]

> 
>> At the moment, we have been able to have all the features in the same
>> Xen binary. So what are the reasons for this restriction?
> 
> Not sure about the first sentence (you mean, until this patch?),

Yes.

> but the
> restriction is just because it's simpler. For example if we have to support
> colored and non-colored domains at the same time,

I am not asking for supporting a mix of colored and non-colored domains. 
What I am asking is to have a runtime switch (rather than compile time) 
to decide whether the system is colored or not.

IOW, why can't system-wide coloring be selected at runtime?

> we probably need to
> change something in the allocator (at least reserving more memory for the
> buddy).

This sentence picked my interesting. How do you decide the size of the 
buddy today?

[...]

>>> +#ifdef CONFIG_CACHE_COLORING
>>> +    unsigned int *colors;
>>> +    unsigned int num_colors;
>>> +#endif >
>>>        /* Virtual MMU */
>>>        struct p2m_domain p2m;
>>> diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
>>> index c8b6058d3a..adf843a7a1 100644
>>> --- a/xen/include/public/arch-arm.h
>>> +++ b/xen/include/public/arch-arm.h
>>> @@ -314,6 +314,8 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
>>>    #define XEN_DOMCTL_CONFIG_TEE_NONE      0
>>>    #define XEN_DOMCTL_CONFIG_TEE_OPTEE     1
>>>
>>> +__DEFINE_XEN_GUEST_HANDLE(color_t, unsigned int);
>>
>> You don't seem to use "color_t" outside of arch-arm.h and we already
>> define guest handle for "unsigned int". So can they be used?
> 
> That's because the guest handle for "unsigned int" is defined later
> (in public/xen.h).

Hmmm... And I guess we can't define "unsigned int" earlier because they 
rely on macro defined in arch-arm.h?

> We can also think of moving the coloring fields from this
> struct to the common one (xen_domctl_createdomain) protecting them with
> the proper #ifdef (but we are targeting only arm64...).

Your code is targeting arm64 but fundamentally this is an arm64 specific 
feature. IOW, this could be used in the future on other arch. So I think 
it would make sense to define it in common without the #ifdef.

@x86 maintainers, what do you think?

> 
>>> +
>>>    struct xen_arch_domainconfig {
>>>        /* IN/OUT */
>>>        uint8_t gic_version;
>>> @@ -335,6 +337,12 @@ struct xen_arch_domainconfig {
>>>         *
>>>         */
>>>        uint32_t clock_frequency;
>>> +    /* IN */
>>> +    uint8_t from_guest;
>>
>> There is an implicit padding here and ...
>>> +    /* IN */
>>> +    uint16_t num_colors;
>>
>> ... here. For the ABI, we are trying to have all the padding explicit.
>> So the layout of the structure is clear.
> 
> Isn't it true also for other fields like gic_version and tee_type?

Indeed, there is missing explicit padding after gic_version. There is no 
padding necessary after 'tee_type'.

I am not asking you to fix the existing missing padding, however we 
should avoid to introduce new ones.

Cheers,

-- 
Julien Grall


  reply	other threads:[~2022-10-25 11:16 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 12:50 [PATCH 00/12] Arm cache coloring Carlo Nonato
2022-08-26 12:51 ` [PATCH 01/12] xen/arm: add cache coloring initialization Carlo Nonato
2022-09-26  6:20   ` Wei Chen
2022-09-26  7:42     ` Jan Beulich
2022-09-27 14:31       ` Carlo Nonato
2022-10-21 17:14   ` Julien Grall
2022-08-26 12:51 ` [PATCH 02/12] xen/arm: add cache coloring initialization for domains Carlo Nonato
2022-09-26  6:39   ` Wei Chen
2022-09-27 14:31     ` Carlo Nonato
2022-10-21 17:25     ` Julien Grall
2022-10-21 18:02   ` Julien Grall
2022-10-25 10:53     ` Carlo Nonato
2022-10-25 11:15       ` Julien Grall [this message]
2022-10-25 11:51         ` Andrea Bastoni
2022-11-07 13:44         ` Carlo Nonato
2022-11-07 18:24           ` Julien Grall
2023-01-26 12:05     ` Jan Beulich
2023-01-26 12:07     ` Jan Beulich
2022-10-21 18:04   ` Julien Grall
2022-08-26 12:51 ` [PATCH 03/12] xen/arm: dump cache colors in domain info debug-key Carlo Nonato
2022-08-26 12:51 ` [PATCH 04/12] tools/xl: add support for cache coloring configuration Carlo Nonato
2022-10-21 18:09   ` Julien Grall
2022-08-26 12:51 ` [PATCH 05/12] xen/arm: add support for cache coloring configuration via device-tree Carlo Nonato
2022-08-26 12:51 ` [PATCH 06/12] xen/common: add cache coloring allocator for domains Carlo Nonato
2022-09-15 13:13   ` Jan Beulich
2022-09-16 16:05     ` Carlo Nonato
2022-09-19  6:26       ` Jan Beulich
2022-09-19 22:42         ` Stefano Stabellini
2022-09-20  7:54           ` Jan Beulich
2022-10-13  9:47         ` Carlo Nonato
2022-10-13 10:44           ` Jan Beulich
2022-10-17  7:06   ` Michal Orzel
2022-10-17  8:44     ` Julien Grall
2022-10-17  9:16       ` Michal Orzel
2022-08-26 12:51 ` [PATCH 07/12] xen/common: add colored heap info debug-key Carlo Nonato
2022-08-26 14:13   ` Jan Beulich
2022-08-26 16:04     ` Carlo Nonato
2022-08-26 12:51 ` [PATCH 08/12] Revert "xen/arm: setup: Add Xen as boot module before printing all boot modules" Carlo Nonato
2022-09-10 14:01   ` Julien Grall
2022-09-12 13:54     ` Carlo Nonato
2022-10-21 16:52       ` Julien Grall
2022-08-26 12:51 ` [PATCH 09/12] Revert "xen/arm: mm: Initialize page-tables earlier" Carlo Nonato
2022-09-10 14:28   ` Julien Grall
2022-09-12 13:59     ` Carlo Nonato
2022-08-26 12:51 ` [PATCH 10/12] Revert "xen/arm: Remove unused BOOT_RELOC_VIRT_START" Carlo Nonato
2022-08-26 12:51 ` [PATCH 11/12] xen/arm: add Xen cache colors command line parameter Carlo Nonato
2022-08-26 12:51 ` [PATCH 12/12] xen/arm: add cache coloring support for Xen Carlo Nonato
2022-09-10 15:22   ` Julien Grall
2022-09-10 15:23     ` Julien Grall
2022-09-15 13:25   ` Jan Beulich
2022-09-16 16:07     ` Carlo Nonato
2022-09-19  8:38       ` Jan Beulich
2022-09-27 14:31         ` Carlo Nonato
2022-09-27 15:28           ` Jan Beulich
2022-09-10 15:12 ` [PATCH 00/12] Arm cache coloring Julien Grall
2022-09-12 13:24   ` Carlo Nonato
2022-09-15 13:29 ` Jan Beulich
2022-09-15 14:52   ` Marco Solieri
2022-09-15 18:15   ` Stefano Stabellini
2022-10-22 15:13 ` 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=9a996e9d-d9ce-f562-122d-1e661d25614c@xen.org \
    --to=julien@xen.org \
    --cc=andrea.bastoni@minervasys.tech \
    --cc=andrew.cooper3@citrix.com \
    --cc=carlo.nonato@minervasys.tech \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=lucmiccio@gmail.com \
    --cc=marco.solieri@minervasys.tech \
    --cc=marco.solieri@unimore.it \
    --cc=stefano.stabellini@amd.com \
    --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.