Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp677096lqt; Fri, 19 Apr 2024 07:23:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWVe7Uc8Ac8qemwqwjpcozWPt63yG5Rv/KLp8NpbFsU6I0+ZvkqYfhEICCPrzaU3v8B0o5kKr6D5p348QS4ksFAPNq75VklqOGSiIEzwg== X-Google-Smtp-Source: AGHT+IG4zhTfTC05cNo8uXMoQdbYqcX1liQFotOrOx6VqDFomwB9XENkCrCFDzJ5CpFRybLko8ct X-Received: by 2002:a05:6122:2009:b0:4da:a82e:95f5 with SMTP id l9-20020a056122200900b004daa82e95f5mr2148683vkd.5.1713536613852; Fri, 19 Apr 2024 07:23:33 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v16-20020a67ff90000000b0047bb31fb5a9si661321vsq.216.2024.04.19.07.23.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:23:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151578-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e3qNCaqP; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-151578-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151578-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 693CD1C20D52 for ; Fri, 19 Apr 2024 14:23:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FB6312E1D4; Fri, 19 Apr 2024 14:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="e3qNCaqP" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 17E3712D1FE; Fri, 19 Apr 2024 14:23:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=192.198.163.18 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713536599; cv=fail; b=qqhxTvJ5hulDPOdfjgdpdpGF1h3DRNbZWgWHjOa3Y50ox1w+t/g9xJU8MdhlGSNxUCvDvzSCSdoGixYpTLMK1n/QEbO+ObfGar0EcGpuHCfCTVNqrk9kykKj0pbOUQaeieFMv7ii7SWeX5xQN7CDjBhKxvqkJwP+S7y7CuBkerc= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713536599; c=relaxed/simple; bh=JMP20GAUWmPV9I03LcIelqciKjb5pfL1AEuuMHBGFJE=; h=Date:From:To:CC:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=LnJLnK3ow8irc6ot/yWMhnu7YJdlMU0ztPtEtwd0L3vWGrPbXiqUc7YCrTYlQnRhacOgzgiRy2idSQuukoBAKQudhDgsT5qdm3PBZCSUer07EZ3zkVmHjpSDMiW3A7ds61i6U+l93dZoBHAmWaENnDticBlidQWH3ITMQFDPJ3k= ARC-Authentication-Results:i=2; 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=e3qNCaqP; arc=fail smtp.client-ip=192.198.163.18 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713536598; x=1745072598; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=JMP20GAUWmPV9I03LcIelqciKjb5pfL1AEuuMHBGFJE=; b=e3qNCaqPtx+KtbRVBxXY/B4vuJ1itJBDMHHfbykYIlUYTEOA/BYYuG3e 2O+o8f+JHEX9WVQWrTgm0ojA4aFfRBD8y1puorvu7nQprcOPfMQ126jxg RMhXut1l19DVM+Tf1nEyRkBnbltU9Rtdau1vlTr3k9C3UeJJnzmf5JgTK 4v7nQrrZx4C9d4Ln+xqR82bJmGPZGgn6c3Cr8VRzcZIGRJzvQFsLD7246 rbjCxT2R7c4IePCS4ZMVwwdni8Ujp8XU3OkfqOB6im4z5avbuhRTPLtzF JxSBfrp5GgIOGeesQHn565k0mBrPpsovvxXZ45/MhuoyV0YEIWZ6VAI6B Q==; X-CSE-ConnectionGUID: Xj4n+/gVQZiAI1q4TBXSJw== X-CSE-MsgGUID: L8po+NGDSxSMY643oTvAqw== X-IronPort-AV: E=McAfee;i="6600,9927,11049"; a="8999488" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="8999488" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2024 07:23:16 -0700 X-CSE-ConnectionGUID: X8eD0m/IQMKoaCGx+svZUQ== X-CSE-MsgGUID: 7oFq8H24QqyHz1In4A/OtQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="28123889" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 19 Apr 2024 07:23:16 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 19 Apr 2024 07:23:15 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Fri, 19 Apr 2024 07:23:15 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.169) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 19 Apr 2024 07:23:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KdtKek+OaG0mFgAZOTlT/oFQ12M0Y7K63EUgebFADWg+WRjUKldeObp+MWw7nRNeHePYy8GqZ2bqRvxPaz/u6fn3uzFUD1Bev9iNHHzIEPFFMRdW/QkeobcRmrKJXfSLE5BPu4zpH8EthqfJn7mQc7OBTzIzlFCLJ8wJ6BZrHk40Vn7yJbHxFXIzvA8vFkttNcOTptXEC1IqEzaj5NQ4tZE9sK95yY4Bi50nzSisvUTjywDsH44AVmfllwGYXSjsOwixW6PF6V2Meos3kn4zy8HWY68y0FZk+dKgVJZo+jKqh2YJ87nFv7TYHhYwpmg1lAV29b6OBn1aYn2NlxpsrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5H1MFBKUvGGZY7QMKCPvgTVXxrWvINgVdoI5NYLig1Y=; b=GZbkuplMjHgVj//UeYpQ0JbrdUmOQnz253LEW4q9Y+A3/hd//zCEzzQ3Wib9kFFDNUKjt0wmj+grlSPN4hy6f3GPPzhEm5KNNh684NuI08hLK0PurNyWCjdUD9j35QJTJMqIOWts2/vObpYZK+J80jKEBRKC/gzZchcPGPtuQtI8DqCexDoxz2ANdaU/spqL3wY6eA4GgPt5qLOs0r9JOVhxPvQcQKR1lJhqIslG5JjKGOJ7USbGY7gDPXg//qDbpfzKZ1cHO93oOFo3/BMzMYu5X7uPDdWu2r7POKsQu6nve3/bVhSC2sgLREQDEf6wk7bdbGpCy9txzSqzM2McIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CH3PR11MB8660.namprd11.prod.outlook.com (2603:10b6:610:1ce::13) by SA3PR11MB7627.namprd11.prod.outlook.com (2603:10b6:806:320::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.14; Fri, 19 Apr 2024 14:23:13 +0000 Received: from CH3PR11MB8660.namprd11.prod.outlook.com ([fe80::5135:2255:52ba:c64e]) by CH3PR11MB8660.namprd11.prod.outlook.com ([fe80::5135:2255:52ba:c64e%4]) with mapi id 15.20.7519.010; Fri, 19 Apr 2024 14:23:13 +0000 Date: Fri, 19 Apr 2024 22:23:02 +0800 From: Chao Gao To: Xin Li CC: , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v2 09/25] KVM: VMX: Switch FRED RSP0 between host and guest Message-ID: References: <20240207172646.3981-1-xin3.li@intel.com> <20240207172646.3981-10-xin3.li@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240207172646.3981-10-xin3.li@intel.com> X-ClientProxiedBy: SI2PR02CA0003.apcprd02.prod.outlook.com (2603:1096:4:194::13) To CH3PR11MB8660.namprd11.prod.outlook.com (2603:10b6:610:1ce::13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR11MB8660:EE_|SA3PR11MB7627:EE_ X-MS-Office365-Filtering-Correlation-Id: afc8f0bb-fec9-446b-f706-08dc607c3f22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|366007|376005|7416005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dnSkaHkN3zEewrdcB7avWETtcJL4Bo5RdlVojswCGVEc+Ljw8hJ5iuP7X2Gd?= =?us-ascii?Q?0pMHUsEpop/eOlA1LdcCriMQghOQWSkz58pq4WAm8bI/W8nu1qzEr1i0fipn?= =?us-ascii?Q?kkE66mjIRbdo8zwLMGslmtLxuczBnHnl+JbL2/DVyLJq9kadoc34u10BJASZ?= =?us-ascii?Q?GZ6Zv9h0QvEW62j+wJwuiTENM4SfSVIVbbpAFWqrZ5+3Opk2jgcXuahW7rF/?= =?us-ascii?Q?HNwuuEbB47ty8CHONq5W4eGCCzR8yIKiXWnl9UYrT4etCBDqAnWXI5m8GpkE?= =?us-ascii?Q?hrE9N+Tf6vdN8aKpfSG/fdcEWJbIDBwP9vM+s3AROli5fbbQ159qcXxdErez?= =?us-ascii?Q?k80hgiv4JnpXPtI2zfWHHDxPQLh65TYOe/edHiXfjqQuk3vX3AnZzTZnIHd9?= =?us-ascii?Q?0uY3RWzu4ZL459UM/hhASbAc9cWQjzHs1VKtzLMe7tC2V7+PWdAvZgAgpjdO?= =?us-ascii?Q?VjORu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M;H:CH3PR11MB8660.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(376005)(7416005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?hh54OvC5sfi6XgVpwMwUWvHc9vsfnPtsNezF5XX1JpBYpeT8ocYhRQtU/7F5?= =?us-ascii?Q?aXDtAfEFbREzwWzxVTX63BZmiQ0DptL00XUhv/ZSvVyzTWctsFdwHgJu5+fI?= =?us-ascii?Q?okYttAEa6D/L90deWN9am/v0hGuFkSjV4yT3p91qoVMKfpdVsGTSdsoJbBkG?= =?us-ascii?Q?XHW8hQ9CT2BFNID9bS2Y049q+NR9c6Vo3e/x2i3eSamhK/+dKsx+HE+teW8Q?= =?us-ascii?Q?7wDGS3PnNQ5r7i54J2PEtvOvzppMp9hcsICFLsNKMTMe7kh6Bgdu3nTmVbhS?= =?us-ascii?Q?jeYYHQsDXIDSfUWZGMx5pSHcfu44YwncFvlxYqazv8IDRacSDnz9MWsIHm51?= =?us-ascii?Q?o75GB1HzZChLGhMFJmTMJKwSLHtDfqbuYdXSmQGJy1ZJ1g3Un1Irh9w0T6EZ?= =?us-ascii?Q?K3bSJvO8EYW02iOJy5uUq35lZRQf2e89Qy6MgTy1d5cM+Cq1TWF7nOevhbNH?= =?us-ascii?Q?F4iPTexGTe8IKO1X8OnUBKOiJ1NxnlLz8AELWCvRJtN+weW4bEzBANlt/S9y?= =?us-ascii?Q?pLr11tITtBzoKHXbaFvWxUrPeibKtvkIDmoiwZKwJF7033tSNn0nZCw3DVIc?= =?us-ascii?Q?Ku2eGtjHq2/1xp/3pDPkCHv2qpkwvuE3blCi3pF99W3mQWpe3zrW2kmClynK?= =?us-ascii?Q?fcNmpMtd5xNUeZEVKmRDHIGa6NQjufbA6HkkGvWBvaIzab8PVismj1S6NABj?= =?us-ascii?Q?akiA0cs2G7PvKcQDHVblQkMHSPUWjZTWve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f0bb-fec9-446b-f706-08dc607c3f22 X-MS-Exchange-CrossTenant-AuthSource: CH3PR11MB8660.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 14:23:13.4679 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sq8iKgDyYpdNTshhcq/kn74YRCwAiC4Gj2JSGSibAYdKklNvVhpPLq5PFdEzaZUCl85za5ioj69XQ1+ngOj8bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR11MB7627 X-OriginatorOrg: intel.com On Wed, Feb 07, 2024 at 09:26:29AM -0800, Xin Li wrote: >Switch MSR_IA32_FRED_RSP0 between host and guest in >vmx_prepare_switch_to_{host,guest}(). > >MSR_IA32_FRED_RSP0 is used during ring 3 event delivery only, thus >KVM, running on ring 0, can run safely with guest FRED RSP0, i.e., >no need to switch between host/guest FRED RSP0 during VM entry and >exit. > >KVM should switch to host FRED RSP0 before returning to user level, >and switch to guest FRED RSP0 before entering guest mode. > >Signed-off-by: Xin Li >Tested-by: Shan Kang >--- > >Changes since v1: >* Don't use guest_cpuid_has() in vmx_prepare_switch_to_{host,guest}(), > which are called from IRQ-disabled context (Chao Gao). >* Reset msr_guest_fred_rsp0 in __vmx_vcpu_reset() (Chao Gao). >--- > arch/x86/kvm/vmx/vmx.c | 17 +++++++++++++++++ > arch/x86/kvm/vmx/vmx.h | 2 ++ > 2 files changed, 19 insertions(+) > >diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c >index b7b772183ee4..264378c3b784 100644 >--- a/arch/x86/kvm/vmx/vmx.c >+++ b/arch/x86/kvm/vmx/vmx.c >@@ -1337,6 +1337,16 @@ void vmx_prepare_switch_to_guest(struct kvm_vcpu *vcpu) > } > > wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); >+ >+ if (guest_can_use(vcpu, X86_FEATURE_FRED)) { >+ /* >+ * MSR_IA32_FRED_RSP0 is top of task stack, which never changes. >+ * Thus it should be initialized only once. >+ */ >+ if (unlikely(vmx->msr_host_fred_rsp0 == 0)) >+ vmx->msr_host_fred_rsp0 = read_msr(MSR_IA32_FRED_RSP0); can we just drop this and use "(unsigned long)task_stack_page(current) + THREAD_SIZE" as host fred rsp0? >+ wrmsrl(MSR_IA32_FRED_RSP0, vmx->msr_guest_fred_rsp0); any reason to not use wrmsrns? >+ } > #else > savesegment(fs, fs_sel); > savesegment(gs, gs_sel); >@@ -1381,6 +1391,11 @@ static void vmx_prepare_switch_to_host(struct vcpu_vmx *vmx) > invalidate_tss_limit(); > #ifdef CONFIG_X86_64 > wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_host_kernel_gs_base); >+ >+ if (guest_can_use(&vmx->vcpu, X86_FEATURE_FRED)) { >+ vmx->msr_guest_fred_rsp0 = read_msr(MSR_IA32_FRED_RSP0); >+ wrmsrl(MSR_IA32_FRED_RSP0, vmx->msr_host_fred_rsp0); same question. >+ } > #endif > load_fixmap_gdt(raw_smp_processor_id()); > vmx->guest_state_loaded = false; >@@ -4889,6 +4904,8 @@ static void __vmx_vcpu_reset(struct kvm_vcpu *vcpu) > > #ifdef CONFIG_X86_64 > if (kvm_cpu_cap_has(X86_FEATURE_FRED)) { >+ vmx->msr_guest_fred_rsp0 = 0; >+ > vmcs_write64(GUEST_IA32_FRED_CONFIG, 0); > vmcs_write64(GUEST_IA32_FRED_RSP1, 0); > vmcs_write64(GUEST_IA32_FRED_RSP2, 0); >diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h >index 3ad52437f426..176ad39be406 100644 >--- a/arch/x86/kvm/vmx/vmx.h >+++ b/arch/x86/kvm/vmx/vmx.h >@@ -278,6 +278,8 @@ struct vcpu_vmx { > #ifdef CONFIG_X86_64 > u64 msr_host_kernel_gs_base; > u64 msr_guest_kernel_gs_base; >+ u64 msr_host_fred_rsp0; >+ u64 msr_guest_fred_rsp0; > #endif > > u64 spec_ctrl; >-- >2.43.0 > >