From patchwork Sun Oct 30 06:23:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 12902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1666787wru; Sat, 29 Oct 2022 23:31:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sH0MD3Rpf9+MmsGBoC74duWg+Gq6lvFLW3O25qpMMuJXB61Z6dvxOzMyBiUIGXQccFg9A X-Received: by 2002:a17:902:be07:b0:187:48d:d9be with SMTP id r7-20020a170902be0700b00187048dd9bemr8050197pls.102.1667111482220; Sat, 29 Oct 2022 23:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667111482; cv=none; d=google.com; s=arc-20160816; b=pZX9vZXlKZIH0e8DHz2GNMTIZh0ungUqKr6jIAZH1/qBLmKRMJ1l2dRgjH/w+AkQKf ec7p0LEiQHEdEUtNSvKopErJ14SSJsGvDLPsJgFaVUxOGlphYt5gJcicuf9dS89Dbt4U Me38wdCOuMEC0G1r9kugYMt+W7x+DbSKIfeKX4WB6539HAatCd+QoUygIOA4S/chiKW0 ZBU04GPmJ1bwN5VOGyWLJegX9RXZZx4UvI1LKVsKU3FiQOnn8lPUI8E1OvBVN9OeFyaz iYBGr1bSV3u9PiDiW+vuoqEXLwP8ov3N3kHwi2Lwgftzxvd089+GJ8XWnssAUii5SBMV oXUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0063pmI4F92CwXB0ynWQVFCNIWIWDc3gQ+WOPhjT3ew=; b=Of0YQbwhrNqwOFy9RWrZSglfW5azUx0rdYwvp7eXA1C8VvOAod9mhej5GdicdM1rlN wIw2lYqWaNzgRgFjQ7kmrGUsAKuuesK6htqr2IKZBJsJR6T2NO/7YKMmUVlROG817Hb+ yCbCMIminIUU3IrfAvmBYuoAxq2MjOFxXS0N30B5YxkvciKTJfrRwh4tJFTmGsAKN6YO eWuj9WyyTjk5NOL78G0WlgbaLZHlKLx8CwB2ZzjcRc2hQCnGQrb5ofcWxY08zg6Cn2k7 7OhEEjlSPhI14qSRd/U4zE/Ecy5JG72LkWk3IFdfeROsB/OD2MM/zQfVlEWVmgWwis7y U77A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hcXsxHar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e38-20020a631e26000000b0046f5808167asi4113739pge.812.2022.10.29.23.31.09; Sat, 29 Oct 2022 23:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hcXsxHar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbiJ3Ga2 (ORCPT + 99 others); Sun, 30 Oct 2022 02:30:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbiJ3G2X (ORCPT ); Sun, 30 Oct 2022 02:28:23 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB462C7; Sat, 29 Oct 2022 23:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111078; x=1698647078; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CH8X9PQ1WntEbptpMuYy9mmJ5w7JHl1yNfjV5rQQPzI=; b=hcXsxHarcNvdltYyWkaBAfAHAcxRbMQFAIgQD2awQLZ1k2hENr26t1VE 2UbKTqPKtwVyZVV50hvGnwA3WPi2f1Xv8p4HZgP5R4MMu8MNLgXHXMvDY Si+CEY9RqPT8Dz0dTqsLXP0NQOdqyE/H4Vvl4VUkPI2EcrqMoMT/PzGb5 JKVydd70uapscre3c+Ey9+vLWkASsbEahVf6Kiy+SfZ6GJBN5a/t7z/6y JbXOt5/2eVkGQJ4PfRpE794I6WXOZqdH2gV1SafRP6Ch/+UUQeH5yw47V Xf2JwvS/gtURev2KxEHmYJR7K9ZmGyDHCcwH1nsevY3w5W2Z5n8YbmWbz Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037188" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037188" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:10 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878393086" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878393086" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:09 -0700 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 , David Matlack Subject: [PATCH v10 075/108] KVM: TDX: restore debug store when TD exit Date: Sat, 29 Oct 2022 23:23:16 -0700 Message-Id: <82a23837a7d35c4144c5eeea6327a8443f0d1be5.1667110240.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748093089251082521?= X-GMAIL-MSGID: =?utf-8?q?1748093089251082521?= 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 7839507b3844..5c310a951a0b 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -2340,3 +2340,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 af13c19af339..5807a2f564af 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -526,6 +526,7 @@ fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu) tdx_vcpu_enter_exit(vcpu, tdx); tdx_user_return_update_cache(); + perf_restore_debug_store(); tdx_restore_host_xsave_state(vcpu); tdx->host_state_need_restore = true;