Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp471772lqh; Thu, 28 Mar 2024 07:24:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMkjf1UTpF2j3odaUn7klu+WAjjW/kRF4WU4GamNJdWBvcWZKfFG5OqCHr4WQz6rWlUDav2u6o64CNwupCLc7DQKtovC3PnOe8NeUT0w== X-Google-Smtp-Source: AGHT+IFWxj5M4lT5PvSYaMgWMk/bxAZFrUPg4ksTScZ9rYBIO7Uu6p22pS5qCsbwaoBurLC2xE+Q X-Received: by 2002:a92:cecb:0:b0:365:e274:5e55 with SMTP id z11-20020a92cecb000000b00365e2745e55mr3274946ilq.7.1711635883385; Thu, 28 Mar 2024 07:24:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711635883; cv=pass; d=google.com; s=arc-20160816; b=0ZZt52d3b9g7YseUAw7Wyob2jlS+qqW6UE3EEyCwFtSHstqLnY4w2q85Zf9ICq8cth Pr9AeJKupOlYE4lPmk/LnLklg16Fniw6H09OaQqWW8cDNJayYyMXiMu8zX+ds8kwnNdc goPfU0AeGnFuCpx6E1XdcDSC+ckGZNw2pbBu5QtnrnmXTH4pY0XQM1JGqT2IXZmsELCj DjLU/+FeXgV1dqplDgFuyeP5aC3IKsj/ewU9B1M+pPaW4XCLe9rekzRT8ElVmVeRtvKT ANY+M7Per2uN6MJT3JLjxeySaCGI4gQLcV8hAsV/tgpwo9rvzqgdBgCt5ICtJf+hVCBc oZAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-filter; bh=1l+2SEDIwQkqSvND2rBzNts74gzDdFBM4fPcS3as+CA=; fh=Il59IoUtHn7TpHabbAr/ygHb2lfI/EyPXOOmaJ2OhEw=; b=TUnKiOiJI7dOT59SQHM2/macEM4/0L4O5VwfKB5C7iB/oRj9O+elJXu4fN3fRYc9Bt vIYoW863EJeQbGPiy7m3DlXdWKETc6/D9YjKj8t+QOOktHcPHHjdL1DdmbeFlg7yb0wZ sypCAHdTc5cZjH2kh37l5mMzfMdodGPURIn+Xp8SAcnjkqaycqWA6WoQOyvXoYQqyDdZ yvEURoXdfWHKj0f8zbI8EfrLnY6t9cLXiF5rcsSNBIv6B7n7xD2L7JApGzOdNSShRVJ9 CoZPq6cHF5TCs0ODY2TfBjiuef9TGJ4haAQ+NzIwBlIXXnPHsm1AE4v/T1J1tP5rO8Zl DsTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=oqvZ3Slr; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-123067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123067-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l14-20020a65680e000000b005cecd95b6besi1531684pgt.685.2024.03.28.07.24.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 07:24:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=oqvZ3Slr; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-123067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123067-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 47C06B20F0A for ; Thu, 28 Mar 2024 14:24:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB9CB8626D; Thu, 28 Mar 2024 14:24:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="oqvZ3Slr" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D25E083CB2; Thu, 28 Mar 2024 14:24:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711635874; cv=none; b=YMJJahB5qgdNim4oLX3q1/zNDKrmxrVPiSSEflU/vXDQjm2ScrmQU5SzEZ0UAf1Lzmi9coGhgBiw/fDFhA46lQeTIjOni1QpcNn1hilc7EKj3amUDJqNghz2kNgpd/idedNLAVc+R0HZdvZZOr9x7e3uU6Xt2W0Sa+m8yGpN48M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711635874; c=relaxed/simple; bh=BK5T9ghNxG0GFU69c70sqjesTdNe8K2qsWISPcbW/BI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NJ0rPbgQxZEbHPTESlENXEdD/FWRtp59OobtsE8YiKltpe1G2tHLc/TmFcgvkBL5eJ9lrAHegHnYxBj0SgKsLGGruyioI+zQJrBUvemOc/kI01fNjk5/+QLySotlFg/F+mfvq5btlepeoj7iRNhZq3YGLk86zNFQDkm/dE4afzM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=oqvZ3Slr; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from [100.66.160.44] (unknown [108.143.43.187]) by linux.microsoft.com (Postfix) with ESMTPSA id F15E820E6AC1; Thu, 28 Mar 2024 07:24:30 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F15E820E6AC1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1711635872; bh=1l+2SEDIwQkqSvND2rBzNts74gzDdFBM4fPcS3as+CA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=oqvZ3Slr8vDh7h6VgMDWNVpWOIqxlXFCFZHQOp45V68Q8+xA6vEFY21zOQ7yJKqRD 28qc6wSFHrMymbwBKatxXWfZzjf4TeqeXww66jc+AHRExNGKP0WQs5MAvnUa3y+vkZ kJXKZR1QB+DTCdaqTcoEBu5eJ403qnuAF9ZoR5lg= Message-ID: Date: Thu, 28 Mar 2024 15:24:29 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/5] x86/CPU/AMD: Track SNP host status with cc_platform_*() To: Borislav Petkov Cc: X86 ML , LKML , KVM , Ashish Kalra , Joerg Roedel , Michael Roth , Tom Lendacky References: <20240327154317.29909-1-bp@alien8.de> <20240327154317.29909-6-bp@alien8.de> <20240328134109.GAZgVzdfQob43XAIr9@fat_crate.local> Content-Language: en-CA From: Jeremi Piotrowski In-Reply-To: <20240328134109.GAZgVzdfQob43XAIr9@fat_crate.local> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 28/03/2024 14:41, Borislav Petkov wrote: > On Thu, Mar 28, 2024 at 12:51:17PM +0100, Jeremi Piotrowski wrote: >> Shouldn't this line be inside the cpu_has(c, X86_FEATURE_SEV_SNP) check? > > The cc_vendor is not dependent on X86_FEATURE_SEV_SNP. > It's not but if you set it before the check it will be set for all AMD systems, even if they are neither CC hosts nor CC guests. cc_vendor being unset is handled correctly in cc_platform_has() checks. >> How about turning this into a more specific check: >> >> if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP) && > > Why? > To leave open the possibility of an SNP hypervisor running nested. > The check is "am I running as a hypervisor on baremetal". > I thought you wanted to filter out SEV-SNP guests, which also have X86_FEATURE_SEV_SNP CPUID bit set. My understanding is that these are the cases: CPUID(SEV_SNP) | MSR(SEV_SNP) | what am I --------------------------------------------- set | set | SNP-guest set | unset | SNP-host unset | ?? | not SNP