Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3403447imm; Tue, 17 Jul 2018 04:23:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc9QA9DmWhlBaJDVdE28g5FTcF3Icvladmewsf+LJ6RjmmLVa17Cj4iZ4u55X1tE113VqlK X-Received: by 2002:a63:7b1b:: with SMTP id w27-v6mr1153736pgc.199.1531826621265; Tue, 17 Jul 2018 04:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531826621; cv=none; d=google.com; s=arc-20160816; b=Bx0+GCCISkobqGu8ISXye8M76pUZ4ea9wOSyXVbmXrBcg6ayiHZru8LoDvDG0hzgHQ Sv41NxhXIZjuvSTv4E1S8KBXESsPGMyLPBN2Upvb61SUvlGMdFb+mrKSK6aRugTiZ9nl X0XCev2Oe2hKJxiVq6HbAP4HbpMPL9598176ALLIZs5lt4U2K+paDZK93LGKRz66gAR5 JhAUw5u5Ll5u/qYfwpNcCld3EJZjtFRna2McYFeXdai+d6ZdcqQ9574T7kZy6rnt58Pd khOaTCDqdzhD+WT5Xo9I0ZyMsMTA0pkLKnyRTP6jvfpQgE5WOxKqp+Jl7S3OQzxyq/ix fugA== 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=Oi+rJI0orA5sIeAYPorZAiEofc0R+/ovPpORMv1Rh94=; b=PgRbNGikk6bIHYIiVOIbh8Z17lEjaZ/jc8n8DKXWcKQ3fMCpYZ9Ot+3H1nJ7/A6dfO Zcy/QHzc3Holl2hBAUU5APwmXZtAIuslZ53O/QpL9YuTdch0PbrS0WGCkvN1aEwOQPNm jB47jDTTzL5iEx6TCtzfpUqgLFZD2t3jB/Uk7U0u0AYf6HaSoxCH8Ge7F2h1if/qaAfl 3FOUJQWnUB4xaUdI95YwdmNlDzeL+7x7W/3sieXkaOXm8bmuBguL7+fyWOgJ2FrUcY8r 7xkQZERijFK7BtcrFxRUEMSSDNnvmGrJ1cRVurS/ERS8HIT0JJNZ4RUVUMv0SK0fULeo zegw== 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 g15-v6si707132pgh.418.2018.07.17.04.23.26; Tue, 17 Jul 2018 04:23: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; 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 S1731696AbeGQLyh (ORCPT + 99 others); Tue, 17 Jul 2018 07:54:37 -0400 Received: from mga07.intel.com ([134.134.136.100]:40801 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730552AbeGQLyU (ORCPT ); Tue, 17 Jul 2018 07:54:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 04:22:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,365,1526367600"; d="scan'208";a="58320654" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 17 Jul 2018 04:21:49 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 729B884E; Tue, 17 Jul 2018 14:21:49 +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: [PATCHv5 18/19] x86/mm: Handle encrypted memory in page_to_virt() and __pa() Date: Tue, 17 Jul 2018 14:20:28 +0300 Message-Id: <20180717112029.42378-19-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180717112029.42378-1-kirill.shutemov@linux.intel.com> References: <20180717112029.42378-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. page_to_virt() definition overwrites default macros provided by . We only overwrite the macros if MTKME is enabled compile-time. 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 ba83fba4f9b3..dbfbd955da98 100644 --- a/arch/x86/include/asm/mktme.h +++ b/arch/x86/include/asm/mktme.h @@ -29,6 +29,9 @@ void arch_free_page(struct page *page, int order); 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 f57fc3cc2246..a4f394e3471d 100644 --- a/arch/x86/include/asm/page_64.h +++ b/arch/x86/include/asm/page_64.h @@ -24,7 +24,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_mask; } #ifdef CONFIG_DEBUG_VIRTUAL -- 2.18.0