From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 EAB8232D0CA for ; Tue, 4 Nov 2025 18:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762279353; cv=none; b=TKMeeWY4naFE2ZFBoK9PZ+2EKyJ/l2v8scRd+digH76R4GYtYY1KzaCvidhI+rZ0BDYj2scLfDqBu7Du4cjeuRSokuhGe1F66UqY+eO/a4aancWaO8HLoWJOXq5zgYjDvnAQ1sXUV1DLI7uy69TBE/Zt8GMwA7pFOlzYXPef2J0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762279353; c=relaxed/simple; bh=OF+yEyqL038M/7cjkLTDiCOgvMsbpIL4Y8u0B391S+g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VPY5BvrHpqYdzw62xcVneZ0yhxtKzkuy5yDAxfvORwY3iJXDYNglMlTXSVaP38VsP5jQqQt/xUvWLlD9OsiKyJGtephWba9MUbW2frUiVECsedy5mqy4JvpIGvgDsSF1P4Vzdqzc6rIqOCSaVVh4IJ2uRFSUF/IlEsaIWdPaXcM= 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=UR4+Tqi1; arc=none smtp.client-ip=209.85.215.201 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="UR4+Tqi1" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b57cf8dba28so5117738a12.1 for ; Tue, 04 Nov 2025 10:02:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1762279351; x=1762884151; 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=z7TAMX5tgRxcaQgmnIz2dr5/J34h/wClq0GmkAjx/eU=; b=UR4+Tqi1L73FMojp9iVDZ+IQvopPBnewz3yrj2mrt7+uFNjZMEjoss+Y89vqlTc6g6 1QkCZc49hnn3O7tD4S7+u05OBdO+fT/7uw3I/UwXMma9HKDA/6rCnl2wgj3kVJQZS417 yoZ/RY+RRIFriCAwiiTn8qM5VemCllpOot/NyH5hPEz7pBGdGOsebyz/vUx8p2Gej/Jw sDFulLp3PJfS+bm/nMZfEN1zAMUKII06enHPIkGOLq1o/At6DNDteG6Tgax73nvNOvqr h+ESmxXJjVeyOzvG/eqKQHjmUmq9C59EmIZ0U+uD072Y8LJ6RmdSEurrbVCQ9PE1+2XT 7crw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279351; x=1762884151; 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=z7TAMX5tgRxcaQgmnIz2dr5/J34h/wClq0GmkAjx/eU=; b=QN9+DqpZjimhg3izrx0V1b0JtUdmgjQaz0NgbIPZ2hHVZCtWfixYEetDAXuQ91Zh7C KF3yrU+DACUu4cjNETWmAgfgBB1baRsb8kcZSGIn7hxvlI89hfoFB/MZCIfBZLGyf2uW FQXMfAqFjlO8fIo+TL9aTTV4QLU1GNjeIg9swxARLMw29hxLLSBVT4zjZCK8ci7SSnE7 jbOJ/pb4XsYzZnlCD8adFN14fQVxb3mdnFmQTI6L3Tl+TlPZXiixzNURiGpxZPMXHP5u kgp49CpOsen9eXFNUJSsR3V9Pza7Go9xCD6hvovcMAFngavOdS7lGi2gzPK9wJJ2y7Me pmCQ== X-Forwarded-Encrypted: i=1; AJvYcCXzC4L1x2krRgBT41sXLkyKZ2w//qtIrSvDmGT/nmN3Epp4kVNk2ZgrIrCtfLUzYFBHoHmSdxCTwQMqun4=@vger.kernel.org X-Gm-Message-State: AOJu0YyytOifZw7HWYpUfZAgCIFZxHk0MHDCVFZ0NUy9piecjA9ORfja Lf+8JyBQOA9qYf9OrEe9vVbchxFvrcf7HLqHzcRedb+u2yxQmYIp3LW+U5wWNpFYzyT7/F6cxkt /n7OEkA== X-Google-Smtp-Source: AGHT+IEToeihVC8rNRp4WXHuCXbja7cJV9DF8/gVM9lRFkFysIMA8abH+TqAL0waWRxDGRap6/agKlo3e+8= X-Received: from pjbmv10.prod.google.com ([2002:a17:90b:198a:b0:340:d512:22dc]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:6d92:b0:32b:7222:7459 with SMTP id adf61e73a8af0-34f8591c355mr151990637.34.1762279351036; Tue, 04 Nov 2025 10:02:31 -0800 (PST) Date: Tue, 4 Nov 2025 10:02:26 -0800 In-Reply-To: <31da959f-d004-4ae0-a6a7-d5d31b646b70@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251030200951.3402865-1-seanjc@google.com> <20251030200951.3402865-28-seanjc@google.com> <31da959f-d004-4ae0-a6a7-d5d31b646b70@linux.intel.com> Message-ID: Subject: Re: [PATCH v4 27/28] KVM: TDX: Bug the VM if extending the initial measurement fails From: Sean Christopherson To: Binbin Wu Cc: Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Madhavan Srinivasan , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Paolo Bonzini , "Kirill A. Shutemov" , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Ira Weiny , Kai Huang , Michael Roth , Yan Zhao , Vishal Annapurve , Rick Edgecombe , Ackerley Tng Content-Type: text/plain; charset="us-ascii" On Tue, Nov 04, 2025, Binbin Wu wrote: > > > On 10/31/2025 4:09 AM, 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. Now that KVM makes all state transitions mutually > > exclusive via tdx_vm_state_guard, it should be impossible for S-EPT > > mappings to be removed between kvm_tdp_mmu_map_private_pfn() and > > tdh_mr_extend(). > > > > Holding slots_lock prevents zaps due to memslot updates, > > filemap_invalidate_lock() prevents zaps due to guest_memfd PUNCH_HOLE, > > vcpu->mutex locks prevents updates from other vCPUs, kvm->lock prevents > > VM-scoped ioctls from creating havoc (e.g. by creating new vCPUs), and all > > usage of kvm_zap_gfn_range() is mutually exclusive with S-EPT entries that > > can be used for the initial image. > > > > For kvm_zap_gfn_range(), the call from sev.c is obviously mutually > > exclusive, TDX disallows KVM_X86_QUIRK_IGNORE_GUEST_PAT so the same goes > > for kvm_noncoherent_dma_assignment_start_or_stop(), and > > __kvm_set_or_clear_apicv_inhibit() is blocked by virtue of holding all > > VM and vCPU mutexes (and the APIC page has its own non-guest_memfd memslot > > Nit: > It sounds like TDX is using the memslot for the APIC page, but for a TD, the > memslot for the APIC page is never initialized or used? Oh! Good point. I'll tweak that snippet when applying.