From nobody Sun Sep 14 14:53:51 2025 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 4384129AB11 for ; Thu, 4 Sep 2025 06:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756968926; cv=none; b=fzXZ+JwZTVs6lrRixUdAsokHzdgGCOlZ10s1adTYaruZFTmFj3T9ZdhHiD4LSlNnQG5sw1wwtiOVyASDrIcIS6SVDcG3WseeiorPFN1JDetXluBy0zG2FD6luuDjaQrAacB/pJOdEE+Mtu7aSi3npjzMyaIow5WiUYihqV2k0L4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756968926; c=relaxed/simple; bh=kdmXN70NkCarKlPiM7rjh7lKLuyNoeGTY57Ar9pmI1k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=r59OcCecozr3rNc91tULyRU1cdomlIggSs3DaQyQHQKmlWJ7AWbBtH6cTxTTZRY+oshn/TMP98A/KWRH9F5m1Hdzo5w9JGLFEaeNfS7L34COXhQ5HK2Np8T24csN5SkhhnV8qvlAjwRg9QyNSFfCExQ+WPDQ+iSuG6WU0sw5jZc= 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=4VbrBfsf; arc=none smtp.client-ip=209.85.215.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--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="4VbrBfsf" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b47174c65b0so875684a12.2 for ; Wed, 03 Sep 2025 23:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756968924; x=1757573724; 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=YqMpdEsUV2fviIjFSLurfARDNWwMLyzNa0D38zVRRV4=; b=4VbrBfsfq5xdoOu8ahuhN3hs+2zXZGA4GvqWDS/m5v1HVqPzy0pEi6axeQfI5LtcrA KcxVnumuBgba7LpP/4ZyhkD2Y7tqQLWwV+3s+c/gx5SwBQ0J7SCzzACF0gt/jbiqQfbR ToPPRWMVNy4fkOWLFLdJ8Bh7k1jxM9e4Krd3TdjLs/Ngvxea/gqnWfoNzXHoLrEIaXs/ FmWxb/+K9hHHTW2fN35jOm08UyZt4N2WsA0FvhiBbSctFV1obVMuRsq0uEnGfmVV9Jd2 MeY0lRTCrU+aaChWyHcfltIAmF3yoxZmB/5ea/M6bQwDu7nrGCtDJUyywy6Zr3DAP2Za uz2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756968924; x=1757573724; 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=YqMpdEsUV2fviIjFSLurfARDNWwMLyzNa0D38zVRRV4=; b=brS8c76pKnt7yFAxX3ga5707Q1pSC6hPvLGJwocY+n+LQ4j9rQCihd5wsvYc8qCJni fxPwTH2EGtFNVvA3JE8TrJLVLwR7kpuzzaL7Bt59BeVLVJQgrkbeaZst8dVdkuBYue85 u9vgNB3vQk4ldLlG9OasLTqQ3TR5ZmiO7QyQ3W1Oo9FDRHzDd8V1QPT6ajUzI8E5p88C vkLy2tdFc7WwDgbRxNzvMsJT/tiw55ET5lUhRLwVSqiQEoNzaJCYnUKk7lxMJ9Bz7UXF Uy3Dl3k/1nalBmIeXQyuCsSMIBOnfAhn1txC8OLdnNkOtjuO+4lRBduBiRl7SWilcHDu pWDw== X-Gm-Message-State: AOJu0YzvLERbJ6ip3/E+KeoTXezKpSBUD+uu8CX1ARP73FAImp/yV21+ A29BhgOTmT/N5HAYFPTSJosd6IbRpJEiIG0L3KPrDixGdmnFMVUhbJMeI+YYqBkf0AaIQJxye2X IYQ== X-Google-Smtp-Source: AGHT+IHU8aE69lKsl42MpOIXvrUGk5nPmd3Q6iw3H5xSke4+EKRTEKinRjrjK+lfCvuFoVBO6ts+bPx8dA== X-Received: from pfch21.prod.google.com ([2002:a05:6a00:1715:b0:76e:396a:e2dd]) (user=sagis job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:9997:b0:243:c76d:ac8c with SMTP id adf61e73a8af0-243d6f051cdmr28758575637.32.1756968924573; Wed, 03 Sep 2025 23:55:24 -0700 (PDT) Date: Wed, 3 Sep 2025 23:54:44 -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-15-sagis@google.com> Subject: [PATCH v10 14/21] KVM: selftests: Call TDX init when creating a new TDX vm 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" TDX VMs need to issue the KVM_TDX_INIT_VM ioctl after VM creation to initialize the TD. This ioctl also sets the cpuids and attributes for the VM. Signed-off-by: Sagi Shahar --- tools/testing/selftests/kvm/lib/x86/processor.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/kvm/lib/x86/processor.c b/tools/testin= g/selftests/kvm/lib/x86/processor.c index 623168ea9a44..c255fe1951be 100644 --- a/tools/testing/selftests/kvm/lib/x86/processor.c +++ b/tools/testing/selftests/kvm/lib/x86/processor.c @@ -641,6 +641,9 @@ void kvm_arch_vm_post_create(struct kvm_vm *vm) vm_sev_ioctl(vm, KVM_SEV_INIT2, &init); } =20 + if (is_tdx_vm(vm)) + vm_tdx_init_vm(vm, 0); + r =3D __vm_ioctl(vm, KVM_GET_TSC_KHZ, NULL); TEST_ASSERT(r > 0, "KVM_GET_TSC_KHZ did not provide a valid TSC frequency= ."); guest_tsc_khz =3D r; --=20 2.51.0.338.gd7d06c2dae-goog