Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp428319pxv; Thu, 24 Jun 2021 11:00:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl3OEUQfYO5r6fe8Y2YwgEBUPeUJNV9I9iYt7tgFlGo8EN/YL0uydO80xUQfdJNOV4YTyg X-Received: by 2002:a02:cc52:: with SMTP id i18mr5764578jaq.47.1624557634900; Thu, 24 Jun 2021 11:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624557634; cv=none; d=google.com; s=arc-20160816; b=eoY1e4nm4pffYwbhuWnWrnMuA9s2xc6ryGaLYccilZ+LZR47lLyuTssnefz0GcCk6P bDWikMsDt7iDDBLFMvEubDAKkEuyyKFm7nPkDbpnkwViPu0ePCB+QajUQtCRohW/6L4f v29uGKhaf1ahUyysYYhnO6NVgQwkXlZ+lCNUIbmZ3SI0uVU7jpFdayb7rhCtrf3kPxMr ajq+VGemIu8JvahcoTDKyCJ7gT5igvns5kwNvkDIXqwRAxE1u9zXsY/A0LrEapJJXXpD yhn8VlhSUVq7XcyyxKxuQqrpKFsAXan+YuoSuYrdS9JeieOXVFI+m9+z4QKWoy43mlIf UkRw== 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=kGJvhsHLTPPwM1wnPkgJKoqWiAEMOulEWFQeQPNWoi8=; b=1LFXCRpY/MuHlNc+aieDxH3oAqAtcz8tN41NVQPhA/CqNdrFcgfkemcK8jl6AXQM8q jRAZtwYj0x/pc6I+EJd5pFVBpnF34pnKm4te/FKyJoqtowYjOJDdpaH6oGtCDiU0Rzqt nmNYK6Er5LWxlyvfcCBtcOHVzGrguxiJY5Bxy/8cw5Nm81N93fFptir8yRNsYkUhzfW6 M+LYEdjs0UeZIyYYH56kLybghAUNTHZ4SRI9FihIQ6p2FRvHHLTtnv4BphalOzS3rim+ dsNM8bghMNmF7OxvDMGdpjwhgrnOTyEljibIag2f716Fgczx/DQDQPVkeTsCitEg+rcp rrsg== 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 i9si3096368ioq.17.2021.06.24.11.00.22; Thu, 24 Jun 2021 11:00:34 -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 S231969AbhFXSBN (ORCPT + 99 others); Thu, 24 Jun 2021 14:01:13 -0400 Received: from mga11.intel.com ([192.55.52.93]:6394 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbhFXSBN (ORCPT ); Thu, 24 Jun 2021 14:01:13 -0400 IronPort-SDR: p49exp2brmX0Du/kH35v1JzfwUVzNkV8QZr+jQ8ePMCyaswD/BSL3lDJi4n036Y6Rxi+bkYO4U whvlWNXzrCEA== X-IronPort-AV: E=McAfee;i="6200,9189,10025"; a="204520654" X-IronPort-AV: E=Sophos;i="5.83,296,1616482800"; d="scan'208";a="204520654" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2021 10:58:53 -0700 IronPort-SDR: kr5zBp9niZ2W2eP6TwnJa/lvwFr4KebFIGQgTnMM41AeBeS+p81QllHKR/8OV/QJ0LfKypEvZ1 7zpxfSc7yyZA== X-IronPort-AV: E=Sophos;i="5.83,296,1616482800"; d="scan'208";a="487861512" Received: from llvujovi-mobl.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.255.82.142]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2021 10:58:51 -0700 Subject: Re: [PATCH v3 04/11] x86: Introduce generic protected guest abstraction To: Borislav Petkov Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org References: <20210618225755.662725-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210618225755.662725-5-sathyanarayanan.kuppuswamy@linux.intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: Date: Thu, 24 Jun 2021 10:58:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 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/24/21 8:01 AM, Borislav Petkov wrote: > On Fri, Jun 18, 2021 at 03:57:48PM -0700, Kuppuswamy Sathyanarayanan wrote: >> Add a generic way to check if we run with an encrypted guest, > > Please use passive voice in your commit message: no "we" or "I", etc, > and describe your changes in imperative mood. > > Also, pls read section "2) Describe your changes" in > Documentation/process/submitting-patches.rst for more details. > > Bottom line is: personal pronouns are ambiguous in text, especially with > so many parties/companies/etc developing the kernel so let's avoid them > please. I will fix this in next version. I will make sure to follow it in future submissions. > >> without requiring x86 specific ifdefs. This can then be used in >> non architecture specific code. > > "... in arch-independent code." or so. I will fix this in next version. > >> prot_guest_has() is used to check for protected guest feature >> flags. >> >> Originally-by: Andi Kleen >> Signed-off-by: Kuppuswamy Sathyanarayanan >> --- >> >> Change since v1: >> * Introduced PR_GUEST_TDX and PR_GUEST_SEV vendor flags as per >> Boris suggestion. >> * Replaced is_tdx_guest() with if (boot_cpu_data.x86_vendor == >> X86_VENDOR_INTEL) in prot_guest_has(). >> * Modified tdx_protected_guest_has() and sev_protected_guest_has() >> to support vendor flags. > > ... > >> diff --git a/arch/x86/include/asm/protected_guest.h b/arch/x86/include/asm/protected_guest.h >> new file mode 100644 >> index 000000000000..d47668dee6c2 >> --- /dev/null >> +++ b/arch/x86/include/asm/protected_guest.h >> @@ -0,0 +1,20 @@ >> +/* SPDX-License-Identifier: GPL-2.0-only */ >> +/* Copyright (C) 2020 Intel Corporation */ >> +#ifndef _ASM_PROTECTED_GUEST_H >> +#define _ASM_PROTECTED_GUEST_H 1 > > #define _ASM_X86_PROTECTED_GUEST_H > >> + >> +#include >> +#include >> +#include >> + >> +static inline bool prot_guest_has(unsigned long flag) >> +{ >> + if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) >> + return tdx_protected_guest_has(flag); >> + else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) >> + return sev_protected_guest_has(flag); > > s/protected/prot/ > > tdx_prot_guest_has > sev_prot_guest_has Ok. I will make this change in next version. > > ... > >> @@ -18,6 +20,21 @@ static inline bool cpuid_has_tdx_guest(void) >> return !memcmp("IntelTDX ", sig, 12); >> } >> >> +bool tdx_protected_guest_has(unsigned long flag) >> +{ >> + switch (flag) { >> + case PR_GUEST_MEM_ENCRYPT: >> + case PR_GUEST_MEM_ENCRYPT_ACTIVE: >> + case PR_GUEST_UNROLL_STRING_IO: >> + case PR_GUEST_SHARED_MAPPING_INIT: >> + case PR_GUEST_TDX: >> + return static_cpu_has(X86_FEATURE_TDX_GUEST); > > return cpu_feature_enabled(...) I will use it in next version. > > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer