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=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 E4FFFC433E0 for ; Fri, 8 Jan 2021 13:40:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 8546A2399A for ; Fri, 8 Jan 2021 13:40:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8546A2399A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=X2tvVjRDgofzxNp9qvWfp4n1EiKIw3dxM1xv/8Z4CcI=; b=o7gwjXXVdjfs7ZWeo5aA0iOe1 WMYdK6sX89lEyzUISbHqU/2cENiW//IVnD1YIwWD/zJIMJrPSUuFF4Ag5U3qyd404J9LaCCrlxShG ym+MbV89aN/dSbNykkLvfhmSfTD6VbyJFqOk1MEyL8gLq5mafaieODBrzJcZzjc2OxEjA3WZpGfeV 5OjB6HK4/TDE53bySfQD9ctp/j7waojZv+6+KsQYPTMvFvltYfcms9i1xnKznp68AqCBNexq1nK6m U/QfQN64Bt+t77DsM6N1305iFlML7yeT+KUNXvKjTsmUXDDA/r/YkcJMEyNO5TZA6zkmuooRTglJI +gRtW660Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxrxG-0001gT-F2; Fri, 08 Jan 2021 13:37:26 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxrwr-0001fp-GO for linux-arm-kernel@lists.infradead.org; Fri, 08 Jan 2021 13:37:02 +0000 Received: by mail-pl1-x631.google.com with SMTP id x12so5658260plr.10 for ; Fri, 08 Jan 2021 05:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2H4NRUpssxmHvO//onxHk/0LPtfW86OVu0j9eYubnLc=; b=SLY+QxdrqHdJ2uP5KNaiBHXk48J1xlfhCMQIVdxTzXaENX8pz32T0lesa+t0AWstHA ARdGIcwCAcMUYw3EG7rttfsxeRdwK+AnmQ3ErSrt+2TME17Z4+XNi/F2DBqfV9uJKRAa udyKmiOCfTjpxv5s4kAW833BX3PTrWacStDLcFUFT2UFPMjfUeLcTXKVsLvC/7ssD0C+ NNFFFuLp8KYEyD9oUg4ft529Pc9h7jr3B6kS2rmHFzcy2V3z/B98L8a/hWZcwyVhLnMs CBC3/eUZMyTO2i4qRv6d4o/78FtYTdKPGKx04E5N57UuSjV7X7ze3jv2ugfdvTZfeo/e X1dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2H4NRUpssxmHvO//onxHk/0LPtfW86OVu0j9eYubnLc=; b=NPn45fQH8U8G3FDWraJC7zQb0lqJTao1A7pOqkB2s/dVB/hSeVsI7CfgDPm4/7Xq2x WfO9UsA5vEcgKfAOdkm6hduQ7eCoogbQYHAX60A2v/HA1Ikd6iRpatG9Mmy6c3gz4Lhz PMUn7d/M2tVwNkf7BSMxv7zRMI96VvBt9cYnYz5vPFjL2oCO+9alkErVsrv9545ufU8p XGg2IVYaQPqFmtD3gI38N2/4ESS7sOj0TNOciqyJ2qoUZT+vFWcHgka/7aVrJl1hRPWJ vaZsmXLqMfIDUiIj9ydbjD1XENqbF5e04VKubK40J97g2ZAw5tjHtU1ukJOQbNqYM6zW qB8w== X-Gm-Message-State: AOAM533+CynMJbrlVZ/zt71U9a0xsVgBywh47DR9KpdAekihpQwHzSCN HjLHfcUQil3U6VwX9o9ZFc/7qQ/gPxvgEe0ooViwww== X-Google-Smtp-Source: ABdhPJzpTc0UQR+hgscAav0gZ5De9rk59XFTJC1VFhvY0Dfql8DGLIjtuXMtQBjGOFKQCOMvXn3p388NehqzJiu5ZJY= X-Received: by 2002:a17:902:9009:b029:dc:52a6:575 with SMTP id a9-20020a1709029009b02900dc52a60575mr3718033plp.57.1610113018926; Fri, 08 Jan 2021 05:36:58 -0800 (PST) MIME-Version: 1.0 References: <20210106115519.32222-1-vincenzo.frascino@arm.com> <20210106115519.32222-3-vincenzo.frascino@arm.com> In-Reply-To: From: Andrey Konovalov Date: Fri, 8 Jan 2021 14:36:47 +0100 Message-ID: Subject: Re: [PATCH 2/4] arm64: mte: Add asynchronous mode support To: Vincenzo Frascino X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210108_083701_566119_D6AD254E X-CRM114-Status: GOOD ( 28.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Branislav Rankov , Marco Elver , Catalin Marinas , Evgenii Stepanov , Will Deacon , LKML , kasan-dev , Alexander Potapenko , Linux ARM , Andrey Ryabinin , Dmitry Vyukov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jan 8, 2021 at 11:44 AM Vincenzo Frascino wrote: > > Hi Andrey, > > On 1/7/21 7:18 PM, Andrey Konovalov wrote: > >> Boolean arguments are generally bad for legibility, hence I tend to avoid them. > >> In this case exposing the constants does not seem a big issue especially because > >> the only user of this code is "KASAN_HW_TAGS" and definitely improves its > >> legibility hence I would prefer to keep it as is. > > > > I don't like that this spills KASAN internals to the arm64 code. > > Could you please elaborate a bit more on this? > > If I understand it correctly these enumerations I exposed are the direct > representation of a kernel command line parameter which, according to me, should > not be considered an internal interface. > Seems that in general the kernel subsystems expose the interface for the > architectures to consume which is the same design pattern I followed in this case. It's fine from the point of view of kernel interfaces and such, but not from a higher-level design perspective. I think the best way to approach the KASAN-MTE architecture is: 1. arm64 code provides API to enable, disable and otherwise work with MTE, and 2. KASAN builds on top of this API to implement the logic of the bug detector, including which APIs to use. Part #2 includes making the decisions about which mode - sync or async - to use and when. And that mode is chosen by KASAN code based on the command line configs. With your current approach, the active decision about enabling sync/async is made by the arm64 code, and that doesn't fit within this architecture. But having a decisionless arm64 API to choose the MTE mode and using it from KASAN code would fit. > > Let's add another enum with two values and pass it as an argument then. > > Something like: > > > > enum mte_mode { > > ARM_MTE_SYNC, > > ARM_MTE_ASYNC > > } > > I had something similar at the beginning of the development but I ended up in a > situation in which the generic kasan code had to know about "enum mte_mode", > hence I preferred to keep kasan agnostic to the hw implementation details. > > What do you think? Perhaps we could add a generic arch-agnostic enum to include/linux/kasan.h and use it in both arm64 and KASAN code? enum kasan_hw_tags_mode { KASAN_HW_TAGS_SYNC, KASAN_HW_TAGS_ASYNC } Assuming other architectures that support memory tagging will end up with sync/async mode separation as well, this should work. But even if that doesn't happen, this interface can be adjusted later. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel