From patchwork Tue Oct 18 10:09:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 4072 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1875365wrs; Tue, 18 Oct 2022 03:19:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IMHEbvhB6E3VF0/+UmzXmNSXlNZHmvKfygxACOm5no5eiS2NmWbO1XBfvDc2jE3FQQi/O X-Received: by 2002:a05:6a00:16c4:b0:535:890:d4a with SMTP id l4-20020a056a0016c400b0053508900d4amr2499641pfc.0.1666088388074; Tue, 18 Oct 2022 03:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666088388; cv=none; d=google.com; s=arc-20160816; b=RvsYV+y/eMZPAYSUk2wbKlDZDCPYzUrLVg+yTVaZpM4JtFFY76iGyVEfXnfkKnIDtN wuWgBrrVR0WoHgv3UXCg10FZsk1GhQzRosThQDjAfHa8fzhsMCpLf1gJsDloEm5mLpVz hiwKLMBLPWdS6b/pGN8B9Ra/5Qo1+RJCQF/ReG+DGe8B/Evt0gFdY0G/0NV6d7rkGp1Y rp687JOfGUdNI49yT+cg4RVrMuM/9OwZsAqSU0uMRtHpK6JKwMPO4KltsjbZ5RPxpTQT vgjmyqzEL4K0CAdshVguj0QqtJl/q6g1sSdFMfZA/BwR4W705HikH6aMg5u53yplBd9W 8x1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TNypx6C1egWB2KUpSWMDguYsZrMG+TK68i/4EzfUiyM=; b=vpJaM8RtF2jkkzS00MCk7CSE69PENxnyK6+Jk5jTCcFNukWdf5OQozs1/yBdlkUYWy CTCDmHK3kirycvafAwCDxQbam0zB0oB0gb5g5unzdxcJHwb0EkxhYfJ69JY8kzI9/2Of lBl14gtPQMnHlQuSJeH8u4uDya2hDKgUXODJqB0YLKrzEdQhkCgkPLzuKrDKOhQKX11R ycE7tkSRCiS5sBNskv3eXazvDSAAH0LnHjYYpAN7KPzHrk6Wa9pbmgbjhG+2axd6Ofcz XJ++Fi9rOU94RVqD0oxg8WSNh9X7AWk2EHVCpphh3c2FYld8EX5E9MxKzvk2cLs6qiMC 6LZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CorlDJ99; 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=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 23-20020a631157000000b004449e02100esi14985681pgr.510.2022.10.18.03.19.35; Tue, 18 Oct 2022 03:19:48 -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=@redhat.com header.s=mimecast20190719 header.b=CorlDJ99; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230373AbiJRKKl (ORCPT + 99 others); Tue, 18 Oct 2022 06:10:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbiJRKKP (ORCPT ); Tue, 18 Oct 2022 06:10:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E71D51402 for ; Tue, 18 Oct 2022 03:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666087812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TNypx6C1egWB2KUpSWMDguYsZrMG+TK68i/4EzfUiyM=; b=CorlDJ99Fm3Q4y2+MTP2YKQW2DgmGFA8H0EFRJH1jEsMp6/+R40jkJVZBAsU3bS6UNehlM UN37wnbpFcDz0vC6EzBRb2KNvAnSacIg1HJWu9JnvR4A7dAIcDyJhZbU7X3FLfHs+OE21s AA8XUf/ojTA6iE9R5yfy7JJQXAsQ/Yg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-490-MzKkp20jOpeW6RnZ-ZWD4A-1; Tue, 18 Oct 2022 06:10:09 -0400 X-MC-Unique: MzKkp20jOpeW6RnZ-ZWD4A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D729A833A0D; Tue, 18 Oct 2022 10:10:08 +0000 (UTC) Received: from ovpn-193-156.brq.redhat.com (ovpn-193-156.brq.redhat.com [10.40.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50F1B40C94EB; Tue, 18 Oct 2022 10:10:07 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] KVM: nVMX: Prepare to sanitize tertiary execution controls with eVMCS Date: Tue, 18 Oct 2022 12:09:59 +0200 Message-Id: <20221018101000.934413-4-vkuznets@redhat.com> In-Reply-To: <20221018101000.934413-1-vkuznets@redhat.com> References: <20221018101000.934413-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747020297575536979?= X-GMAIL-MSGID: =?utf-8?q?1747020297575536979?= In preparation to restoring vmcs_conf sanitization for KVM-on-Hyper-V, (and for completeness) add tertiary VM-execution controls to 'evmcs_supported_ctrls'. No functional change intended as KVM doesn't yet expose MSR_IA32_VMX_PROCBASED_CTLS3 to its guests. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx/evmcs.c | 4 ++++ arch/x86/kvm/vmx/evmcs.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/arch/x86/kvm/vmx/evmcs.c b/arch/x86/kvm/vmx/evmcs.c index 0f031d27741a..47f6d1cbd428 100644 --- a/arch/x86/kvm/vmx/evmcs.c +++ b/arch/x86/kvm/vmx/evmcs.c @@ -370,6 +370,7 @@ enum evmcs_ctrl_type { EVMCS_ENTRY_CTRLS, EVMCS_EXEC_CTRL, EVMCS_2NDEXEC, + EVMCS_3RDEXEC, EVMCS_PINCTRL, EVMCS_VMFUNC, NR_EVMCS_CTRLS, @@ -388,6 +389,9 @@ static const u32 evmcs_supported_ctrls[NR_EVMCS_CTRLS][NR_EVMCS_REVISIONS] = { [EVMCS_2NDEXEC] = { [EVMCSv1_LEGACY] = EVMCS1_SUPPORTED_2NDEXEC & ~SECONDARY_EXEC_TSC_SCALING, }, + [EVMCS_3RDEXEC] = { + [EVMCSv1_LEGACY] = EVMCS1_SUPPORTED_3RDEXEC, + }, [EVMCS_PINCTRL] = { [EVMCSv1_LEGACY] = EVMCS1_SUPPORTED_PINCTRL, }, diff --git a/arch/x86/kvm/vmx/evmcs.h b/arch/x86/kvm/vmx/evmcs.h index 4c351f334446..205b5b467617 100644 --- a/arch/x86/kvm/vmx/evmcs.h +++ b/arch/x86/kvm/vmx/evmcs.h @@ -96,6 +96,8 @@ DECLARE_STATIC_KEY_FALSE(enable_evmcs); SECONDARY_EXEC_NOTIFY_VM_EXITING | \ SECONDARY_EXEC_ENCLS_EXITING) +#define EVMCS1_SUPPORTED_3RDEXEC (0ULL) + #define EVMCS1_SUPPORTED_VMEXIT_CTRL \ (VM_EXIT_ALWAYSON_WITHOUT_TRUE_MSR | \ VM_EXIT_SAVE_DEBUG_CONTROLS | \