Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1463440imm; Thu, 19 Jul 2018 02:01:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfWh8XpkV6mY86851vUpyV7UJfFE/5w0Isckvv4iu0CVnuQHMtD1Nq6wPMwWqce/JkNUmx5 X-Received: by 2002:a63:338e:: with SMTP id z136-v6mr8915180pgz.171.1531990872905; Thu, 19 Jul 2018 02:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531990872; cv=none; d=google.com; s=arc-20160816; b=NNeQ2NWZgkbSBQ+CmjUcX7q+hNd/NyP2kGkx1ibMR+MmetOIq5ZG0loqHQU1tfMSyk o6bHqZKbGlCdWbJrkOA2qK7wrOvedSdBukaGxsfU1/bx+/xQQLyvaWVXaZBpSFFAvWTw DZyQvh5cBs0ZC+0Aylxm3w1THZUi2H+/l45gDGgJoGKKgQZrDzCz39MAYKtofxYS83xp oI6UF+q2TFMc3r8LTKLrwOf0x1d1xQc92TXBwSecJaLsV4jjVHdK8ektw23+DZ7+20px OPmP0pW0CMkGodfiIw2Q8AMyouWiXWM+c09KbDRt9OLeqB64nTstcnMVW4BiS3MID0t9 0Ydg== 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:arc-authentication-results; bh=h5ISeWJc/srOmvhxo0cGjvHRvpk3elP4jyhkDgdH15U=; b=JteyrZmk2UWpJG3b/hzinCQvW927HaoRj0DxGYSQdk5mfeAmgV3xM9GObOwtYEsquF Vwu6hnmO1pd2wUrgCvMQUmLYeDugGRugzuHe8EgVSzEoEEfD8ULpoKzL/c1JDwNBKAWB TTP/PQoAKlCIJERUHEiOCuBM0ZcFHYF6b99O4NWHOkCuPbj7bfo7Y52FMkSYoOwlpojQ DCFki1lvC+cD0a+haaPUDYJuUdpWVcyooPr2F/NBxejf1q10+SKBiUghXo0mMGy4klPZ olvj70sTjW/M1BoL4YGBdsOFZApvyGbq7wfim8dBa4Hl0oIe53C7xTrDMvnwCgscYsv8 0oqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=z3W4dQU2; 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 70-v6si4521710ple.157.2018.07.19.02.00.58; Thu, 19 Jul 2018 02:01:12 -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=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=z3W4dQU2; 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 S1727508AbeGSJlR (ORCPT + 99 others); Thu, 19 Jul 2018 05:41:17 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:43642 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726975AbeGSJlR (ORCPT ); Thu, 19 Jul 2018 05:41:17 -0400 Received: by mail-pl0-f67.google.com with SMTP id o7-v6so3337933plk.10 for ; Thu, 19 Jul 2018 01:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=h5ISeWJc/srOmvhxo0cGjvHRvpk3elP4jyhkDgdH15U=; b=z3W4dQU2i2xzfSiTY1e2bS+gyKQGTxCISODetkJJP4vIQa9nI66XlfMp3WEwAsQNhu TRyOHAK23yhhTfbK/P8gSyZrf106ZgzPolV6+PdoSuwtmX0bYgMS8GUuAF9VGh2Ivt0K FaEsq3EAuijGRVzfEFbI9MhdShpWirdElMFRjmoqgdVCcsJykDojDABy7ze1xRnIhfMW S3e6OzxtgRc6fii7GjvwVLMSqBjf/2cAgxdwmGBzXUfCPH2Q+CHLvs6Ej0Yru37K6iYN NiRutIBNRzKD1dpkDFRXE5Xlf38VvGxErnqqVZxG8FOVnMYs1jKymFE7qpVOvWORf4mn MQHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=h5ISeWJc/srOmvhxo0cGjvHRvpk3elP4jyhkDgdH15U=; b=sn30nqAIV+sXzaODI3Nq/TLz7Mv3ju8Dzv92xM3fhACDV0eRM4sSV+fv+UmMcGEPlQ 5gETO1jxoiBZkbKcPbXgoSnM9EWrVLYTJvZOUAU5feNMZYc/twAiJ9OEhLEecDi1RO15 eZSkIw2jaXn9/308Ex6S83ihNipZfkeOjcjh/5kGOu/1oXKfURhUzHRDi58puGLLgGbW jkTe1y06Y4fcz+9SFeLxbguF0ficemleKMVt6deuvWO0ODIg2PFgKxwgyVm7zGq5BjSG G2Fc7TjQeZs5uTZVEhRcT8yByMt+t+BS8boy4ZOa74Y1PmGbmTvvUDLTfzw4SZLqOT/I h8bQ== X-Gm-Message-State: AOUpUlHVBexN22t8bKbzNop9Z/RKDiUSuR2KQc1T9Dsx8vMFpxEO2aj3 TE/TzqdoprN4+6rlYFs55oRfZw== X-Received: by 2002:a17:902:6b84:: with SMTP id p4-v6mr9301075plk.272.1531990747870; Thu, 19 Jul 2018 01:59:07 -0700 (PDT) Received: from kshutemo-mobl1.localdomain (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by smtp.gmail.com with ESMTPSA id z20-v6sm12086517pfd.99.2018.07.19.01.59.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 01:59:07 -0700 (PDT) Received: by kshutemo-mobl1.localdomain (Postfix, from userid 1000) id 10457300251; Thu, 19 Jul 2018 11:59:02 +0300 (+03) Date: Thu, 19 Jul 2018 11:59:01 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: "Kirill A. Shutemov" , Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky , Kai Huang , Jacob Pan , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv5 06/19] mm/khugepaged: Handle encrypted pages Message-ID: <20180719085901.ebdciqkjpx6hy4xt@kshutemo-mobl1> References: <20180717112029.42378-1-kirill.shutemov@linux.intel.com> <20180717112029.42378-7-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180622 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 18, 2018 at 04:11:57PM -0700, Dave Hansen wrote: > On 07/17/2018 04:20 AM, Kirill A. Shutemov wrote: > > khugepaged allocates page in advance, before we found a VMA for > > collapse. We don't yet know which KeyID to use for the allocation. > > That's not really true. We have the VMA and the address in the caller > (khugepaged_scan_pmd()), but we drop the lock and have to revalidate the > VMA. For !NUMA we allocate the page in khugepaged_do_scan(), well before we know VMA. > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > index 5ae34097aed1..d116f4ebb622 100644 > > --- a/mm/khugepaged.c > > +++ b/mm/khugepaged.c > > @@ -1056,6 +1056,16 @@ static void collapse_huge_page(struct mm_struct *mm, > > */ > > anon_vma_unlock_write(vma->anon_vma); > > > > + /* > > + * At this point new_page is allocated as non-encrypted. > > + * If VMA's KeyID is non-zero, we need to prepare it to be encrypted > > + * before coping data. > > + */ > > + if (vma_keyid(vma)) { > > + prep_encrypted_page(new_page, HPAGE_PMD_ORDER, > > + vma_keyid(vma), false); > > + } > > I guess this isn't horribly problematic now, but if we ever keep pools > of preassigned-keyids, this won't work any more. I don't get this. What pools of preassigned-keyids are you talking about? -- Kirill A. Shutemov