From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9021BC49EA6 for ; Thu, 24 Jun 2021 17:58:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69E7F613C5 for ; Thu, 24 Jun 2021 17:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232186AbhFXSBO (ORCPT ); Thu, 24 Jun 2021 14:01:14 -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