Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-19 Thread Wei Liu
On Tue, Apr 19, 2016 at 08:32:17PM +0800, Fu Wei wrote:
> Hi Wei Liu
> 
> On 15 April 2016 at 17:47, Wei Liu  wrote:
> > On Wed, Apr 13, 2016 at 05:45:27PM +0800, Fu Wei wrote:
> >> Hi Julien,
> >>
> >> On 8 April 2016 at 23:19, Julien Grall  wrote:
> >> > Hi Wei,
> >> >
> >> > On 08/04/16 15:58, Wei Liu wrote:
> >> >>
> >> >> On Fri, Apr 08, 2016 at 03:51:22PM +0100, Julien Grall wrote:
> >> >>>
> >> >>> Hi Fu Wei,
> >> >>>
> >> >>> On 05/04/16 17:46, fu@linaro.org wrote:
> >> 
> >>  From: Fu Wei 
> >> 
> >>  This patch adds a has_xsm_magic helper function for detecting XSM
> >> >>>
> >> >>> >from the second unknown module.
> >> 
> >> 
> >>  If Xen can't get the kind of module from compatible, we guess the kind
> >>  of
> >>  these unknowns respectively:
> >>   (1) The first unknown must be kernel.
> >>   (2) Detect the XSM Magic from the 2nd unknown:
> >>   a. If it's XSM, set the kind as XSM, and that also means we
> >>  won't load ramdisk;
> >>  b. if it's not XSM, set the kind as ramdisk.
> >>  So if user want to load ramdisk, it must be the 2nd unknown.
> >> >>>
> >> >>>
> >> >>> The documentation in docs/misc/arm/device-tree/booting.txt needs to be
> >> >>> update.
> >> >>>
> >> >>> Otherwise, the rest of the patch looks good to me.
> >> >>>
> >> >>> Regards,
> >> >>>
> >> >>
> >> >> Is this targeting 4.7? Today is the last day for committing stuff. The
> >> >> doc can come in later.
> >> >
> >> >
> >> > Yes, it's targeting 4.7. Fu Wei, can you send a follow-up for the doc?
> >> >
> >>
> >> yes, of course, I will do ASAP.
> >>
> >
> > Yes please. Note that the anticipated release date would be the
> > beginning of June, so you have five weeks to do that.
> 
> I have posted the doc patch:
> http://lists.xen.org/archives/html/xen-devel/2016-04/msg02070.html
> 

Strange, I don't seem to have that in my inbox or xen-devel archive.

> could some one review it ??

I will leave that to Julien and Stefano, but if it takes too long I will
look at it myself.

Thanks for writing the patch.

Wei.

> 
> >
> > Wei.
> 
> 
> 
> -- 
> Best regards,
> 
> Fu Wei
> Software Engineer
> Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
> Ph: +86 21 61221326(direct)
> Ph: +86 186 2020 4684 (mobile)
> Room 1512, Regus One Corporate Avenue,Level 15,
> One Corporate Avenue,222 Hubin Road,Huangpu District,
> Shanghai,China 200021

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-19 Thread Fu Wei
Hi Wei Liu

