From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B11FCCCF9E3 for ; Thu, 23 Oct 2025 17:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PMd4YohbYBDUY30TTRBHmO9DyPvx8MjhdR/tVFXtYYI=; b=sY5FO7iwzukg6I8G2YIobhUiHM HAobjSmBVNG/N0PY9hh1WYRAcF2Y6iVhQaDIhH4e43LlvvRl26N4yHK4s7q8eSMP7m2yjaZ3AX+Iy 4IBr4DUVGiLHS5DvmV0dZF/3NC8dcghYfWndWK68LeIsC5q6ouY5jHgCb5mJyGsjPu3aszVK7H9Yi hzbnB5zPu7aWo61Vra9KBLadCuAKcTodWDtJi81korpi3DokNGn4wAmSchuqUNofRTKwKltdqez5N zjUgknqQQA+ewO7OtGEM9X90be1XRBtpQnogy8pL43XGUtRNyeGJRJT06YLXszecSHSxqf34eW2oO Ve9tu6mw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vBz5t-000000074Lg-21Ls; Thu, 23 Oct 2025 17:27:21 +0000 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vBz5r-000000074Ko-0Lrl for linux-arm-kernel@lists.infradead.org; Thu, 23 Oct 2025 17:27:20 +0000 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-28973df6a90so9564215ad.2 for ; Thu, 23 Oct 2025 10:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761240437; x=1761845237; darn=lists.infradead.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=PMd4YohbYBDUY30TTRBHmO9DyPvx8MjhdR/tVFXtYYI=; b=KHA/adG+IcBFOsmsbEhv36qbaAIED+9Tsgl2OhqqmJXaecO8DHNOqS9r0/bw2jI/Pc LDicPkN/j5u+yxf50fIttRGvAhfSFI3MiC5qGp75zZtHq99UlWl0SB6cw7qa6PCTP2MA otUBHyfD5z0V7Mvz/Yxb2xrP0m2wJVQLQhZQ0iKZIHUYAwk+kghlo8DpubgxB1JvK8Mf a5g+tsrd4X2uAM54GSnlRNbb8g4DBZoG3lk//83dx+USzmvklfNaP+qoEAWBoqHnjcRD 4Jbze3pjJkxPFxRZgKM/vs7btFF5jmND3DcxzxxO829wyscEumAb23TOw+2VGiKXbLRk MeaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761240437; x=1761845237; 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=PMd4YohbYBDUY30TTRBHmO9DyPvx8MjhdR/tVFXtYYI=; b=W1mE9VPNqEFfYb748AlcDOppy8AcNOl1+dpCEKEUIeCTJyIZ9NxRd4PAn8V/gcxjUj gtru39Lg2LyP4Pfs/CX5TLH8gqjZ3Z2IA/9be180F7dqcIbUg2AkmztQ+prEtkW0WABH 70Qw/K/ubysPIX/I04XPckkIP6BZeS+f+z312czCvD813KDqZECg2ENAIh5DBafIUbLl PbRacVx5sbgFNTnuBGJnt7csaylonvKdtv/tUZQm1lRkQhkJ8CBMPxY46/LWu3iHfKBi LxaJlv5ZPYXwvgwZlgaGN94PXt2sA002m2K3vEQZW9I3qn5BNfTwPgtIdG+AUdgCdfaB 1cWw== X-Forwarded-Encrypted: i=1; AJvYcCUfBKb9iKs+qGx/URMgvTKfVvODyzsImRuUzGdkBEtqiYib9dEDwWzxOE851QnZgmUZepD5ry7u/3huvnJhQOEz@lists.infradead.org X-Gm-Message-State: AOJu0YzjRN7tCGhWvfM3d5vZ9sd2GICLFgtIjn/XvfcNqY3O3/J0HQe3 XVyhWhxjVjXkSzp191XpPcNmxuyim+r81lFQwQfaJ9jThJXSP3w3IB35G6HYJa23TxtKqsjobuS +9UfaMw== X-Google-Smtp-Source: AGHT+IFjhG//1khxmFCKdE4+6wWu9+6PA/jOl4XyR0eCgR53v+ZECkEt8twGk0B4jVNQwQCsevpreYrKXxc= X-Received: from pjuj5.prod.google.com ([2002:a17:90a:d005:b0:33b:a35b:861]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:db11:b0:240:48f4:40f7 with SMTP id d9443c01a7336-290cba4efc9mr387536115ad.39.1761240437319; Thu, 23 Oct 2025 10:27:17 -0700 (PDT) Date: Thu, 23 Oct 2025 10:27:16 -0700 In-Reply-To: <707a01ee36c28863bdc6a4444a5560e9a0b19597.camel@intel.com> Mime-Version: 1.0 References: <20251017003244.186495-1-seanjc@google.com> <20251017003244.186495-15-seanjc@google.com> <707a01ee36c28863bdc6a4444a5560e9a0b19597.camel@intel.com> Message-ID: Subject: Re: [PATCH v3 14/25] KVM: TDX: Bug the VM if extended the initial measurement fails From: Sean Christopherson To: Rick P Edgecombe Cc: "chenhuacai@kernel.org" , "frankja@linux.ibm.com" , "maz@kernel.org" , "borntraeger@linux.ibm.com" , "pjw@kernel.org" , "aou@eecs.berkeley.edu" , "kas@kernel.org" , "maobibo@loongson.cn" , "pbonzini@redhat.com" , "maddy@linux.ibm.com" , "palmer@dabbelt.com" , "imbrenda@linux.ibm.com" , "zhaotianrui@loongson.cn" , "anup@brainfault.org" , "oliver.upton@linux.dev" , "kvm@vger.kernel.org" , "linux-coco@lists.linux.dev" , Kai Huang , Yan Y Zhao , "michael.roth@amd.com" , "linux-kernel@vger.kernel.org" , Ira Weiny , "loongarch@lists.linux.dev" , "binbin.wu@linux.intel.com" , "ackerleytng@google.com" , "kvmarm@lists.linux.dev" , Vishal Annapurve , "kvm-riscv@lists.infradead.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mips@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "x86@kernel.org" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251023_102719_119800_D7C03CF2 X-CRM114-Status: GOOD ( 20.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 21, 2025, Rick P Edgecombe wrote: > On Thu, 2025-10-16 at 17:32 -0700, Sean Christopherson wrote: > > WARN and terminate the VM if TDH_MR_EXTEND fails, as extending the > > measurement should fail if and only if there is a KVM bug, or if the S-= EPT > > mapping is invalid, and it should be impossible for the S-EPT mappings = to > > be removed between kvm_tdp_mmu_map_private_pfn() and tdh_mr_extend(). > >=20 > > Holding slots_lock prevents zaps due to memslot updates, > > filemap_invalidate_lock() prevents zaps due to guest_memfd PUNCH_HOLE, > > and all usage of kvm_zap_gfn_range() is mutually exclusive with S-EPT > > entries that can be used for the initial image.=C2=A0 The call from sev= .c is > > obviously mutually exclusive, TDX disallows KVM_X86_QUIRK_IGNORE_GUEST_= PAT > > so same goes for kvm_noncoherent_dma_assignment_start_or_stop, and whil= e > > __kvm_set_or_clear_apicv_inhibit() can likely be tripped while building= the > > image, the APIC page has its own non-guest_memfd memslot and so can't b= e > > used for the initial image, which means that too is mutually exclusive. > >=20 > > Opportunistically switch to "goto" to jump around the measurement code, > > partly to make it clear that KVM needs to bail entirely if extending th= e > > measurement fails, partly in anticipation of reworking how and when > > TDH_MEM_PAGE_ADD is done. > >=20 > > Fixes: d789fa6efac9 ("KVM: TDX: Handle vCPU dissociation") > > Signed-off-by: Yan Zhao > > Signed-off-by: Sean Christopherson > > --- >=20 > Per the discussion in v2, shouldn't it go after patch 24 'KVM: TDX: Guard= VM > state transitions with "all" the locks'? Otherwise it introduces a KVM_BU= G_ON() > that can be triggered from userspace. not a huge deal though. Oh, right. And then the changelog needs to be updated too.