Message ID | 20240226190344.787149-4-pbonzini@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-82192-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2278462dyb; Mon, 26 Feb 2024 11:08:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXBM4EyE5jThHfUhizYuIbSKyESTt3ssHE+7VFSD35RrHcySx3gSBIHtZcqG1pbuI4qhVyj9h/l/owjqhwOdr40OupQ+Q== X-Google-Smtp-Source: AGHT+IEBFgUKINxKNF+1uilmqTc9FPOuYBUsFJ6RU00jthBd9Z3EHHQFi+F8e7olo0i7Mmu0IDeg X-Received: by 2002:a05:622a:410:b0:42e:6b08:c7e7 with SMTP id n16-20020a05622a041000b0042e6b08c7e7mr9797182qtx.7.1708974500982; Mon, 26 Feb 2024 11:08:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708974500; cv=pass; d=google.com; s=arc-20160816; b=eANiy/kfhK/vwyNbb/I4wrau9Uakfe40nPZJFMmGD68nsI2uXcImt5731Rh6YhrlG1 SIGuijaexzR+bcNc9Q8gnWWIxCFHd4ENJySufqsTTJPHMc2Tk5hZBYkUNfCjpD4q3RMa oT/Oz3blaS7RLR7xAEGcfdZsAOXPkjX1wxca4KDmB9JIF21cvcxuJLlptn54a2isSf1p dsAaK9afB7SknKmErRNrJJZL2340XmHJK637xvGXjJowotNggp2JRhEppozvxXpLoHqN pcoDOXLIndoO7LCRumRkR4T0Dw3eQgzUAhrZopT1qFsY6kc70v7ScBGQbM/alHw3ScEM F+sw== 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=9cUZ/D/2UiLjM9T2gYRl36gTxhVW4aQM4GLnpybbj2E=; fh=TLdZJsFzSA0fpm6Q4iUv+uB0sG0oU+h3Bp6HiSGyZm8=; b=0hAooRD573BvarmTmm/nhUD9Cy/4T04ifW6tDsiHzCrjbFB9DviqLEJnjyAbWSPBGb e2BgReybL6se/kh6BcZMyhoOz/I2SGi8ZkerWDu5qu+4jDQCWDl6TcFp8TffSNiUu4C8 qEXpI4SOxM6J5EaF1IqSckg8gHBxLrbCfEaNLgP8Mhat/K2ASCRyI660e0LPa9PEghyv kdneUjbntLb/05Zs5QtvxVOa9qp1xybciCYU49DeWYQHGzx0Q13CcAeswMTHhXBkdn06 UmbkncGPRuhlUQt3Qmqce2xfBCcQ3NJUmWakYyP15Ud8n4WgLBW85xtx33Qy7qqikCgp pGQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WF9n+k84; 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-82192-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82192-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b22-20020ac844d6000000b0042dc85eeda8si5556789qto.121.2024.02.26.11.08.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 11:08:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82192-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WF9n+k84; 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-82192-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82192-ouuuleilei=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 C13F61C22E52 for <ouuuleilei@gmail.com>; Mon, 26 Feb 2024 19:08:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50E5413472F; Mon, 26 Feb 2024 19:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WF9n+k84" 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 17C2C12FF8C for <linux-kernel@vger.kernel.org>; Mon, 26 Feb 2024 19:03:52 +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=1708974236; cv=none; b=MnYOD5P9fHlPOxhKMKdSt3kv0sYMmmj25Jgts84aavvQkkxgTbfrWiC4bKfb2DkieF+UDlabs5HOZPcE+TlPuI8Z9ZBiOLPL8Sl2bk/dVVR80QOT1SgYiKMKcZ6xgNioz1bI2eOlRVAx7lze/z7ogesEOUkqzau4ot928br50oQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708974236; c=relaxed/simple; bh=xRuYJawEF4kvHSjkADqCRreS8rILKCdjMjmSYx1/tFA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=YerVleh2Mm7Y9H1yC/TitjOsLFVT5nfJnmu7Qp08TXzowVsOTD+6WnXaE1l4VMjFHIxWSYFsrKrYKU4n09+BsSglEX446XxTiE+hClITp0142/3CDv+E0v8YdG1AePfe2ZZaaDGEgq+BFYvuvuBNJPQf8qcvmgM0dI0eEB4Ort4= 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=WF9n+k84; 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=1708974231; 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=9cUZ/D/2UiLjM9T2gYRl36gTxhVW4aQM4GLnpybbj2E=; b=WF9n+k84Hh5+g72tA1YYHSGpGqBoa4bl0OFA3HGksjljdctEEdPt1wNc2ZuxmnC4qQgHEX JKmWuZr6eK2UEbYrpO53kLf1nRCmrJT6tiDKQVdxtyxGm0IRR6fKJ8HRLTI1NMdCbjhWCW 6VPEk1ymH/8Z2LAdUTNpELmzY3itM5w= 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-615--VDt4PPOM7C11CRlyBtIbA-1; Mon, 26 Feb 2024 14:03:46 -0500 X-MC-Unique: -VDt4PPOM7C11CRlyBtIbA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 44AD1185A783; Mon, 26 Feb 2024 19:03:46 +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 1C098492BC6; Mon, 26 Feb 2024 19:03:46 +0000 (UTC) From: Paolo Bonzini <pbonzini@redhat.com> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, michael.roth@amd.com, aik@amd.com Subject: [PATCH v3 03/15] KVM: SVM: Invert handling of SEV and SEV_ES feature flags Date: Mon, 26 Feb 2024 14:03:32 -0500 Message-Id: <20240226190344.787149-4-pbonzini@redhat.com> In-Reply-To: <20240226190344.787149-1-pbonzini@redhat.com> References: <20240226190344.787149-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791989646713442758 X-GMAIL-MSGID: 1791989646713442758 |
Series |
KVM: SEV: allow customizing VMSA features
|
|
Commit Message
Paolo Bonzini
Feb. 26, 2024, 7:03 p.m. UTC
From: Sean Christopherson <seanjc@google.com> 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 <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- 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 f06f9e51ad9d..aec3453fd73c 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2178,10 +2178,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)