Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp56407pxb; Mon, 7 Feb 2022 06:22:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKsJvqXdV7PhKlOik4y587Ej/2gdYN7XvtFv1gNzuhLKiXMU+Q38VbFtC6YV1IaUQcKKId X-Received: by 2002:a05:6a00:1882:: with SMTP id x2mr15885197pfh.26.1644243767854; Mon, 07 Feb 2022 06:22:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644243767; cv=none; d=google.com; s=arc-20160816; b=pL9kOiTZRLAfcIB4JpfVauX1DeXIfV6MeaTemQr6KTHLKaa2gGcyBkfR+IGfMUQMeB JmuDtSVas6fYaP6w7X8VdHma+9DmK/13M+CizUK4uxiEItQlgDLW2tVkCBn/qAvWeBTN 5w+85ODY/R9D7FE/aVkRUmUlPvbBUEPi6nwVIcGilTB9FHSYumhxUxJLQaSlRMUVTRe/ J8YOUlxbREJ/YPpJDhWflpcdokhMsWzx5RYZJg5HibpvIAi7PkWeY0opZqorcxP4KfCk 4QJL0yGBAnrdHu3mvcrbG0Y3MUKvMZra1lr+83SNX6IeeGazQQGUi9/Yzo+oo/QUvoRS ZljQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=d3UOzqmkGSk4yxg9xIoTDxQcxvI9+28GeTmhgUKEIH8=; b=sXJ3WHorLNC5d7QbFbUbqD2cG+Mg7N3LnywEVTtYG/W2GmvAV8VzGetzugeTV7/0hB 9eDJW/8kZLJJNzA0d/4JLpogWMATecTIkt66Glj5BjeDtEzunuw15LGPfSW1uzWSdLai OOg4HcqUYQNqpQJwzCa8pdAgvkZTVVHp1O/nhlG9pwKBY8yqngcLtTmaYCqSuGjXEUdc FSmGvxjwnZV9yXZddadk8Gu55sdj/WRlF6TdXjlhDJ8TFVCS5qcerhLTnXdITJbpYSH2 T53Q/Utx6GajVIL9xnCqQP4t0kYrIy+ROyfElApENyDp6UosN1EhbQtfdnrhgwJC0JEg OSmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kpx2rU7x; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9si3958558plh.243.2022.02.07.06.22.13; Mon, 07 Feb 2022 06:22:47 -0800 (PST) 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=@intel.com header.s=Intel header.b=kpx2rU7x; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239500AbiBBT1E (ORCPT + 99 others); Wed, 2 Feb 2022 14:27:04 -0500 Received: from mga05.intel.com ([192.55.52.43]:30049 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235908AbiBBT1D (ORCPT ); Wed, 2 Feb 2022 14:27:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643830023; x=1675366023; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=OUNxb+dsMQzkYohtFuYtyeG+odtGDuE51GNKzPIL6xU=; b=kpx2rU7xho5/d48JgXLiVHbiRXaarpm0h7im87HyeL/GWoe/iq0/FAPk ECJm/UHq3R2nFuivR0Jx8/klTmJDRcb3lZugH0/VlrrvKSQ4kVJ0YFZMr EtUQsZBka4094/oteUiNJhTxrKpDbnL8PyNThE7x75oqeqoNhl5d5s3h4 8C53M6sUbWyy0SAh2fGmfFFA9juF/5IkXgbxEnqkSgHIniXKhmS+gIVDU heqyxl3zEfTvloJD4ciNv7YNfd0luq5P4JlqU3efRb9/8+8GLetdsV9R+ kGACsZ5bI2Qo1fYfRRMk6lrVbYYwJ/4DEKecQgVYV539cBL6hwYwLu/Mi A==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="334362721" X-IronPort-AV: E=Sophos;i="5.88,337,1635231600"; d="scan'208";a="334362721" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2022 11:27:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,337,1635231600"; d="scan'208";a="566134932" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 02 Feb 2022 11:26:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id AAFD03B7; Wed, 2 Feb 2022 21:27:10 +0200 (EET) Date: Wed, 2 Feb 2022 22:27:10 +0300 From: "Kirill A. Shutemov" To: Thomas Gleixner Cc: mingo@redhat.com, bp@alien8.de, dave.hansen@intel.com, luto@kernel.org, peterz@infradead.org, sathyanarayanan.kuppuswamy@linux.intel.com, aarcange@redhat.com, ak@linux.intel.com, dan.j.williams@intel.com, david@redhat.com, hpa@zytor.com, jgross@suse.com, jmattson@google.com, joro@8bytes.org, jpoimboe@redhat.com, knsathya@kernel.org, pbonzini@redhat.com, sdeep@vmware.com, seanjc@google.com, tony.luck@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 22/29] x86/tdx: Make pages shared in ioremap() Message-ID: <20220202192710.d7k4pgqczpyrkers@black.fi.intel.com> References: <20220124150215.36893-1-kirill.shutemov@linux.intel.com> <20220124150215.36893-23-kirill.shutemov@linux.intel.com> <87bkzqw1vr.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bkzqw1vr.ffs@tglx> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 02, 2022 at 01:25:28AM +0100, Thomas Gleixner wrote: > On Mon, Jan 24 2022 at 18:02, Kirill A. Shutemov wrote: > > > 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. > > > > Since TDX memory encryption support is similar to AMD SEV architecture, > > reuse the infrastructure from AMD SEV code. > > > > Add tdx_shared_mask() interface to get the TDX guest shared bitmask. > > > > pgprot_decrypted() is used by drivers (i915, virtio_gpu, vfio). Export > > both pgprot_encrypted() and pgprot_decrypted(). > > How so? > > # git grep pgprot_encrypted > arch/x86/include/asm/pgtable.h:#define pgprot_encrypted(prot) __pgprot(__sme_set(pgprot_val(prot))) > arch/x86/mm/ioremap.c: prot = pgprot_encrypted(prot); > arch/x86/mm/ioremap.c: return encrypted_prot ? pgprot_encrypted(prot) > arch/x86/mm/mem_encrypt_amd.c: protection_map[i] = pgprot_encrypted(protection_map[i]); > arch/x86/mm/pat/set_memory.c: cpa.mask_clr = pgprot_encrypted(cpa.mask_clr); > arch/x86/platform/efi/quirks.c: pgprot_val(pgprot_encrypted(FIXMAP_PAGE_NORMAL))); > fs/proc/vmcore.c: prot = pgprot_encrypted(prot); > include/linux/pgtable.h:#ifndef pgprot_encrypted > include/linux/pgtable.h:#define pgprot_encrypted(prot) (prot) > > I cannot find any of the above mentioned subsystems in this grep > output. Neither does this patch add any users which require those > exports. Try to grep pgprot_decrypted(). I guess we can get away not exporting pgprot_encrypted(), but this asymmetry bothers me :) -- Kirill A. Shutemov