Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp403813rdb; Tue, 31 Oct 2023 10:29:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEM7zAc7kEhOyjQqe8+ceoxz1FddDyDGRSQv7vagy0qE8bQRm1Yro27FbMyUUzEHd8G4A0c X-Received: by 2002:a05:6a20:728e:b0:14c:daa9:5e22 with SMTP id o14-20020a056a20728e00b0014cdaa95e22mr17275328pzk.45.1698773392415; Tue, 31 Oct 2023 10:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698773392; cv=none; d=google.com; s=arc-20160816; b=JuL+t4MZXbePzI5R9YcgTpB7APXCwZ0XIF+0FMstaJGgWhIHpcHORBOO7Um6iU5mQN pf5tZdqOx00jsR7H0zLSFJCR305NorYwq5+Jhd/gIcW3dXCJzrLObBiKbbo04AcZxkHr zYMmGX5ycbPG8FZf6/88fa0ciND/Z8jXhcFb/B8eT18cHbhMcJNNTUmftBCs5FaLkk3X CCtO9+Y93ToniB9TE9FgVb1N/lKN8/Kqr8OlcP7dvek50xTLBwHJCEryfgdZ3kSOJLPg 9A12CQypIj9t5DjW5ooC2yPO44CqXZCcgeQVB4RlJ8O1+FSBZxBun2uZdwtcLhd33O4i x3Aw== 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:autocrypt :from:content-language:references:cc:to:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=B6aEIhwEV+uOGmAG0jTxRqmBo5hE68Bxjr/IuvGLN18=; fh=M/D/7n8R775nWuRon/DyJyWGkxKPgjfvQmV+XEU3fRo=; b=IIe0869GAKcqQygHipKKRfkL3nQXLJNy7LipgFGC1EhomWdV9H9THXYzdWU2wScn+h p1QghFbNquGQzx6hjHLEHBFC4Z9bTPu+ZtoWzjxTSehoIULhKrcMbf384OAdKuObjbMX UqSzc/xdAcVpSc8XDPgDsYmVgPLLt7yQHE++SAoreEg9JnSzhsnenXFnlF1l6mp/QTaZ dXnVR+D2zOBMO2tIkHbqYN2lpjJs3RaK4rfl5oBYG49dTEpBpOUa3kKo7kuMQpCe293E iTnVfITyvg05ItXzk87btm3OSz0qbTgvhYA2bI44lGVYSyp1Uahcyq8yF2bmY1dcBte/ cqBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2023101201 header.b=dKl5mYy7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id r15-20020a63e50f000000b005acba4c9bf4si1279325pgh.2.2023.10.31.10.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 10:29:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2023101201 header.b=dKl5mYy7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7BAFA8053B1D; Tue, 31 Oct 2023 10:29:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344802AbjJaR3j (ORCPT + 99 others); Tue, 31 Oct 2023 13:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231805AbjJaR3h (ORCPT ); Tue, 31 Oct 2023 13:29:37 -0400 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20AFF8F; Tue, 31 Oct 2023 10:29:35 -0700 (PDT) Received: from [192.168.7.187] ([76.103.185.250]) (authenticated bits=0) by mail.zytor.com (8.17.1/8.17.1) with ESMTPSA id 39VHSp11715311 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Tue, 31 Oct 2023 10:28:52 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 39VHSp11715311 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2023101201; t=1698773332; bh=B6aEIhwEV+uOGmAG0jTxRqmBo5hE68Bxjr/IuvGLN18=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=dKl5mYy7JMqrVTtuWB9Odr5sSc04kgg8QaFB0r3R7TZU5cvVv2dnHBjDu26g1qksP +hGd0RaDgarsHv8Bgen8+za8rm+ZIbpUDyx0EC1VT17O+p2AW7dumM2D0aJlcHvAyk aPlaDCf0fkC8x1+ukpWvTzFno510+fg5JdPPddJM3Vs6LhAkIn/RJxznn3bqL3rldr A+huVix52+SFJSFEf8JgLfJ2jLSBnzoCyfME9D2LyknwW+s2/7rP6tNQRD8zoM/qBN oaEM7xs0n/WYNycaL9ySnQtGJhSmeWnXYgrjdAKGTa7LwULTgvmjXNy8Kl1lTsY71j WxhBNMJSK7I5w== Message-ID: <47316871-db95-4f72-9f3a-71743d97d336@zytor.com> Date: Tue, 31 Oct 2023 10:28:49 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/2] KVM: VMX: Cleanup VMX basic information defines and usages To: "Huang, Kai" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: "Yang, Weijiang" , "Christopherson,, Sean" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "hpa@zytor.com" , "mingo@redhat.com" , "tglx@linutronix.de" , "bp@alien8.de" , "pbonzini@redhat.com" References: <20231030233940.438233-1-xin@zytor.com> <2158ef3c5ce2de96c970b49802b7e1dba8b704d6.camel@intel.com> Content-Language: en-US From: Xin Li Autocrypt: addr=xin@zytor.com; keydata= xsDNBGUPz1cBDACS/9yOJGojBFPxFt0OfTWuMl0uSgpwk37uRrFPTTLw4BaxhlFL0bjs6q+0 2OfG34R+a0ZCuj5c9vggUMoOLdDyA7yPVAJU0OX6lqpg6z/kyQg3t4jvajG6aCgwSDx5Kzg5 Rj3AXl8k2wb0jdqRB4RvaOPFiHNGgXCs5Pkux/qr0laeFIpzMKMootGa4kfURgPhRzUaM1vy bsMsL8vpJtGUmitrSqe5dVNBH00whLtPFM7IbzKURPUOkRRiusFAsw0a1ztCgoFczq6VfAVu raTye0L/VXwZd+aGi401V2tLsAHxxckRi9p3mc0jExPc60joK+aZPy6amwSCy5kAJ/AboYtY VmKIGKx1yx8POy6m+1lZ8C0q9b8eJ8kWPAR78PgT37FQWKYS1uAroG2wLdK7FiIEpPhCD+zH wlslo2ETbdKjrLIPNehQCOWrT32k8vFNEMLP5G/mmjfNj5sEf3IOKgMTMVl9AFjsINLHcxEQ 6T8nGbX/n3msP6A36FDfdSEAEQEAAc0WWGluIExpIDx4aW5Aenl0b3IuY29tPsLBDQQTAQgA NxYhBIUq/WFSDTiOvUIqv2u9DlcdrjdRBQJlD89XBQkFo5qAAhsDBAsJCAcFFQgJCgsFFgID AQAACgkQa70OVx2uN1HUpgv/cM2fsFCQodLArMTX5nt9yqAWgA5t1srri6EgS8W3F+3Kitge tYTBKu6j5BXuXaX3vyfCm+zajDJN77JHuYnpcKKr13VcZi1Swv6Jx1u0II8DOmoDYLb1Q2ZW v83W55fOWJ2g72x/UjVJBQ0sVjAngazU3ckc0TeNQlkcpSVGa/qBIHLfZraW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F6K+PE+OTJUh2F dOhslN5C2kgl0dvUuevwMgQF3IljLmi/6APKYJHjkJpu1E6luZec/lRbetHuNFtbh3xgFIJx 2RpgVDP4xB3f8r0I+y6ua+p7fgOjDLyoFjubRGed0Be45JJQEn7A3CSb6Xu7NYobnxfkwAGZ Q81a2XtvNS7Aj6NWVoOQB5KbM4yosO5+Me1V1SkX2jlnn26JPEvbV3KRFcwV5RnDxm4OQTSk PYbAkjBbm+tuJ/Sm+5Yp5T/BnKz21FoCS8uvTiziHj2H7Cuekn6F8EYhegONm+RVg3vikOpn gao85i4HwQTK9/D1wgJIQkdwWXVMZ6q/OALaBp82vQ2U9sjTyFXgDjglgh00VRAHP7u1Rcu4 l75w1xInsg== In-Reply-To: <2158ef3c5ce2de96c970b49802b7e1dba8b704d6.camel@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 31 Oct 2023 10:29:49 -0700 (PDT) On 10/31/2023 2:03 AM, Huang, Kai wrote: > On Mon, 2023-10-30 at 16:39 -0700, Xin Li (Intel) wrote: >> From: Xin Li >> >> Define VMX basic information fields with BIT_ULL()/GENMASK_ULL(), and >> replace hardcoded VMX basic numbers with these field macros. >> >> Per Sean's ask, save the full/raw value of MSR_IA32_VMX_BASIC in the >> global vmcs_config as type u64 to get rid of the hi/lo crud, and then >> use VMX_BASIC helpers to extract info as needed. >> > > [...] > > Btw, it's better to have a cover letter even for this small series and give a > lore link for old versions so that people can easily find old discussions. Well, this patch set has few (I would say no) logic and functionality changes, and the change history should be it. > >> >> +/* x86 memory types, explicitly used in VMX only */ >> +#define MEM_TYPE_WB 0x6ULL >> +#define MEM_TYPE_UC 0x0ULL > > The renaming of memory type macros deserves some justification in the changelog > IMHO, because it doesn't belong to what the patch title claims to do. I thought about it, however the changes are more of how these 2 memory type macros are used, which is still cleanup. > > You can even split this part out, but will leave to Sean/Paolo. My point too :) > >> + >> +/* VMX_BASIC bits and bitmasks */ >> +#define VMX_BASIC_32BIT_PHYS_ADDR_ONLY BIT_ULL(48) >> +#define VMX_BASIC_INOUT BIT_ULL(54) >> + >> #define VMX_MISC_PREEMPTION_TIMER_RATE_MASK 0x0000001f >> #define VMX_MISC_SAVE_EFER_LMA 0x00000020 >> #define VMX_MISC_ACTIVITY_HLT 0x00000040 >> @@ -143,6 +151,16 @@ static inline u32 vmx_basic_vmcs_size(u64 vmx_basic) >> return (vmx_basic & GENMASK_ULL(44, 32)) >> 32; >> } >> >> +static inline u32 vmx_basic_vmcs_basic_cap(u64 vmx_basic) >> +{ >> + return (vmx_basic & GENMASK_ULL(63, 45)) >> 32; >> +} > > Is this still needed? no. > >> + >> +static inline u32 vmx_basic_vmcs_mem_type(u64 vmx_basic) >> +{ >> + return (vmx_basic & GENMASK_ULL(53, 50)) >> 50; >> +} > > You already have VMX_BASIC_MEM_TYPE_SHIFT defined below, so it looks a little > bit odd to still use hard-coded values here. > > But per Sean I agree it's quite noisy to have all these _SHIFT defined just in > order to get rid of these hard-coded values. > > How about, ... > >> +#define VMX_BASIC_VMCS_SIZE_SHIFT 32 >> +#define VMX_BASIC_DUAL_MONITOR_TREATMENT BIT_ULL(49) >> +#define VMX_BASIC_MEM_TYPE_SHIFT 50 >> +#define VMX_BASIC_TRUE_CTLS BIT_ULL(55) >> + >> > > ... since, if I am reading correctly, the two _SHIFT above are only used ... > > [...] > >> @@ -6964,7 +6975,7 @@ static void nested_vmx_setup_basic(struct nested_vmx_msrs *msrs) >> VMCS12_REVISION | >> VMX_BASIC_TRUE_CTLS | >> ((u64)VMCS12_SIZE << VMX_BASIC_VMCS_SIZE_SHIFT) | >> - (VMX_BASIC_MEM_TYPE_WB << VMX_BASIC_MEM_TYPE_SHIFT); >> + (MEM_TYPE_WB << VMX_BASIC_MEM_TYPE_SHIFT); >> > > ... here, we can remove the two _SHIFT but define below instead: > > #define VMX_BASIC_VMCS12_SIZE ((u64)VMCS12_SIZE << 32) > #define VMX_BASIC_MEM_TYPE_WB (MEM_TYPE_WB << 50) I personally don't like such names, unless we can name them in a better way. > > And use above two macros in nested_vmx_setup_basic()? > Thanks! Xin