From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED5AB36CDE9 for ; Thu, 9 Apr 2026 21:17:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775769481; cv=none; b=Pit5MAboalVo/LyStSlsk3v0anT+md/vGDA8zsg9c01ugVCfktyitKFr5M1zo4AB0kITsHqfdP5r9tETYhwsMDgQqr9l0zOPYk8tbjasy4MDdTW8IAV/3wEXLKVYAPdZMFyXupbeU404IWLFQKZpY4IurMyq8DC+SJEcHfy8BRE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775769481; c=relaxed/simple; bh=kTGNLbn4hMgKaLX8TjQOM8N2QBw0VnJstnv2OfEAq4o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SWic3JVNrJnrHogd++sRmlzbvTjnavsF0ES33hzyR71I4ioww8L2eJO8osmOYGs63aFlrO+9yRfq1+YnGZy9E2gsefl+qcibgN2410quv7LecHJb9LpnwhgNZ3lCPzXai9UqsShuH1Rv+g8kM2uG1ErORVvt78NpCfRbKAhnQfI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=M7QKu54u; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="M7QKu54u" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35dacc40f92so1570370a91.2 for ; Thu, 09 Apr 2026 14:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775769478; x=1776374278; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=463dllVAQ+CXXYb1cF+GtnlCvXOZXdOn20lYdKT+eLg=; b=M7QKu54uxIYZnsPyUxowHmIoEdSF6/uxRX4ghURj98Kd+M+cdrsLtQqNxGcpaXbhks Ehqls/oBTkC8x1Zg6npzwWGe9x9OY1xkn2Cc8ipFTr10SYMj7xKYe21fG6k1/R3okiBs F4nDeV0JN2tdCYIrOqSHG7WbH2TTR/XzZ9OWpmMeh4gvyjlc3xSDIjrdgaKQtLvC6sbM o66wRVzZHX1IhHLVhdiLqQpHYT1kTmL5CdnHNldew1Ezxc7zjFnbkMDIDtcJeAHIeZgM x902TEuuh5bDu00LnlI7RkLPk5Wz8dS64j3R9EpqFgaYuJADpm/WHN8jY9WPBRtyXOQk +VJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775769478; x=1776374278; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=463dllVAQ+CXXYb1cF+GtnlCvXOZXdOn20lYdKT+eLg=; b=CSOn+nLSFlNrlfZKMjo8pYLhwbJ/PVruZkRyd+oCMz0bVqUtvP0Dzwsb+xk/rWo5jf 4wnar5/BkSnhro4hI1mm05Xp4jACu5tko3K/PItrwQaVWTtr9CDhWRVIHnaB/Oan5r+Y xjZ2pT03IC+JUoABOqTEtXo7UrMu/PVUal2L+dhyL3eDmMbuQJVgBUrnw00ro/uG6IeF VI77jT4NuV8rbpSZ9fNaQT1jOnVNIoSjDFIpH23kf0eFI789SZR+NnBxYVRuGM5FZ6jY E+kWRVYUBw9bLJQaaWBBV+7o9neoysD8qC15THf+mHEfwhZlkcGWrLLDFO6O7JKcEP+k 2J+Q== X-Forwarded-Encrypted: i=1; AJvYcCXIVmVlz45NEMgI0OqiaJfC0xooF/57cmD+W6Q3WYKpVpFlI/kvxhQimdZsufRCOFfzD8YGwJlx+3Crl/s=@vger.kernel.org X-Gm-Message-State: AOJu0Ywl5NihaKy2tSWJzBDxbQXlN3Aym/Mj6Q8obUeBdNNiLK7BvPLM 0n/HL3aZtlyjuor1QUOi6/gDwnUjxsE9MzeI1A/DgHa7DrOlTMKa87m0u5IoIP4+2DaYNLPH5zB fZ6NnFA== X-Received: from pjbgi21.prod.google.com ([2002:a17:90b:1115:b0:35d:a45d:bc03]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2d07:b0:35d:a3b4:2f0d with SMTP id 98e67ed59e1d1-35e4274e1damr551175a91.6.1775769478020; Thu, 09 Apr 2026 14:17:58 -0700 (PDT) Date: Thu, 9 Apr 2026 14:17:56 -0700 In-Reply-To: <20260324194034.1442133-5-tycho@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260324194034.1442133-1-tycho@kernel.org> <20260324194034.1442133-5-tycho@kernel.org> Message-ID: Subject: Re: [PATCH v2 4/5] KVM: SEV: mask off firmware unsupported vm types From: Sean Christopherson To: Tycho Andersen Cc: Ashish Kalra , Tom Lendacky , John Allen , Herbert Xu , "David S. Miller" , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Kim Phillips , Alexey Kardashevskiy , Nikunj A Dadhania , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Tue, Mar 24, 2026, Tycho Andersen wrote: > From: "Tycho Andersen (AMD)" > > In some configurations not all VM types are supported by the firmware. > Reflect this information in the supported_vm_types that KVM exports. > > Link: https://lore.kernel.org/all/aZyLIWtffvEnmtYh@google.com/ > Suggested-by: Sean Christopherson > Signed-off-by: Tycho Andersen (AMD) > --- > arch/x86/kvm/svm/sev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 37490803f2e8..0fe9515db1e7 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -2976,7 +2976,8 @@ void __init sev_set_cpu_caps(void) > supported_vm_types |= BIT(KVM_X86_SNP_VM); > } > > - kvm_caps.supported_vm_types |= supported_vm_types; > + kvm_caps.supported_vm_types |= (supported_vm_types & > + sev_firmware_supported_vm_types()); This is slightly flawed, in that sev_hardware_setup() still reports SEV-ES as fully enabled, whereas the other cases (ASID exhaustation) clear the VM type *and* report the feature as "unusable". Addressing that is actually a great opportunity to dedup some code in the previous path. I.e. if we first relocate the supported_vm_types updates to sev_hardware_setup(), then there's no need to copy+paste the ASID checks. And then restricting VM types based on firmware support Just Works. E.g. to yield: [ 1813.863571] ccp 0000:24:00.1: SEV-SNP API:1.58 build:1 [ 1813.876790] kvm_amd: SEV enabled (ASIDs 254 - 509) [ 1813.881595] kvm_amd: SEV-ES unusable (ASIDs 1 - 253) [ 1813.886574] kvm_amd: SEV-SNP enabled (ASIDs 1 - 253) [ 1813.891549] kvm_amd: Virtual VMLOAD VMSAVE supported [ 1813.896522] kvm_amd: Virtual GIF supported I'll send a v3, I've got everything coded up (I wanted to make sure my idea actually worked before suggesting it :-) ).