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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 BEE54CCD1BC for ; Thu, 23 Oct 2025 17:27:27 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4cstJZ24Zyz3bf8; Fri, 24 Oct 2025 04:27:26 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::649" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1761240446; cv=none; b=jX4Hnp6PwAajCW14cdG0OHa38XifCxhVZiVrTmb/Xvdqq+3JRuB3v1FWC46HrH1y2yHII+KBqdWdl/2Kq/g4q8MZb3dFr0sAwUuSGKdpfippDmrfA/W6ypVxCvnenGeXWC6MeMJqp8hqypFm1jeG25nV8VoP8jsAbX3EGCcNDwrxhgz5l3bZQHYzvLBc8HgrUxhoDkRTTaecZNf5a41s0lzoBrYWm1ytj9z7u6Trx3ionwNcbpNzx6vbBfpUMGfMUnMJfA0EKuGmKO+Vh7twyKIsQBdb72sQhzl+e6KfguQzaXVdGRHpShA8UOzjuy5N5EHjtYgRq78Tf6ifbUbE9A== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1761240446; c=relaxed/relaxed; bh=PMd4YohbYBDUY30TTRBHmO9DyPvx8MjhdR/tVFXtYYI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MB//fINre+oi5SXLa91PZ4y5o557a/XbllTjHcK9cczmAwa70vbQwtYMRUYqHsqIooVwtEon+uDMmXhNi3k3P6F/gKSLD3/XTh8Z+jt9sxvd+h+PePoqxEgkCCPr0wR38ADWhVU3ADjsFF0AOhHZVdjl9T77ZNhCy8xzp1Ci8s79PLPAAuX/QF9Zccd12FExElw5cJjHE7RkkFIvZcJlVL71slmIsfzHmjbxEghbtXcN33luWZ5a7YOVjFjMBfJyCUMptJzYmmmN4cs/o8lOCwiTqW/E6QkPRHsPNQCzjAZVr1BT95FKyE6KXVuBJM1quwtnHCk9lSVvSFTplv9fDg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=ET/DPV4C; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::649; helo=mail-pl1-x649.google.com; envelope-from=3dwx6aaykdhgoawjfyckkcha.ykihejqtlly-zarheopo.kvhwxo.knc@flex--seanjc.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=ET/DPV4C; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--seanjc.bounces.google.com (client-ip=2607:f8b0:4864:20::649; helo=mail-pl1-x649.google.com; envelope-from=3dwx6aaykdhgoawjfyckkcha.ykihejqtlly-zarheopo.kvhwxo.knc@flex--seanjc.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) (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 lists.ozlabs.org (Postfix) with ESMTPS id 4cstJY0hLhz3bf4 for ; Fri, 24 Oct 2025 04:27:24 +1100 (AEDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-27356178876so7254285ad.1 for ; Thu, 23 Oct 2025 10:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761240437; x=1761845237; darn=lists.ozlabs.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=ET/DPV4Cpk7Pi91Y6d4MmoR9xk3O/g5jSuiqu5Lp5jZ/BXTBkzkiRDyl88Ba4kG68+ Y4I6sLodHkSenoViA7MApiwq3f14M7QgVCjpqBNDvjtOJGnkIKg/hVNs1JSi+GSEIDiD +R4SuhN4zqapBn/lO5pbLJjVF4qK/L0wZNXk7mb//XFU4EMdMy3NSmnp8MX8xoR2vw1F ILSK1MvK6Eru+msflBsQyKsICHcECC8TKVkIKqt3o/hG4GzRfLD16EeeIatEm6eW4pti yQHZC/T6XADybL0vBFLP4c+yscNERdVzdV+I3nR99OLfEN4GdppwFoj9ppj/8YABhDf0 fiZA== 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=jJ+iApT/4lB0ARsAHt40U8pLNQkTio2XKxdz8tYKal3IjlJS18zuvecqOizJ/7CAkc xKecZyU71bPotTycXO75O1Rnc9wos1R9SD+Ia/ZKrnIHUlnFjrDgzLC88XpXnqA/02IC j4CQDARbQnk+LCRK+H+qdvoju6g28TD7duLSM+qMfTysxQ/FxE/1BXtwRXBlv7jVs/fE GQvsfiNxuZwp3fHmpyzaEIbsbcSW+pJlXaDNgmCIzrkcdabJ5m+j5gAf/KSYWAW1S8LT 9aX/40VEMqxjhRj+v4kb52qWQCdvSWxQ9CVgst0FEh4mjD+hGjajdZBSxOmGzZ8Jc/ob Rv+Q== X-Forwarded-Encrypted: i=1; AJvYcCW4FDVaeBz3T4AM012aFozyIwph0vCeP/e4Fcj3IkQqdXJ4A+oiYgh+1o0oHUWy+xlyMjl5NLKxBULsA8U=@lists.ozlabs.org X-Gm-Message-State: AOJu0YzLUOWBlyzb4LvOk7DhBs61F5iRh9dK4Bgkc4FqTxNVGU9uYZUc +6qabyCdcJoIt0c55rktgsbpqnigOOta02TzE0Z+U9w0rbjH8Gpglv7ueuwOXVUHL3enJM3valV 5RpkKCQ== 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> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list 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 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.