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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46619C433F5 for ; Fri, 22 Apr 2022 17:45:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231503AbiDVRsT (ORCPT ); Fri, 22 Apr 2022 13:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234421AbiDVRru (ORCPT ); Fri, 22 Apr 2022 13:47:50 -0400 Received: from mail-vs1-f53.google.com (mail-vs1-f53.google.com [209.85.217.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA930DF0 for ; Fri, 22 Apr 2022 10:44:55 -0700 (PDT) Received: by mail-vs1-f53.google.com with SMTP id v133so8089631vsv.7 for ; Fri, 22 Apr 2022 10:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1B5OLyPzDad+a9/JvoswRLL9dkqWt3XLCqj2yVlzJ3g=; b=EXx39caVzrDVxXmzeFHNJ/VpA0Vf9nhcaUODJblSmmzfQCqSIclIq3k/72jlhOe7xU mxS7DiSX8wD9WeA0yp1NbvWAVdMNUxuU4gaIzQh8JJ8fyCnu0l5lwI1ZT5DQmvo3o/GL giMkmhaOpRIcD3Pxc/WQ0G8uNs49u4slv1VqwwKj8ILUDMpg4P2Gy0pNs+Rl8wxHkt2u AaT3fwMdeZX7l84TVbveI7BoObbfwdo20kpJqU2PgPdBHaSHTHXSz6+BpCsCPepPwYib Pzvv+mS2caK2fXnFrZHgiNJflVFXQzaIMwIiG9huu4nfjIBK80wyF276rcBbBNxqduav T9FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1B5OLyPzDad+a9/JvoswRLL9dkqWt3XLCqj2yVlzJ3g=; b=gHUKOTnutZmbtAq4dNMcb1RbeiWakWEH1gHQ4Jc13KG6xfn5VZhN1LrdH7cLrXncW3 CKXzYEeFNkQHxBvGOdTxv5jb3JCH60yj25QgiGQBRVv+Gfgqp6WIZcfp1r226UQn6jAX OSVi0zx1h+bppfu7XgiSbncIfcj1Iq4+18AdS/RfmIXZvjm81OLdLsOFnJeO8eb6aba0 qnHxV743zD4aYXhjwpAAjmHCV+7AJqD0zmTTZAJCindmrq2EVL2wrMBrpTeDjuYhweqy 86yuMoSMJqqs6D+Zs+DjikAsenDsEQKbELZkCyjzcfwC76rBSUIeKk4PIRLMTQFdzoqI q+NQ== X-Gm-Message-State: AOAM532vtIMTBqtxqFNtldSODB9Zuce1vMJi4Z3nvXxm1zv3HnTkT+2z 2jtcjo4YhO3FAal9MgDKZJ9qa9iqTTfylm+1ovIonw== X-Google-Smtp-Source: ABdhPJy/drKzRgAnJKsyet9UFIFe9YFVUJ6n+nx0nVlvY8ge39RLxem+hEvlIrX4RwcQ7fJ7ieneEfTfETa2SyrnmFY= X-Received: by 2002:a05:6102:390e:b0:324:c2b1:f077 with SMTP id e14-20020a056102390e00b00324c2b1f077mr1825856vsu.67.1650649219372; Fri, 22 Apr 2022 10:40:19 -0700 (PDT) MIME-Version: 1.0 References: <20220421031738.3168157-1-pcc@google.com> In-Reply-To: From: Peter Collingbourne Date: Fri, 22 Apr 2022 10:40:08 -0700 Message-ID: Subject: Re: [PATCH] mm: make minimum slab alignment a runtime property To: Andrey Konovalov Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrew Morton , Linux ARM , Linux Memory Management List , Linux Kernel Mailing List , Vlastimil Babka , Pekka Enberg , cl@linux.org, roman.gushchin@linux.dev, Joonsoo Kim , David Rientjes , Catalin Marinas , Herbert Xu , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev , Eric Biederman , Kees Cook Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 22, 2022 at 9:09 AM Andrey Konovalov wrote: > > On Fri, Apr 22, 2022 at 2:39 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > > > > > kasan_hw_tags_enabled() is also false when kasan is just not initialized yet. > > > > What about writing a new helper something like kasan_is_disabled() > > > > instead? > > > > > > The decision of whether to enable KASAN is made early, before the slab > > > allocator is initialized (start_kernel -> smp_prepare_boot_cpu -> > > > kasan_init_hw_tags vs start_kernel -> mm_init -> kmem_cache_init). If > > > you think about it, this needs to be the case for KASAN to operate > > > correctly because it influences the behavior of the slab allocator via > > > the kasan_*poison* hooks. So I don't think we can end up calling this > > > function before then. > > > > Sounds not bad. I wanted to make sure the value of arch_slab_minaligned() > > is not changed during its execution. > > > > Just some part of me thought something like this would be more > > intuitive/robust. > > > > if (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF) > > return MTE_GRANULE_SIZE; > > else > > return __alignof__(unsigned long long); > > Hi Hyeonggon, > > We could add and use kasan_hw_rags_requested(), which would return > (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF). > > However, I'm not sure we will get a fully static behavior: > systems_supports_mte() also only starts returning proper result at > some point during CPU bring-up if I'm not mistaken. > > Thanks! Yes, either way we are going to rely on something that hasn't obviously been initialized yet, so I think we should stick with what I have since it's used by the rest of the KASAN code as well. Peter 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E93DBC433EF for ; Fri, 22 Apr 2022 17:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc: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=jKewDIIFcF3+DFWn5lc5YglttK5YKVxql17nvT109AU=; b=GEko0rAb8v/wrj WlpBQEeHXBhfM5gVWApfyHFhvqJgCHcXwrPRE0i/H68zpS+LaDQJahG3Gr1GOfH3G8k12VulZXEtM OsyqRl4G+an2akNRStsNAIt4F5DeacpHiC5kaWcnOZMUynBibHlmlAPuqQazZy+uDj7/bD40KGEmd pWA41J+orguSbVlQXbeb+apQDHf3QcgxMqy0TI8sSkIyJV89PJJ0Z1l1FyX4qZp04mBqVLIMLpGUu Q+FiXKpU9IrcbDcpNqdsb89XXm/4zHB8nxJ/s9eBdoN40X/buLrwwFdaCtefkaqgMDe6x0jZ3htd5 u0olbI3e5E/0zalIr1qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhxGj-001pjQ-6f; Fri, 22 Apr 2022 17:40:33 +0000 Received: from mail-vs1-xe32.google.com ([2607:f8b0:4864:20::e32]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhxGf-001pho-SZ for linux-arm-kernel@lists.infradead.org; Fri, 22 Apr 2022 17:40:31 +0000 Received: by mail-vs1-xe32.google.com with SMTP id m14so8092092vsp.11 for ; Fri, 22 Apr 2022 10:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1B5OLyPzDad+a9/JvoswRLL9dkqWt3XLCqj2yVlzJ3g=; b=EXx39caVzrDVxXmzeFHNJ/VpA0Vf9nhcaUODJblSmmzfQCqSIclIq3k/72jlhOe7xU mxS7DiSX8wD9WeA0yp1NbvWAVdMNUxuU4gaIzQh8JJ8fyCnu0l5lwI1ZT5DQmvo3o/GL giMkmhaOpRIcD3Pxc/WQ0G8uNs49u4slv1VqwwKj8ILUDMpg4P2Gy0pNs+Rl8wxHkt2u AaT3fwMdeZX7l84TVbveI7BoObbfwdo20kpJqU2PgPdBHaSHTHXSz6+BpCsCPepPwYib Pzvv+mS2caK2fXnFrZHgiNJflVFXQzaIMwIiG9huu4nfjIBK80wyF276rcBbBNxqduav T9FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1B5OLyPzDad+a9/JvoswRLL9dkqWt3XLCqj2yVlzJ3g=; b=inp2x8VgA6wWFVtGrx3lsiXq9Iog3sMDIwJnp3PZDj1v4KRN7+E9P4FqF/cvXbZtBM jrnAXD5qv96RiAseBXCk7fV6aIJFvuGY0n22glX5BgbliHo7TV3JfA33+BCrgWI8Rbn1 UPylzAqJ5ZPpHb6sr0rEayRAED3sANBFXxjetbSh58pgEzZVb1lBFteNzm63rmY6Ffo7 B4WJRg9uTA8r2SU4lkMdb8sNSPqdUjVrR8lLY38KTjBSjt6nfqMQMxdTAdKRaTeHi/9d uBJW5swOhikf9N8iJG7RP7cu07fNXdqmtIT2srOWB7qDorUCMHXSNlMSkrnVnwwKi/ux 0lnQ== X-Gm-Message-State: AOAM5322LvuG8IrElzxGZwniSp08UEgfCXCV1LjelhFq9c9zB73/3sBa +kropZJCUU2Bn46nY3hU8PeahhWKeMfk0lP7PPnt7A== X-Google-Smtp-Source: ABdhPJy/drKzRgAnJKsyet9UFIFe9YFVUJ6n+nx0nVlvY8ge39RLxem+hEvlIrX4RwcQ7fJ7ieneEfTfETa2SyrnmFY= X-Received: by 2002:a05:6102:390e:b0:324:c2b1:f077 with SMTP id e14-20020a056102390e00b00324c2b1f077mr1825856vsu.67.1650649219372; Fri, 22 Apr 2022 10:40:19 -0700 (PDT) MIME-Version: 1.0 References: <20220421031738.3168157-1-pcc@google.com> In-Reply-To: From: Peter Collingbourne Date: Fri, 22 Apr 2022 10:40:08 -0700 Message-ID: Subject: Re: [PATCH] mm: make minimum slab alignment a runtime property To: Andrey Konovalov Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrew Morton , Linux ARM , Linux Memory Management List , Linux Kernel Mailing List , Vlastimil Babka , Pekka Enberg , cl@linux.org, roman.gushchin@linux.dev, Joonsoo Kim , David Rientjes , Catalin Marinas , Herbert Xu , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev , Eric Biederman , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220422_104029_959132_D2AFA803 X-CRM114-Status: GOOD ( 25.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, Apr 22, 2022 at 9:09 AM Andrey Konovalov wrote: > > On Fri, Apr 22, 2022 at 2:39 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > > > > > kasan_hw_tags_enabled() is also false when kasan is just not initialized yet. > > > > What about writing a new helper something like kasan_is_disabled() > > > > instead? > > > > > > The decision of whether to enable KASAN is made early, before the slab > > > allocator is initialized (start_kernel -> smp_prepare_boot_cpu -> > > > kasan_init_hw_tags vs start_kernel -> mm_init -> kmem_cache_init). If > > > you think about it, this needs to be the case for KASAN to operate > > > correctly because it influences the behavior of the slab allocator via > > > the kasan_*poison* hooks. So I don't think we can end up calling this > > > function before then. > > > > Sounds not bad. I wanted to make sure the value of arch_slab_minaligned() > > is not changed during its execution. > > > > Just some part of me thought something like this would be more > > intuitive/robust. > > > > if (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF) > > return MTE_GRANULE_SIZE; > > else > > return __alignof__(unsigned long long); > > Hi Hyeonggon, > > We could add and use kasan_hw_rags_requested(), which would return > (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF). > > However, I'm not sure we will get a fully static behavior: > systems_supports_mte() also only starts returning proper result at > some point during CPU bring-up if I'm not mistaken. > > Thanks! Yes, either way we are going to rely on something that hasn't obviously been initialized yet, so I think we should stick with what I have since it's used by the rest of the KASAN code as well. Peter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel