From nobody Sun Sep 14 14:53:52 2025 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 1349B29293D for ; Thu, 4 Sep 2025 06:55:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756968923; cv=none; b=UwUJnH39PUYbYDPCSPtmB3XbOXsWbqBdBwrW1NRMPR9xjPGk3zlZ+brd/ZTLv871Gk932MWVLzRrJVTmOTAtCaacJu4xvIeRXsUrWMaR5iydnDin2h6zFiIPLYIzNWY/EtzYxE2y0ElA0xGGSI1X5Pu7HxW6tCb3D4POt78R6mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756968923; c=relaxed/simple; bh=aonB/eCuRYccRY3VvDhmGFtx766iDhuLel2iFuyfPvg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Gi3swZAVwlnynZ7hcFqQgKtHbtEHAt4lwl1KN3y9tNwXmD4s5pbuYvuw3KpZWB5SjOTMVsMRDY4Mm3TyUKvMkYmBKC7TQafDQJyu+UOaR0subucxy6j1BpkP4aWS9T8QjL0whd3z8LydEqC51frUb34dLuxHVa41zhdpRZ238Mo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sagis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GHDsK5Ms; arc=none smtp.client-ip=209.85.216.73 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--sagis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GHDsK5Ms" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-329745d6960so621029a91.0 for ; Wed, 03 Sep 2025 23:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756968921; x=1757573721; 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=qvz/RUhUzWK3YIgJJiz6JbOWQToi8UuNVcz+/1d9b6I=; b=GHDsK5MsAxRggN8MPd96QUG9UIUHn0pfsyYCtpnYrmhrkYwsD7hM/fiV8KOnCNdW5P SkmlnxQ2KYca14SgJZFcHUenorcWwYIFOtLKkVB4mekRmjHLw9bw8qJZpMquwroZFlaZ 3YLbjb/YlGpGw+a7gii08gCHzdeiBzcuisBMxXXBTt0tdQkja4kdvxYBIKpZRYVHUs85 lSy4GsKD7w67dQe0UX1e1TmkC+46ThiFg/DJPL9VrbbNSzczmgIlzf3bnQP3BxD8zJTi QOavwF8T7pyUoKD95LTIg0vJF0P0TnrFLS+2HKr3AcUgcgRMmo6U8Yda1rS+JWpr6Vuh gc+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756968921; x=1757573721; 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=qvz/RUhUzWK3YIgJJiz6JbOWQToi8UuNVcz+/1d9b6I=; b=eHmSNwR+l3ckBU9uWY+NOnIAqMdNqklsKM9ayO5g6ijwfgZQKdrrhg+ycr9tcQdks3 nXrROpUlWO584qZo75q6RumvFrf9Y3JjqXzUeAlAPkJ9H10Kewg1E88bQgvgXuFw1ByX 8cnia7zozxYlz6O25NxyOswzS+yUwtVi91lWPy6sJYMQ3JCl/G/Q8OsyFIx8AS2Q8APA MfbfTDW1u1PQK1/6FGE57GpPPXnO+co4mKBdZedIkXD6sjZbadRfk0BCmoFVstCaHHms aLfDSRwkbjLxmQcaIZqYP0g6/EPH8Pv944UGSK9YlIW++LmCIeQEO7QLKKANzN4W8+3e g7VQ== X-Gm-Message-State: AOJu0Yyt7F6/YEozhs8F85/w48lLYYo7cZkTkureD7+iyX4TJ8MMJw9Y R1tfP2xjoGXWUH0gtRnwh1eGuZWU5uDbNxcHmnn5NiOM89ueOkAOrQXnUS6B8aa8adBlI670vV7 Qug== X-Google-Smtp-Source: AGHT+IHOjWuQK34dUf4IdxwrpKRnSqRG6X0hBaPJ0I2Ra4SwU/ya2UpxFzedgGOgdGACsTrDLh7HJK5caQ== X-Received: from pjbse15.prod.google.com ([2002:a17:90b:518f:b0:32b:95bb:dbc]) (user=sagis job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:570d:b0:329:f535:6e3c with SMTP id 98e67ed59e1d1-329f5356ef7mr10386542a91.35.1756968921579; Wed, 03 Sep 2025 23:55:21 -0700 (PDT) Date: Wed, 3 Sep 2025 23:54:42 -0700 In-Reply-To: <20250904065453.639610-1-sagis@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250904065453.639610-1-sagis@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250904065453.639610-13-sagis@google.com> Subject: [PATCH v10 12/21] KVM: selftests: TDX: Use KVM_TDX_CAPABILITIES to validate TDs' attribute configuration From: Sagi Shahar To: linux-kselftest@vger.kernel.org, Paolo Bonzini , Shuah Khan , Sean Christopherson , Ackerley Tng , Ryan Afranji , Andrew Jones , Isaku Yamahata , Erdem Aktas , Rick Edgecombe , Sagi Shahar , Roger Wang , Binbin Wu , Oliver Upton , "Pratik R. Sampat" , Reinette Chatre , Ira Weiny , Chao Gao , Chenyi Qiang Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Transfer-Encoding: quoted-printable 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 the TDX module. This also exercises the KVM_TDX_CAPABILITIES ioctl. Signed-off-by: Isaku Yamahata Co-developed-by: Sagi Shahar Signed-off-by: Sagi Shahar --- tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c b/tools/tes= ting/selftests/kvm/lib/x86/tdx/tdx_util.c index aa0cb6c2205b..1b5c01faf1cd 100644 --- a/tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c +++ b/tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c @@ -234,6 +234,18 @@ static void vm_tdx_filter_cpuid(struct kvm_vm *vm, free(tdx_cap); } =20 +static void tdx_check_attributes(struct kvm_vm *vm, uint64_t attributes) +{ + struct kvm_tdx_capabilities *tdx_cap; + + tdx_cap =3D tdx_read_capabilities(vm); + + /* Make sure all the attributes are reported as supported by the TDX modu= le */ + TEST_ASSERT_EQ(attributes & tdx_cap->supported_attrs, attributes); + + free(tdx_cap); +} + void vm_tdx_init_vm(struct kvm_vm *vm, uint64_t attributes) { struct kvm_tdx_init_vm *init_vm; @@ -253,6 +265,8 @@ void vm_tdx_init_vm(struct kvm_vm *vm, uint64_t attribu= tes) memcpy(&init_vm->cpuid, cpuid, kvm_cpuid2_size(cpuid->nent)); free(cpuid); =20 + tdx_check_attributes(vm, attributes); + init_vm->attributes =3D attributes; =20 vm_tdx_vm_ioctl(vm, KVM_TDX_INIT_VM, 0, init_vm); --=20 2.51.0.338.gd7d06c2dae-goog