Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8163917rwb; Tue, 13 Dec 2022 03:06:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf51wr+v53gbTXr8IRbwRzm7NIgYC22aeW4TP2BCU0LBHiA1G8GYoyyCi1BGIkk/8lUMu01I X-Received: by 2002:a17:90b:396:b0:219:1509:fb14 with SMTP id ga22-20020a17090b039600b002191509fb14mr20613048pjb.33.1670929560401; Tue, 13 Dec 2022 03:06:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670929560; cv=none; d=google.com; s=arc-20160816; b=K0D3P7lARynxI8ZvN0BpcJ2Vdvyf+WK9a0cXIF+mXbnKo5NhP2v1pEESGKR/BHIrSn tQcJQR3g+sshpCKX8DaDQG7cfAcwQ2wGNEv7olJZwswW3p9cup7iOzqRQJ0C7TMrtBNz ABgXbOguiWPaTQ1wjAAzVcyX6crW/Cn9a54hxO/rbiCI2ZODRB40mJeoYW3buw2nNZMc jxEAlPUf250Nh02r26BiuMO6Y23em/CucBb5JFK9pOx4FN2t0eI5k7QNPhCc9zV3x5/d G2AKqUo8hRvcyzFXHi2UhIZSHiIaWnz2cG4KuGh/wOJECditRPuKunl7am1ubwSYEEih Bqog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2xFT8V9V9/XOY+w2BEuOFr+pY8FCB83MCfZOxgYVrzQ=; b=g/gr/1hY9cgqiG6xJfLc7lYjp3VckMUN5pem9u5lf/c4uhfxonFlh8+gRJzi3keqM3 MvMsk9fwKGliWjTA/o+8/R1xlNj32MLqyqx84rJBMmZ+SxUm2chmySr4KoqAA1zIXMlb sCAxEWBVmfEZjuxmVG/GKUZUK7Ezy0q28T/Hqr0fHiwdPhR+WAfTJhNiudS/BW9WRqFu +hEcHdEIMWLEff00WCZuZ7DAUUv+4jg30/V9qyVeVlvIJQLWFKqmilDqOQRgySckv8WR 73s+NpkHlACGC5l47yvq8oymExss2ZcaVhUb9DjO3QEBl1JoP9ikSBzNR0g067/RkDyE Z9Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="M/GLUAT6"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn10-20020a17090b38ca00b00213b6c822acsi12727712pjb.167.2022.12.13.03.05.51; Tue, 13 Dec 2022 03:06:00 -0800 (PST) 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="M/GLUAT6"; 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 S235038AbiLMK1G (ORCPT + 73 others); Tue, 13 Dec 2022 05:27:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235021AbiLMK0o (ORCPT ); Tue, 13 Dec 2022 05:26:44 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97AB41CFCB; Tue, 13 Dec 2022 02:26:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670927202; x=1702463202; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=MgDJrUXeSavZ9oBZ0ZsWHe76MqY6VNRSfNVI7k18A9w=; b=M/GLUAT612Jiq7XryFa/e7CflYDmO7FukANYGzrUUg4HBcKrITyJB0En hdZ8jesVDZZLvPuBoeriuvOWnigzT8S3Kme37Y4hBDylGO7rYER25OnEc zvdeinNmBdHEbgDU1LmmFC3rPRiOKRgj8zyqkQfXHbFUJokCm1w3CqPnD 8dsgjhmt7ONRYjj5NF2Tz6rE2LD+ZIoTa8KvkVGuufX9XnX7mQagZ8nFf 8xhrdIIGMd7ENacAg/rLFnGHyYmSIxi+DLVh+ful62uQZ5Zzi3LesCHEQ fNVfV6PwAFv7kSMOj6fkjAR03lK6flwBfbDz2KLrUZrdKY6Aymu/8hptE Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10559"; a="297778157" X-IronPort-AV: E=Sophos;i="5.96,241,1665471600"; d="scan'208";a="297778157" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2022 02:26:41 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10559"; a="679250447" X-IronPort-AV: E=Sophos;i="5.96,241,1665471600"; d="scan'208";a="679250447" Received: from wangl2-mobl.ccr.corp.intel.com (HELO localhost) ([10.254.214.204]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2022 02:26:36 -0800 Date: Tue, 13 Dec 2022 18:26:32 +0800 From: Yu Zhang To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Aaron Lewis , Lixiao Yang Subject: Re: [PATCH v2 1/4] KVM: nVMX: Properly expose ENABLE_USR_WAIT_PAUSE control to L1 Message-ID: <20221213102632.7otsl3lfuylntsho@linux.intel.com> References: <20221213062306.667649-1-seanjc@google.com> <20221213062306.667649-2-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221213062306.667649-2-seanjc@google.com> User-Agent: NeoMutt/20171215 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, 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 On Tue, Dec 13, 2022 at 06:23:03AM +0000, Sean Christopherson wrote: > Set ENABLE_USR_WAIT_PAUSE in KVM's supported VMX MSR configuration if the > feature is supported in hardware and enabled in KVM's base, non-nested > configuration, i.e. expose ENABLE_USR_WAIT_PAUSE to L1 if it's supported. > This fixes a bug where saving/restoring, i.e. migrating, a vCPU will fail > if WAITPKG (the associated CPUID feature) is enabled for the vCPU, and > obviously allows L1 to enable the feature for L2. > > KVM already effectively exposes ENABLE_USR_WAIT_PAUSE to L1 by stuffing > the allowed-1 control ina vCPU's virtual MSR_IA32_VMX_PROCBASED_CTLS2 when > updating secondary controls in response to KVM_SET_CPUID(2), but (a) that > depends on flawed code (KVM shouldn't touch VMX MSRs in response to CPUID > updates) and (b) runs afoul of vmx_restore_control_msr()'s restriction > that the guest value must be a strict subset of the supported host value. > > Although no past commit explicitly enabled nested support for WAITPKG, > doing so is safe and functionally correct from an architectural > perspective as no additional KVM support is needed to virtualize TPAUSE, > UMONITOR, and UMWAIT for L2 relative to L1, and KVM already forwards > VM-Exits to L1 as necessary (commit bf653b78f960, "KVM: vmx: Introduce > handle_unexpected_vmexit and handle WAITPKG vmexit"). > > Note, KVM always keeps the hosts MSR_IA32_UMWAIT_CONTROL resident in > hardware, i.e. always runs both L1 and L2 with the host's power management > settings for TPAUSE and UMWAIT. See commit bf09fb6cba4f ("KVM: VMX: Stop > context switching MSR_IA32_UMWAIT_CONTROL") for more details. > > Fixes: e69e72faa3a0 ("KVM: x86: Add support for user wait instructions") > Cc: stable@vger.kernel.org > Reported-by: Aaron Lewis > Reported-by: Yu Zhang > Signed-off-by: Sean Christopherson Could you please help add "Reported-by: Yang, Lixiao " She identified the failure of vmx_msrs_test in KVM selftest first. Thanks! B.R. Yu