Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5424917imm; Tue, 12 Jun 2018 07:40:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJPOvTTsNcejFU9Uhz5nyJHutD+AiKHeeKI6IoMPOv1hFNsnquicx++RI/rAwtjVAFdmI8m X-Received: by 2002:aa7:8491:: with SMTP id u17-v6mr734450pfn.48.1528814456355; Tue, 12 Jun 2018 07:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528814456; cv=none; d=google.com; s=arc-20160816; b=hIQQdn08M13xR0MjKq7sj8vljFzR0FeyAjlQNmy4EWS08nbwWVKb1IIRXBY85OKheq aB81jPFQAEWwLft9Oru9x5cfV4bAiVKKkk0QMUNTUbeLRAmL1Vq2M0bFl+Q43TKzpZJX bZK3x6yN47FGtdFQkx5Rx2K8bmXwXUbucrNP6qn7/nEV0NZHjLcqxjW+9bt4odMYPti0 FiEK+DLTqw6mnt0denK/S4A28T5de3OtX5sMFrSF9NPjD5RedgVpEwAu9unMO4EiLkA8 O91yWZJBovcy6GnB6y0saCjphH4AyfeOQQ0/WIvSWh23XDZrmbcAk2zyWyvBXQc0n62T V5Pg== 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=StQM7r592572HhqAQp6Z1xbssYIys815jApiRiSNJeo=; b=uq2aHaU37Ss4Zuv+A6ReIO75AnuSupSjwbGzVUKjz8Wu6wZDUZi04O/BvlJuTvfHM9 QJMGMOBp+w4S8KnSTF/o54O2odnKDUg/D43RURCe2ewFwlkzb1Z+Ivsg2tt8hMzd56x8 PWuEfBOxQj7FDdTK6JziZCdIgBvUiJUNGB327ErCGk5rjiToXV63rv+EQ4odhNVNkAo4 nteDrFQVBZupnXpvB9NcBl9B8dqgm7banoot8sAqd5nNewTomUx0cGHrUJ/uaRRNDjUR VZbT8FNvapNSFByROj9lBpOyPLr3Bj/hL31p+eP4OTMmbiKnjnKNFYsGEy6Bv/bbtpvU VSpQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18-v6si223734pgt.529.2018.06.12.07.40.41; Tue, 12 Jun 2018 07:40:56 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934352AbeFLOje (ORCPT + 99 others); Tue, 12 Jun 2018 10:39:34 -0400 Received: from mga12.intel.com ([192.55.52.136]:32098 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934302AbeFLOja (ORCPT ); Tue, 12 Jun 2018 10:39:30 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2018 07:39:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,215,1526367600"; d="scan'208";a="236788346" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 12 Jun 2018 07:39:27 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 4AEA483A; Tue, 12 Jun 2018 17:39:21 +0300 (EEST) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky Cc: Dave Hansen , Kai Huang , Jacob Pan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [PATCHv3 16/17] x86/mm: Handle encrypted memory in page_to_virt() and __pa() Date: Tue, 12 Jun 2018 17:39:14 +0300 Message-Id: <20180612143915.68065-17-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612143915.68065-1-kirill.shutemov@linux.intel.com> References: <20180612143915.68065-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 Per-KeyID direct mappings require changes into how we find the right virtual address for a page and virt-to-phys address translations. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/mktme.h | 3 +++ arch/x86/include/asm/page_64.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/mktme.h b/arch/x86/include/asm/mktme.h index efc0d4bb3b35..d6edcabacfc7 100644 --- a/arch/x86/include/asm/mktme.h +++ b/arch/x86/include/asm/mktme.h @@ -43,6 +43,9 @@ void mktme_disable(void); void setup_direct_mapping_size(void); int sync_direct_mapping(void); +#define page_to_virt(x) \ + (__va(PFN_PHYS(page_to_pfn(x))) + page_keyid(x) * direct_mapping_size) + #else #define mktme_keyid_mask ((phys_addr_t)0) #define mktme_nr_keyids 0 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h index 53c32af895ab..ffad496aadad 100644 --- a/arch/x86/include/asm/page_64.h +++ b/arch/x86/include/asm/page_64.h @@ -23,7 +23,7 @@ static inline unsigned long __phys_addr_nodebug(unsigned long x) /* use the carry flag to determine if x was < __START_KERNEL_map */ x = y + ((x > y) ? phys_base : (__START_KERNEL_map - PAGE_OFFSET)); - return x; + return x % direct_mapping_size; } #ifdef CONFIG_DEBUG_VIRTUAL -- 2.17.1