From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68304 invoked by alias); 19 Jun 2017 15:45:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 51672 invoked by uid 89); 19 Jun 2017 15:45:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,COMPENSATION,KAM_LAZY_DOMAIN_SECURITY,KHOP_DYNAMIC,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Jun 2017 15:45:19 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5JFcgtV016550 for ; Mon, 19 Jun 2017 11:45:20 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2b5uhc27qh-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 19 Jun 2017 11:45:19 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 Jun 2017 16:45:18 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 19 Jun 2017 16:45:16 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v5JFjFlo35192980; Mon, 19 Jun 2017 15:45:15 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5BD8BA404D; Mon, 19 Jun 2017 16:43:02 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15DBAA4040; Mon, 19 Jun 2017 16:43:02 +0100 (BST) Received: from ThinkPad (unknown [9.152.212.148]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 19 Jun 2017 16:43:02 +0100 (BST) Date: Mon, 19 Jun 2017 15:45:00 -0000 From: Philipp Rudo To: Yao Qi Cc: gdb-patches@sourceware.org, omair.javaid@linaro.org, yao.qi@linaro.org, peter.griffin@linaro.org, arnez@linux.vnet.ibm.com Subject: Re: [RFC v4 9/9] Add S390 support for linux-kernel target In-Reply-To: <86poe0nmfx.fsf@gmail.com> References: <20170612170836.25174-1-prudo@linux.vnet.ibm.com> <20170612193900.234bc540@ThinkPad> <86poe0nmfx.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17061915-0040-0000-0000-000003CDD265 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17061915-0041-0000-0000-000020676E0D Message-Id: <20170619174514.1f3496c9@ThinkPad> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-19_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706190262 X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00520.txt.bz2 Hi Yao On Mon, 19 Jun 2017 14:20:34 +0100 Yao Qi wrote: > Philipp Rudo writes: > > > +/* S390s kernel stack is split up on several memory locations: > > + > > + - kernel stack (per task) > > + - async aka. interrupt stack (per cpu) > > + - panic stack (per cpu) > > + - restart stack (unique, global) > > + > > + Each memory location is page aligned and has a size of four consecutive > > + pages (except the panic stack with only one page). */ > > + > > +enum s390_lk_stack_location > > +{ > > + S390_LK_STACK_INVALID = -1, > > + S390_LK_STACK_USER, > > + S390_LK_STACK_KERNEL, > > + S390_LK_STACK_ASYNC, > > + S390_LK_STACK_PANIC, > > + S390_LK_STACK_RESTART > > +}; > > + > > Did you consider adding different frame unwinders for frames on > different memory locations? Your patches only adds two, but IMO, we > need more unwinders for different frames, All those stacks (except user space) are working the same way. That's why it is sufficient to only add one unwinder. In theory it is sufficient to only distinguish three cases (KERNEL, INVALID and "OTHER") but for the sake of completeness I also added the other possible cases. This makes the code only a little longer but makes extending it (e.g. to compensate a bug as been done for the kernel stack) much easier. Philipp > > + > > +/* Helper macro for s390_lk_get_stack_location to check for stacks which > > + locations are stored in the lowcore. > > + > > + _addr address to be checked for > > + _lc address of the corresponding lowcore > > + _stack field name of stack in lowcore > > + _type type to be returned if _addr is on _stack > > + _size size of _stack > > +*/ > > + > > +#define s390_lk_check_lowcore_stack(_addr, _lc, _stack, _type, > > _size) \ > > + > > do \ > > + > > { \ > > + CORE_ADDR _##_stack, _##_stack##_top, > > _##_stack##_bottom; \ > > + _##_stack = lk_read_addr ((_lc) + LK_OFFSET (lowcore, > > _stack)); \ > > + _##_stack##_top = S390_LK_ROUNDUP (_##_stack, > > S390_LK_PAGESIZE); \ > > + _##_stack##_bottom = _##_stack##_top - > > (_size); \ > > + if ((_addr) <= _##_stack##_top && (_addr) >= > > _##_stack##_bottom) \ > > + return > > (_type); \ > > + } > > \ > > + while (0) > > + > > +/* Find and return the stack location of ADDR belonging to TASK. */ > > + > > +static enum s390_lk_stack_location > > +s390_lk_get_stack_location (CORE_ADDR task, CORE_ADDR addr) > > +{ > > + CORE_ADDR lowcore, top, bottom; > > + unsigned int cpu = lk_task_running (task); > > + > > + > > + /* Kernel stack. */ > > + bottom = lk_read_addr (task + LK_OFFSET (task_struct, stack)); > > + top = bottom + S390_LK_STACKSIZE; > > + if (addr <= top && addr >= bottom) > > + return S390_LK_STACK_KERNEL; > > + > > + /* A sleeping task only has the kernel stack. If a sleeping task reaches > > + this point ADDR isn't on the stack. */ > > + if (cpu == LK_CPU_INVAL) > > + return S390_LK_STACK_INVALID; > > + > > + lowcore = s390_lk_get_lowcore (cpu); > > + > > + /* Async aka. interrupt stack. */ > > + s390_lk_check_lowcore_stack (addr, lowcore, async_stack, > > + S390_LK_STACK_ASYNC, S390_LK_ASYNCSIZE); > > + > > + /* Panic stack. > > + Note: The panic stack only has a size of one page. */ > > + s390_lk_check_lowcore_stack (addr, lowcore, panic_stack, > > + S390_LK_STACK_PANIC, S390_LK_PAGESIZE); > > + > > + /* Restart stack. */ > > + s390_lk_check_lowcore_stack (addr, lowcore, restart_stack, > > + S390_LK_STACK_RESTART, S390_LK_ASYNCSIZE); > > + > > + return S390_LK_STACK_INVALID; > > +} > > The unwinders for different frames should be chained in this order. >