From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EB13C433E0 for ; Wed, 20 Jan 2021 18:20:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CA12D233ED for ; Wed, 20 Jan 2021 18:20:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA12D233ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.71713.128649 (Exim 4.92) (envelope-from ) id 1l2I5l-0001a6-S7; Wed, 20 Jan 2021 18:20:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 71713.128649; Wed, 20 Jan 2021 18:20:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l2I5l-0001Zz-O3; Wed, 20 Jan 2021 18:20:29 +0000 Received: by outflank-mailman (input) for mailman id 71713; Wed, 20 Jan 2021 18:20:28 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l2I5k-0001Zu-6p for xen-devel@lists.xenproject.org; Wed, 20 Jan 2021 18:20:28 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l2I5h-0006t7-UN; Wed, 20 Jan 2021 18:20:25 +0000 Received: from [54.239.6.186] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l2I5h-0003Jp-M9; Wed, 20 Jan 2021 18:20:25 +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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=ojQlBruuLx0KuV3n0WgowvgB3GXL8aO4Ea58rni+Oe4=; b=4iRNUvBpU+PIYl1DdUR93LHTp4 9QTFr+q/F5UtdboPFYhhEGBpOYYa5pBDqr2kKt4WiKpp8ydZfGSvu27JmckflSaEVPqlR3ZX3sTgs 2GTjVRw0w4v3QuMg7nwm6tJp4KKFR0FadyDyYEHZbATNBXhg67xA8Nt7oTGVGQXJUDVA=; Subject: Re: [PATCH v6 1/3] xen/arm: add support for run_in_exception_handler() To: Juergen Gross , xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Wei Liu References: <20210116103339.21708-1-jgross@suse.com> <20210116103339.21708-2-jgross@suse.com> From: Julien Grall Message-ID: <4e8cc6e6-dc55-6dda-ffbc-6487e45d5aaf@xen.org> Date: Wed, 20 Jan 2021 18:20:23 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210116103339.21708-2-jgross@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Hi Juergen, On 16/01/2021 10:33, Juergen Gross wrote: > Add support to run a function in an exception handler for Arm. Do it > as on x86 via a bug_frame, but pass the function pointer via a > register (this needs to be done that way, because inline asm support > for 32-bit Arm lacks the needed functionality to reference an > arbitrary function via the bugframe). I was going to commit the series, but then realized the commit message and comment needs some tweaking because technically GCC is supporting 'i' (I managed to get it working with -fno-pie). So how about: "This is needed to be done that way because GCC complains about invalid constraint when using a function pointer with "i" and PIE is enabled (default on most of GCC shipped with distro). Clang happily accepts it, so it may be a bug in GCC." > +/* > + * Unfortunately gcc for arm 32-bit doesn't support the "i" constraint, so > + * the easiest way to implement run_in_exception_handler() is to pass the > + * to be called function in a fixed register. > + */ This comment should also be updated. I can update both while committing if you are happy with the change. > +#define run_in_exception_handler(fn) do { \ > + asm ("mov " __stringify(BUG_FN_REG) ", %0\n" \ > + "1:"BUG_INSTR"\n" \ > + ".pushsection .bug_frames." __stringify(BUGFRAME_run_fn) "," \ > + " \"a\", %%progbits\n" \ > + "2:\n" \ > + ".p2align 2\n" \ > + ".long (1b - 2b)\n" \ > + ".long 0, 0, 0\n" \ > + ".popsection" :: "r" (fn) : __stringify(BUG_FN_REG) ); \ > +} while (0) > + > #define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, "") > > #define BUG() do { \ > @@ -73,7 +91,8 @@ struct bug_frame { > extern const struct bug_frame __start_bug_frames[], > __stop_bug_frames_0[], > __stop_bug_frames_1[], > - __stop_bug_frames_2[]; > + __stop_bug_frames_2[], > + __stop_bug_frames_3[]; > > #endif /* __ARM_BUG_H__ */ > /* > Cheers, -- Julien Grall