Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp827840ybi; Fri, 14 Jun 2019 04:07:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWAfqNEOy4RrXD4psEYA/GdIASfNkHm1IZ3Dfo6yDLboX6QVvoWRToG9gjLomWTHuP82Tg X-Received: by 2002:a63:3142:: with SMTP id x63mr13493236pgx.105.1560510461201; Fri, 14 Jun 2019 04:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560510461; cv=none; d=google.com; s=arc-20160816; b=pauXchgYKom1UrBoECwJDebzDIa+0Su1UOmBk7mcZPgk+PDLt25AIR9QsXE1PRVuyW t//MH5289bC5KoEZIKrh8VKXgDON9NefXmFG8+dN/X8enFb4APGhzgODEY2IJzugDiqx chE+AJrDv77QQoiqad3XIYUwvZjajy4obs1QjqwFATNmHh2pjtP8MtGlpNnh1v2j93TW 8kx5CChNazdHSLZdYasscUYd7LuGYQ1RBxxb2QNZqmDJH6xWfH3MDS6FotHfpeBcVGj+ Tp0x/22bLZQZtjbwy+42IUDfbo9+4NIQMyzew//jh493cTAW8UICn4rgIxkw72qxxho/ jkcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=E87CowIp+htiYTGS6CsPTPTEGv8n2gNXy2U9+KLGIFs=; b=CIrIqZYhPBMHzfHCifsfpUEMEZt2VfqG6XcHYf78sig8rL6ojD6bflOkrQD+5GIyr8 HuqFLdMj/EojldjlOX+7H56x1eFKm5ARRT+vCv0y8xFU9K6tikzQokyz634aDmzpSfVr l60IRs/Heph8hBpASY3Ab6j8uY49eIZU8CW5q0jYa7YQr+DSpy6CrzXKL6Ouvzwi1eAU pZWdi7t1/TtsJPEjCDkxcVMktrQv2J1mPpaBe9FFOyh10O31sNlaZakMtsjCQy85/JfP xYFzJTcCw1qcdU80vmudQ4z1GfhVXV0S9HD+/8FUl4KR203TqW8qohJEVm0oNp5npo6g MKKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=0cz3WNC1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s129si2238910pgs.436.2019.06.14.04.07.24; Fri, 14 Jun 2019 04:07:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=0cz3WNC1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727345AbfFNLFQ (ORCPT + 99 others); Fri, 14 Jun 2019 07:05:16 -0400 Received: from merlin.infradead.org ([205.233.59.134]:37538 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727162AbfFNLFP (ORCPT ); Fri, 14 Jun 2019 07:05:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=E87CowIp+htiYTGS6CsPTPTEGv8n2gNXy2U9+KLGIFs=; b=0cz3WNC1WoJh9tx/1EngoYVrj 5upJl14QfanK6cDpB5fCGNRv5B3ME4jKW4uShU0mPxNf1ByhA3yS71ZijaxYowR3yVkRJuwr+r13z DPrnvz8ByacVbE+PhTrPw2kEhfxMZ0twHAlKKHBsllzQLb/xHv5SaUUk4BdaxVuH3XlzTbUqW5+v6 Bu6c90dPPkaM+lRb5Xy8hVVkgkHjzqFA8tSogeh10XgLVxB0x0/43FodCOEDqtjTn/+Za5VcuOzl4 fRaZ/IhRtLbrICoDIv2pYyqBtKLXX5G6XVYDsIaUAvPPZ9KTtqC9MPOQDESxPDCUnrg749HYny8zZ X5CGE4h7g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbk0z-000724-Gu; Fri, 14 Jun 2019 11:05:01 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1AD9B20A29B4F; Fri, 14 Jun 2019 13:04:58 +0200 (CEST) Date: Fri, 14 Jun 2019 13:04:58 +0200 From: Peter Zijlstra To: "Kirill A. Shutemov" Cc: Andrew Morton , x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Andy Lutomirski , David Howells , Kees Cook , Dave Hansen , Kai Huang , Jacob Pan , Alison Schofield , linux-mm@kvack.org, kvm@vger.kernel.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH, RFC 13/62] x86/mm: Add hooks to allocate and free encrypted pages Message-ID: <20190614110458.GN3463@hirez.programming.kicks-ass.net> References: <20190508144422.13171-1-kirill.shutemov@linux.intel.com> <20190508144422.13171-14-kirill.shutemov@linux.intel.com> <20190614093409.GX3436@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190614093409.GX3436@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 14, 2019 at 11:34:09AM +0200, Peter Zijlstra wrote: > On Wed, May 08, 2019 at 05:43:33PM +0300, Kirill A. Shutemov wrote: > > > + lookup_page_ext(page)->keyid = keyid; > > + lookup_page_ext(page)->keyid = 0; Also, perhaps paranoid; but do we want something like: static inline void page_set_keyid(struct page *page, int keyid) { /* ensure nothing creeps after changing the keyid */ barrier(); WRITE_ONCE(lookup_page_ext(page)->keyid, keyid); barrier(); /* ensure nothing creeps before changing the keyid */ } And this is very much assuming there is no concurrency through the allocator locks.