Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D319DC636D6 for ; Thu, 23 Feb 2023 10:12:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.500146.771376 (Exim 4.92) (envelope-from ) id 1pV8Zi-0001aw-6V; Thu, 23 Feb 2023 10:11:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 500146.771376; Thu, 23 Feb 2023 10:11:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pV8Zi-0001ap-3C; Thu, 23 Feb 2023 10:11:42 +0000 Received: by outflank-mailman (input) for mailman id 500146; Thu, 23 Feb 2023 10:11:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pV8Zg-0001ae-5M for xen-devel@lists.xenproject.org; Thu, 23 Feb 2023 10:11:40 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on20602.outbound.protection.outlook.com [2a01:111:f400:fe16::602]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 75ed61ae-b362-11ed-88bb-e56d68cac8db; Thu, 23 Feb 2023 11:11:38 +0100 (CET) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PA4PR04MB7664.eurprd04.prod.outlook.com (2603:10a6:102:f1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.19; Thu, 23 Feb 2023 10:11:35 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6134.019; Thu, 23 Feb 2023 10:11:35 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 75ed61ae-b362-11ed-88bb-e56d68cac8db ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XGEghjvPXbk0mqv07lyQXbwZrJCUrOoBhh4+B/m4zk886BqvQEdyXxb5Ty0sdt03ldMJQWDnh6dS6eBXnkQngFPuEvRtELJuT5YFcDKczkmQleCUVfJMNxtWT4rUUPJigZpNtZEE8ljPwBSlqyc6m9TWigWjiBSWyNtVIMkylmTGfiKizGZkLzLV+IWO1A4rOLzdLzWXRdbE6xj4eEUFPQp/O/2tIgEjwKftbbf2qY4c65HmRqDXVGzCkwILjyNgAzjPGClKk/v/Xt0xQMpd4AMPkOQ/scvN/lVqqOWwsRvproykvcB/rH9ovrF5OE9QCNJ9tMXVNGp0qUuiDysG/g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/BPHwQK6RhV39CQbmdTgVpoLkkPcki07C1OWjtIF+mo=; b=IsEyTf+56CC9tKJbs0dxWpDC+gHOwVm63NrFyxt/fuXOHx3e2T1+JsijFBSs9FkiIOESiQROOJUZRSLicTAkbQrhJsAvwkvNAHJCUns+EVlkZ8b2rynUJ3uxCCGwM6rZdKmOZsQ144BEfAXTcCzPC6EB1JfbLBqJdacv6u8VTJmyx1VS56QxbJGYTFhlF88yobsKJlN8HxXPLpoV9cpy6Y9DLR9Nj+IEL0QWarVbC7Vx5Dpj2gxmyMYRAHXFqPn9NQJfmtnzz1wiFec3BVSuKJS8f82VOH9iBFjCk/c+EpTqkYdldOKCB0GFY+knY4Ym/soDOZEVLdxteXSNlkSSbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/BPHwQK6RhV39CQbmdTgVpoLkkPcki07C1OWjtIF+mo=; b=wuEIxtGbDDibI/pcQAfkoylIoz6JShwh3YdYY4XtAGv1w2SZoXn582mhObuNU47F05rvDCgJ82cuRAPKgRMvFpvWFlUir6BpQu1MwIjp0HNqrBMJ8gJUbA9XA8QyoVIiA9+jifMFEGhYBZ2I0ZBWOemlNXFEF1MlvNXfEnrn4E7EIzuz0rU+DKTzs40NFvPEkKHaxIbOMf/w2EuhClcbtKTKjAN00jVCru2JMlqcQ4L7YyN59v6c1R55idxMfBbDQfneGNRWNNq7zVI/u7aahoFfNLx2DKTqT0uj6MHdSw0wwmMjJKl4Jx2f/veE1rweeMokxvWKk9vl2wTCogCkWQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Thu, 23 Feb 2023 11:11:32 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2 1/4] xen: introduce CONFIG_GENERIC_BUG_FRAME Content-Language: en-US To: Oleksii Cc: Stefano Stabellini , Gianluca Guida , George Dunlap , Julien Grall , Wei Liu , xen-devel@lists.xenproject.org, Andrew Cooper References: <214973b0-5fe7-9208-2cfc-dd2884583157@suse.com> From: Jan Beulich In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR0P281CA0149.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::16) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PA4PR04MB7664:EE_ X-MS-Office365-Filtering-Correlation-Id: 707d94c7-8afe-46e6-3c3a-08db1586584a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3aiIYkaWknBvtkezotQPHWT4i6HWIFJtKUJAkcNP1ol5Xcbimx6L5+F7EpGdRuNXGeJQafJTDdsCxqwIhgbarJbm8apPZjtOmC+6i43qd2lKOmKlTBplcsG7Co6zdrSGOVGFMGp+gaSCMRbS4OmaV8DxsldLrIk9YVZf6EshQhqBWZelhl8+pCleXOSyiy28nAAwD1qgIj79xAaOj1VQBeOjIk6l2JIQOhhntAZVarr99KfyJ5G0UoKqPUbgCj9C5f8bcoIFVSa4xPCqFQCPcwffiFo77gWQISxWiQIsH9sCMQx8XTE9at2o/krx6Erhhp3JmbwOMCo96E8p71XLjIIAlye3tpSQDsEH7zOxYC4gjFGuILPqfLbIorfta9oXYv57IbQCxDR5DzXY21un6bsZBFoLFwu9YxsxHQJtAYsB5FDLAsogR7wPhnnuE+yQYOEGe77bK0nZZq2RVInpRMcq/lS+YAIVo37rWaZCNhu4eA2jMTES9JKpYuY65teXRr+KkU1mkLXC22dhhXonBM0rGzcgE17nH+J9/PlJCieu19rzcz9/bRZMElV5UBi3QLK1+IXmQKZChV7+ITq5K+c1R+5aJkjl6aJVXUSYJUjVZl+++KuFvPFmPq3uh14kZgL1oHaPT9vUT4Z3uYQpyMAxzY+6P8oYIyEZXBety8nkSksvgvCLjhzUvEJFzfu+8CNY9Gtpq9roQJeMa/rbNIEomLy/WAiIr+uCXZ7l8dFt4JSfVZRzvSAvnw+L6LKMibYRLfDs63A/0coRNulhbfCDZ7/036RlDE/12wCE5fE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(366004)(136003)(346002)(396003)(39860400002)(451199018)(186003)(26005)(31686004)(5660300002)(2616005)(966005)(6486002)(6666004)(6512007)(6506007)(54906003)(53546011)(478600001)(316002)(66476007)(4326008)(6916009)(41300700001)(8936002)(8676002)(66556008)(66946007)(38100700002)(86362001)(36756003)(2906002)(31696002)(41533002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QXhrWnF1YWtMZklPMEk3UTNzc2NUWWtGWThIVlhEcFl4TjNpY3FzT215OFgz?= =?utf-8?B?QllGb1R1NFpla3d3WlBZTDVweGFlM1YzRWlVWU5iOGFyZWVib3haVHUxT0c5?= =?utf-8?B?djZFUnRhY3hFOEJRN3pOb2hQcUVLRkpqV0ZJMVFiWGFLV1JORCtnd3VGYVVT?= =?utf-8?B?S25LV3FENmFQNFduS1JRR1BhaXp1YjBlZG5JblhIL084VmVmV1phTGpGSTdo?= =?utf-8?B?c1dDV2hPbzg2c21LcTQ3MGxiT0lyT0FwdFV1Z3NXRkw2VThHNWNPSHgrNWFl?= =?utf-8?B?NXIvL2FTczRZZmkweVdrdkh4R2IzNzhvdW02bldXY1FKUnBrVHF6UTJQSXpL?= =?utf-8?B?bk11UW9RbmxKaDl5WVZGMGM2ZVVqTGxINUlMbHdsd0pmVWhZTm5RT2ZUci9H?= =?utf-8?B?UmZaTHlHYXZKdC9EaXZFL2JJUy9WZlMwZ29tcGNrWHRzM0FWdDRwMnZZVVdD?= =?utf-8?B?akRPaVg3QWJyW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ArczBjZ0ZrdWliWGZ6WHJEZ3NieGNCdUpxbDdYZ3FDUzlpZnJS?= =?utf-8?B?bnB6MFozN0c0SWlEeG9ZV0NYVUNJaXJnL1NXYStaNzhiZ2lhZGxwQ250QVJ0?= =?utf-8?B?eVdUeEMvSWpZeWlUaTRuS1IrQ1VHbUd6QnZxUndmcWpLL0JHd1k2eGRVQUU4?= =?utf-8?B?TzA2Y1hVSnR6WHNwQU9BbEtIc3pzUFQ1ODVJc2Vmbk5OcklpZVk5cWRxTFJI?= =?utf-8?B?b3VkcWdPMjAvUm85ZkJvdXE3czFJTURzNXdQMDlPZ1kyQThtMm5iemQ0SW14?= =?utf-8?B?L2hUcWF6cmEwTHZhWk84d05McUFydWtiRjR0NVZOWlViRXFpRmFTdkZmWEtX?= =?utf-8?B?aHArVmZWZDBZL0RJaDZkbCtmRHlhNzRualEyc2QvNGRqNUdHMURoaTI2Mk1w?= =?utf-8?B?bW5MRGtzSFdsdVAwK3B1cGgwK3RvbC9CUTllTDFOa2psUG1sNkk3TXh4MU9k?= =?utf-8?B?a2ZkN1MyMWZqWExYbkNaWTY2RUJIcEdJSkhSSVNNZHRWVzlmOFoyNE96Zmg3?= =?utf-8?B?ajZUK0UzQkhiemNxbFIzTjRJZ0lBR0U5M004ZVl4UkpKVm1mYk5HTFZNaHU3?= =?utf-8?B?VzFDN281S3VCSzkzQllRSmxTckIxVUZ1TUxCUjFDM1FZR2tBVDh2d3ZpSEc4?= =?utf-8?B?YnBiTlgxNmVlL1YybUdOSFozMzFJMDRmSE1ha3FzcWRZWHU1SDI4SUQ5R3Q4?= =?utf-8?Q?EX2PpRC6tb30ofk3KxhGPNFb9?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 707d94c7-8afe-46e6-3c3a-08db1586584a X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 10:11:35.5836 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VOTCA/yX7qzNaqkIbftQyc7vRvv2OtMq+s3UPuybqVUd4hbT+j4VndJXln5HaBcZhiwyRb+36I7kGjtHJptzOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7664 On 22.02.2023 17:16, Oleksii wrote: > On Wed, 2023-02-22 at 13:46 +0100, Jan Beulich wrote: >> On 20.02.2023 17:40, Oleksii Kurochko wrote: >>> --- /dev/null >>> +++ b/xen/common/bug.c >>> @@ -0,0 +1,113 @@ >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include >> >> Is this really needed here? > Yes, it is. > > Function show_execution_state() is declared in this header for all > architectures and is used by handle_bug_frame(). Ugly, but yes, you're right. >>> +const struct bug_frame* find_bug_frame(unsigned long pc, unsigned >>> int *id) >> >> Is this function going to be needed outside of this CU? IOW why is it >> not >> static? >> > It's not static because there is not possible to use do_bug_frame() as > is for x86 as x86 has some additional checks for some cases which > aren't in generic implementation: > [1] > https://gitlab.com/xen-project/people/olkur/xen/-/blob/staging/xen/arch/x86/traps.c#L1217 > [2] > https://gitlab.com/xen-project/people/olkur/xen/-/blob/staging/xen/arch/x86/traps.c#L1238 > [3] > https://gitlab.com/xen-project/people/olkur/xen/-/blob/staging/xen/arch/x86/traps.c#L1259 > > Probably to make generic do_bug_frame() more re-usable for x86 we can > implement as stubs fixup_exception_return() and debugger_trap_fatal() > under #ifndef X86 ... #endif inside common/bug.c. > > Could you please share your thoughts about that? Isn't all that's needed a suitable return value from the function, for the caller to take appropriate further action? (Maybe even that isn't really necessary.) That said, debugger_trap_fatal() imo may sensibly be generalized, and hence could be left in common code. Arm may simply stub this to nothing then for the time being. >>> +{ >>> +    const char *prefix = "", *filename, *predicate; >>> +    unsigned long fixup; >>> +    unsigned int lineno; >>> + >>> +    if ( id == BUGFRAME_run_fn ) >>> +    { >>> +#ifdef ARM        >> >> Who or what defines ARM? Anyway, seeing ... > it is defined by default in Kconfig: > https://gitlab.com/xen-project/people/olkur/xen/-/blob/staging/xen/arch/arm/Kconfig#L13 That'll be CONFIG_ARM then in uses in C code. >>> +        void (*fn)(const struct cpu_user_regs *) = (void *)regs- >>>> BUG_FN_REG; >> >> ... this, wouldn't it be better (and independent of the specific >> arch) if >> you checked for BUG_FN_REG being defined? > If I understand Kconfig correctly than there is no significant > difference what check. But probably BUG_FN_REG would be a little bit > better if someone will decide to change a way how pointer to function > will be passed in case of ARM than we will get compilation error and so > won't miss to fix the line in do_bug_frame(). Indeed - #ifdef like this one generally want to check for the precise aspect in question, without making assumptions about something implying something else. (Pretty certainly there are exceptions to this rule, but it holds here.) >>> +    ".p2align >>> 2\n"                                                          \ >>> +    >>> ".Lfrm%=:\n"                                                        >>>      \ >>> +    ".long (.Lbug%= - .Lfrm%=) + >>> %"MODIFIER"[bf_line_hi]\n"                  \ >>> +    ".long (%"MODIFIER"[bf_ptr] - .Lfrm%=) + >>> %"MODIFIER"[bf_line_lo]\n"       \ >>> +    ".if " #second_frame >>> "\n"                                               \ >>> +    ".long 0, %"MODIFIER"[bf_msg] - >>> .Lfrm%=\n"                               \ >>> +    >>> ".endif\n"                                                          >>>      \ >>> +    ".popsection\n" >> >> I think I said so in reply to an earlier version already: The moment >> assembly code moves to a common header, it should be adjusted to be >> as >> portable as possible. In particular directives should never start at >> the >> beginning of a line, while labels always should. (Whether .long is >> actually portable is another question, which I'll be happy to leave >> aside for now.) > I am not sure that I understand about which one directive we are > talking about... Are we talking about .{push/pop}section and .p2align? > Probably you can show me an example in Xen or other project? I'm talking about all directives here. Fundamentally assembly language source lines are like this (assuming colons follow labels): [