From patchwork Thu Feb 29 06:37:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoyao Li X-Patchwork-Id: 13576611 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5135050261 for ; Thu, 29 Feb 2024 06:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709189073; cv=none; b=MbQXEukTbhKVVz8kwfGBbfpiNP8HhvCl8vzYHeISbV27mii0VGTYDEoHfSa9xIWHNrjzRD1r6fgqq7xLKHuBqYdNy5m/qGgIpXnZTXRtKgSRB1h+1yixaoGxTwEP+XV/RwsPJZAqMmqJLvtC48JlDpWyEZcWboxzaan+KrEuR6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709189073; c=relaxed/simple; bh=VTp5F6mIs7twJi0yuRSzLDSYAKLqNn6eJlbE1TyLtH8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C6b9PF5oa1elesZvTWStKgqDCQqfsmzJfdXhonQ/yNrzdK6CIlxkhEbgnOoFFczF+D5oK2bJ48o2sEetGP9J6yG5D21kXfzHcZrKiuWqX4/w7enuN+Q+wBwci1OUxOJjTT0VoIhGHXXWoZmCMYe9E82DcD+7ReNuEE9DWE/UGtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ixMtrs0o; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ixMtrs0o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709189072; x=1740725072; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VTp5F6mIs7twJi0yuRSzLDSYAKLqNn6eJlbE1TyLtH8=; b=ixMtrs0o22TgaBRI/vyw975wvosB/Up5coMT3VfxkVbOBWnRMWNBRP5i adfmhc9IecnnypRc4FxarHj094n27FB3izO3x7pyML19MCjtcS8YMZjFD oEQ7tFbvSxhreyWjgVA8VsDgVwwfBq7pFQorMds/z7b6nybVJpuEnnx2n /cSrwTwFmeg4BisUQFU31DUFUDC+eN4AEbxi47T4choeHCH1PJprB6oQe Nvbss2R6WDU8u0CK9XQrXkiGyvEvjXPFB5NU9swGy+7mUpy6nrc8Wevmv C1zkY/WCsE3A8gWKB3ca3hR59pPujZFYeziF88fL9qnOOIi8/PWcGNiia A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3803337" X-IronPort-AV: E=Sophos;i="6.06,192,1705392000"; d="scan'208";a="3803337" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 22:44:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,192,1705392000"; d="scan'208";a="8076575" Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by orviesa007.jf.intel.com with ESMTP; 28 Feb 2024 22:44:26 -0800 From: Xiaoyao Li To: Paolo Bonzini , David Hildenbrand , Igor Mammedov , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , "Michael S. Tsirkin" , Richard Henderson , Ani Sinha , Peter Xu , Cornelia Huck , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Marcelo Tosatti Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, Michael Roth , Claudio Fontana , Gerd Hoffmann , Isaku Yamahata , Chenyi Qiang , xiaoyao.li@intel.com Subject: [PATCH v5 64/65] i386/tdx: Don't get/put guest state for TDX VMs Date: Thu, 29 Feb 2024 01:37:25 -0500 Message-Id: <20240229063726.610065-65-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229063726.610065-1-xiaoyao.li@intel.com> References: <20240229063726.610065-1-xiaoyao.li@intel.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Sean Christopherson Don't get/put state of TDX VMs since accessing/mutating guest state of production TDs is not supported. Note, it will be allowed for a debug TD. Corresponding support will be introduced when debug TD support is implemented in the future. Signed-off-by: Sean Christopherson Signed-off-by: Xiaoyao Li Acked-by: Gerd Hoffmann --- target/i386/kvm/kvm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 31aed1c9aae0..39113718ea14 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -4620,6 +4620,11 @@ int kvm_arch_put_registers(CPUState *cpu, int level) assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); + /* TODO: Allow accessing guest state for debug TDs. */ + if (is_tdx_vm()) { + return 0; + } + /* * Put MSR_IA32_FEATURE_CONTROL first, this ensures the VM gets out of VMX * root operation upon vCPU reset. kvm_put_msr_feature_control() should also @@ -4720,6 +4725,12 @@ int kvm_arch_get_registers(CPUState *cs) if (ret < 0) { goto out; } + + /* TODO: Allow accessing guest state for debug TDs. */ + if (is_tdx_vm()) { + return 0; + } + ret = kvm_getput_regs(cpu, 0); if (ret < 0) { goto out;