Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp1052505pxw; Sat, 9 Apr 2022 09:37:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznkQkS65m150sQkaaiUeD2PaxBMFk7SCTVy3S8NA4Yg3qMnbS2vUttLx5rflNlVQl874qI X-Received: by 2002:a05:6a00:1a06:b0:4fc:d6c5:f3d7 with SMTP id g6-20020a056a001a0600b004fcd6c5f3d7mr25006789pfv.53.1649522248374; Sat, 09 Apr 2022 09:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649522248; cv=none; d=google.com; s=arc-20160816; b=htZYSHlonzzwOJHxshb26U+5OQiV3+Ra8uf/R4qKJnvcudQkFeEJDeBW+UpuvksH8l 9TZ055/TjH/BTGpEvLH+v7fd5ckXnRu26ll0WOeZF7tWiPpouymGU4uLbh5YHRv5cqO8 Y5G+3pratYwI8SJk/8sAMhI+wfk2O8iFfFadHMwdIfXrSX17yEnF0o3PN7/LOHrWPJWv f9cIu+OcNPCus6I832SZGeINUwkFmGt12RFxgn/33d4jX4NE3Lxt3AIzt3OeiIhu+QlO Y1ClOMWAKfwTz5PpIKedqcElPUd3eTGFMksR36HGE8WM8JATX00sOc4awHb9yOOVxERp 2bmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=pj7zAY+ecbdHbFINkS7R1cfeTd265W+vWoWHJuTlpxo=; b=fAfhWSWgNJGAumyhm+3ZzwgnfUoetgHTSBLtbGU2lYKlDPyt3s5Yhll08xYC1w92xa TaAV9pCyfU1Zt638+4Otr0gF8iFdYI5LCUpAEE5zMlSI2WvSL/BjMkSeMJxF6ulGdV93 3SmSAysLRpcHj29jtNoPFmeufLDIWUBZ/Suwkn0fExSlVt5JyIVSokyOqhR8seGRCbRu Lxbd38Bm6ED4b5sjvx/Uo4RrPlskCvDHnED8Y76Tdv8P0E615TvbqhS6rRccYidlWllH VT7bPy1/RB5tbkcUF3xswWc1/HrUWXvzSgbqn1iiBlWUgYAxfStawNXQkZM7LAfiHdki l01Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="OUkBWS/0"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=QT6f4+wu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020a656a82000000b00386231ec326si4846046pgu.613.2022.04.09.09.37.13; Sat, 09 Apr 2022 09:37:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="OUkBWS/0"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=QT6f4+wu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240303AbiDIB37 (ORCPT + 99 others); Fri, 8 Apr 2022 21:29:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240246AbiDIB3b (ORCPT ); Fri, 8 Apr 2022 21:29:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DBB4DA6DF; Fri, 8 Apr 2022 18:27:25 -0700 (PDT) Date: Sat, 09 Apr 2022 01:27:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649467643; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pj7zAY+ecbdHbFINkS7R1cfeTd265W+vWoWHJuTlpxo=; b=OUkBWS/0mTUmSLJSWQ2HBji8YhoSVSRkWZZT7B89wq2YxxW72GkBTXWyx06oFFVg0+sdHG YEQXljyGwZTNdCCTDKijMAabhY+1k4GbxSEnOCl5mVNIcbMKwHx3eHMgE7l8wwt5nRsZve FY1Dzw8Plpci1Z+ILe9p5ZqFesplyGeslPkqkJJZMlCZZYqWu1T6n3XsH11ydWzEmlt/fP iMYtfysd+Zsbjia3sggLwCkNxOi0uZ/X5ROPMf10O9/jpivKJqt220iFjii/YBuc3mH0og jNSEjwn0nIc+O6raHJBl9q2NRa/zq5EbFIftbhS0In6BOsGKGYeDBs897PMJMg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649467643; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pj7zAY+ecbdHbFINkS7R1cfeTd265W+vWoWHJuTlpxo=; b=QT6f4+wuoxz1nwco4jdxYD4xnT/VFU0tlMvnkX2L0cN2nYi9HHK4vICrY/b+tUPCykdbGo LzaoQgRPwJa/XoDA== From: "tip-bot2 for Kirill A. Shutemov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/tdx] x86/tdx: Make pages shared in ioremap() Cc: Kuppuswamy Sathyanarayanan , "Kirill A. Shutemov" , Dave Hansen , Andi Kleen , Tony Luck , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220405232939.73860-26-kirill.shutemov@linux.intel.com> References: <20220405232939.73860-26-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Message-ID: <164946764230.4207.8183154708201575322.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/tdx branch of tip: Commit-ID: 9aa6ea69852c46e551f4180dce4208bd53df418c Gitweb: https://git.kernel.org/tip/9aa6ea69852c46e551f4180dce4208bd53df418c Author: Kirill A. Shutemov AuthorDate: Wed, 06 Apr 2022 02:29:34 +03:00 Committer: Dave Hansen CommitterDate: Thu, 07 Apr 2022 08:27:53 -07:00 x86/tdx: Make pages shared in ioremap() In TDX guests, guest memory is protected from host access. If a guest performs I/O, it needs to explicitly share the I/O memory with the host. Make all ioremap()ed pages that are not backed by normal memory (IORES_DESC_NONE or IORES_DESC_RESERVED) mapped as shared. The permissions in PAGE_KERNEL_IO already work for "decrypted" memory on AMD SEV/SME systems. That means that they have no need to make a pgprot_decrypted() call. TDX guests, on the other hand, _need_ change to PAGE_KERNEL_IO for "decrypted" mappings. Add a pgprot_decrypted() for TDX. Co-developed-by: Kuppuswamy Sathyanarayanan Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: Kirill A. Shutemov Signed-off-by: Dave Hansen Reviewed-by: Andi Kleen Reviewed-by: Tony Luck Reviewed-by: Dave Hansen Reviewed-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20220405232939.73860-26-kirill.shutemov@linux.intel.com --- arch/x86/mm/ioremap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 17a492c..1ad0228 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -242,10 +242,15 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size, * If the page being mapped is in memory and SEV is active then * make sure the memory encryption attribute is enabled in the * resulting mapping. + * In TDX guests, memory is marked private by default. If encryption + * is not requested (using encrypted), explicitly set decrypt + * attribute in all IOREMAPPED memory. */ prot = PAGE_KERNEL_IO; if ((io_desc.flags & IORES_MAP_ENCRYPTED) || encrypted) prot = pgprot_encrypted(prot); + else + prot = pgprot_decrypted(prot); switch (pcm) { case _PAGE_CACHE_MODE_UC: