Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3456846pxj; Mon, 7 Jun 2021 11:03:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4e8nCr4Wj7aBeGEnkNER42ZpCHbSryIumW3k6SLFY0JGHoe4flXR0x/TElrN3D18KyoJF X-Received: by 2002:a05:6402:366:: with SMTP id s6mr14029350edw.209.1623089025508; Mon, 07 Jun 2021 11:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623089025; cv=none; d=google.com; s=arc-20160816; b=IeXTDipKQCksBokoc6yjZHhWpWLdsH8PyPuXezlgAhvb/Ji4Q3Z7HNFmnPaXV95O7S 6p2HWMbQUYZF/VYomWUnLDludedDRJaUI+wrcYLT/rj2JfY2UuRgY44e7DUkS3+bTE03 jbG0yH1iJhK1CPPYXo8uU+fX1aTh9lsaDD8i0HC1g1vBqE/qNcwpfM6X/DC5zC0MfwqS 9Y9pf/QWu0RE5hgbCNfLrsTqTwkP2VlXu+Jw5DvWC/RMzDO6M2W7V0cxb80K3gwHoMBM PVGExe30eTJQSKTIhd9zFcC7zVhngxmGUN9YJbwWhH+UGqoPnrWu3tJ6qqktyUYuR8Do 1B0Q== 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=gB96axndPRTG3maLotMX9UNrKwuwpEd66TUQmBuf7bw=; b=zUA82Er+lNAMm65YJc5iuEaLH3BWT3N4M4Tk6UQfwodEbi7I0ZacE+suNiMriPNpJ6 87ZcTVaY8GEdoi4tFLEQh8L0gbCci5mJ5YXsvmaOZO0EQ85pDG/ygEJWGd8eHmV7M71H D+iw9INHSu/SI3x/S8i2TWAB9vRCbifTNJD7G5V1Yh+TxesAGnIab2ALvzEZNQFtCllN +KV82O61EKttj2dVect7bcd9Alsbsc3vK1CijDPEGDKbzR0b8lrUpeuY0PIdEUe5MFzE lH94ReKpAXeRBKQuziuDhr4Sh9wQxWSHSGZu41KWDPfQw7fbLhJv3pmllq1/O6el4EVD l1Dw== 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 m7si4747621edq.604.2021.06.07.11.03.20; Mon, 07 Jun 2021 11:03:45 -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 S231175AbhFGSDD (ORCPT + 99 others); Mon, 7 Jun 2021 14:03:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:34078 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbhFGSDB (ORCPT ); Mon, 7 Jun 2021 14:03:01 -0400 IronPort-SDR: 7GH5SV6zW5V5y+58tutXH+1O1jBBG20lG6J4ZM49+a7s2INM079kTgH7cWZfLyJQkD1pP4cc3w zfXRxIAkpvYA== X-IronPort-AV: E=McAfee;i="6200,9189,10008"; a="226012434" X-IronPort-AV: E=Sophos;i="5.83,255,1616482800"; d="scan'208";a="226012434" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 11:01:08 -0700 IronPort-SDR: AtVubwasQhCX8WWv5y9frrS1uEfpxMIAR80njkx6cCJKXRR5xBPpc4AGN2jAvcqZIb/Aefhm9S XleIjLuz73Wg== X-IronPort-AV: E=Sophos;i="5.83,255,1616482800"; d="scan'208";a="619026583" Received: from ssanje1x-mobl1.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.251.153.170]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 11:01:07 -0700 Subject: Re: [RFC v2-fix-v2 1/1] x86: Introduce generic protected guest abstraction To: Borislav Petkov Cc: Peter Zijlstra , Andy Lutomirski , Dave Hansen , Tony Luck , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Dan Williams , Raj Ashok , Sean Christopherson , linux-kernel@vger.kernel.org, Tom Lendacky References: <20210527042356.3983284-2-sathyanarayanan.kuppuswamy@linux.intel.com> <20210601211417.2177598-1-sathyanarayanan.kuppuswamy@linux.intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: <82f9e5a9-682a-70be-e5ea-938bb742265f@linux.intel.com> Date: Mon, 7 Jun 2021 11:01:05 -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 6/3/21 11:14 AM, Borislav Petkov wrote: > On Tue, Jun 01, 2021 at 02:14:17PM -0700, Kuppuswamy Sathyanarayanan wrote: snip > diff --git a/include/linux/protected_guest.h b/include/linux/protected_guest.h > index 6855d5b3e244..bb4b1a06b21f 100644 > --- a/include/linux/protected_guest.h > +++ b/include/linux/protected_guest.h > @@ -2,7 +2,9 @@ > #ifndef _LINUX_PROTECTED_GUEST_H > #define _LINUX_PROTECTED_GUEST_H 1 > > -#include > +#include > +#include > +#include > > /* Protected Guest Feature Flags (leave 0-0xff for arch specific flags) */ > > @@ -20,23 +22,18 @@ > #define VM_DISABLE_UNCORE_SUPPORT 0x105 > > #if defined(CONFIG_INTEL_TDX_GUEST) || defined(CONFIG_AMD_MEM_ENCRYPT) > - > -#include > - Why move this header outside CONFIG_INTEL_TDX_GUEST or CONFIG_AMD_MEM_ENCRYPT ifdef? This header only exists in x86 arch code. So it is better to protect it with x86 specific header file. > static inline bool protected_guest_has(unsigned long flag) > { > if (is_tdx_guest()) > return tdx_protected_guest_has(flag); > - else if (mem_encrypt_active()) > - return amd_protected_guest_has(flag); > + else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) > + return sev_protected_guest_has(flag); > > return false; > } > > #else > - > static inline bool protected_guest_has(unsigned long flag) { return false; } > - > #endif > > -#endif > +#endif /* _LINUX_PROTECTED_GUEST_H */ > > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer