Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp551332lqt; Mon, 18 Mar 2024 16:34:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5FUGlZ+cIkaiBP8FXHEh/+zLtwRniE8U+++BpcSJ3XogHbrNieWA84IW6ozIVqaiGUqiIZc8ERDhqDWF3RrqpJa3QaklX2xnOhLArAg== X-Google-Smtp-Source: AGHT+IE/qm47OaIikGoqLcYx86OqUiUOv/R5MDwIAyK1FlwEJx313qysbjJqDwTCM3U2Kj9pucGm X-Received: by 2002:a05:622a:202:b0:42e:b457:b882 with SMTP id b2-20020a05622a020200b0042eb457b882mr14561737qtx.37.1710804854415; Mon, 18 Mar 2024 16:34:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710804854; cv=pass; d=google.com; s=arc-20160816; b=RX/UX6YUpv9XZ2eVeAtcWx3cBmzhv+6KKhM8904nQGZUzGhydf68yWjeiK46snlVKL 35AqrLrH7MmyyskE8I0BAchURcgX7v2wm2Oj2whEi39v5iU6aVYVgTtmSNkRKYiWxdWB vXX1Ou/hrbLtNPopwhp89hmxKQBFQqstWzlwuouMOW5B7htNmDaZ11fYILn7PgNla/Zd +3GSzCUQpx60ZEi/tmsn6tNGWdge+cywqrdL3n4mK25LmpoMUx9PbISrrAyGbQI2lkpk k4FH6qCAAd6wWFwRgYor7ZhJHvkRlibIhbLxZZqxdMQp1TWqQIa0yXZl/1g2XtgK5Yu6 luaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ON5fE7hrojJzQ2xG5TVkP4zn85dxrOKCit9Bo+PfrAs=; fh=3hAI0TnvvweyuafrDQR9sJAViJ87fw+qG0excEgpXGk=; b=HiH60OAdTVc+6ckov5iW9yO4cXVTC7kMJGfyiaqWyM70gmIU5ZHU93/xTla/yapuoo //BYYG4rwDHvBhH4dhcShq3BCGe/yrgRGWYNFgSm26Hap+TjvOF48fQMWX/9lvmdupy2 52p8Oya0SQKkg2EN7AJqQWlufYZLR6HYKIwzK9sS5QbhW46l0A462+3c2F9i9tAK/O2C 0QfmvtOjJm/JWwwQRiPm6wGKAMuYw5THVQ4xezS/QX5naRJ19Nu37OL+p404vi7ovVvU ms7GC5it/rt6MF9X2+sIBAKl2Er1InJuwU8ywFnos4ky7qBPr980YfgXgvn6RaTnixJM JTgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iWjeyHFg; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106805-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n10-20020a05622a11ca00b0042ef4852a36si1370578qtk.500.2024.03.18.16.34.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iWjeyHFg; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106805-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 244F21C21AF3 for ; Mon, 18 Mar 2024 23:34:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DE955FB8F; Mon, 18 Mar 2024 23:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iWjeyHFg" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 748F45F85F for ; Mon, 18 Mar 2024 23:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710804840; cv=none; b=mST2QCGvZJ/1o0jdMn//PmzHXHRKAhMb4KBuBTfvFFtX+pYpgfeIzVA6ou+9KsNqsO6MyKk8Qr2ZeY7N7LTjUHKssgGJzeJLwkzeWlFvi7YKjjUqt5cweCLvwUuZDGcpv1/p62ozG7shnSxCEUDRDVfU98cNauHUsD5MDnXdNXo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710804840; c=relaxed/simple; bh=Tf4feJZhWwnmgiC2l7Is9hf7qtWmR8OKc/AKvKQIlNA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lIZCchf9V7md1YQBj3rYXoFWdlwvnjhJ0dM13myeMTv2nRv3sXaxqW/YU6254EcXvbttscuMdGTQcnOr5D7JO5/ojdTWEcB2CAABnqY+XXTCnXl/4/xSeK11PL7ZFUbN8/gi/GAS0ENX03GmCwNP4QJYES/RNODiHv0SInofG2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iWjeyHFg; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710804837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ON5fE7hrojJzQ2xG5TVkP4zn85dxrOKCit9Bo+PfrAs=; b=iWjeyHFga4HEEHT9OPzjOah248pIHcbDKDl211e7v4W2nPEgAXyrh+vnxF9OiwhNMnE3ZR vnzeIcnAfWY4LEpaoA/jyoR3NRNojlHF1dWUJcCzrYXcQyACsbA1v6g/R/nYaJj3Hl7sem jEWz/NShJe/WwTPn5ja7f2W0HYUiH4E= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-1fJNkKPdNo6AozPsADC4pg-1; Mon, 18 Mar 2024 19:33:54 -0400 X-MC-Unique: 1fJNkKPdNo6AozPsADC4pg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE58D101A523; Mon, 18 Mar 2024 23:33:53 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A72371121312; Mon, 18 Mar 2024 23:33:53 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: michael.roth@amd.com, isaku.yamahata@intel.com, seanjc@google.com Subject: [PATCH v4 01/15] KVM: SVM: Invert handling of SEV and SEV_ES feature flags Date: Mon, 18 Mar 2024 19:33:38 -0400 Message-ID: <20240318233352.2728327-2-pbonzini@redhat.com> In-Reply-To: <20240318233352.2728327-1-pbonzini@redhat.com> References: <20240318233352.2728327-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 From: Sean Christopherson Leave SEV and SEV_ES '0' in kvm_cpu_caps by default, and instead set them in sev_set_cpu_caps() if SEV and SEV-ES support are fully enabled. Aside from the fact that sev_set_cpu_caps() is wildly misleading when it *clears* capabilities, this will allow compiling out sev.c without falsely advertising SEV/SEV-ES support in KVM_GET_SUPPORTED_CPUID. Signed-off-by: Sean Christopherson Reviewed-by: Michael Roth Signed-off-by: Paolo Bonzini --- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/svm/sev.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index adba49afb5fe..bde4df13a7e8 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -761,7 +761,7 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_mask(CPUID_8000_000A_EDX, 0); kvm_cpu_cap_mask(CPUID_8000_001F_EAX, - 0 /* SME */ | F(SEV) | 0 /* VM_PAGE_FLUSH */ | F(SEV_ES) | + 0 /* SME */ | 0 /* SEV */ | 0 /* VM_PAGE_FLUSH */ | 0 /* SEV_ES */ | F(SME_COHERENT)); kvm_cpu_cap_mask(CPUID_8000_0021_EAX, diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index e5a4d9b0e79f..382c745b8ba9 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2186,10 +2186,10 @@ void sev_vm_destroy(struct kvm *kvm) void __init sev_set_cpu_caps(void) { - if (!sev_enabled) - kvm_cpu_cap_clear(X86_FEATURE_SEV); - if (!sev_es_enabled) - kvm_cpu_cap_clear(X86_FEATURE_SEV_ES); + if (sev_enabled) + kvm_cpu_cap_set(X86_FEATURE_SEV); + if (sev_es_enabled) + kvm_cpu_cap_set(X86_FEATURE_SEV_ES); } void __init sev_hardware_setup(void) -- 2.43.0