Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1267607pxj; Wed, 19 May 2021 02:03:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFOWD/NtWG4HSHEQOmyInzlh3eFmunY2kQ7UjY22UDcLB3Dp9G9/gYiN1IZeo1PkJUdXnb X-Received: by 2002:a92:6610:: with SMTP id a16mr9593152ilc.124.1621415023079; Wed, 19 May 2021 02:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621415023; cv=none; d=google.com; s=arc-20160816; b=UzZImYFR7UZCwnDdqs9j3gdKxSKZfBeLci+xZyLKi3RYugLuOMLcA42E5iBpudV4N2 3U19I0L3nkDevkE0B/D82Wybpz0sjpolY44Cjx5TCyTROF8Z3YXCXeDzd8kF0n/hkQZe ao/pJ7WBAsX40KxXRjhLGKlZyGhiLOziOKDKvsCWcAAOCbZ8jmAHlXbicDrIjpT/dGra 2+QgD1x9DyRB9QtwaC0CkwFWmGm6aW7MkVkQfdukDtsYvsRc7DpaBdOx5dFXT2UjOn+G tlkS4jnn7Uf9Ir49NlwNBcpJuymV3x1HqPB5ehuOs3Y8g9KkvovaE7To0v+YcZsNlBtS qbLg== 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=M0UANtRaXh+0Ib7Z2NHNE5ZKyicRcAnLzyuM/F1TUvY=; b=rpgmm6pKgcP8pwKGB/n6VRTev2jYSKXmIo77Gh2HjLWs3a+AksiLCRhQ2+DwM+vDw9 zFErpSroq8xXQ+EFRSEecs4Hq1FgrC3RnVlPLlHsrY5f8K7yVrJkJa81yVx0gVxOqdyI MxsHwU1uWOk3hlAtwO3MCFouL/DRGWjMduJMkecoGFaFq95mXcxUMJP/2RyJSrc26H7K H2nmdFrQ3OB57oFdkgGQW+upcUqnp0w2fTmA9YF/sR20EYAMhKuO2B+VNo3Xu2HqarY3 /SMW7cjSiqXk1oU2886eeThiiDeqNhcFir8eZxgmmimbljmqeOK7lLsIvQI5/UoTq6aH kI6g== 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 f4si9547930ilj.107.2021.05.19.02.03.26; Wed, 19 May 2021 02:03:43 -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 S1343804AbhEQWdY (ORCPT + 99 others); Mon, 17 May 2021 18:33:24 -0400 Received: from mga03.intel.com ([134.134.136.65]:47293 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238052AbhEQWdX (ORCPT ); Mon, 17 May 2021 18:33:23 -0400 IronPort-SDR: cPW1V6n0WLiAYaMWDlzYxMiEzGsDHVD6QYUFI0e0qudyHYh2sulyPPHebYKgakoF0egFH2RqgK Ek5kKd+FtcMQ== X-IronPort-AV: E=McAfee;i="6200,9189,9987"; a="200632718" X-IronPort-AV: E=Sophos;i="5.82,307,1613462400"; d="scan'208";a="200632718" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2021 15:32:06 -0700 IronPort-SDR: 3pPbgw7KR3+4EfEe+dtQOrQE887y10H1DxmYzQT8KwAHjrBK4I3/Ziojxgrakddz7GKwb9ft9X rR8+Eh0+RHCQ== X-IronPort-AV: E=Sophos;i="5.82,307,1613462400"; d="scan'208";a="543866390" Received: from daltonda-mobl.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.209.182.28]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2021 15:32:05 -0700 Subject: Re: [RFC v2 26/32] x86/mm: Move force_dma_unencrypted() to common code To: Sean Christopherson , Dave Hansen Cc: Andi Kleen , "Kirill A. Shutemov" , Peter Zijlstra , Andy Lutomirski , Dan Williams , Tony Luck , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Raj Ashok , linux-kernel@vger.kernel.org References: <20210512130821.7r2rtzcyjltecun7@box.shutemov.name> <943645b7-3974-bf05-073c-03ef4f889379@intel.com> <5cc06488-09fe-17b5-077b-02c4ba9ca198@intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: <37da11b3-0313-982d-5a2b-af592db6f9e8@linux.intel.com> Date: Mon, 17 May 2021 15:32:01 -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: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/17/21 11:37 AM, Sean Christopherson wrote: >> Just remember, a "common framework" doesn't mean that it can't be backed >> by extremely arch-specific mechanisms. >> >> For instance, there's a lot of pkey-specific code in mm/mprotect.c. It >> still gets optimized away on x86 with all the goodness of X86_FEATUREs. > Ya, exactly. Ideally, generic code shouldn't have to differentiate between SEV, > SEV-ES, SEV-SNP, TDX, etc..., a vanilla "bool is_protected_guest(void)" should > suffice. Under the hood, x86's implementation for is_protected_guest() can be > boot_cpu_has() checks (if we want). What about the use case of protected_guest_has(flag)? Do you want to call it with with X86_FEATURE_* flags outside arch/x86 code ? -- Sathyanarayanan Kuppuswamy Linux Kernel Developer