Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3807681pxk; Tue, 29 Sep 2020 06:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdiiaCKVmUnC91QagTsDupw+1YuOmyra3ZlH++WOGAK6cxRxR8FY8BEB0bqE25BlJKHRLv X-Received: by 2002:a05:6402:b9a:: with SMTP id cf26mr3240006edb.375.1601387417834; Tue, 29 Sep 2020 06:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601387417; cv=none; d=google.com; s=arc-20160816; b=Efp8mSzN2+TGBlgCBe88gzv8GzaggKflDyD7xOTaGj/pnLPgirTkzdu68+Mus6l9zQ cck0dEgksjhzMm3A53B3/nuuSotC+ZleFhOsueEhBKNRIAfQDTzHcmW5WMEx9m0Y2vfr dCHhLh9sVpsZoIq/b/xKjfmGXueP04nav7oRNVjFiKRNY4QzqTYUNVVbZy2rwnO4nDH/ DPh5x4+JfpQgMIIk0T1yKPY4s+eeP5qkZIILp581fNOVWWsANffN0Ql5c5pbmal+J2fg vIHLgbXM9YuYpokjQkUlivC+ppu7vZSqhWorFFQ60f3N3U/Q4PyH95YtsIxWKRL7qTP3 qWnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=IPm4tw86pN2WUua3zyIf+UMu5higdStDKbiJez1ULJI=; b=YohZTnQmhhmOz/n3fP+MpskEL/GOhVFMWRYrQx4LcQELv+mJnDEwhMlqu21m5+IEQc CrfzEywKMX6eVtJQkLgHTqvlyYn4c+gYnsHbnwZTvATTuyDfcJ9aoKt/IXV+YYvlUIs4 K2qSlaruu4WzyIbZvBgDgGqGCR/f8+wuNkJotGhjkLGGmZw8HPYiWexXxR1POrhiBccm 9FRVeBHDgbFGNrC4m1wnNYqGZdckbSOLc40ppctSEEUtVswL83nlGkhEkF49mt1SfJg+ Q01raZZXDOPGHh3vvmzCtZAsG/Ya4dBSFtyA+l3KNZTi5UCoU2tHnJA9XdlGY2oo3t6G HR5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bSfQ00UY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si3139748edl.230.2020.09.29.06.49.55; Tue, 29 Sep 2020 06:50:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bSfQ00UY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729243AbgI2Nsj (ORCPT + 99 others); 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-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?