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

Re: [Minios-devel] [UNIKRAFT PATCH 2/3] plat/common: Implement a few extra registers stub helpers on arm64


  • To: Julien Grall <Julien.Grall@xxxxxxx>, "minios-devel@xxxxxxxxxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxxxxxxxxx>, Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
  • From: "Justin He (Arm Technology China)" <Justin.He@xxxxxxx>
  • Date: Thu, 26 Sep 2019 12:52:45 +0000
  • Accept-language: en-US, zh-CN
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bh8+wx2gQDdbgEkpzU/QsqHfTT+bBTYW0OPShCCLyno=; b=LiILnerSiFIFATJJ1H5HfRunh9j4D53ewKJ9rLxrVxUApGass3MqLUPzA11REm8xn1vFx4QmsYtsnXZpbp8XPahnj+tsEmLy+E+YxTUgwcii5YB3EQqvFzCfXSpiyKSECoYXM/qxmyvc/sa6rV389DrZz0Xx++HVoSguLtOiyIGwIWzy6fIYkT2qhvMpK566IyDV26umqruWo9mau7y8PxZZXpScNwicK8mSUqX8Xku8m9QyhJGHidYFgzjKEX/FCGWXz5Zg4SQV2+Jww3WIxN5BluHvnO8iRCllytj0rG+BiuQQx0xbR7H5xt8MbAfcFSfgIMkGw+PGjaGHNXk2GQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQj+tdEOS9CaUD3vp1UZ9PNz+v3aOAju3LLWkxHyw/06n6OlqLDUF+qdByevAkEy+xlbDZwLDUUx0GNZHZh/fHLTjaiwgOdt47gCtMmzE4ceg/RlsWxI4j4ttnOYsyAKQEhzPUqKyGBRhBHgYj0c81qX1Bq2glppxhn+bg/Jgu5BvAsL7vqZkqdsPOJYymWAslPn7TRmgnkcmvnOgkvWcdCQU7KHw5aqyWgLq5wz8AqULl8m41YnOPZOQzAwKvGtGxhbzoXPigNQZOsMZRlgUWtTyuairF3wwInDJqZAEUU5j3jLIYp+HMuDrspDAZX/YdJizQnBhOtsH5ILIa44eA==
  • Authentication-results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; dmarc=none action=none header.from=arm.com;
  • Authentication-results-original: spf=none (sender IP is ) smtp.mailfrom=Justin.He@xxxxxxx;
  • Cc: Felipe Huici <felipe.huici@xxxxxxxxx>, "Kaly Xin \(Arm Technology China\)" <Kaly.Xin@xxxxxxx>, "Sharan.Santhanam@xxxxxxxxx" <Sharan.Santhanam@xxxxxxxxx>, "Santiago.Pagani@xxxxxxxxx" <Santiago.Pagani@xxxxxxxxx>
  • Delivery-date: Thu, 26 Sep 2019 12:53:04 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Justin.He@xxxxxxx;
  • Thread-index: AQHVdENBfSsEaZvCAkSC4B/Gwt02bKc9q9QAgAA8ejA=
  • Thread-topic: [UNIKRAFT PATCH 2/3] plat/common: Implement a few extra registers stub helpers on arm64

Hi Julien

> -----Original Message-----
> From: Julien Grall <julien.grall@xxxxxxx>
> Sent: 2019年9月26日 17:10
> To: Justin He (Arm Technology China) <Justin.He@xxxxxxx>; minios-
> devel@xxxxxxxxxxxxxxxxxxxx; Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> Cc: Sharan.Santhanam@xxxxxxxxx; Felipe Huici <felipe.huici@xxxxxxxxx>;
> Kaly Xin (Arm Technology China) <Kaly.Xin@xxxxxxx>;
> Santiago.Pagani@xxxxxxxxx
> Subject: Re: [UNIKRAFT PATCH 2/3] plat/common: Implement a few extra
> registers stub helpers on arm64
>
> Hi,
>
> On 9/26/19 9:20 AM, Jia He wrote:
> > On arm64, we don't need the extra registers during context switching so
> > far. This patch decouple the arch specific structures/functions info arch
> > related files.
>
> AFAICT, the patch adding x86 header in sw_ctx.c were committed last
> January. It would be good to understand how this is suddently an issue.
>
> If this is because of one series not yet merged, then it should be
> squashed in it. If not, an explanation in the commit message to explain
> the exact problem (possibly compilation issue?) is the best.

