Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp119130pxj; Wed, 26 May 2021 17:57:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEqfKB1jlCzY+lGS0cCovQNehQoke9W8UQVX/gxfrMyEAG73YZmDgwtjnmI/lYiphf8DFx X-Received: by 2002:a05:6e02:1d9a:: with SMTP id h26mr799494ila.224.1622077068782; Wed, 26 May 2021 17:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622077068; cv=none; d=google.com; s=arc-20160816; b=ndc8yY4jpP4bKmeUWcN5r3Tdw8G9LmEe4H/0qH3BBnOk2dvkmRD/hftoNFIzKeEh+M GcHsuAMOXBggQ1Wd59mtajZhg8JQ4Aq6LaZRJgynFgtPJSyWi3qgeehYxDLqSKqbEWUt xR5FOjUN8fR8mVscQF1W2YBVbUOe1Su1KrZwoEuj8kPVFOAMzqg8pVjW6M5mGwwlQ1Pc 9NOLBMWTA+cOdn1WYsZSfMTIm42mmaETwRoG3pqkzuoigNYcCXmW1wTnUuwqDEZvx5i9 nE4qM+S4qcuCgeJmF1t3agS9S018OwvEUxFyJRqQG24jQ9duWDlj4gbn/JoPe3HyZSYU HRgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=RiBjbaoltZagdG1+Bb5SeMjlptzXUNEHGpuFYALBJnY=; b=XOJpijiV7/YKMNxBWGIT7kowfCfNz3rlT3Mq501g9liRK8b6CTwnE7bKhnFdIhQ34k NlLq2LruKKUUdXh7ixbYUi/TggxMmSZReYO5LgQXbgLlUDX6krJVzFiD8AyfEygRy9No e2aJuh3NVxibtXYC2Ey3HiYi79iAc09QhQCT+r27xuCdrahH5Pk/4Jgw/QZztKWWXDLR BE84u9Q5GDprtaAAzNTfkYM12sQdeC+qPEHpctrPioxcbZYz4mKXDdf5rAbMLDIbxTdH aItK4/Xgks1U28uc2KZmOGgdxXOmaalJHozXuwm2ESh6J7r6dBoVGKRDZ8QvpJeXjjKx GUig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id d5si697813ilr.23.2021.05.26.17.57.36; Wed, 26 May 2021 17:57:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233817AbhEZWWR (ORCPT + 99 others); Wed, 26 May 2021 18:22:17 -0400 Received: from mga07.intel.com ([134.134.136.100]:42385 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbhEZWWL (ORCPT ); Wed, 26 May 2021 18:22:11 -0400 IronPort-SDR: bhRMq735Kytr34Jy0eCoynvfnz7qFlkbEBrZFVhRy9hUfTgizbwbEKqQC43553QgwqZQHjZb4t rvJhk/S18fGQ== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="266486596" X-IronPort-AV: E=Sophos;i="5.82,333,1613462400"; d="scan'208";a="266486596" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 15:20:36 -0700 IronPort-SDR: e70GE4DzWnsLwUwfKj1GcK0bKGGBICwOF6Z/vnRvtUQA4/5ro9a7GQQFo1Rsha7M7/Z9qBMpWs BN2H/6ik1/6w== X-IronPort-AV: E=Sophos;i="5.82,333,1613462400"; d="scan'208";a="547403537" Received: from skgiroua-mobl2.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.251.151.24]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 15:20:35 -0700 Subject: Re: [RFC v2 28/32] x86/tdx: Make pages shared in ioremap() To: Tom Lendacky , Borislav Petkov Cc: Sean Christopherson , Dave Hansen , Andi Kleen , Peter Zijlstra , Andy Lutomirski , Dan Williams , Tony Luck , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Raj Ashok , linux-kernel@vger.kernel.org, Brijesh Singh References: <312879fb-d201-a16d-2568-150152044c54@linux.intel.com> <797c95bf-9516-8aee-59d0-f5259d77bb75@linux.intel.com> <5b4b4fc0-aaa8-3407-6602-537d59572bc1@intel.com> <0e233779-9c10-11df-b527-ef61e003ea35@linux.intel.com> <777db866-4c3d-d849-94cf-b4248c6ac2aa@amd.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: Date: Wed, 26 May 2021 15:20:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/26/21 3:14 PM, Tom Lendacky wrote: > On 5/26/21 5:02 PM, Tom Lendacky wrote: >> On 5/26/21 4:37 PM, Kuppuswamy, Sathyanarayanan wrote: >>> >>> >>> On 5/21/21 9:19 AM, Tom Lendacky wrote: >>>> In arch/x86/mm/mem_encrypt.c, sme_early_init() (should have renamed that >>>> when SEV support was added), we do: >>>>     if (sev_active()) >>>>         swiotlb_force = SWIOTLB_FORCE; >>>> >>>> TDX should be able to do a similar thing without having to touch >>>> arch/x86/kernel/pci-swiotlb.c. >>>> >>>> That would remove any confusion over SME being part of a >>>> protected_guest_has() call. >>> >>> You mean sme_active() check in arch/x86/kernel/pci-swiotlb.c is redundant? >> >> No, the sme_active() check is required to make sure that SWIOTLB is >> available under SME. Encrypted DMA is supported under SME if the device >> supports 64-bit DMA. But if the device doesn't support 64-bit DMA and the >> IOMMU is not active, then DMA will be bounced through SWIOTLB. >> >> As compared to SEV, where all DMA has to be bounced through SWIOTLB or >> unencrypted memory. For that, swiotlb_force is used. > > I should probably add that SME is memory encryption support for > host/hypervisor/bare-metal, while SEV is memory encryption support for > virtualization. Got it. Thanks for clarification. > > Thanks, > Tom > >> >> Thanks, >> Tom >> >>> >>>  41 int __init pci_swiotlb_detect_4gb(void) >>>  42 { >>>  43         /* don't initialize swiotlb if iommu=off (no_iommu=1) */ >>>  44         if (!no_iommu && max_possible_pfn > MAX_DMA32_PFN) >>>  45                 swiotlb = 1; >>>  46 >>>  47         /* >>>  48          * If SME is active then swiotlb will be set to 1 so that bounce >>>  49          * buffers are allocated and used for devices that do not support >>>  50          * the addressing range required for the encryption mask. >>>  51          */ >>>  52         if (sme_active() || is_tdx_guest()) >>>  53                 swiotlb = 1; >>> >>> -- Sathyanarayanan Kuppuswamy Linux Kernel Developer