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 D803933E358 for ; Thu, 30 Oct 2025 23:40:42 +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=1761867645; cv=none; b=mddQI26rXDVOyG93GdQKKpr5+f9C8zrTIulwS/cad+FMlxBRVt1J1n9hjw35l4HpvDj+T+tL6yk6S0Xzju9rspCkVi2lVmxBY4hM8QHXphk7BYGRmWXYX2hkk9rkKcHFUyi3bL6uXXu6m0XaKFY31TDakQC2z+3oGpyrG/ai9NU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761867645; c=relaxed/simple; bh=eUlRvGsTDsOghmrMBild//Vvtgn5Z9S+p8wIvknhN0Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QJrhs9rwyc449XSRAHjeb17mlufcCz7l1ByVpgKS9EyN0iKEE+Eoyd4eq0YqV5W2U3ie+EjwGXjOi2JpI/ggI+GM/CX0HamWFtTV/L1Me2BJvZ22SGgBrHpX6j3mWXSBLUlBJFGc1eZt5qYs/SI77hgL/cQO3z+cyz4sUxikwMc= 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=nYfzY8J4; 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="nYfzY8J4" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-781171fe1c5so1554687b3a.0 for ; Thu, 30 Oct 2025 16:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761867642; x=1762472442; darn=lists.linux.dev; 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=hANv7xEJBy7S5lh8h/UQF87h23G6mY0gbFBLav72O2Q=; b=nYfzY8J4fzBx3r9WtnfUuYHT8Q87joKiawIBFxFmFB59vnEm+M2u7pTfN70/QIDbO5 pgE2B3/ux40x9lW9zWkelax6lYYPpSWJ3iLcrtrFsjFzSeu28ofVXQ0uRLAAOi5T/8Tt buy252ubCIN0HZB1tab3j6D2zgSa6QFDaVJUcUn3TsgmdBCdlOGEXkrK8v4e+SCFSF0F xE1NnWycpNmpHyKMO3kLKj9peV7IILKCZnzW4/cTxzgwW1xDhh9wPmjXDLHg3EqZSBTp fxoKFvdcozDij+iIkpoks6SWiWs8UElpl7zcT8vntDh98hqNeWtRHjimxdobi/ll6w5t OP2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761867642; x=1762472442; 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=hANv7xEJBy7S5lh8h/UQF87h23G6mY0gbFBLav72O2Q=; b=oVvQJa+jrdbMdMJmICPw18NfUoldizVzKpzZ1Y9gfnPa8eb2lRGuFP53B7KQcb+cdE CICzVWI25pyrlETkD25Ic/TP3cdLMvVi6cwc7fYbwBXtFZSjVIV0NNDZM+x4aLjmS2WH 5Izyz0fDrCn6D7aXrH5MDW+g/cR3xZmAZyqKVCD+DJ2WbtOnliKNa0jm0wGNzISUXUAa yQ8NAt6dr52n6wGlCM6tkA+pE7aa4jv+eV5m+sgbPCBT1MIUFg/8Y22n5N3A7u9EIDUK bko64BECEeIbBWllEsIJrDpAKE8/h0quD4Bqy5jEiSiGQGGlbcbn53bL7LD4aRhXMFAG LFOg== X-Forwarded-Encrypted: i=1; AJvYcCVdLek43/B8ZILZiX3+9FkIhO1zC/1JbkPM2YGrGPMJKY3rBiTPGXaOCEir6jH8z7ohh4SaHWaskqkS@lists.linux.dev X-Gm-Message-State: AOJu0YyQfXVjM28fHol7wOWoDC7Qed4wqYGU//4pZnJq/KAFElY8Pu29 9GZBRE4Hj2KO+aTVI2FEuRN9Ryl924KtJZwsi0YKUGPGcKh5ItHAs2BCPuQaveLzTcHBPuM7qps nT2Nlug== X-Google-Smtp-Source: AGHT+IH6kktSpJB8uW8dOccHej0bRJlF9t4mdGsOdXoLRdKSPbgGpCfMdKkfH5SPES5/Onbr9IfT7/Ky4i8= X-Received: from pfbhm7.prod.google.com ([2002:a05:6a00:6707:b0:77e:40c7:d12e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3996:b0:7a4:460e:f86a with SMTP id d2e1a72fcca58-7a7796c8a99mr1645968b3a.25.1761867642073; Thu, 30 Oct 2025 16:40:42 -0700 (PDT) Date: Thu, 30 Oct 2025 16:40:40 -0700 In-Reply-To: <6572689b28a76bd95bc653b1fc1131fa57ed7669.camel@intel.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251030200951.3402865-1-seanjc@google.com> <20251030200951.3402865-13-seanjc@google.com> <6572689b28a76bd95bc653b1fc1131fa57ed7669.camel@intel.com> Message-ID: Subject: Re: [PATCH v4 12/28] KVM: TDX: WARN if mirror SPTE doesn't have full RWX when creating S-EPT mapping From: Sean Christopherson To: Kai Huang 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" , Yan Y Zhao , "michael.roth@amd.com" , "binbin.wu@linux.intel.com" , Ira Weiny , "loongarch@lists.linux.dev" , "ackerleytng@google.com" , "kvmarm@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "kvm-riscv@lists.infradead.org" , Vishal Annapurve , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mips@vger.kernel.org" , Rick P Edgecombe , "linux-riscv@lists.infradead.org" , "x86@kernel.org" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Thu, Oct 30, 2025, Kai Huang wrote: > On Thu, 2025-10-30 at 13:09 -0700, Sean Christopherson wrote: > > Pass in the mirror_spte to kvm_x86_ops.set_external_spte() to provide > > symmetry with .remove_external_spte(), and assert in TDX that the mirro= r > > SPTE is shadow-present with full RWX permissions (the TDX-Module doesn'= t > > allow the hypervisor to control protections). > >=20 > > Signed-off-by: Sean Christopherson >=20 > Reviewed-by: Kai Huang >=20 > [...] >=20 > > static int tdx_sept_set_private_spte(struct kvm *kvm, gfn_t gfn, > > - enum pg_level level, kvm_pfn_t pfn) > > + enum pg_level level, u64 mirror_spte) > > { > > struct kvm_tdx *kvm_tdx =3D to_kvm_tdx(kvm); > > + kvm_pfn_t pfn =3D spte_to_pfn(mirror_spte); > > =20 > > /* TODO: handle large pages. */ > > if (KVM_BUG_ON(level !=3D PG_LEVEL_4K, kvm)) > > return -EIO; > > =20 > > + WARN_ON_ONCE(!is_shadow_present_pte(mirror_spte) || > > + (mirror_spte & VMX_EPT_RWX_MASK) !=3D VMX_EPT_RWX_MASK); > > + >=20 > Nit:=C2=A0 >=20 > I am a little bit confused about when to use WARN_ON_ONCE() and > KVM_BUG_ON(). :-) Very loosely: WARN if there's a decent chance carrying on might be fine, KVM_BUG_ON() if there's a good chance carrying on will crash the host and/o= r corrupt the guest, e.g. if KVM suspects a hardware/TDX-Module issue.