From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 3659E459AE5 for ; Wed, 22 Jul 2026 23:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784762063; cv=none; b=fKq0Ir1h4QAnj7490caS3y+GcZcJgclvBEj/aOOA1SBPq3unpzQ9M4vq8MxMpr3X8vq+hFMdXH6GDZh9G3UlgctB7cxCJ6ri2udgkY5K7d+zLww0o6a712Q5HuWumDYWiUAyHEmzK59oqLIbgyHECqjPdcqwJY5lnB2IT9K/0I4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784762063; c=relaxed/simple; bh=rn7lIDTWcxoiO6D4/Cdhdy8K/SysdSX/CMUU+rwcLOI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fIRqSteaf0pkEgktYsZlHV0MmZtGcCx3PjLY6kccS31g8+5bLLoKCJWtUaWh0+8t72y+V4U5+ov/itPL+5JL2bcr/O9LWZpNt2ou68NKlX9o5y8fAbari6U7khvMoP2mpGaA/gbbdZ+uefn9v7YqJXe/VwYErvkmhovk2zW3/b4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wyihan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sYz4lIaB; arc=none smtp.client-ip=209.85.216.71 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--wyihan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sYz4lIaB" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-381abcccbf4so15070a91.3 for ; Wed, 22 Jul 2026 16:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784762060; x=1785366860; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oVBS289J/Z2jqIHEMCM1gipu2UkhJ+nCd+Y4BOZxwFE=; b=sYz4lIaBhgjKh7P3vwVIFuVgDh3ncPe1Fj5pPCCxZtxtEGWAkKedIyMqlneLSloW7w Qh2Sa+SrqTVgL8vdbAqFGazOanHFfgp4sr9I/4rtqx3DIWEbPeXXo6RxRqaznr8jEpur S/se+zby5hWNDlKUiYcezukt+oV/PaKR/tDGTlq+8VMcqvls+I6IBvwEgmdkOGZRjVL7 vmnRf7Iokk+qwsAXxuMC5tyJdFjO0LIwAD3pA5zxcaGfuU9TCYvsI2+t8AtIUXFlPSfX oehei4WcHwJipZNPNv7S891MTdiG4qsntOkfuTTBI33eG7WUZWQWnK0gho94jvm4FJd9 DVgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784762060; x=1785366860; h=content-type: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:content-type; bh=oVBS289J/Z2jqIHEMCM1gipu2UkhJ+nCd+Y4BOZxwFE=; b=iZYySCuW4GS4HCEOCgaCWWOd746ATyzYRz7LVkS2iZknTn8+piX04hX69YhJ88wMAb qyt8kRRra+bLnuAKeJnXT1XYr5p+W8+4ztOBLoYZSvZpqkYn1iTvIp9mQuKiLtXMVkef IicyysFruNaEIini8XRSgAzdy9TIjmSZ7/FDpHKIGHjuj4X5EjknwfnA6jnkCzhFpodm bugpe/29ATKSnmfIAjc+3YgVeGd5qYpOwfj3JoIxCe/dduQ8eva9BlGcwClSCcYt4vol J7dETWuvyQUYs8FchBMQUUfF5QWAeH1/2JesdaxwpYNhKBHE0ZKs0qV2j2OJQE38DCih O2Hg== X-Forwarded-Encrypted: i=1; AHgh+RohraKsKgnaruuTpzLwt/ohCxv8iJUYvNC3SzK2Glfz6C1hNT+16vPxNwJ7NwpyVrFq15paKjvwuZi4YpM=@vger.kernel.org X-Gm-Message-State: AOJu0Yww0ABzCVVfYC3df9peZbuoSKOpUBc9z1SAeZTv0hYifFwLYagm 24RgJTZ+JakXcjIiKG/L/p9m3TVVyuuQ08QbaVvn1oMm8rFdn33jjfDziFOUUZO2pPuBrEI6PVU xzKooEg== X-Received: from pjq11.prod.google.com ([2002:a17:90b:560b:b0:384:aeb6:624c]) (user=wyihan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:184c:b0:37f:9ce1:735a with SMTP id 98e67ed59e1d1-38ec658e892mr709493a91.27.1784762060184; Wed, 22 Jul 2026 16:14:20 -0700 (PDT) Date: Wed, 22 Jul 2026 23:13:09 +0000 In-Reply-To: <20260722-tdx-selftests-v14-0-15ad654a50db@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260722-tdx-selftests-v14-0-15ad654a50db@google.com> X-Developer-Key: i=wyihan@google.com; a=ed25519; pk=cRi0fKzS5BMxlHyHY2pJv3w/1zcgfYKr6EYGYppdMYc= X-Developer-Signature: v=1; a=ed25519-sha256; t=1784762054; l=1765; i=wyihan@google.com; s=20260319; h=from:subject:message-id; bh=bOj/gnaWbqCSO1dw0E/Ufv9dZGd8nQXtcW3IYQ+RbjE=; b=Fwd4fvyFJukTctt1WNFLyHmWmkoUi+2SW/wiXay2xsIEBRQnOVDGm6MjuzZw7NYD7fl7HIlgs 4ynYSy6pNK1DYAyNeNpv3ljZihaRfmzv4bmj+B2fCdI0PwJSdaRXzqC X-Mailer: b4 0.14.3 Message-ID: <20260722-tdx-selftests-v14-4-15ad654a50db@google.com> Subject: [PATCH v14 04/22] KVM: selftests: TDX: Use KVM_TDX_CAPABILITIES to validate TDs' attribute configuration From: Lisa Wang To: Andrew Jones , Ackerley Tng , Binbin Wu , Chao Gao , Chenyi Qiang , Dave Hansen , Erdem Aktas , Ira Weiny , Isaku Yamahata , Kiryl Shutsemau , linux-kselftest@vger.kernel.org, Paolo Bonzini , "Pratik R. Sampat" , Reinette Chatre , Rick Edgecombe , Roger Wang , Ryan Afranji , Sagi Shahar , Sean Christopherson , Shuah Khan , Xiaoyao Li , Oliver Upton Cc: Jeremiah McReynolds , kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, x86@kernel.org, Lisa Wang Content-Type: text/plain; charset="utf-8" From: Isaku Yamahata Make sure that all the attributes enabled by the test are reported as supported by both the TDX module and KVM. KVM filters out the attributes not supported by itself. This also exercises the KVM_TDX_CAPABILITIES ioctl. Signed-off-by: Isaku Yamahata Co-developed-by: Sagi Shahar Signed-off-by: Sagi Shahar Reviewed-by: Binbin Wu Reviewed-by: Ira Weiny Signed-off-by: Lisa Wang Reviewed-by: Xiaoyao Li --- tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c b/tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c index e1ffb67a106c..c01a26567b73 100644 --- a/tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c +++ b/tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c @@ -93,6 +93,16 @@ static void tdx_filter_cpuid(struct kvm_vm *vm, } } +static void tdx_check_attributes(struct kvm_vm *vm, u64 attributes) +{ + struct kvm_tdx_capabilities *tdx_cap; + + tdx_cap = tdx_read_capabilities(vm); + + /* Make sure all the attributes are reported as supported */ + TEST_ASSERT_EQ(attributes & tdx_cap->supported_attrs, attributes); +} + void tdx_init_vm(struct kvm_vm *vm, u64 attributes) { struct kvm_tdx_init_vm *init_vm; @@ -112,6 +122,8 @@ void tdx_init_vm(struct kvm_vm *vm, u64 attributes) memcpy(&init_vm->cpuid, cpuid, kvm_cpuid2_size(cpuid->nent)); free(cpuid); + tdx_check_attributes(vm, attributes); + init_vm->attributes = attributes; tdx_vm_ioctl(vm, KVM_TDX_INIT_VM, 0, init_vm); -- 2.55.0.229.g6434b31f56-goog