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

Re: [PATCH 3/3] xen/arm: stack check instrumentation


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 30 Jul 2024 13:59:20 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2hLBkBNp6xGIMHq5CfzoN6NZid8uO2Qk/Xnt+K4+0/E=; b=QFnMsHCXKJQJLibVIKT9k6XGC5PtZbgJIlH9MaF7c6p7WvU47IMPn0RhRqU2TnGrOKgUrEdkU3D33GZiu2IyvRSzOsSHrT2TFFWlr1NlygZe04u+oIQsIts5qozLG/HpdHRto8i0MWx2GYxyi11MXFch/ty6oCgMUT8Qtq6VNMCga89S9bTH+QKQUOSmv2vokZ2OBpTHkmo5xwYkmUrwkM2eaj5Iaen9LKV4RbBkA/G+GlUICIWkVuJBSdMeQtY9TiasNdBYJK8A/Bi9zVFSamHIHfah/IxbcHRmZcl99/24jjxJnfFwv/OdKdN5xSCi/G1vRmt499T8TQev+Y/wEA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eKWP3MxQ1RH3t67j9YehFdOVCD3XXWjPqA5AQR+/kDgxW5La5+nNWF1o05UaKaSkT/SWaokybcoUCaXHMERHrVrotf56H58VvkJgb6w7yGI94Zd6k+8WqIeCCqXv66T/tQfv8KuVUt5o1X4B4ffayVlFf8JNCHmiUgfB/CEZ7x/s1Gx+/AnUR+jPU8Gf08/Jy+z4sQsRLKAIDT2j1roBkHOV+3wVSaTIGfeEf+dw2f+NVJn9KRiSyr8PFr2v5xfLKpPtDPPY0Ne330CivYiGNtinejZo8Oz7nSTJif95C42U2oUs9c/qIQta1y/zymwnl+3oQM3OHifVIrqLadaF5A==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 30 Jul 2024 18:00:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 7/29/24 16:37, Julien Grall wrote:
> Hi,
> 
> On 29/07/2024 20:40, Stewart Hildebrand wrote:
>> On 7/29/24 14:50, Julien Grall wrote:
>>> Hi again,
>>>
>>> On 29/07/2024 15:24, Stewart Hildebrand wrote:
>>>> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
>>>> index aac6c599f878..b4890eec7ec4 100644
>>>> --- a/xen/arch/arm/traps.c
>>>> +++ b/xen/arch/arm/traps.c
>>>> @@ -2325,6 +2325,51 @@ void asmlinkage leave_hypervisor_to_guest(void)
>>>>            arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 0, NULL);
>>>>    }
>>>>    +#ifdef CONFIG_DEBUG
>>>> +DEFINE_PER_CPU(unsigned int, stack_check_nesting);
>>>> +DEFINE_PER_CPU(unsigned char *, stack_base);
>>>
>>> While looking at the code, I just realized that this should be equivalent 
>>> to current->arch.base.
>>
>> current->arch.stack
>>
>> That's true only after the idle vcpu stacks have been allocated.
>>
>>> So do we actually need stack_base?
>>
>> This is a way to enable stack instrumentation much earlier during boot
>> when we are still using the static boot stack.
> 
> Sure. But we are only partially checking the static boot stack.

The stack checking begins just a few lines into C world, after the
percpu_init_areas(), set_processor_id(), and stack_check_init() calls in
arch/arm/setup.c:start_xen().

> I am not entirely sure if there is any value for that because at that point 
> the stack would be barely used.

The entirety of start_xen() uses the boot stack, and it makes plenty of
device tree parsing calls (where there is recursion) and performs domain
creation, which hits the stack significantly.

arch/arm/dom0less-build.c: In function ‘construct_domU’:
arch/arm/dom0less-build.c:742:19: warning: stack usage is 7824 bytes 
[-Wstack-usage=]
  742 | static int __init construct_domU(struct domain *d,
      |                   ^~~~~~~~~~~~~~

arch/arm/domain_build.c: In function ‘make_memory_node’:
arch/arm/domain_build.c:788:12: warning: stack usage is 4720 bytes 
[-Wstack-usage=]
  788 | int __init make_memory_node(const struct kernel_info *kinfo, int 
addrcells,
      |            ^~~~~~~~~~~~~~~~

arch/arm/domain_build.c: In function ‘construct_dom0’:
arch/arm/domain_build.c:2120:19: warning: stack usage is 7776 bytes 
[-Wstack-usage=]
 2120 | static int __init construct_dom0(struct domain *d)
      |                   ^~~~~~~~~~~~~~

> 
> Anyway, this is only for debug build so far, so I am ok to keep it.
> 
> Cheers,
> 




 


Rackspace

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