From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 E03C91FBEAA for ; Wed, 18 Dec 2024 19:10:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549051; cv=none; b=VDkGkI13MY9mang749k1j0g2cE7keFR+Uj4yWvIe9tkZMTzivSJrYDIK17egBR/PLnSFvb4/bruIDfhmSrUdLEWtK6FbrpsA0wJ/4mCyIpNGoTwMQq04RG5WDWJMTIqJlcfPLHIjTyZZW2Mg84UYZYSN71SglMdPQO+YzkBG2pE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549051; c=relaxed/simple; bh=jMj1OzrDjIrxeMoYOsAPw/b7S6pBg2XX6eTDS2vTCUk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VXHUlA/IpSPxGv73BZqZmI+jTVw5umdI/Ej8lF82dfu7t60vTmM+hIParYKWa/8kCK+dxm8O2L8YuTNP2QGir//K247+E8mlWUYiMuF8Z8w1NvY08J4tNECP0N4+LoTd+30KgpdeX+LY8jNRtcGws9iiO74vanirDNPtcF9zFag= 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=i6cbz8jy; arc=none smtp.client-ip=209.85.210.202 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="i6cbz8jy" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-725d8bdc634so27072b3a.3 for ; Wed, 18 Dec 2024 11:10:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734549049; x=1735153849; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=YClUdPoywXVSqRLvOMBrpQD/YaQSG0s79CHQrCDEw+U=; b=i6cbz8jyMqb2VdeZyEovdZzi5pM+Rs5D/WSs9i3tQmh6UMfUTPdTgNtV4e4UARhmWk 9cEtf4hNwByGUaUzv2CCXvcn3gORXmn8bVVJ+1NmskffzmbrFnFLHZRyKCyms+2XckbV APnwB1Rda19/wgFQ/G6NuDQY8+gav4ruFaTyrFa1UyPip1WfyaC53ZRxP2lS8GZBLYiK aCkgAq2t4tIpG2FwbIQferNWkQudyd/NFp+rBwNb/QSLu2trX5OlM1k9KlY+oIKj/HUz uOAdBAqDCfZsP9gRFWW0OEi+GmWsBZH56XOTOnT1tkHkfLmRhzej/C9GxsTIMKF5fG9/ C99g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734549049; x=1735153849; h=content-transfer-encoding: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=YClUdPoywXVSqRLvOMBrpQD/YaQSG0s79CHQrCDEw+U=; b=JIzU7Wr2I1hm072J1OfhOzZ9a4pqVo+WSWOXxA2DBQo3RLfQ1LnJM4xACpIT5aDyBx rOjm19znWUmCKJoIfaKohFPO6oVrKgiZkapWKuZzvuyjO97jdoddGJuGUCswA4IaYYKT K9p7qjD5OuunnazFcf6eNBY+sQJwOwqlcDyphTK0mJMt2yN7kruiGg63VA79XPU9/Gq/ qb5onkO+y60BIYjvrnHUX+qsiNqO2soHm50fBSFdaex3ObVinJxQqHFGFmgCUcSmcbXq EqexYXe6YAwAEJEakaNrsfs75PfxKefS8zOV96FWHBYKQJuO9xmzKA/WUhSuvbQI3mnL YPDQ== X-Forwarded-Encrypted: i=1; AJvYcCVyv+AzB1JaMLECZF3lol12eLQzBKigSIQ/hxdzOBo1RhugY/zu9qcoataZXD50Iwn/Ux0eIrgXUz9rxlk=@vger.kernel.org X-Gm-Message-State: AOJu0YwgpSS6KAIrhtOHuxLzuOH3kp114/cr0QY25N/Xdh6jFdNGzrwZ bJ0UgYflY5QOYdA0SFXkmL9HU0CEn3nzw3TJPaZPMFxaqPF9ZVe0qAJ1nq59Anf5l5HlooG+ljQ Eow== X-Google-Smtp-Source: AGHT+IH1B/bbkp0G6ABRo9fqVZ6adP+tKt8f/j21FuyOVEbiorHToFEL5buQ5JKv3Q2UPzxlMkYtWT3lSj0= X-Received: from pgda26.prod.google.com ([2002:a63:7f1a:0:b0:7fd:561e:62dd]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:e68f:b0:1e1:aa24:2e56 with SMTP id adf61e73a8af0-1e5c76afd3emr528641637.30.1734549049187; Wed, 18 Dec 2024 11:10:49 -0800 (PST) Date: Wed, 18 Dec 2024 11:10:47 -0800 In-Reply-To: <57d43fae-ab5e-4686-9fed-82cd3c0e0a3c@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <57d43fae-ab5e-4686-9fed-82cd3c0e0a3c@amd.com> Message-ID: Subject: Re: [PATCH v2 0/9] Move initializing SEV/SNP functionality to KVM From: Sean Christopherson To: Ashish Kalra Cc: Dionna Amalie Glaze , pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, thomas.lendacky@amd.com, john.allen@amd.com, herbert@gondor.apana.org.au, davem@davemloft.net, michael.roth@amd.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-coco@lists.linux.dev Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 17, 2024, Ashish Kalra wrote: > On 12/17/2024 3:37 PM, Sean Christopherson wrote: > > On Tue, Dec 17, 2024, Ashish Kalra wrote: > >> On 12/17/2024 10:00 AM, Dionna Amalie Glaze wrote: > >>> On Mon, Dec 16, 2024 at 3:57=E2=80=AFPM Ashish Kalra wrote: > >>>> > >>>> From: Ashish Kalra > >>> > >>>> The on-demand SEV initialization support requires a fix in QEMU to > >>>> remove check for SEV initialization to be done prior to launching > >>>> SEV/SEV-ES VMs. > >>>> NOTE: With the above fix for QEMU, older QEMU versions will be broke= n > >>>> with respect to launching SEV/SEV-ES VMs with the newer kernel/KVM a= s > >>>> older QEMU versions require SEV initialization to be done before > >>>> launching SEV/SEV-ES VMs. > >>>> > >>> > >>> I don't think this is okay. I think you need to introduce a KVM > >>> capability to switch over to the new way of initializing SEV VMs and > >>> deprecate the old way so it doesn't need to be supported for any new > >>> additions to the interface. > >>> > >> > >> But that means KVM will need to support both mechanisms of doing SEV > >> initialization - during KVM module load time and the deferred/lazy > >> (on-demand) SEV INIT during VM launch. > >=20 > > What's the QEMU change? Dionna is right, we can't break userspace, but= maybe > > there's an alternative to supporting both models. >=20 > Here is the QEMU fix : (makes a SEV PLATFORM STATUS firmware call via PSP > driver ioctl to check if SEV is in INIT state) > =20 > diff --git a/target/i386/sev.c b/target/i386/sev.c > index 1a4eb1ada6..4fa8665395 100644 > --- a/target/i386/sev.c > +++ b/target/i386/sev.c > @@ -1503,15 +1503,6 @@ static int sev_common_kvm_init(ConfidentialGuestSu= pport *cgs, Error **errp) > } > } >=20 > - if (sev_es_enabled() && !sev_snp_enabled()) { > - if (!(status.flags & SEV_STATUS_FLAGS_CONFIG_ES)) { > - error_setg(errp, "%s: guest policy requires SEV-ES, but " > - "host SEV-ES support unavailable", > - __func__); > - return -1; > - } > - } Aside from breaking userspace, removing a sanity check is not a "fix". Can't we simply have the kernel do __sev_platform_init_locked() on-demand f= or SEV_PLATFORM_STATUS? The goal with lazy initialization is defer initializa= tion until it's necessary so that userspace can do firmware updates. And it's q= uite clearly necessary in this case, so...