On 15 April 2016 at 17:47, Wei Liu  wrote:
> On Wed, Apr 13, 2016 at 05:45:27PM +0800, Fu Wei wrote:
>> Hi Julien,
>>
>> On 8 April 2016 at 23:19, Julien Grall  wrote:
>> > Hi Wei,
>> >
>> > On 08/04/16 15:58, Wei Liu wrote:
>> >>
>> >> On Fri, Apr 08, 2016 at 03:51:22PM +0100, Julien Grall wrote:
>> >>>
>> >>> Hi Fu Wei,
>> >>>
>> >>> On 05/04/16 17:46, fu@linaro.org wrote:
>> 
>>  From: Fu Wei 
>> 
>>  This patch adds a has_xsm_magic helper function for detecting XSM
>> >>>
>> >>> >from the second unknown module.
>> 
>> 
>>  If Xen can't get the kind of module from compatible, we guess the kind
>>  of
>>  these unknowns respectively:
>>   (1) The first unknown must be kernel.
>>   (2) Detect the XSM Magic from the 2nd unknown:
>>   a. If it's XSM, set the kind as XSM, and that also means we
>>  won't load ramdisk;
>>  b. if it's not XSM, set the kind as ramdisk.
>>  So if user want to load ramdisk, it must be the 2nd unknown.
>> >>>
>> >>>
>> >>> The documentation in docs/misc/arm/device-tree/booting.txt needs to be
>> >>> update.
>> >>>
>> >>> Otherwise, the rest of the patch looks good to me.
>> >>>
>> >>> Regards,
>> >>>
>> >>
>> >> Is this targeting 4.7? Today is the last day for committing stuff. The
>> >> doc can come in later.
>> >
>> >
>> > Yes, it's targeting 4.7. Fu Wei, can you send a follow-up for the doc?
>> >
>>
>> yes, of course, I will do ASAP.
>>
>
> Yes please. Note that the anticipated release date would be the
> beginning of June, so you have five weeks to do that.

I have posted the doc patch:
http://lists.xen.org/archives/html/xen-devel/2016-04/msg02070.html

could some one review it ??

>
> Wei.



-- 
Best regards,

Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15,
One Corporate Avenue,222 Hubin Road,Huangpu District,
Shanghai,China 200021

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-15 Thread Wei Liu
On Wed, Apr 13, 2016 at 05:45:27PM +0800, Fu Wei wrote:
> Hi Julien,
> 
> On 8 April 2016 at 23:19, Julien Grall  wrote:
> > Hi Wei,
> >
> > On 08/04/16 15:58, Wei Liu wrote:
> >>
> >> On Fri, Apr 08, 2016 at 03:51:22PM +0100, Julien Grall wrote:
> >>>
> >>> Hi Fu Wei,
> >>>
> >>> On 05/04/16 17:46, fu@linaro.org wrote:
> 
>  From: Fu Wei 
> 
>  This patch adds a has_xsm_magic helper function for detecting XSM
> >>>
> >>> >from the second unknown module.
> 
> 
>  If Xen can't get the kind of module from compatible, we guess the kind
>  of
>  these unknowns respectively:
>   (1) The first unknown must be kernel.
>   (2) Detect the XSM Magic from the 2nd unknown:
>   a. If it's XSM, set the kind as XSM, and that also means we
>  won't load ramdisk;
>  b. if it's not XSM, set the kind as ramdisk.
>  So if user want to load ramdisk, it must be the 2nd unknown.
> >>>
> >>>
> >>> The documentation in docs/misc/arm/device-tree/booting.txt needs to be
> >>> update.
> >>>
> >>> Otherwise, the rest of the patch looks good to me.
> >>>
> >>> Regards,
> >>>
> >>
> >> Is this targeting 4.7? Today is the last day for committing stuff. The
> >> doc can come in later.
> >
> >
> > Yes, it's targeting 4.7. Fu Wei, can you send a follow-up for the doc?
> >
> 
> yes, of course, I will do ASAP.
> 

Yes please. Note that the anticipated release date would be the
beginning of June, so you have five weeks to do that.

Wei.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-13 Thread Fu Wei
Hi Julien,

On 8 April 2016 at 23:19, Julien Grall  wrote:
> Hi Wei,
>
> On 08/04/16 15:58, Wei Liu wrote:
>>
>> On Fri, Apr 08, 2016 at 03:51:22PM +0100, Julien Grall wrote:
>>>
>>> Hi Fu Wei,
>>>
>>> On 05/04/16 17:46, fu@linaro.org wrote:

 From: Fu Wei 

 This patch adds a has_xsm_magic helper function for detecting XSM