Sure, I will explain it in more detail.
>
> >
> > Signed-off-by: Jia He <justin.he@xxxxxxx>
> > ---
> >   plat/common/include/arm/arm64/cpu.h | 25
> +++++++++++++++++++++++++
> >   plat/common/include/x86/cpu.h       | 10 ++++++++++
> >   plat/common/sw_ctx.c                | 10 +++++-----
> >   3 files changed, 40 insertions(+), 5 deletions(-)
> >
> > diff --git a/plat/common/include/arm/arm64/cpu.h
> b/plat/common/include/arm/arm64/cpu.h
> > index 1495192..298424e 100644
> > --- a/plat/common/include/arm/arm64/cpu.h
> > +++ b/plat/common/include/arm/arm64/cpu.h
> > @@ -32,7 +32,12 @@
> >    * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
> >    */
> >
> > +#ifndef __PLAT_COMMON_ARM64_CPU_H__
> > +#define __PLAT_COMMON_ARM64_CPU_H__
>
> TBH, this belongs to a separate patch with ...
Okay, I will isolate this part as another patch
>
> > +
> >   #include <inttypes.h>
> > +#include <uk/essentials.h>
> > +#include <sw_ctx.h>
> >
> >   /* Define macros to access IO registers */
> >   #define __IOREG_READ(bits) \
> > @@ -108,3 +113,23 @@ int32_t smcc_psci_smc_call(uint32_t, uint64_t,
> uint64_t, uint64_t);
> >   void halt(void);
> >   void reset(void);
> >   void system_off(void);
> > +
> > +static inline unsigned long get_extregs_align(void)
> > +{
> > +   return 1;
> > +}
> > +
> > +static inline unsigned long get_extregs_size(void)
> > +{
> > +   return 0;
> > +}
> > +
> > +static inline void save_extregs(struct sw_ctx *ctx __unused)
> > +{
> > +}
> > +
> > +static inline void restore_extregs(struct sw_ctx *ctx __unused)
> > +{
> > +}
> > +
> > +#endif /* __PLAT_COMMON_ARM64_CPU_H__ */
> > diff --git a/plat/common/include/x86/cpu.h
> b/plat/common/include/x86/cpu.h
> > index 8acd71e..838bcea 100644
> > --- a/plat/common/include/x86/cpu.h
> > +++ b/plat/common/include/x86/cpu.h
> > @@ -56,6 +56,16 @@ struct _x86_features {
> >
> >   extern struct _x86_features x86_cpu_features;
> >
> > +static inline unsigned long get_extregs_align(void)
> > +{
> > +   return x86_cpu_features.extregs_align;
> > +}
> > +
> > +static inline unsigned long get_extregs_size(void)
> > +{
> > +   return x86_cpu_features.extregs_size;
> > +}
> > +
> >   static inline void save_extregs(struct sw_ctx *ctx)
> >   {
> >     switch (x86_cpu_features.save) {
> > diff --git a/plat/common/sw_ctx.c b/plat/common/sw_ctx.c
> > index 88a377f..74b935c 100644
> > --- a/plat/common/sw_ctx.c
> > +++ b/plat/common/sw_ctx.c
> > @@ -40,7 +40,7 @@
> >   #include <sw_ctx.h>
> >   #include <uk/assert.h>
> >   #include <tls.h>
> > -#include <x86/cpu.h>
> > +#include <cpu.h>
> >
> >   static void *sw_ctx_create(struct uk_alloc *allocator, unsigned long sp,
> >                             unsigned long tlsp);
> > @@ -61,8 +61,8 @@ static void *sw_ctx_create(struct uk_alloc *allocator,
> unsigned long sp,
> >
> >     UK_ASSERT(allocator != NULL);
> >
> > -   sz = ALIGN_UP(sizeof(struct sw_ctx), x86_cpu_features.extregs_align)
> > -           + x86_cpu_features.extregs_size;
> > +   sz = ALIGN_UP(sizeof(struct sw_ctx), get_extregs_align())
> > +           + get_extregs_size();
> >     ctx = uk_malloc(allocator, sz);
> >     uk_pr_debug("Allocating %lu bytes for sw ctx at %p\n", sz, ctx);
> >     if (ctx == NULL) {
> > @@ -74,9 +74,9 @@ static void *sw_ctx_create(struct uk_alloc *allocator,
> unsigned long sp,
> >     ctx->tlsp = tlsp;
> >     ctx->ip = (unsigned long) asm_thread_starter;
> >     ctx->extregs = ALIGN_UP(((uintptr_t)ctx + sizeof(struct sw_ctx)),
> > -                           x86_cpu_features.extregs_align);
> > +                           get_extregs_align());
> >     // Initialize extregs area: zero out, then save a valid layout to it.
> > -   memset((void *)ctx->extregs, 0, x86_cpu_features.extregs_size);
> > +   memset((void *)ctx->extregs, 0, get_extregs_size());
>
> This is a bit a waste for Arm and also quite dangerous because extregs
> is not going to be NULL but pointing just after the end of the allocated
> space.
>
> Couldn't we try to abstract it further? Maybe by providing a function
> that will allocate the structure and initialize arch specific things?
> Something like:
>
> ctx = arch_alloc_ctx(allocator);
>
> where arch_alloc_ctx for x86 would be implemented as
>
> sz = ALIGN_UP(sizeof(struct sw_ctx), ...) + ...;
> ctx = uk_malloc(..., sz);
> ctx->extregs = ...
> memset(ctx->extregs, 0, ...)
> save_ctx_regs();
> return ctx;
>
> For arm, it would be:
>
> return uk_malloc(..., sizeof(struct sw_ctx));
>
Ok, I will try your suggestions.
Unfortunately, when I rebased my patches to latest unikraft tree. I met more
issues (at first glance not related to this patch series). I will take more 
time to
dig into it.

--
Cheers,
Justin (Jia He)


>
> Cheers,
>
> --
> Julien Grall
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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