Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2446586lqo; Mon, 20 May 2024 06:22:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOwjL9bukST+RhO8BRt4mC6cgI9uV7rxBzfkaI7vYgApLeo5t0OQMmN4DnlqzmlJuLyL9L7haTjWLo4S4Efny+ky7cE7kxjmqiRjrUpg== X-Google-Smtp-Source: AGHT+IH4Et/xR3DfYXk1dglGTt0+uZ0jyRU1J8kEozH+u/SuJmlGtIRqMcEVyBzcB+EiQkl0KUmT X-Received: by 2002:a0c:cd81:0:b0:6a3:434c:beec with SMTP id 6a1803df08f44-6a3434cc025mr168954576d6.32.1716211321186; Mon, 20 May 2024 06:22:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716211321; cv=pass; d=google.com; s=arc-20160816; b=SGbhXpxJoF5GJlBdJhW9EPeX1L/Y5QGW2z5JmQEbOyPyFd/MmBe/yp4n3jkOa7aDEJ Dh+JEMFxY3aOLn8a4zITblVcqkVNeSOCX1pOMVuBIy99qHXp8T8hZ36751hkjowdpzE4 IUGykA28Iq/Y4X7xNdwQNC/GOsJr5qudeo75BiVWsK+i4uleJ8Mb3Suom0XfJ74pWUe4 9ss4i2hVlh0xM9WjMkoLQrositWg1ULrj9wC9aUNvrptpiiGnm8KayA/tRruW9oZoWY8 GP0c24gNSaAWml8E8LFbFVYnfJPst3RzznmdCZcYxTgmjDkcr0SRyFBfH49v/SWTUq4L wtkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :cc:references:to:subject; bh=UgC4gxokttnGQew+TqtgDdCC7KsKLXO7HRugKuP4Or0=; fh=jfANlBTppjwt6sOsoNk+P23oRI9WNIhPxO/cQCDU8Sk=; b=CF/d0iSvLq5vl6h3iGctWNuz3nh043OhgqCVn0k/YrhDjgcKOqvlI0Z7sydaunHeGs Ra7/C7KpXo9kgk5wCFYWxx8GKrc+7qF4UxnnFFYaGVp2Bhjil8wYcaiebytqfSljK+hD qSYjuNOjnAJMZQHpEoqjN4pyRH7w6m+bC0IB2sAEEnZb7xPbsAeSJd3SZ0zG8ImNWPne mna16ckjqikQQpPiiRBA3JiMNY6PfvDl6E41XWXBwBtMw9gxpTgQ5LKfvHKnIt5jVJ+3 CrEHcG2q3LnUM/J0NvsiVzpC2BiTEPURJn7RMaN+xJDp+Eo2fEL0f+EhHUvbSgZEb5i1 tiYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-183784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f29afdasi100902216d6.288.2024.05.20.06.22.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 06:22:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-183784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E2F461C21AEE for ; Mon, 20 May 2024 13:22:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C991A135A7E; Mon, 20 May 2024 13:21:55 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49C5554FA1 for ; Mon, 20 May 2024 13:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716211315; cv=none; b=CcSqiv7tmbEgLLE/SmCA9uQrUZOgfIi0XdrMzW6gAArlm3vein7NN3RlcLDfZHi55hAeUteqXww8ZY4sazuhwiorlcbW+Y6CY7M216w1d2f7ppJ0TdwygIyWO37/2ssTX41Hiw4315R+d2qslFeL3Pger6bqS6rouiOLETgwKmI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716211315; c=relaxed/simple; bh=lFhFicoTUR0HTjRnwiKX7Nhd2JVpOUuOPHos2f7lCwo=; h=Subject:To:References:CC:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=lte8wTObOfx23ATsoWPN9x4l9/QYLtMTN9505D1fIr9nxe5XjsHQFpioUAQy5EpouZzkBVk8x+VYZqX+Q4x8EY5sYIYwz6AeS2k8fbMjSUh4VS92pBuiR7lgKKp7K+Wso6aay2kT04VQ8YrOm3LeLAMjfG0a4IJFD+p2CPCH2Uo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4VjdTp3zn5z1HCJF; Mon, 20 May 2024 21:20:14 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 8334B180062; Mon, 20 May 2024 21:21:44 +0800 (CST) Received: from [10.67.111.82] (10.67.111.82) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 20 May 2024 21:21:44 +0800 Subject: Re: [PATCH] arm64: asm-bug: Add .align 2 to the end of __BUG_ENTRY To: Li Zetao , Mark Rutland References: <1715955208-17109-1-git-send-email-xiaojiangfeng@huawei.com> <20d70835-9411-9a08-c567-56d7040e01dd@huawei.com> CC: , , , , , , , , , , , , "zhangjianhua (E)" From: Jiangfeng Xiao Message-ID: <876b3571-b7f5-03f1-5da2-07a2ec47ad08@huawei.com> Date: Mon, 20 May 2024 21:21:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20d70835-9411-9a08-c567-56d7040e01dd@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) On 2024/5/20 20:05, Li Zetao wrote: >>> diff --git a/arch/arm64/include/asm/asm-bug.h b/arch/arm64/include/asm/asm-bug.h >>> index c762038..6e73809 100644 >>> --- a/arch/arm64/include/asm/asm-bug.h >>> +++ b/arch/arm64/include/asm/asm-bug.h >>> @@ -28,6 +28,7 @@ >>> 14470: .long 14471f - .; \ >>> _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ >>> .short flags; \ >>> + .align 2; \ > The use of .align 2 here is based on the assumption that struct bug_entry is 4-byte aligned. Currently, there is no problem with this assumption, but for compatibility reasons, refer to the riscv architecture and refactor the implementation of __BUG_FLAGS: > > #define __BUG_FLAGS(flags) \ > do { \ > __asm__ __volatile__ ( \ > "1:\n\t" \ > "ebreak\n" \ > ".pushsection __bug_table,\"aw\"\n\t" \ > "2:\n\t" \ > __BUG_ENTRY "\n\t" \ > ".org 2b + %3\n\t" \ > ".popsection" \ > : \ > : "i" (__FILE__), "i" (__LINE__), \ > "i" (flags), \ > "i" (sizeof(struct bug_entry))); \ > } while (0) > > Align the real size of struct bug_entry through .org. What do you think? The implementation of risc-v BUG_ENTRY does handle the `implicit padding` at the end of the struct correctly, however, it does not handle the `implicit padding` in the middle of the struct correctly, for example, assume that the struct bug_entry changes as follows in the future: struct bug_entry { signed int bug_addr_disp; // 4 bytes unsigned short flags; // 2 bytes < implicit padding > // 6 bytes unsigned long long flags2; // 8 bytes } Even the implementation of risc-v BUG_ENTRY can't handle this situation. Referencing risc-v solution complicates things, but doesn't completely solve the problem. In the current scenario, we know the contents of struct bug_entry and generate variables using assembly language. I don't think it's necessary to complicate things.