Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp271606rwd; Tue, 16 May 2023 00:25:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zCPZ9bWBCGay9JgGUUWpkJgahrJDInMONlOXSikqB0aL3QRCEelOWHzp3ExJ2a+gwVfqk X-Received: by 2002:a05:6a20:748c:b0:104:ffd0:2338 with SMTP id p12-20020a056a20748c00b00104ffd02338mr14350530pzd.26.1684221926339; Tue, 16 May 2023 00:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684221926; cv=none; d=google.com; s=arc-20160816; b=DhAgZf8Cdx27vO0U2yOT7F/g+BuHndUISWCN68vna1mt7TmV2yUm4+9kuNQEhKSikC i4r/5cuiJ0NvUClnSRjKBUMFfd617C5z8GWYayX0NkwmSJ3yo5hHuZkNGls7oZfzUIXn /dyp3u6ap2onXD0AY1LK6DPbd8c+2qKOAJ4Wh6+Qc953p46I2OLEBbqW1Q7J2y/WmoR6 0jiBMDYUd1U3FBiuCih3+p+NtteKAwwfXXM9LW2+b2JBScZ+4tDyT1jQb3A4pJQuI1bU +k3AYo39k5Q1YKGbKWFDdIg6fkSSuxK6eWpVq6uS5owJqJPrriXV32uMPjwmq1Hl+hin AZVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=EKW7fctJR5dO2rAXiwn85KccsbRkEpEDeYmFJVARUCc=; b=SsinIwyD3nujXIiTxey3eJYqXY1mh/vlZ3AOT3TvJaSk2lX3z2VJA1k+aLhKlr3JP3 vTM4PBjx8bvDFSQWzmSiCuUwuavObLsIUkGXPfe/tWYOs2NkYsQg4BKn+40Oah2Njrwh xdT3XQeDSqlRs/rdVYKlHRBm8FmWbqbNY0Sh93U2XNOyRfRtU0fGF2WJi1Y4lpgiHJy3 bGPky9BtxrEQsHDvlEvNlFqTcpGp0/cnsH5lmaQKyBvB8SlXOXRi7iO16F59jZc3oc9l fFLel+DaasOBd/nbr2wbw9nhRl1FjISz7FjamBv4hI9VaBuj2zVG+xsq3W/3N4vqFqP4 Silw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YUJQGQc0; 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 q125-20020a632a83000000b0051412a8bc7csi17751122pgq.695.2023.05.16.00.25.12; Tue, 16 May 2023 00:25:26 -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=YUJQGQc0; 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 S231200AbjEPHRU (ORCPT + 99 others); Tue, 16 May 2023 03:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbjEPHRT (ORCPT ); Tue, 16 May 2023 03:17:19 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CF0910D7; Tue, 16 May 2023 00:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684221437; x=1715757437; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=CF0PB4WyLDyRSIxIQH72Oz59jXQfGxiqd8zGQ1WP2Do=; b=YUJQGQc0SCX969GByBLSmZvBnBnywZYqv+6340np5hMkD8bn5DWe3xyc FACpzvRayV8Zw89S5EoWT6eDQ3RR+UUoybmB/Y1ye9PljukFkun004tcI DWy5KGPDwcYpPvu3Lsul5C0DuGPGwHyVV38/nUZRn/xrbWH0pz3EHblwo HU5npBUlhU2zDwkjtjOantvaxhm4wvXWTLRjMiFaNCKoA1ZafiicZjt/l DXdkBBWveb7gnF82n80vhCe3F6EG7VQ1aqkk5dMD9+RpBM2tYD8hyRBJM n2o4uIbA09UbCEMD1iQojIW1uGKBbRHsGXKDERdP/5RYlgTUGKvjydS6F g==; X-IronPort-AV: E=McAfee;i="6600,9927,10711"; a="414810525" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="414810525" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 00:17:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10711"; a="770929129" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="770929129" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.255.31.11]) ([10.255.31.11]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 00:17:01 -0700 Message-ID: <6b861c8d-9b93-74f2-6073-6f1284e72fd2@intel.com> Date: Tue, 16 May 2023 15:16:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.10.1 Subject: Re: [RFC PATCH v2 04/11] KVM: VMX: Add IA32_SPEC_CTRL virtualization support Content-Language: en-US To: Chao Gao , kvm@vger.kernel.org Cc: Jiaan Lu , Zhang Chen , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org References: <20230414062545.270178-1-chao.gao@intel.com> <20230414062545.270178-5-chao.gao@intel.com> From: Xiaoyao Li In-Reply-To: <20230414062545.270178-5-chao.gao@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 4/14/2023 2:25 PM, Chao Gao wrote: ... > +static inline void vmx_set_guest_spec_ctrl(struct vcpu_vmx *vmx, u64 val) > +{ > + vmx->guest_spec_ctrl = val; > + > + /* > + * For simplicity, always keep IA32_SPEC_CTRL_SHADOW up-to-date, > + * regardless of the MSR intercept state. > + */ > + if (cpu_has_spec_ctrl_virt()) > + vmcs_write64(IA32_SPEC_CTRL_SHADOW, val); > + > + /* > + * Update the effective value of IA32_SPEC_CTRL to reflect changes to > + * guest's IA32_SPEC_CTRL. Bits in the mask should always be set. > + */ Why bits in the mask should always be set? The bits set in the mask only means them cannot be modified by guest. KVM can use the mask to force the bits to 0 as well. > + vmx->spec_ctrl = val | vmx_get_spec_ctrl_mask(vmx); > +} > #endif /* __KVM_X86_VMX_H */