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=-11.9 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 3C8FAC4727C for ; Tue, 29 Sep 2020 13:48:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9C8A2145D for ; Tue, 29 Sep 2020 13:48:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bSfQ00UY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729865AbgI2Nsj (ORCPT ); Tue, 29 Sep 2020 09:48:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728367AbgI2Nsj (ORCPT ); Tue, 29 Sep 2020 09:48:39 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3234BC061755 for ; Tue, 29 Sep 2020 06:48:39 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id bw23so2702761pjb.2 for ; Tue, 29 Sep 2020 06:48:39 -0700 (PDT) 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=IPm4tw86pN2WUua3zyIf+UMu5higdStDKbiJez1ULJI=; b=bSfQ00UYm4VoJlquAI7V6jVEQo4rLlwg3aERyFQwm5d2bcD2RuSliJPcyonBtdq/ZN VvtPxIglw3bP70TwMysOCQigvfrpJG5cVvoGzuxUOz7ebd0+R2+WOVxDLfja2EdFIw86 oHju9/tu+hGRSe9XSlz1mv37TYzGHHLo4MOIeW6BT9yq9OAOppmMVmVdbr59zPAquJ0Q zIkQ3Jje0wj7eyMksGfm8fCOIsbSb8gjJJqa/fCHSQ1EYhDH+S9HIJvVGKkVpicjB299 UPjQVRx2K+46bs+6lG7chdR0y5VBQTLqBCRUr0knfqDC/5w+scyhixQ/3URhOBW5mDq2 naWQ== 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=IPm4tw86pN2WUua3zyIf+UMu5higdStDKbiJez1ULJI=; b=EAq/id+fS9sFHGH9bPpQNIgOyA9+1E2IviiHkfCFwzXlFWsywT8fvffPjZFIMF8qVn uXkUYHi6Awt4aPPHBD239+YyMjzFwnWCYfqUa22hnfmxMuvY7rcsf+3C1jguXjDhAfQl ZeE3MRqK4AfWDF7n9TvK5B8ORMVFicTLsjfAQILC7KZ29eir1kY6RcwKBBWUaxL5dNap WRtixyXjGS3ed7PQ/83XMS/NMzeGYY/ADEE6HLhVY/H+156BUOU/GqjKHLTOJyV98O4p KWS0pMF9nWuQ4UqFjk5ujQEqTAxqErplPzPvn4I+bRbZ9efgKQrg7OrOUFsCkyv58aPM rFIg== X-Gm-Message-State: AOAM531ty12ibK6bZ4Ximly2m2FosJBBFfT1OoaGbj8JoZIhjDyr0Z75 +IiHAZlvCkUfwAbGQAJvuxLpr3BVZkifQlgmyVwtMw== X-Google-Smtp-Source: ABdhPJw47F0+7jUDxETZXpy6HGkN76Pw3ijxd4TL/rithtPlxyOge6EdgdmYyxt2sw1OTCcxptDiCw/No4O/AUpJpcs= X-Received: by 2002:a17:90a:81:: with SMTP id a1mr3910753pja.136.1601387318512; Tue, 29 Sep 2020 06:48:38 -0700 (PDT) MIME-Version: 1.0 References: <20200921132611.1700350-1-elver@google.com> <20200921132611.1700350-2-elver@google.com> <20200929131135.GA2822082@elver.google.com> In-Reply-To: <20200929131135.GA2822082@elver.google.com> From: Andrey Konovalov Date: Tue, 29 Sep 2020 15:48:27 +0200 Message-ID: Subject: Re: [PATCH v3 01/10] mm: add Kernel Electric-Fence infrastructure To: Marco Elver Cc: Andrew Morton , Alexander Potapenko , "H. Peter Anvin" , "Paul E . McKenney" , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Christoph Lameter , Dave Hansen , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Hillf Danton , Ingo Molnar , Jann Horn , Jonathan.Cameron@huawei.com, Jonathan Corbet , Joonsoo Kim , Kees Cook , Mark Rutland , Pekka Enberg , Peter Zijlstra , sjpark@amazon.com, Thomas Gleixner , Vlastimil Babka , Will Deacon , "the arch/x86 maintainers" , "open list:DOCUMENTATION" , LKML , kasan-dev , Linux ARM , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 3:11 PM Marco Elver wrote: > > On Tue, Sep 29, 2020 at 02:42PM +0200, Andrey Konovalov wrote: > [...] > > > + */ > > > + index = (addr - (unsigned long)__kfence_pool) / (PAGE_SIZE * 2) - 1; > > > > Why do we subtract 1 here? We do have the metadata entry reserved for something? > > Above the declaration of __kfence_pool it says: > > * We allocate an even number of pages, as it simplifies calculations to map > * address to metadata indices; effectively, the very first page serves as an > * extended guard page, but otherwise has no special purpose. > > Hopefully that clarifies the `- 1` here. So there are two guard pages at the beginning and only then a page that holds an object?