From nobody Thu Oct 2 01:01:46 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 D7BEB31354A for ; Thu, 25 Sep 2025 17:29: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=1758821364; cv=none; b=NlIh8pj1W1GaPUyu611Cf6rvFmkEirB8Yx2qbT3WQWf731jWxPYt4vSJGH3TcpNwQFzr1Y5EP0iQerpJA9cVfBpQR4bx9pC5boP/wK4wwhoLvFm7Bv1y8fGhbVXO4iJrKuf1AjoeRUH4W3ukLBJuvALCozoxs3tEEE/rHt1X6iY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758821364; c=relaxed/simple; bh=zHc45FNunudgpxBR4JWuEiZa0w9yuYjewmkAKB9HjsY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=I73t1vxVaBULHGVkQgvMRsuvU8vAa/fL0I2SJ6QUakK9E53D3xknrKGZP/0f3kNLYiJg5yXGFGYvCl/O7H5zmBaiHHXJ7HYvTo/DvBA7Yf57C2+rp7du+W4Nbu1MSfEnz3SBjHqSZ31LbZLTcl/7ZUj5VJ/yzT11cAPqYPeywBY= 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=FVnR4uT8; 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="FVnR4uT8" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-335276a711cso188792a91.2 for ; Thu, 25 Sep 2025 10:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1758821362; x=1759426162; 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=5cDfoEeJQNzVJqyItlC9ynzGaEr3okFQ1wEjDJ/9WZc=; b=FVnR4uT8FWWcn7eZ6eEsRPeYqtWpdH1gzgaA3ex1yC0Nt9Q0xdTL6XFkdwoVs5brMG oneohsu3L8tz50JWFpGCYrdA2qf+ODixy+rm4sjt++4dHOKqt+5IFIGcNWO4V1sull9f cpCKhujK8GuqLKyO+rUMvmyULwkfRNOeXR9n7H6j09wyA2s0Vs+PKQfqdIUmU0g8le+Z uo9p3akKLtqMZsRHGkS2OjvrTbS/HDqkSZT4GQ/RATwyObGg3o+nNWnJ+MXZE58J8oZT NAUwBT1GMBLlIyQnVPVm535TVSuzeTLr9Bx4XgA0z0NBMj2NeIqpuX3InWPA+skTdUFV OilA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758821362; x=1759426162; 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=5cDfoEeJQNzVJqyItlC9ynzGaEr3okFQ1wEjDJ/9WZc=; b=ri5MTYCR8ONaKQEth/kfbbmzWNgP+ylVNDC4WcQEMDhkdwaX5inI2/NEKLrspMSXXx XA3dBSNJ+lcIaZRuT2pf1VhUZTmPtUAQOftH/qxx4nTHsQqLX8Ugz3u2bgPEtVp3Nzyx j2yK7g1QcZGwS23GC1hWAAKPex9l+zMT4V7GtDCbdvKMkZk7UiKwFeKeJ9kBsjNBVK04 KkjnvX+TnFF0WUgJRBLwqpdWFkLgp6D99G8FSE3+LtR9B63xxZpti3DxzarcQkuaNjWi q+sqASG/RRxAN7cA1AoCZ+ch+LpJzCYq0nbVUptk+SXvPKiPtuOxl2ggYgcg35PYvYTs tAWw== X-Gm-Message-State: AOJu0Yxu/zylMw00Qpt+DzFts49BMoy8Y7SXliOM3mXIkM//dvsbSZK4 mvvSYuMqBxXzT/cDidlnyyR/W6pT3JpUwOEkEpNyPW3so9x8QXbnWlFomKabAo8WIJ7e6sj7HIa RPw== X-Google-Smtp-Source: AGHT+IFiX5yq/423ZwdRIOB/VoKEpIBcTMitBDLAXUyebQio6K4Ks9LdhVWtAAfHLvX8WQ69wO2GK0ei+Q== X-Received: from pjbqo15.prod.google.com ([2002:a17:90b:3dcf:b0:332:a4e1:42ec]) (user=sagis job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1a8b:b0:32e:38b0:1600 with SMTP id 98e67ed59e1d1-3342a22d164mr4911146a91.6.1758821362103; Thu, 25 Sep 2025 10:29:22 -0700 (PDT) Date: Thu, 25 Sep 2025 10:28:42 -0700 In-Reply-To: <20250925172851.606193-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: <20250925172851.606193-1-sagis@google.com> X-Mailer: git-send-email 2.51.0.536.g15c5d4f767-goog Message-ID: <20250925172851.606193-15-sagis@google.com> Subject: [PATCH v11 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. At this point we can also set the common boot parameters such as CR3, CR4, etc. These parameters will get copied to the relevant registers by the TD boot code trampoline. Signed-off-by: Sagi Shahar --------------------------------------------- Changes from v10: * The call to vm_tdx_load_common_boot_parameters() was accidently dropped as part of the refactor from v9 to v10. I re-added it here. --- tools/testing/selftests/kvm/lib/x86/processor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/kvm/lib/x86/processor.c b/tools/testin= g/selftests/kvm/lib/x86/processor.c index 623168ea9a44..63b751253d1b 100644 --- a/tools/testing/selftests/kvm/lib/x86/processor.c +++ b/tools/testing/selftests/kvm/lib/x86/processor.c @@ -641,6 +641,11 @@ 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); + vm_tdx_load_common_boot_parameters(vm); + } + 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.536.g15c5d4f767-goog