Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbdHNSvH (ORCPT ); Mon, 14 Aug 2017 14:51:07 -0400 Received: from mail-qk0-f178.google.com ([209.85.220.178]:35854 "EHLO mail-qk0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896AbdHNSvF (ORCPT ); Mon, 14 Aug 2017 14:51:05 -0400 Subject: Re: [PATCH v5 02/10] mm, x86: Add support for eXclusive Page Frame Ownership (XPFO) To: Tycho Andersen , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, kernel-hardening@lists.openwall.com, Marco Benatto , Juerg Haefliger , Juerg Haefliger References: <20170809200755.11234-1-tycho@docker.com> <20170809200755.11234-3-tycho@docker.com> From: Laura Abbott Message-ID: Date: Mon, 14 Aug 2017 11:51:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170809200755.11234-3-tycho@docker.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2217 Lines: 86 On 08/09/2017 01:07 PM, Tycho Andersen wrote: > diff --git a/mm/xpfo.c b/mm/xpfo.c > new file mode 100644 > index 000000000000..3cd45f68b5ad > --- /dev/null > +++ b/mm/xpfo.c > @@ -0,0 +1,208 @@ > +/* > + * Copyright (C) 2017 Hewlett Packard Enterprise Development, L.P. > + * Copyright (C) 2016 Brown University. All rights reserved. > + * > + * Authors: > + * Juerg Haefliger > + * Vasileios P. Kemerlis > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License version 2 as published by > + * the Free Software Foundation. > + */ > + > +#include > +#include > +#include > +#include > + > +#include > + > +/* XPFO page state flags */ > +enum xpfo_flags { > + XPFO_PAGE_USER, /* Page is allocated to user-space */ > + XPFO_PAGE_UNMAPPED, /* Page is unmapped from the linear map */ > +}; > + > +/* Per-page XPFO house-keeping data */ > +struct xpfo { > + unsigned long flags; /* Page state */ > + bool inited; /* Map counter and lock initialized */ > + atomic_t mapcount; /* Counter for balancing map/unmap requests */ > + spinlock_t maplock; /* Lock to serialize map/unmap requests */ > +}; > + > +DEFINE_STATIC_KEY_FALSE(xpfo_inited); > + > +static bool xpfo_disabled __initdata; > + > +static int __init noxpfo_param(char *str) > +{ > + xpfo_disabled = true; > + > + return 0; > +} > + > +early_param("noxpfo", noxpfo_param); > + > +static bool __init need_xpfo(void) > +{ > + if (xpfo_disabled) { > + printk(KERN_INFO "XPFO disabled\n"); > + return false; > + } > + > + return true; > +} > + > +static void init_xpfo(void) > +{ > + printk(KERN_INFO "XPFO enabled\n"); > + static_branch_enable(&xpfo_inited); > +} > + > +struct page_ext_operations page_xpfo_ops = { > + .size = sizeof(struct xpfo), > + .need = need_xpfo, > + .init = init_xpfo, > +}; > + > +static inline struct xpfo *lookup_xpfo(struct page *page) > +{ > + return (void *)lookup_page_ext(page) + page_xpfo_ops.offset; > +} lookup_page_ext can return NULL so this function and its callers need to account for that. Thanks, Laura