>>>
>>> >from the second unknown module.


 If Xen can't get the kind of module from compatible, we guess the kind
 of
 these unknowns respectively:
  (1) The first unknown must be kernel.
  (2) Detect the XSM Magic from the 2nd unknown:
  a. If it's XSM, set the kind as XSM, and that also means we
 won't load ramdisk;
 b. if it's not XSM, set the kind as ramdisk.
 So if user want to load ramdisk, it must be the 2nd unknown.
>>>
>>>
>>> The documentation in docs/misc/arm/device-tree/booting.txt needs to be
>>> update.
>>>
>>> Otherwise, the rest of the patch looks good to me.
>>>
>>> Regards,
>>>
>>
>> Is this targeting 4.7? Today is the last day for committing stuff. The
>> doc can come in later.
>
>
> Yes, it's targeting 4.7. Fu Wei, can you send a follow-up for the doc?
>

yes, of course, I will do ASAP.


>>
>> Julien and Daniel's acks are needed here.
>
>
> Acked-by: Julien Grall 
>
> Regards,
>
> --
> Julien Grall



-- 
Best regards,

Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15,
One Corporate Avenue,222 Hubin Road,Huangpu District,
Shanghai,China 200021

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-13 Thread Fu Wei
Hi Julien,

On 8 April 2016 at 22:51, Julien Grall  wrote:
> Hi Fu Wei,
>
> On 05/04/16 17:46, fu@linaro.org wrote:
>>
>> From: Fu Wei 
>>
>> This patch adds a has_xsm_magic helper function for detecting XSM
>> from the second unknown module.
>>
>> If Xen can't get the kind of module from compatible, we guess the kind of
>> these unknowns respectively:
>>  (1) The first unknown must be kernel.
>>  (2) Detect the XSM Magic from the 2nd unknown:
>>  a. If it's XSM, set the kind as XSM, and that also means we
>> won't load ramdisk;
>> b. if it's not XSM, set the kind as ramdisk.
>> So if user want to load ramdisk, it must be the 2nd unknown.
>
>
> The documentation in docs/misc/arm/device-tree/booting.txt needs to be
> update.

Yes, I may forgot this part, but I will make a new doc patch.
Thanks for reminding me

>
> Otherwise, the rest of the patch looks good to me.

Great thanks for your help

>
> Regards,
>
> --
> Julien Grall



-- 
Best regards,

Fu Wei
Software Engineer
Red Hat Software (Beijing) Co.,Ltd.Shanghai Branch
Ph: +86 21 61221326(direct)
Ph: +86 186 2020 4684 (mobile)
Room 1512, Regus One Corporate Avenue,Level 15,
One Corporate Avenue,222 Hubin Road,Huangpu District,
Shanghai,China 200021

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-08 Thread Julien Grall

Hi Wei,

On 08/04/16 15:58, Wei Liu wrote:

On Fri, Apr 08, 2016 at 03:51:22PM +0100, Julien Grall wrote:

Hi Fu Wei,

On 05/04/16 17:46, fu@linaro.org wrote:

From: Fu Wei 

This patch adds a has_xsm_magic helper function for detecting XSM

>from the second unknown module.


If Xen can't get the kind of module from compatible, we guess the kind of
these unknowns respectively:
 (1) The first unknown must be kernel.
 (2) Detect the XSM Magic from the 2nd unknown:
 a. If it's XSM, set the kind as XSM, and that also means we
won't load ramdisk;
b. if it's not XSM, set the kind as ramdisk.
So if user want to load ramdisk, it must be the 2nd unknown.


The documentation in docs/misc/arm/device-tree/booting.txt needs to be
update.

Otherwise, the rest of the patch looks good to me.

Regards,



Is this targeting 4.7? Today is the last day for committing stuff. The
doc can come in later.


Yes, it's targeting 4.7. Fu Wei, can you send a follow-up for the doc?



Julien and Daniel's acks are needed here.


Acked-by: Julien Grall 

Regards,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-08 Thread Daniel De Graaf

On 04/05/2016 12:46 PM, fu@linaro.org wrote:

