Received: by 10.223.185.116 with SMTP id b49csp2776385wrg; Mon, 5 Mar 2018 08:30:47 -0800 (PST) X-Google-Smtp-Source: AG47ELvIS5ZUhmt+2xHeybPMMR3bIDZlsfbgM5fIl80s7s1B0cIvAIB1eVKJYQlN3rJ+1bsha6dq X-Received: by 2002:a17:902:b187:: with SMTP id s7-v6mr13735332plr.448.1520267447588; Mon, 05 Mar 2018 08:30:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520267447; cv=none; d=google.com; s=arc-20160816; b=0Zg3O7EIOTtQMRtDd/rmCeirLc3Wxr026Lo901BEPaemBEfm0G6cUGKhY4gqXxtS2d Iimdo/ArCsIuy7dpJVLzs5o0rM6iM8Ep+Gos6G24/MipnAQduEXojB919IXk3UPKX0lw jy62EnPIQlD9TtiVIrzo7odAObvxyVVwSC9KD5s0rtcoRWOih711UOqCj7iKBuwvqDdN uen4cj7l1ZCpdqdME/DbMbf9YOSuJf+hKanC9lyaL2vbgFxiifn98DxIUd0yl6QvJ0/r OlSgjloAcE5cMw8OVr0SXcvB8jhlT63jRAU279NPyw41i98gQiZmbxC/HhpVLqpdfRxJ iK+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=tlAVctugdszeH2tXObQpkVfqwSgcmrskHEFJ3X6iaFE=; b=oD2VibfKUttk1F169/RqvUkqLf0/tYlle9o1Y+DYrOOn7fqO2ZUEGCX7f74AsBNgRC 96Se+xUA4PsLyjFJqhNBSLMPTAKeRGr97qhOF29TQFVetUZ/kQoZtzKvMod0aQ3o/fFE QMb3XN0GWNsaUGjLbS+8b45VThTDTCNzrV7SPUdlnE8mYnnE2nRcc2VPtTm3IOvZFOpX 2E2CaKOyIk6VbQxFnOyly8HGvWv5BAdmUHUykbE2UBTGo7R9tQv83i8UyOEZIlfZb/Do N6MpRJuLh+hDpPgKXWJUobnx/hgcGmr2Ni3TWMXVeniIJN2YrpQDLLgkkoF22A5+dxk+ 5UxQ== ARC-Authentication-Results: i=1; mx.google.com; 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 b17si8505784pgu.407.2018.03.05.08.30.33; Mon, 05 Mar 2018 08:30:47 -0800 (PST) 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; 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 S1752922AbeCEQ2U (ORCPT + 99 others); Mon, 5 Mar 2018 11:28:20 -0500 Received: from mga01.intel.com ([192.55.52.88]:49459 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752629AbeCEQ0a (ORCPT ); Mon, 5 Mar 2018 11:26:30 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 08:26:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,427,1515484800"; d="scan'208";a="208994403" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 05 Mar 2018 08:26:27 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 9B9E76DB; Mon, 5 Mar 2018 18:26:20 +0200 (EET) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky Cc: Dave Hansen , Kai Huang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [RFC, PATCH 16/22] x86/mm: Preserve KeyID on pte_modify() and pgprot_modify() Date: Mon, 5 Mar 2018 19:26:04 +0300 Message-Id: <20180305162610.37510-17-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180305162610.37510-1-kirill.shutemov@linux.intel.com> References: <20180305162610.37510-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Encrypted VMA would have KeyID stored in vma->vm_page_prot. This way we don't need to do anything special to setup encrypted page table entries and don't need to reserve space for KeyID in a VMA. This patch changes _PAGE_CHG_MASK to include KeyID bits. Otherwise they are going to be stripped from vm_page_prot on the first pgprot_modify(). Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/pgtable_types.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 246f15b4e64c..800f66770163 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -121,8 +121,13 @@ * protection key is treated like _PAGE_RW, for * instance, and is *not* included in this mask since * pte_modify() does modify it. + * + * It includes full range of PFN bits regardless if they were claimed for KeyID + * or not: we want to preserve KeyID on pte_modify() and pgprot_modify(). */ -#define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \ +#define PTE_PFN_MASK_MAX \ + (((signed long)PAGE_MASK) & ((1UL << __PHYSICAL_MASK_SHIFT) - 1)) +#define _PAGE_CHG_MASK (PTE_PFN_MASK_MAX | _PAGE_PCD | _PAGE_PWT | \ _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY | \ _PAGE_SOFT_DIRTY) #define _HPAGE_CHG_MASK (_PAGE_CHG_MASK | _PAGE_PSE) -- 2.16.1