Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3296011pxj; Tue, 1 Jun 2021 01:51:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfbpEhBUS6vfsXhCUDJNwq5MIIv9nbz8SkZBF8YOPu439hFA8eWRxuf5XAZF94o6aIwY7k X-Received: by 2002:a6b:7f44:: with SMTP id m4mr9914342ioq.92.1622537465354; Tue, 01 Jun 2021 01:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622537465; cv=none; d=google.com; s=arc-20160816; b=t4rAOJYQOepDUAQSaKrz8CdGd1QxOkwP+Z5pHDgIqAKi+ykopb+UfRu3AyDRaRbJb7 zB9sPSE31zfFGLyIYHwOr8YF1wEsm/sChkVpINiGyWzR62/XnXLLAbC9TycJhVWEkFiu 47+FX3f6OKF6y3ArDAZI2ixS5tgLDKTeZB1V4QQNYQrOp7M6ShP51Mz9U9+As+tvAv52 0WBN2ahVJEoRsJYqsrnoB02EYKuYeb9kaLOG4RRjHE129T6FHajA0qZDwmPU+vmCnnzu olVT1qDmXFW5mOvsly6tkeyJtIaK49uKPx6smXZCL4bMuZ4RH3vgtAp3wiLHlzmptKCE 0+WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=70XZjkHDQzrrIVWouf/AIv6qbtJGHXr6mBj2IwA+wPc=; b=PLdEyazxzzB0lTFq2+/pTU3z+DloOegLtE0WvSlUwo9OIiv4Y1LQ8J3IPpSHmtBdGM ZP4k439pBfujXm1Yf7s4jqSzBDwSM9yXIx23TV/dUKtJRIXR7tnVKnBlpH6eSmtrHrGQ VutV1IV0ZB60o8seBYS4/hkMriO0xe1B1x26WyWSzmUHvmg6JdfEzqVfe4/eJoPDVyxC 1RICQEpLLbr7bRFvbTExBqe38EdLVrvXxDZH7glX22HOSSnTKBzA4lMnS/RpgRBI94Vb ChJiVBUpcRoIjVCZH4fIxhjNcEamAc9U+9IICAkj/yZ6xS0kaBrD31gUyTRm5xtt+Ueg 1ffQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si3648032jaq.30.2021.06.01.01.50.52; Tue, 01 Jun 2021 01:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbhFAIuX (ORCPT + 99 others); Tue, 1 Jun 2021 04:50:23 -0400 Received: from mga07.intel.com ([134.134.136.100]:45164 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233182AbhFAIt6 (ORCPT ); Tue, 1 Jun 2021 04:49:58 -0400 IronPort-SDR: wBaon7NPHhrrvu6F3UZ8GvxttPkWt1sCRlYvpu/yCfvBBeZZkfWJU5T5ZWfXKfSxDsMX5WXJRO qBlhCf2WFZrA== X-IronPort-AV: E=McAfee;i="6200,9189,10001"; a="267381353" X-IronPort-AV: E=Sophos;i="5.83,239,1616482800"; d="scan'208";a="267381353" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 01:48:15 -0700 IronPort-SDR: CP44KpMcMxtiTFQ+YGit0IDawMBPvayVTbQ78XltNVn8mmIPhxZTUvxUi5I2dsTgAmheGyTfS6 g2xGdt8aRxng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,239,1616482800"; d="scan'208";a="437967791" Received: from sqa-gate.sh.intel.com (HELO robert-ivt.tsp.org) ([10.239.48.212]) by orsmga007.jf.intel.com with ESMTP; 01 Jun 2021 01:48:12 -0700 From: Robert Hoo To: pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org Cc: x86@kernel.org, linux-kernel@vger.kernel.org, chang.seok.bae@intel.com, robert.hu@intel.com, robert.hu@linux.intel.com Subject: [PATCH 06/15] kvm/vmx: Set Tertiary VM-Execution control field When init vCPU's VMCS Date: Tue, 1 Jun 2021 16:47:45 +0800 Message-Id: <1622537274-146420-7-git-send-email-robert.hu@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1622537274-146420-1-git-send-email-robert.hu@linux.intel.com> References: <1622537274-146420-1-git-send-email-robert.hu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define the new 64bit VMCS field, as well as its auxiliary set function. In init_vmcs(), set this field to the value previously configured. But in vmx_exec_control(), at this moment, returning vmcs_config.primary_exec_control with tertiary-exec artifially disabled, as till now no real feature on it is enabled. This will be removed later in Key Locker enablement patch. Signed-off-by: Robert Hoo --- arch/x86/include/asm/vmx.h | 2 ++ arch/x86/kvm/vmx/vmcs.h | 1 + arch/x86/kvm/vmx/vmx.c | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index c035649..dc549e3 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -222,6 +222,8 @@ enum vmcs_field { ENCLS_EXITING_BITMAP_HIGH = 0x0000202F, TSC_MULTIPLIER = 0x00002032, TSC_MULTIPLIER_HIGH = 0x00002033, + TERTIARY_VM_EXEC_CONTROL = 0x00002034, + TERTIARY_VM_EXEC_CONTROL_HIGH = 0x00002035, GUEST_PHYSICAL_ADDRESS = 0x00002400, GUEST_PHYSICAL_ADDRESS_HIGH = 0x00002401, VMCS_LINK_POINTER = 0x00002800, diff --git a/arch/x86/kvm/vmx/vmcs.h b/arch/x86/kvm/vmx/vmcs.h index 1472c6c..343c329 100644 --- a/arch/x86/kvm/vmx/vmcs.h +++ b/arch/x86/kvm/vmx/vmcs.h @@ -48,6 +48,7 @@ struct vmcs_controls_shadow { u32 pin; u32 exec; u32 secondary_exec; + u64 tertiary_exec; }; /* diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 554e572..56a56f5 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4255,6 +4255,9 @@ u32 vmx_exec_control(struct vcpu_vmx *vmx) CPU_BASED_MONITOR_EXITING); if (kvm_hlt_in_guest(vmx->vcpu.kvm)) exec_control &= ~CPU_BASED_HLT_EXITING; + + /* Disable Tertiary-Exec Control at this moment, as no feature used yet */ + exec_control &= ~CPU_BASED_ACTIVATE_TERTIARY_CONTROLS; return exec_control; } @@ -4413,6 +4416,9 @@ static void init_vmcs(struct vcpu_vmx *vmx) secondary_exec_controls_set(vmx, vmx->secondary_exec_control); } + if (cpu_has_tertiary_exec_ctrls()) + tertiary_exec_controls_set(vmx, vmcs_config.cpu_based_3rd_exec_ctrl); + if (kvm_vcpu_apicv_active(&vmx->vcpu)) { vmcs_write64(EOI_EXIT_BITMAP0, 0); vmcs_write64(EOI_EXIT_BITMAP1, 0); -- 1.8.3.1