From patchwork Mon Jan 22 23:53:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 13526484 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 4965F60ECA; Mon, 22 Jan 2024 23:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.120 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967746; cv=none; b=qQmrQdKRWcS4xIg3FfypucnlvBqZQZTTOFU5Iiw1VsqVAr21qB/LPV8hAS6u2W5Vynkadgxyxpd+s1U0zb9x73kt3zbzEGLSiQeV2JsAOVksz4PwpZ1aV8OUM6naY3oWrloFO6kfsdrBA8K8dPwlUlYw82GUUIK3hyY9GVUZwCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967746; c=relaxed/simple; bh=T3zzp82ffDW6xJPkTdQ5XEAQN5qO3N9Dr5YafHIr2ho=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aGbxqyIRR8zRhRwA/eoJb83m9qksIOoarvFDsQ34P4xV/X1aMX0IQaQrdx2dak3TXRJPAcHoHLoasSTREwnLD5KroR0TDk913CVsb6febDmCHocur3IYBQGXGbbTC/NTPoq4v8IVlVwCPJ9PEhwkWPwyOFplWCuWTnKMDVQOJiI= 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=h7B9E1tj; arc=none smtp.client-ip=192.55.52.120 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="h7B9E1tj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705967744; x=1737503744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T3zzp82ffDW6xJPkTdQ5XEAQN5qO3N9Dr5YafHIr2ho=; b=h7B9E1tjO8XWBs0IYyD/uDC4PGsQhovEkGlZx6wJEuhCcwsn9+xaeFfe LgjWVY+A7mOaC7ASxUipcJtsXzP0FG0y9YSF0N+i3E5PS23eYaUQIwntm 9Pw7MSjniHOaClmIcwrQ6pmra16u425fcRLDNEhzItMiT1Siqyou82sFH YLe3zMUlt3dxBe/RslB45Gq57+8NIMCv+Gyb86nu8IpBM5T/QuIDuK2Zv y2dECCsdZYYGSgV7AF7vAxPj1sPT2NipBdx0kO9gPawnscOfK3FxQ/rBY nzaAgmaMZWLqNI8MBo7p9wha2P8cmHi4mXqJ0PPAxMovS1f4hT+vXUKhE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="400217760" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="400217760" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="27817904" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:41 -0800 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v18 075/121] KVM: TDX: restore debug store when TD exit Date: Mon, 22 Jan 2024 15:53:51 -0800 Message-Id: <7eaf9c55acb56cb6d3d74cac34fdf1436fa2465b.1705965635.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Isaku Yamahata Because debug store is clobbered, restore it on TD exit. Signed-off-by: Isaku Yamahata Reviewed-by: Paolo Bonzini --- arch/x86/events/intel/ds.c | 1 + arch/x86/kvm/vmx/tdx.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index d49d661ec0a7..25670d8a485b 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -2428,3 +2428,4 @@ void perf_restore_debug_store(void) wrmsrl(MSR_IA32_DS_AREA, (unsigned long)ds); } +EXPORT_SYMBOL_GPL(perf_restore_debug_store); diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 3b2ba9f974be..68a8d01c03bd 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -715,6 +715,7 @@ fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu) tdx_vcpu_enter_exit(tdx); tdx_user_return_update_cache(vcpu); + perf_restore_debug_store(); tdx_restore_host_xsave_state(vcpu); tdx->host_state_need_restore = true;