From: Fu Wei 

This patch adds a has_xsm_magic helper function for detecting XSM
from the second unknown module.

If Xen can't get the kind of module from compatible, we guess the kind of
these unknowns respectively:
 (1) The first unknown must be kernel.
 (2) Detect the XSM Magic from the 2nd unknown:
 a. If it's XSM, set the kind as XSM, and that also means we
won't load ramdisk;
b. if it's not XSM, set the kind as ramdisk.
So if user want to load ramdisk, it must be the 2nd unknown.
We also detect the XSM Magic for the following unknowns, then set its kind
according to the return value of has_xsm_magic.

By this way, arm64 behavior can be compatible to x86 and can simplify
multi-arch bootloader such as GRUB.

Signed-off-by: Fu Wei 


Acked-by: Daniel De Graaf 


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-08 Thread Wei Liu
On Fri, Apr 08, 2016 at 03:51:22PM +0100, Julien Grall wrote:
> Hi Fu Wei,
> 
> On 05/04/16 17:46, fu@linaro.org wrote:
> >From: Fu Wei 
> >
> >This patch adds a has_xsm_magic helper function for detecting XSM
> >from the second unknown module.
> >
> >If Xen can't get the kind of module from compatible, we guess the kind of
> >these unknowns respectively:
> > (1) The first unknown must be kernel.
> > (2) Detect the XSM Magic from the 2nd unknown:
> > a. If it's XSM, set the kind as XSM, and that also means we
> > won't load ramdisk;
> > b. if it's not XSM, set the kind as ramdisk.
> > So if user want to load ramdisk, it must be the 2nd unknown.
> 
> The documentation in docs/misc/arm/device-tree/booting.txt needs to be
> update.
> 
> Otherwise, the rest of the patch looks good to me.
> 
> Regards,
> 

Is this targeting 4.7? Today is the last day for committing stuff. The
doc can come in later.

Julien and Daniel's acks are needed here.

(I notice this patch is first posted on March 18 hence eligible for
4.7).

Wei.

> -- 
> Julien Grall
> 
> ___
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-08 Thread Julien Grall

Hi Fu Wei,

On 05/04/16 17:46, fu@linaro.org wrote:

From: Fu Wei 

This patch adds a has_xsm_magic helper function for detecting XSM
from the second unknown module.

If Xen can't get the kind of module from compatible, we guess the kind of
these unknowns respectively:
 (1) The first unknown must be kernel.
 (2) Detect the XSM Magic from the 2nd unknown:
 a. If it's XSM, set the kind as XSM, and that also means we
won't load ramdisk;
b. if it's not XSM, set the kind as ramdisk.
So if user want to load ramdisk, it must be the 2nd unknown.


The documentation in docs/misc/arm/device-tree/booting.txt needs to be 
update.


Otherwise, the rest of the patch looks good to me.

Regards,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v5] xen/arm64: check XSM Magic from the second unknown module.

2016-04-05 Thread fu . wei
From: Fu Wei 

This patch adds a has_xsm_magic helper function for detecting XSM
from the second unknown module.

If Xen can't get the kind of module from compatible, we guess the kind of
these unknowns respectively:
(1) The first unknown must be kernel.
(2) Detect the XSM Magic from the 2nd unknown:
a. If it's XSM, set the kind as XSM, and that also means we
won't load ramdisk;
b. if it's not XSM, set the kind as ramdisk.
So if user want to load ramdisk, it must be the 2nd unknown.
We also detect the XSM Magic for the following unknowns, then set its kind
according to the return value of has_xsm_magic.

By this way, arm64 behavior can be compatible to x86 and can simplify
multi-arch bootloader such as GRUB.

Signed-off-by: Fu Wei 
---
Changelog:
v5: Wrap "#include " up by #ifdef CONFIG_HAS_DEVICE_TREE
Improve has_xsm_magic code.

