From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 90AB02DE6E6 for ; Tue, 10 Mar 2026 23:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773186517; cv=none; b=CU49ighqZYEM1JUlWFQKU98yjBysidXGhcPSL7Y0HAUbbpdfGEilZPTDOh5pTWMCa1P+kZCS6ks86V6jOkcpPgRkhx/1fBYBM4P3ketpt+l4chVkc5kHTEhju9yJEj9sXQIe2ZCIVG1TrhjdjvxPITBveHwOftO+JE9cWP4eoz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773186517; c=relaxed/simple; bh=Hxrp8TzxGDVoHzsErS/FYSvlAvs9D0Vx4AmF9OknU+I=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=FF4ce6t3YyL2v9QLbhiSzI2WzjKHSeL8KbzJqblu9oWT8N3MdRmnP+GZKVrKCI0q03Yr0Xzy04HpFUTxr9iVwKnoeXLTyxpQ5T0UguZOfX84YnS5b97enJZYEB/sk7elDsOCgyGK9rnOWsYLkgXIj4F5D59uiyPiQ3LJM37tM40= 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=TNdnyYr0; arc=none smtp.client-ip=209.85.214.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="TNdnyYr0" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2ae42659a39so595304925ad.1 for ; Tue, 10 Mar 2026 16:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773186516; x=1773791316; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:reply-to:from:to:cc:subject:date:message-id :reply-to; bh=QmyMv70eqtNH27YII0Pv9uQYRElVQRLLBwleEaiib/8=; b=TNdnyYr0cdm3/FKPBce/Rg5GXbob4SEFH3DMuOO965Gvybq3tYi77oTx6RFFrvjyKY sD/7pGKjePmXeCdP62PmjOIUrKpC4unIbjH4Wm2TQeOGKk+jwsY4p7J5GKNKAXAlOmFA 2Coix498WwI+2Wr3jLp+TAWZfwOGAf6zEc3BfrKAr7qYZiuhkwVRyHzGsIYflF5UmtzO fpBf2c+wu+CBYI7Smp/F/hJ2NzCvE3CQy1qxW9UO5lOmRLaOTvrQq4okUK3kYVBJ8jX2 2sfe/QEoPR876ns1TA68Fyt0XeCc95iqJtv/fhTHGE0n9lVW1tv+a31B+Vn68p/hOQKj LXDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773186516; x=1773791316; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=QmyMv70eqtNH27YII0Pv9uQYRElVQRLLBwleEaiib/8=; b=kCRA5Z4YT81IN4P6kwMOCNvZ1p5TMAqW/OvIZGwnSZs6Cv4sWAb7bs0cLhJRTYKLQY eyzZyExCLuxklTj6khA5b5oqDCMe/Uw4W0hn1sKg1NfS3n3LTKL+6SVqcflo9M9fF1k9 qcGB6HHJd1hnRtO5E2feioJkZN77GliJ+3zAkim4l0sCbiWqR2F2kwKh/PuTwfjTjyiI tKBjSb16bmtacMgKrpMfDxPL8EhxCmjMhEGldY26ySZCRqmxsMmVYa96jigzSQRdQqu1 luMIQsG9NKBerRT98fGj6wudPifLASh2rTn/QVLNiiTDZOARV9CQzUqzAbY46Wvajql3 CZfw== X-Forwarded-Encrypted: i=1; AJvYcCVe74ud6rZ9C9EM3Iss+7bj7q3gFQhUfhOHTd1lCy8GSWE4LBeu7r9Ugqax6BlGcyn2tSQ+XsMGc87Dm+Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yzu0Osrf1GFpxgay5s6ism4y3F3DT/n/sOdkYdkZNd9pB1iJrUL y6kNKTQZABT5U7OwFGbBz9ALzwFineJmlLNEIfSPC1PSi057gRKPRq72HDWAHo9NJ6OO+D+FuI1 wI4lk9Q== X-Received: from plbv9.prod.google.com ([2002:a17:903:44c9:b0:2ae:44fc:75e9]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ea0f:b0:2ae:51bb:9809 with SMTP id d9443c01a7336-2aeae85a668mr5099875ad.36.1773186515795; Tue, 10 Mar 2026 16:48:35 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 10 Mar 2026 16:48:08 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260310234829.2608037-1-seanjc@google.com> Subject: [PATCH 00/21] Fixes and lock cleanup+hardening From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jethro Beekman , Alexander Potapenko , "=?UTF-8?q?Carlos=20L=C3=B3pez?=" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Fix several fatal SEV bugs, then clean up the SEV+ APIs to either document that they are safe to query outside of kvm->lock, or to use lockdep-protect= ed version. The sev_mem_enc_register_region() goof is at least the second bug we've had related to checking for an SEV guest outside of kvm->lock, and in general it's nearly impossible to just "eyeball" the safety of KVM's usage. I included Carlos' guard() cleanups here to avoid annoying conflicts (well, to solve them now instead of when applying). Carlos L=C3=B3pez (5): KVM: SEV: use mutex guard in snp_launch_update() KVM: SEV: use mutex guard in sev_mem_enc_ioctl() KVM: SEV: use mutex guard in sev_mem_enc_unregister_region() KVM: SEV: use mutex guard in snp_handle_guest_req() KVM: SVM: Move lock-protected allocation of SEV ASID into a separate helper Sean Christopherson (16): KVM: selftests: Remove duplicate LAUNCH_UPDATE_VMSA call in SEV-ES migrate test KVM: SEV: Reject attempts to sync VMSA of an already-launched/encrypted vCPU KVM: SEV: Protect *all* of sev_mem_enc_register_region() with kvm->lock KVM: SEV: Disallow LAUNCH_FINISH if vCPUs are actively being created KVM: SEV: Lock all vCPUs when synchronzing VMSAs for SNP launch finish KVM: SEV: Lock all vCPUs for the duration of SEV-ES VMSA synchronization KVM: SEV: Provide vCPU-scoped accessors for detecting SEV+ guests KVM: SEV: Add quad-underscore version of VM-scoped APIs to detect SEV+ guests KVM: SEV: Document the SEV-ES check when querying SMM support as "safe" KVM: SEV: Move standard VM-scoped helpers to detect SEV+ guests to sev.c KVM: SEV: Move SEV-specific VM initialization to sev.c KVM: SEV: WARN on unhandled VM type when initializing VM KVM: SEV: Hide "struct kvm_sev_info" behind CONFIG_KVM_AMD_SEV=3Dy KVM: SEV: Document that checking for SEV+ guests when reclaiming memory is "safe" KVM: SEV: Assert that kvm->lock is held when querying SEV+ support KVM: SEV: Goto an existing error label if charging misc_cg for an ASID fails arch/x86/kvm/svm/sev.c | 315 +++++++++++------- arch/x86/kvm/svm/svm.c | 106 +++--- arch/x86/kvm/svm/svm.h | 36 +- include/linux/kvm_host.h | 7 + .../selftests/kvm/x86/sev_migrate_tests.c | 2 - 5 files changed, 275 insertions(+), 191 deletions(-) base-commit: 11439c4635edd669ae435eec308f4ab8a0804808 --=20 2.53.0.473.g4a7958ca14-goog