v4: http://lists.xen.org/archives/html/xen-devel/2016-04/msg00553.html
Fix some code style and comments problems.
Only check the Magic number.
Re-order the code in process_multiboot_node to get the base address
first, then the XSM Magic checking function only need to check if the
Magic number is valid.
Factor the XSM Magic checking code into an helper and re-use it
in xsm_dt_policy_init.

v3: http://lists.xen.org/archives/html/xen-devel/2016-03/msg03564.html
Using memcmp instead of strncmp.
Using "return 0;" instead of panic();
Improve some comments.

v2: http://lists.xen.org/archives/html/xen-devel/2016-03/msg03543.html
Using XEN_MAGIC macro instead of 0xf97cff8c :
uint32_t selinux_magic = 0xf97cff8c; --> uint32_t xen_magic = XEN_MAGIC;
Comment out the code(return 0 directly), if CONFIG_FLASK is not set.

v1: http://lists.xen.org/archives/html/xen-devel/2016-03/msg02430.html
The first upstream patch to xen-devel mailing lists.

 xen/arch/arm/bootfdt.c | 37 +
 xen/include/xsm/xsm.h  |  8 +++-
 xen/xsm/xsm_core.c | 27 +++
 xen/xsm/xsm_policy.c   |  8 ++--
 4 files changed, 61 insertions(+), 19 deletions(-)

diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 8a14015..d130633 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static bool_t __init device_tree_node_matches(const void *fdt, int node,
@@ -175,6 +176,17 @@ static void __init process_multiboot_node(const void *fdt, 
int node,
 const char *cmdline;
 int len;
 
+prop = fdt_get_property(fdt, node, "reg", );
+if ( !prop )
+panic("node %s missing `reg' property\n", name);
+
+if ( len < dt_cells_to_size(address_cells + size_cells) )
+panic("fdt: node `%s': `reg` property length is too short\n",
+name);
+
+cell = (const __be32 *)prop->data;
+device_tree_get_reg(, address_cells, size_cells, , );
+
 if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") == 0 ||
  fdt_node_check_compatible(fdt, node, "multiboot,kernel") == 0 )
 kind = BOOTMOD_KERNEL;
@@ -186,7 +198,17 @@ static void __init process_multiboot_node(const void *fdt, 
int node,
 else
 kind = BOOTMOD_UNKNOWN;
 
-/* Guess that first two unknown are kernel and ramdisk respectively. */
+/**
+ * Guess the kind of these first two unknowns respectively:
+ * (1) The first unknown must be kernel.
+ * (2) Detect the XSM Magic from the 2nd unknown:
+ * a. If it's XSM, set the kind as XSM, and that also means we
+ * won't load ramdisk;
+ * b. if it's not XSM, set the kind as ramdisk.
+ * So if user want to load ramdisk, it must be the 2nd unknown.
+ * We also detect the XSM Magic for the following unknowns,
+ * then set its kind according to the return value of has_xsm_magic.
+ */
 if ( kind == BOOTMOD_UNKNOWN )
 {
 switch ( kind_guess++ )
@@ -195,19 +217,10 @@ static void __init process_multiboot_node(const void 
*fdt, int node,
 case 1: kind = BOOTMOD_RAMDISK; break;
 default: break;
 }
+   if ( kind_guess > 1 && has_xsm_magic(start) )
+kind = BOOTMOD_XSM;
 }
 
-prop = fdt_get_property(fdt, node, "reg", );
-if ( !prop )
-panic("node %s missing `reg' property\n", name);
-
-if ( len < dt_cells_to_size(address_cells + size_cells) )
-panic("fdt: node `%s': `reg` property length is too short\n",
-name);
-
-cell = (const __be32 *)prop->data;
-device_tree_get_reg(, address_cells, size_cells, , );
-
 prop = fdt_get_property(fdt, node, "bootargs", );
 if ( prop )
 {
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index 3afed70..803c7ea 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -745,6 +745,7 @@ extern int xsm_multiboot_policy_init(unsigned long