From patchwork Mon Feb 26 16:42:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E97CC48BF6 for ; Mon, 26 Feb 2024 16:42:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685637.1066659 (Exim 4.92) (envelope-from ) id 1ree3L-0006er-9h; Mon, 26 Feb 2024 16:42:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685637.1066659; Mon, 26 Feb 2024 16:42:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree3L-0006ek-79; Mon, 26 Feb 2024 16:42:07 +0000 Received: by outflank-mailman (input) for mailman id 685637; Mon, 26 Feb 2024 16:42:05 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree3J-0006ea-GP for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:42:05 +0000 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [2a00:1450:4864:20::52b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f8c9f634-d4c5-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:42:04 +0100 (CET) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-563c595f968so4333920a12.0 for ; Mon, 26 Feb 2024 08:42:04 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.42.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:42:03 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f8c9f634-d4c5-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965724; x=1709570524; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=6L5GGffCzRNgfzqvhyjL4MWez5VsJpAVC5R921GjUEE=; b=VVRBB1ynWbQeqlOy1mDrFYTUkp3QbwS2QrBa/75swhRLf5d5E78PYQXk8ZPiisxfcp UuGSLMK696rfC32SBH7FbGEQ8msGXU3WUed4s5/L1JmKhHnTZgDStqWnIvCXe/iH1vEG RGZl9sifExS5Mbh5JjHy0F0fIxrHahh0qbUpMbfhnUy4lAsDhEqtCThJVdxl3BeUEFD4 u5W54zxWGn2mnRZEI7dSEY80dhfC32UgLW7VE7VfrgytZyw+Om7JU3EphngrjnUIBYnY iaoguAcIY06MeoLLatgAr1N3ecTvthkNf9ylDDN9DOWw4hHNmnEkeZGhh1E8Q5kUqe07 aVbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965724; x=1709570524; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6L5GGffCzRNgfzqvhyjL4MWez5VsJpAVC5R921GjUEE=; b=qfiaO91j6/bERuGWoPDanph0UmDguDTQQowU4thqntOR7o3671QGnKq3BEx+ea+UeJ c0/tmZdY91+BvVuWCoistE+sn2uHe2qSTYX7ez//WuYmYTfBPwP2rJZFSPDCyx3fennM oqSJIl3MDuEHc+GdfDOTPSCcc8kGLBqpKa9Z5HnDMvOjWiw/XgUd2rwM9gHN/bQRQGFp F6SWpAW6bmpx3OXZt7a+G1RAH8L7zi9TNEGfROzhzlxJB922W86mcudV6d+JtiNACJi6 mLAyV/4/w4M6yPKegKf4ofUzvMK8X66aNyPNHlaXqWI9N6urgdqNqA0RMlxGX6CaQRjV mULA== X-Gm-Message-State: AOJu0Yz4XfqJDoxkyVVUeDvdNHEfGoe0rBTRlViLvtBb0EgNxKhPoAn+ Jvod4cvdbDErMGBRvPEpvHQTL8OjywLYR0LkHkLgnj8wcFuetNM+yL+NbPtIpASgWviMFo+POQ4 = X-Google-Smtp-Source: AGHT+IFObpng2g0iR1LdcIGU+8vI61RJHJXBCIcZv6BTvuxx+tYrdIce4ZzeYalYq38YVjeDbHqyEA== X-Received: by 2002:aa7:cb13:0:b0:566:2a1c:9c0f with SMTP id s19-20020aa7cb13000000b005662a1c9c0fmr187597edt.16.1708965723871; Mon, 26 Feb 2024 08:42:03 -0800 (PST) Message-ID: <21e6cbec-dc29-452f-b6a2-6926245a8beb@suse.com> Date: Mon, 26 Feb 2024 17:42:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 01/12] VMX: don't run with CR4.VMXE set when VMX could not be enabled From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507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v+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> While generally benign, doing so is still at best misleading. Signed-off-by: Jan Beulich --- Using set_in_cr4() seems favorable over updating mmu_cr4_features despite the resulting redundant CR4 update. But I certainly could be talked into going the alternative route. --- v2: Actually clear CR4.VMXE for the BSP on the error path. --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2961,14 +2961,18 @@ static bool __init has_if_pschange_mc(vo const struct hvm_function_table * __init start_vmx(void) { - set_in_cr4(X86_CR4_VMXE); + write_cr4(read_cr4() | X86_CR4_VMXE); if ( vmx_vmcs_init() ) { + write_cr4(read_cr4() & ~X86_CR4_VMXE); printk("VMX: failed to initialise.\n"); return NULL; } + /* Arrange for APs to have CR4.VMXE set early on. */ + set_in_cr4(X86_CR4_VMXE); + vmx_function_table.singlestep_supported = cpu_has_monitor_trap_flag; if ( cpu_has_vmx_dt_exiting ) From patchwork Mon Feb 26 16:42:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFE36C48BF6 for ; Mon, 26 Feb 2024 16:42:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685638.1066669 (Exim 4.92) (envelope-from ) id 1ree3c-00073d-Gp; Mon, 26 Feb 2024 16:42:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685638.1066669; Mon, 26 Feb 2024 16:42:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree3c-00073W-E9; Mon, 26 Feb 2024 16:42:24 +0000 Received: by outflank-mailman (input) for mailman id 685638; Mon, 26 Feb 2024 16:42:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree3b-000739-FG for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:42:23 +0000 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [2a00:1450:4864:20::531]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 02e920d9-d4c6-11ee-98f5-efadbce2ee36; Mon, 26 Feb 2024 17:42:21 +0100 (CET) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-563fe793e1cso4459006a12.3 for ; Mon, 26 Feb 2024 08:42:21 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.42.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:42:20 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 02e920d9-d4c6-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965741; x=1709570541; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=856hL3x+HrIg0hf4NEQ6xzQ16mC6OszsgQrB/VvbrOE=; b=NJdb4fk5w8RBnb14LfyQtixMKG9L3lJld6Mi5Hmjuql8QTj+rzqULWmUpHAlBpULR8 loU5IyTvYF6dtu2k+h97Ajp4wVkyvixsuDvwz543GkphoDgEEoEGUj3ifCJ+9SfWsCHZ r7b29Oshu9M3eql7oFeJZXL+7h1q1Yajx5dvEYP4H8xcrO6d8dj6Z91LJO514v0US0kO BN2P7tQD9djO07vibb9oq1L93UuFCvV/ZVA8QxYx10P2mlsDpLRgs6hnC+XffC1MlNgV dgqo6LOC763mXGqZQSNHQa+MLsKdnV9HDuYO2NMFlPWvRuH9gbOZ9v4IldXYmitFGtKp eqxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965741; x=1709570541; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=856hL3x+HrIg0hf4NEQ6xzQ16mC6OszsgQrB/VvbrOE=; b=fVhljMzqOXKDhNWjWnRIReKxwLtxw182Op7kz4nKV7n6qTDTaOZck0blpHz2JVpY29 2swCLuTXLrufs8I3Xds83oGS9LARLd5eTi/PjGLtU3BCenG9B1Ffjo3aK+knSdlbNgYX UGkCXtq6zipk2z10yrRlTeJBce4IE2FnHwJODQEQocmSISvGRk4fXvprpbpl4Hw7kq84 RAEV0xNFof+6qfnf+ak+2RHuqGF1uEvcWgUOJBM/PPLBMR3TxOV5JhCoyR6A0niKAKH8 Zg6s0Tw84v12v1Y7Ahg7gYSEaNqg67ruFiK+mbl7D91RbkCgBEtb0LUCYo5A//LtgCqg +r8Q== X-Gm-Message-State: AOJu0YzjdkQWLPBb1sI8DIXJgLAj83XaaitiVbq7QpQVlVzXBEuMVHJQ r9mUWsekZhSzhPp/HD2mQrl2KBcWpMvjjIIDagYsctmtNLkZwYjTA0WMPM8Ab6EdOiNU+rgLOYc = X-Google-Smtp-Source: AGHT+IFX4tC3kWKlsoQOmrfXbRUbYfg6ORAJGlbqb7HSf3nXJ3JiVN1u1vNGBzF/EmN/XqFAYOBrQA== X-Received: by 2002:aa7:d0d4:0:b0:565:76b6:920c with SMTP id u20-20020aa7d0d4000000b0056576b6920cmr4634899edo.9.1708965740965; Mon, 26 Feb 2024 08:42:20 -0800 (PST) Message-ID: <537b0d9c-1936-4cf5-a012-d50b1097a22d@suse.com> Date: Mon, 26 Feb 2024 17:42:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 02/12] x86/HVM: improve CET-IBT pruning of ENDBR Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ah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28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> __init{const,data}_cf_clobber can have an effect only for pointers actually populated in the respective tables. While not the case for SVM right now, VMX installs a number of pointers only under certain conditions. Hence the respective functions would have their ENDBR purged only when those conditions are met. Invoke "pruning" functions after having copied the respective tables, for them to install any "missing" pointers. Signed-off-by: Jan Beulich --- This is largely cosmetic for present hardware, which when supporting CET-IBT likely also supports all of the advanced VMX features for which hook pointers are installed conditionally. The only case this would make a difference there is when use of respective features was suppressed via command line option (where available). For future hooks it may end up relevant even by default, and it also would be if AMD started supporting CET-IBT; right now it matters only for .pi_update_irte, as iommu_intpost continues to default to off. Originally I had meant to put the SVM and VMX functions in presmp- initcalls, but hvm/{svm,vmx}/built_in.o are linked into hvm/built_in.o before hvm/hvm.o. And I don't think I want to fiddle with link order here. --- v3: Re-base. v2: Use cpu_has_xen_ibt in prune_{svm,vmx}(). --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -161,10 +161,15 @@ static int __init cf_check hvm_enable(vo else if ( cpu_has_svm ) fns = start_svm(); + if ( fns ) + hvm_funcs = *fns; + + prune_vmx(); + prune_svm(); + if ( fns == NULL ) return 0; - hvm_funcs = *fns; hvm_enabled = 1; printk("HVM: %s enabled\n", fns->name); --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -2587,6 +2587,19 @@ const struct hvm_function_table * __init return &svm_function_table; } +void __init prune_svm(void) +{ + /* + * Now that svm_function_table was copied, populate all function pointers + * which may have been left at NULL, for __initdata_cf_clobber to have as + * much of an effect as possible. + */ + if ( !cpu_has_xen_ibt ) + return; + + /* Nothing at present. */ +} + void asmlinkage svm_vmexit_handler(void) { struct cpu_user_regs *regs = guest_cpu_user_regs(); --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3042,6 +3042,30 @@ const struct hvm_function_table * __init return &vmx_function_table; } +void __init prune_vmx(void) +{ + /* + * Now that vmx_function_table was copied, populate all function pointers + * which may have been left at NULL, for __initdata_cf_clobber to have as + * much of an effect as possible. + */ + if ( !cpu_has_xen_ibt ) + return; + + vmx_function_table.set_descriptor_access_exiting = + vmx_set_descriptor_access_exiting; + + vmx_function_table.update_eoi_exit_bitmap = vmx_update_eoi_exit_bitmap; + vmx_function_table.process_isr = vmx_process_isr; + vmx_function_table.handle_eoi = vmx_handle_eoi; + + vmx_function_table.pi_update_irte = vmx_pi_update_irte; + + vmx_function_table.deliver_posted_intr = vmx_deliver_posted_intr; + vmx_function_table.sync_pir_to_irr = vmx_sync_pir_to_irr; + vmx_function_table.test_pir = vmx_test_pir; +} + /* * Not all cases receive valid value in the VM-exit instruction length field. * Callers must know what they're doing! --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -250,6 +250,9 @@ extern s8 hvm_port80_allowed; extern const struct hvm_function_table *start_svm(void); extern const struct hvm_function_table *start_vmx(void); +void prune_svm(void); +void prune_vmx(void); + int hvm_domain_initialise(struct domain *d, const struct xen_domctl_createdomain *config); void hvm_domain_relinquish_resources(struct domain *d); From patchwork Mon Feb 26 16:42:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10D6AC54E4A for ; Mon, 26 Feb 2024 16:43:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685642.1066679 (Exim 4.92) (envelope-from ) id 1ree44-0007gV-V3; Mon, 26 Feb 2024 16:42:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685642.1066679; Mon, 26 Feb 2024 16:42:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree44-0007gO-Rw; Mon, 26 Feb 2024 16:42:52 +0000 Received: by outflank-mailman (input) for mailman id 685642; Mon, 26 Feb 2024 16:42:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree44-0006ea-6t for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:42:52 +0000 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [2a00:1450:4864:20::12d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 14fa70fa-d4c6-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:42:51 +0100 (CET) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5129cdae3c6so4246468e87.1 for ; Mon, 26 Feb 2024 08:42:51 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.42.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:42:50 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 14fa70fa-d4c6-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965771; x=1709570571; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=lGEwsapTSmnGaMr1Jgff2JJNs1NGP6rlb8MtqM0Zg5M=; b=VVWNh8lM51dFkQXcYCAuVqphIixln+YbzyPvK2JsC+Qn7+qE1thSQiS7zY5d/shsgM VyoCKhBEmLLbQfUpHqSXg5F1t3lW4Pcy4bg4xDwb3e0oBnCzJGr4E19jYUq3ZbzDSLB+ uXnt2NjeJ010cdADbUCC0iIZ0DDHpMkwx0Ls1mSiieI7i9K8DTMsTmNqlN9upnmUrV+h oCqh964V9sXYYoRbeRb0n1fKpLdE/nWLAFLShDQ/lheb/8jwUniTTmNRWXScihDLIcjl M8yOWcMTkZ+kp+qaxGEZVEtkvYtpZ7ud5MHWefWMbhHnT0PCbxghihlnOUCnMZy5gbfj OZdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965771; x=1709570571; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lGEwsapTSmnGaMr1Jgff2JJNs1NGP6rlb8MtqM0Zg5M=; b=SpBlZEqwvzRdvELvNEROf5CbBfPM8sRaduZ/UQpxDEVjkk73fUeLgBxACWWrrpQFBK ELjLasiHTsyeB25tVR2WvqKZSbT37SvXMgnOKp34+2tEkzOka/X24jtdeaVnv+ay43mr zyVtrID7TQwzti0llU6gV/+jnql6AHhfClhJ95UVsLraSsMI5yj0mV6/Wy0gNVg0EqEj G0oUK8AH5LYR8s3RSFOSFZmBk2JCRhTDKnP5QOAYwYMM8kPSQHISVab6BXt9bwDEQkup dXxyMFLq2r4a6as9ruEhRfOD7ZNzaTU+6yQNIYc/FruG6VWHU2E2jPV1IaeGrDcfeWP0 5S0g== X-Gm-Message-State: AOJu0YyLh3Sq3WOp7B7+/U2F+V87iXVfc9yATB8rqLw3GyExTsv57L+U F3FM4Kuztmeaim/Eljxn+IXbWBnKt+7lwN15Ve5lyF1PXy0KaA9jJHaLApF5NoDp7nJnt9q7wmI = X-Google-Smtp-Source: AGHT+IFzOe9RPrj/tlAUmp2ftETyB287NeXrdceNxcU4UMcEgBERU+cMFdJrD1BufPsTF8baSgqG0A== X-Received: by 2002:ac2:4e6e:0:b0:512:a939:3fcc with SMTP id y14-20020ac24e6e000000b00512a9393fccmr4269698lfs.32.1708965771184; Mon, 26 Feb 2024 08:42:51 -0800 (PST) Message-ID: <7a4ec627-f801-409b-995e-42732970e47c@suse.com> Date: Mon, 26 Feb 2024 17:42:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 03/12] VMX: drop vmcs_revision_id Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1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bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> It's effectively redundant with vmx_basic_msr. For the #define replacement to work, struct vmcs_struct's respective field name also needs to change: Drop the not really meaningful "vmcs_" prefix from it. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -175,7 +175,7 @@ static DEFINE_PER_CPU(paddr_t, current_v static DEFINE_PER_CPU(struct list_head, active_vmcs_list); DEFINE_PER_CPU(bool, vmxon); -static u32 vmcs_revision_id __read_mostly; +#define vmcs_revision_id (vmx_basic_msr & VMX_BASIC_REVISION_MASK) u64 __read_mostly vmx_basic_msr; static void __init vmx_display_features(void) @@ -498,7 +498,6 @@ static int vmx_init_vmcs_config(bool bsp if ( !vmx_pin_based_exec_control ) { /* First time through. */ - vmcs_revision_id = vmx_basic_msr_low & VMX_BASIC_REVISION_MASK; vmx_pin_based_exec_control = _vmx_pin_based_exec_control; vmx_cpu_based_exec_control = _vmx_cpu_based_exec_control; vmx_secondary_exec_control = _vmx_secondary_exec_control; @@ -610,7 +609,7 @@ static paddr_t vmx_alloc_vmcs(void) vmcs = __map_domain_page(pg); clear_page(vmcs); - vmcs->vmcs_revision_id = vmcs_revision_id; + vmcs->revision_id = vmcs_revision_id; unmap_domain_page(vmcs); return page_to_maddr(pg); --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1166,7 +1166,7 @@ static void nvmx_set_vmcs_pointer(struct paddr_t vvmcs_maddr = v->arch.hvm.vmx.vmcs_shadow_maddr; __vmpclear(vvmcs_maddr); - vvmcs->vmcs_revision_id |= VMCS_RID_TYPE_MASK; + vvmcs->revision_id |= VMCS_RID_TYPE_MASK; v->arch.hvm.vmx.secondary_exec_control |= SECONDARY_EXEC_ENABLE_VMCS_SHADOWING; __vmwrite(SECONDARY_VM_EXEC_CONTROL, @@ -1181,7 +1181,7 @@ static void nvmx_clear_vmcs_pointer(stru paddr_t vvmcs_maddr = v->arch.hvm.vmx.vmcs_shadow_maddr; __vmpclear(vvmcs_maddr); - vvmcs->vmcs_revision_id &= ~VMCS_RID_TYPE_MASK; + vvmcs->revision_id &= ~VMCS_RID_TYPE_MASK; v->arch.hvm.vmx.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VMCS_SHADOWING; __vmwrite(SECONDARY_VM_EXEC_CONTROL, @@ -1799,10 +1799,10 @@ static int nvmx_handle_vmptrld(struct cp { struct vmcs_struct *vvmcs = vvmcx; - if ( ((vvmcs->vmcs_revision_id ^ vmx_basic_msr) & - VMX_BASIC_REVISION_MASK) || + if ( ((vvmcs->revision_id ^ vmx_basic_msr) & + VMX_BASIC_REVISION_MASK) || (!cpu_has_vmx_vmcs_shadowing && - (vvmcs->vmcs_revision_id & ~VMX_BASIC_REVISION_MASK)) ) + (vvmcs->revision_id & ~VMX_BASIC_REVISION_MASK)) ) { hvm_unmap_guest_frame(vvmcx, 1); vmfail(regs, VMX_INSN_VMPTRLD_INCORRECT_VMCS_ID); @@ -2214,7 +2214,7 @@ int nvmx_msr_read_intercept(unsigned int map_domain_page(_mfn(PFN_DOWN(v->arch.hvm.vmx.vmcs_pa))); data = (host_data & (~0ul << 32)) | - (vmcs->vmcs_revision_id & 0x7fffffff); + (vmcs->revision_id & 0x7fffffff); unmap_domain_page(vmcs); if ( !cpu_has_vmx_vmcs_shadowing ) --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -17,7 +17,7 @@ int cf_check vmx_cpu_up(void); void cf_check vmx_cpu_down(void); struct vmcs_struct { - u32 vmcs_revision_id; + uint32_t revision_id; unsigned char data [0]; /* vmcs size is read from MSR */ }; From patchwork Mon Feb 26 16:43:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BB40C48BF6 for ; Mon, 26 Feb 2024 16:43:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685644.1066690 (Exim 4.92) (envelope-from ) id 1ree4b-0008Em-7C; Mon, 26 Feb 2024 16:43:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685644.1066690; Mon, 26 Feb 2024 16:43:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree4b-0008Ef-49; Mon, 26 Feb 2024 16:43:25 +0000 Received: by outflank-mailman (input) for mailman id 685644; Mon, 26 Feb 2024 16:43:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree4Z-000739-Tg for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:43:23 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2723a141-d4c6-11ee-98f5-efadbce2ee36; Mon, 26 Feb 2024 17:43:22 +0100 (CET) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-55a179f5fa1so3890892a12.0 for ; Mon, 26 Feb 2024 08:43:22 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.43.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:43:21 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2723a141-d4c6-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965801; x=1709570601; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=LkkYKIciLpGXm67Xsu4H8V04SVbEw+0lUvEF+5IhLIk=; b=XXfDVeaXDw+1DjizdDZpyg46sz3YYfuN8o7Hvkuui0aj9Gm10sOgli6uE0v1FKCbvj Ry9EAne5Xu1V64WXrKaem62KKyVG83dIJvAIRS1kOXs5J2O62YwoncSvpm6nQ2MyBUbs TkPu4VG2sC5IqnhW22GYZz9Oo4TD4kQSFDhEWKXneiQ9rW8Bwy5QH7xTin5HRymkqKmj 2FlpFYAo5k2MQtdubxQq8WA7Sk3OrYf6XrWBWM1Y6oGyE5TBhjvl6w8OFqG+PKCwFxif OzsPQgo/5EuYuAzCFoynsIxYTOf0ffB1AOHVS2Op+O2kMvSyjofVtNlYq37KCkmcTVDy OPjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965801; x=1709570601; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LkkYKIciLpGXm67Xsu4H8V04SVbEw+0lUvEF+5IhLIk=; b=E1QzGJt8vrJBRS8N7BPkKPom+sgndLRGyNium8Fh+Bdjy2XpJJ2vuvOgx/piPLSCZN Vg8eQ7mhRo1jzcfzHG0roQEFqSaBAvaWqKmSURu2NRO9pdg0ELFOUhUHJn4gmvGQ7miF EzgwRm/8I7bigBeeEbTWzBbOXlir603sFbINyzjYO/7l5enBsTAS4E2yorvG5m4qpUEe PWMYdMZotcMGQzgt3kBFwxP2wwAE8kdXKZGgTTORfiXm2bc/tYhO3rgq2EbMUqp11czU TfEwNShRGFknSrHIlABgivIehIA24ntYv2/w4RrvxwtV+Plaz5QnGflwxB2nFQnF1Qmj R73w== X-Gm-Message-State: AOJu0Yz7pKaCklTI/oKDIYb9UwFNcSvqdmdAovQ8tWQP2pX7Fl7oS8/Z XerRsnh07eHgYhvde8SrzLjrxJtPEFU5Iprajz0i0yOF/A2LNSiKnsx5J1XQEqsAQbJvZoqar54 = X-Google-Smtp-Source: AGHT+IE66fn6sd7RGWxgxOc52YFINHv/3XxkEA1CzC+GF36RQh6W0nd1PBlnpyG6b+0X8mqAOeueZw== X-Received: by 2002:aa7:d912:0:b0:564:a62e:dad with SMTP id a18-20020aa7d912000000b00564a62e0dadmr5156319edr.34.1708965801706; Mon, 26 Feb 2024 08:43:21 -0800 (PST) Message-ID: Date: Mon, 26 Feb 2024 17:43:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 04/12] VMX: convert vmx_basic_msr Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiw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tlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> ... to a struct field, which is then going to be accompanied by other capability/control data presently living in individual variables. As this structure isn't supposed to be altered post-boot, put it in .data.ro_after_init right away. Suggested-by: Roger Pau Monné Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -161,6 +161,7 @@ static int cf_check parse_ept_param_runt #endif /* Dynamic (run-time adjusted) execution control flags. */ +struct vmx_caps __ro_after_init vmx_caps; u32 vmx_pin_based_exec_control __read_mostly; u32 vmx_cpu_based_exec_control __read_mostly; u32 vmx_secondary_exec_control __read_mostly; @@ -175,8 +176,7 @@ static DEFINE_PER_CPU(paddr_t, current_v static DEFINE_PER_CPU(struct list_head, active_vmcs_list); DEFINE_PER_CPU(bool, vmxon); -#define vmcs_revision_id (vmx_basic_msr & VMX_BASIC_REVISION_MASK) -u64 __read_mostly vmx_basic_msr; +#define vmcs_revision_id (vmx_caps.basic_msr & VMX_BASIC_REVISION_MASK) static void __init vmx_display_features(void) { @@ -505,8 +505,8 @@ static int vmx_init_vmcs_config(bool bsp vmx_ept_vpid_cap = _vmx_ept_vpid_cap; vmx_vmexit_control = _vmx_vmexit_control; vmx_vmentry_control = _vmx_vmentry_control; - vmx_basic_msr = ((u64)vmx_basic_msr_high << 32) | - vmx_basic_msr_low; + vmx_caps.basic_msr = ((uint64_t)vmx_basic_msr_high << 32) | + vmx_basic_msr_low; vmx_vmfunc = _vmx_vmfunc; vmx_display_features(); @@ -560,7 +560,7 @@ static int vmx_init_vmcs_config(bool bsp mismatch = 1; } if ( (vmx_basic_msr_high & (VMX_BASIC_VMCS_SIZE_MASK >> 32)) != - ((vmx_basic_msr & VMX_BASIC_VMCS_SIZE_MASK) >> 32) ) + ((vmx_caps.basic_msr & VMX_BASIC_VMCS_SIZE_MASK) >> 32) ) { printk("VMX: CPU%d unexpected VMCS size %Lu\n", smp_processor_id(), @@ -2214,7 +2214,7 @@ int __init vmx_vmcs_init(void) * _vmx_vcpu_up() may have made it past feature identification. * Make sure all dependent features are off as well. */ - vmx_basic_msr = 0; + memset(&vmx_caps, 0, sizeof(vmx_caps)); vmx_pin_based_exec_control = 0; vmx_cpu_based_exec_control = 0; vmx_secondary_exec_control = 0; --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -294,6 +294,12 @@ extern u64 vmx_ept_vpid_cap; #define VMX_TSC_MULTIPLIER_MAX 0xffffffffffffffffULL +/* Capabilities and dynamic (run-time adjusted) execution control flags. */ +struct vmx_caps { + uint64_t basic_msr; +}; +extern struct vmx_caps vmx_caps; + #define cpu_has_wbinvd_exiting \ (vmx_secondary_exec_control & SECONDARY_EXEC_WBINVD_EXITING) #define cpu_has_vmx_virtualize_apic_accesses \ @@ -379,9 +385,8 @@ extern u64 vmx_ept_vpid_cap; */ #define VMX_BASIC_DEFAULT1_ZERO (1ULL << 55) -extern u64 vmx_basic_msr; #define cpu_has_vmx_ins_outs_instr_info \ - (!!(vmx_basic_msr & VMX_BASIC_INS_OUT_INFO)) + (!!(vmx_caps.basic_msr & VMX_BASIC_INS_OUT_INFO)) /* Guest interrupt status */ #define VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK 0x0FF --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1561,7 +1561,7 @@ static int nvmx_handle_vmxon(struct cpu_ rc = hvm_copy_from_guest_phys(&nvmcs_revid, gpa, sizeof(nvmcs_revid)); if ( rc != HVMTRANS_okay || (nvmcs_revid & ~VMX_BASIC_REVISION_MASK) || - ((nvmcs_revid ^ vmx_basic_msr) & VMX_BASIC_REVISION_MASK) ) + ((nvmcs_revid ^ vmx_caps.basic_msr) & VMX_BASIC_REVISION_MASK) ) { vmfail_invalid(regs); return X86EMUL_OKAY; @@ -1799,7 +1799,7 @@ static int nvmx_handle_vmptrld(struct cp { struct vmcs_struct *vvmcs = vvmcx; - if ( ((vvmcs->revision_id ^ vmx_basic_msr) & + if ( ((vvmcs->revision_id ^ vmx_caps.basic_msr) & VMX_BASIC_REVISION_MASK) || (!cpu_has_vmx_vmcs_shadowing && (vvmcs->revision_id & ~VMX_BASIC_REVISION_MASK)) ) @@ -2192,7 +2192,7 @@ int nvmx_msr_read_intercept(unsigned int case MSR_IA32_VMX_TRUE_PROCBASED_CTLS: case MSR_IA32_VMX_TRUE_EXIT_CTLS: case MSR_IA32_VMX_TRUE_ENTRY_CTLS: - if ( !(vmx_basic_msr & VMX_BASIC_DEFAULT1_ZERO) ) + if ( !(vmx_caps.basic_msr & VMX_BASIC_DEFAULT1_ZERO) ) return 0; break; From patchwork Mon Feb 26 16:43:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFA72C54E4A for ; Mon, 26 Feb 2024 16:43:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685646.1066699 (Exim 4.92) (envelope-from ) id 1ree4t-0000F2-EW; Mon, 26 Feb 2024 16:43:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685646.1066699; Mon, 26 Feb 2024 16:43:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree4t-0000Ev-Bf; Mon, 26 Feb 2024 16:43:43 +0000 Received: by outflank-mailman (input) for mailman id 685646; Mon, 26 Feb 2024 16:43:42 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree4s-0000BK-Fu for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:43:42 +0000 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [2a00:1450:4864:20::131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 32db792f-d4c6-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:43:41 +0100 (CET) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-512b13bf764so4022409e87.0 for ; Mon, 26 Feb 2024 08:43:41 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.43.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:43:41 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 32db792f-d4c6-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965821; x=1709570621; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=9n+bbgXBOrLiMHM6zz3tWMkdYfLaMnbCqmKV8XjOqSc=; b=LAHOrbhOX03bGkAeSyUIQCZqlxKaBHl+A0Lw8oZHYf/X82uwcPHnwUQWGqhW616bdI zjKpb3lGm+C1aaUyzNdjfTq0x7u+1ZF7yUQrRTsYgSNpagjoxOepww32ci7J6vUVaZ6T cfQi8ZJ7/0ye0rTSoyqVKR3MPEDKFLITh0hVZObNVPaGAna3l9hsMBeHSIJdgzqBisGV QdCZS05/CVz/DuwGlQzF5kS/dI89ttt7Wf4lTHpx7eO3O/cfLKNXWlta6ZW4jxAouVH6 S6Ad9KHfuX2I99OZjju60X4Qkikia7jtHhY6fGbYGiItAQxNBtTmpBydlFJlx8R5b4Ss GZ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965821; x=1709570621; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9n+bbgXBOrLiMHM6zz3tWMkdYfLaMnbCqmKV8XjOqSc=; b=DIT5+O1PT3JblcDsg79dCEGLb/Nw+mLJfHRouGfMjf+LmdeGYKxG5O/2Jn6p05kSss ppkewOxJurlwYVqu825+05Evx9J03Hm/+TNViRH5cOF3aIIWlx5CFzamQM0F+d0C8rac NSeaCBy4WdjxlZVGjiu/UVNz8VJexHnDo51M5Q1iiHDw3e/LKaOEzaxHTFXDR1YiOOmK qHqlYIrpqO8YGnC7hOEU9J3tpICg3HBqs27BAn3NsDgIyduI+rcmLDKHQ8ciTkXIwb+h JjyTEV6m3E44uzjBmhZf2FnUNSQ5Ws/jo9jJtpZyWGOR/5FYUJLdGB03O/FwbrERVR+E eRtw== X-Gm-Message-State: AOJu0YyU2k6hXNlTyJBiWFwUD3IsarHtLYPuC5b1NmkC1qb3oiFXNoAa f0CJeK4bEb+2IEKtNYi4h1UO43E1ROJRSqtwN1tirW+ZfAA328B2vznJHNt22zU5WfuRyIbjZuU = X-Google-Smtp-Source: AGHT+IGNNeXW8Ss1pszPMFziokqO8jfdNI1FqfvC4Bl8vdK9qMAgCYc7W6+h/6lo68CWeWhxqVdjZw== X-Received: by 2002:ac2:47fa:0:b0:512:cbf4:8f93 with SMTP id b26-20020ac247fa000000b00512cbf48f93mr4744980lfp.19.1708965821334; Mon, 26 Feb 2024 08:43:41 -0800 (PST) Message-ID: <57a00d7b-1df1-4b74-b990-8b1e88784589@suse.com> Date: Mon, 26 Feb 2024 17:43:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 05/12] VMX: convert vmx_pin_based_exec_control Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9H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M51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> ... to a field in the capability/controls struct. Use an instance of that struct also in vmx_init_vmcs_config(). Signed-off-by: Jan Beulich --- v3: Add initializer to vmx_init_vmcs_config() new local var. v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -162,7 +162,6 @@ static int cf_check parse_ept_param_runt /* Dynamic (run-time adjusted) execution control flags. */ struct vmx_caps __ro_after_init vmx_caps; -u32 vmx_pin_based_exec_control __read_mostly; u32 vmx_cpu_based_exec_control __read_mostly; u32 vmx_secondary_exec_control __read_mostly; uint64_t vmx_tertiary_exec_control __read_mostly; @@ -261,7 +260,7 @@ static bool cap_check( static int vmx_init_vmcs_config(bool bsp) { u32 vmx_basic_msr_low, vmx_basic_msr_high, min, opt; - u32 _vmx_pin_based_exec_control; + struct vmx_caps caps = {}; u32 _vmx_cpu_based_exec_control; u32 _vmx_secondary_exec_control = 0; uint64_t _vmx_tertiary_exec_control = 0; @@ -278,7 +277,7 @@ static int vmx_init_vmcs_config(bool bsp PIN_BASED_NMI_EXITING); opt = (PIN_BASED_VIRTUAL_NMIS | PIN_BASED_POSTED_INTERRUPT); - _vmx_pin_based_exec_control = adjust_vmx_controls( + caps.pin_based_exec_control = adjust_vmx_controls( "Pin-Based Exec Control", min, opt, MSR_IA32_VMX_PINBASED_CTLS, &mismatch); @@ -440,7 +439,7 @@ static int vmx_init_vmcs_config(bool bsp if ( (_vmx_secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) && ple_gap == 0 ) { - if ( !vmx_pin_based_exec_control ) + if ( !vmx_caps.pin_based_exec_control ) printk(XENLOG_INFO "Disable Pause-Loop Exiting.\n"); _vmx_secondary_exec_control &= ~ SECONDARY_EXEC_PAUSE_LOOP_EXITING; } @@ -458,10 +457,10 @@ static int vmx_init_vmcs_config(bool bsp * is a minimal requirement, only check the former, which is optional. */ if ( !(_vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) ) - _vmx_pin_based_exec_control &= ~PIN_BASED_POSTED_INTERRUPT; + caps.pin_based_exec_control &= ~PIN_BASED_POSTED_INTERRUPT; if ( iommu_intpost && - !(_vmx_pin_based_exec_control & PIN_BASED_POSTED_INTERRUPT) ) + !(caps.pin_based_exec_control & PIN_BASED_POSTED_INTERRUPT) ) { printk("Intel VT-d Posted Interrupt is disabled for CPU-side Posted " "Interrupt is not enabled\n"); @@ -495,10 +494,10 @@ static int vmx_init_vmcs_config(bool bsp if ( mismatch ) return -EINVAL; - if ( !vmx_pin_based_exec_control ) + if ( !vmx_caps.pin_based_exec_control ) { /* First time through. */ - vmx_pin_based_exec_control = _vmx_pin_based_exec_control; + vmx_caps = caps; vmx_cpu_based_exec_control = _vmx_cpu_based_exec_control; vmx_secondary_exec_control = _vmx_secondary_exec_control; vmx_tertiary_exec_control = _vmx_tertiary_exec_control; @@ -529,7 +528,7 @@ static int vmx_init_vmcs_config(bool bsp vmcs_revision_id, vmx_basic_msr_low & VMX_BASIC_REVISION_MASK); mismatch |= cap_check( "Pin-Based Exec Control", - vmx_pin_based_exec_control, _vmx_pin_based_exec_control); + vmx_caps.pin_based_exec_control, caps.pin_based_exec_control); mismatch |= cap_check( "CPU-Based Exec Control", vmx_cpu_based_exec_control, _vmx_cpu_based_exec_control); @@ -1110,7 +1109,7 @@ static int construct_vmcs(struct vcpu *v vmx_vmcs_enter(v); /* VMCS controls. */ - __vmwrite(PIN_BASED_VM_EXEC_CONTROL, vmx_pin_based_exec_control); + __vmwrite(PIN_BASED_VM_EXEC_CONTROL, vmx_caps.pin_based_exec_control); v->arch.hvm.vmx.exec_control = vmx_cpu_based_exec_control; if ( d->arch.vtsc && !cpu_has_vmx_tsc_scaling ) @@ -2136,7 +2135,7 @@ void vmcs_dump_vcpu(struct vcpu *v) printk("TSC Offset = 0x%016lx TSC Multiplier = 0x%016lx\n", vmr(TSC_OFFSET), vmr(TSC_MULTIPLIER)); if ( (v->arch.hvm.vmx.exec_control & CPU_BASED_TPR_SHADOW) || - (vmx_pin_based_exec_control & PIN_BASED_POSTED_INTERRUPT) ) + (vmx_caps.pin_based_exec_control & PIN_BASED_POSTED_INTERRUPT) ) printk("TPR Threshold = 0x%02x PostedIntrVec = 0x%02x\n", vmr32(TPR_THRESHOLD), vmr16(POSTED_INTR_NOTIFICATION_VECTOR)); if ( (v->arch.hvm.vmx.secondary_exec_control & @@ -2215,7 +2214,6 @@ int __init vmx_vmcs_init(void) * Make sure all dependent features are off as well. */ memset(&vmx_caps, 0, sizeof(vmx_caps)); - vmx_pin_based_exec_control = 0; vmx_cpu_based_exec_control = 0; vmx_secondary_exec_control = 0; vmx_tertiary_exec_control = 0; --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1057,7 +1057,7 @@ static void load_shadow_control(struct v * and EXCEPTION * Enforce the removed features */ - nvmx_update_pin_control(v, vmx_pin_based_exec_control); + nvmx_update_pin_control(v, vmx_caps.pin_based_exec_control); vmx_update_cpu_exec_control(v); vmx_update_secondary_exec_control(v); nvmx_update_exit_control(v, vmx_vmexit_control); --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -217,7 +217,6 @@ extern u32 vmx_cpu_based_exec_control; #define PIN_BASED_VIRTUAL_NMIS 0x00000020 #define PIN_BASED_PREEMPT_TIMER 0x00000040 #define PIN_BASED_POSTED_INTERRUPT 0x00000080 -extern u32 vmx_pin_based_exec_control; #define VM_EXIT_SAVE_DEBUG_CNTRLS 0x00000004 #define VM_EXIT_IA32E_MODE 0x00000200 @@ -297,6 +296,7 @@ extern u64 vmx_ept_vpid_cap; /* Capabilities and dynamic (run-time adjusted) execution control flags. */ struct vmx_caps { uint64_t basic_msr; + uint32_t pin_based_exec_control; }; extern struct vmx_caps vmx_caps; @@ -307,7 +307,7 @@ extern struct vmx_caps vmx_caps; #define cpu_has_vmx_tpr_shadow \ (vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW) #define cpu_has_vmx_vnmi \ - (vmx_pin_based_exec_control & PIN_BASED_VIRTUAL_NMIS) + (vmx_caps.pin_based_exec_control & PIN_BASED_VIRTUAL_NMIS) #define cpu_has_vmx_msr_bitmap \ (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_MSR_BITMAP) #define cpu_has_vmx_secondary_exec_control \ @@ -344,7 +344,7 @@ extern struct vmx_caps vmx_caps; #define cpu_has_vmx_virtualize_x2apic_mode \ (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE) #define cpu_has_vmx_posted_intr_processing \ - (vmx_pin_based_exec_control & PIN_BASED_POSTED_INTERRUPT) + (vmx_caps.pin_based_exec_control & PIN_BASED_POSTED_INTERRUPT) #define cpu_has_vmx_vmcs_shadowing \ (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VMCS_SHADOWING) #define cpu_has_vmx_vmfunc \ From patchwork Mon Feb 26 16:43:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8655C5478C for ; Mon, 26 Feb 2024 16:44:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685648.1066710 (Exim 4.92) (envelope-from ) id 1ree5B-0000pO-Sy; Mon, 26 Feb 2024 16:44:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685648.1066710; Mon, 26 Feb 2024 16:44:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree5B-0000pH-Pa; Mon, 26 Feb 2024 16:44:01 +0000 Received: by outflank-mailman (input) for mailman id 685648; Mon, 26 Feb 2024 16:43:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree59-0000BK-Ro for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:43:59 +0000 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [2a00:1450:4864:20::230]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3d3b3ca4-d4c6-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:43:59 +0100 (CET) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2d09cf00214so51658461fa.0 for ; Mon, 26 Feb 2024 08:43:59 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.43.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:43:58 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3d3b3ca4-d4c6-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965838; x=1709570638; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=I+hozS1nSCFWHKTN5uvAFxwcd3lo+nQd/gYn/2VyyrI=; b=QvpsZJUucOiHyY4YAqgv1YaVsvSIqt2sQbs0k5EWR8e6T/B/zSFij39iRRtNt0oUv8 ENigmxjW3d6vM6cE4uLOhpPr8tV0ut4kdul4k7wHHIzDtqo7Frno6UOsBCokf1tGH9/j QWBEvlSqi+YTNC8b/oIIgmlNr8WLrOQLl1IBXYXyxt0UwoqtWShqCLS2TenxALylgYaD Ny+6UusEnvl/3t5BtkWcpIbq/slZvNXVBAXEfhuztAZxaoOakFY9MFyBbuW7IWlqLEPG Wu0yB/jL9KE5CfjH/Gsw/dTOTnhg7RIDrdc3XnLsN6uDwmWATR4VxZj/5aeIjlU90Iay IQVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965838; x=1709570638; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I+hozS1nSCFWHKTN5uvAFxwcd3lo+nQd/gYn/2VyyrI=; b=vG0FZTcKd8ISrB4va7io+aVP5eWJOT+GCQXeiSn5e7eLBbRYlcSLk7zwwwrTgmTB+s QtRmbwcNGJgS6RNrjKJUyY3PIiXHz3NqXsVyjQd9eJ4ODxSyajkRrhR9/ZbfC+GNVltW IEKzALt9dFoYYuoBwIdCZUvumVzDoLSe5PM/7TEUCIsfBu0fVhY1nx9BhvaAzFWlZShV /RK8t+Yfc2hqa12dEWUCLznAR1krU4jJ7+7g0Es6vfQVhU7kknHRWiKP50BScFNwlWkG 2uDowlKVnhXQnEvx/hYk+c5qBoMw5yEAhtRbiJPYLbU0+Bjnm3hxgEHDL/fa6AJ0fgkx kFlA== X-Gm-Message-State: AOJu0Yxd8sCGCZf6jHA1AZK+oSx24SxyOhdLQBUIxKXxlD1ljiUQuB4N GEt9VVqI+2zozihV/daRKtpOy9Vz4mwxG1pG+HUJzYn+wEIygI3zld8AoSGCWjexJ0Cvbq7NM0Y = X-Google-Smtp-Source: AGHT+IGW/ceIqxVXPr0RzY6ctXnRWKp3aDNdb1/mUUv8JqciivLWvhcaIi3a9r4IsAjstRF9WGeotQ== X-Received: by 2002:ac2:55a3:0:b0:513:31c:e54e with SMTP id y3-20020ac255a3000000b00513031ce54emr52954lfg.30.1708965838745; Mon, 26 Feb 2024 08:43:58 -0800 (PST) Message-ID: <36dd8c5a-7b50-404e-ac96-3407c9d574c4@suse.com> Date: Mon, 26 Feb 2024 17:43:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 06/12] VMX: convert vmx_cpu_based_exec_control Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAU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ui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> ... to a field in the capability/controls struct. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -162,7 +162,6 @@ static int cf_check parse_ept_param_runt /* Dynamic (run-time adjusted) execution control flags. */ struct vmx_caps __ro_after_init vmx_caps; -u32 vmx_cpu_based_exec_control __read_mostly; u32 vmx_secondary_exec_control __read_mostly; uint64_t vmx_tertiary_exec_control __read_mostly; u32 vmx_vmexit_control __read_mostly; @@ -261,7 +260,6 @@ static int vmx_init_vmcs_config(bool bsp { u32 vmx_basic_msr_low, vmx_basic_msr_high, min, opt; struct vmx_caps caps = {}; - u32 _vmx_cpu_based_exec_control; u32 _vmx_secondary_exec_control = 0; uint64_t _vmx_tertiary_exec_control = 0; u64 _vmx_ept_vpid_cap = 0; @@ -299,12 +297,12 @@ static int vmx_init_vmcs_config(bool bsp CPU_BASED_MONITOR_TRAP_FLAG | CPU_BASED_ACTIVATE_SECONDARY_CONTROLS | CPU_BASED_ACTIVATE_TERTIARY_CONTROLS); - _vmx_cpu_based_exec_control = adjust_vmx_controls( + caps.cpu_based_exec_control = adjust_vmx_controls( "CPU-Based Exec Control", min, opt, MSR_IA32_VMX_PROCBASED_CTLS, &mismatch); - _vmx_cpu_based_exec_control &= ~CPU_BASED_RDTSC_EXITING; - if ( _vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW ) - _vmx_cpu_based_exec_control &= + caps.cpu_based_exec_control &= ~CPU_BASED_RDTSC_EXITING; + if ( caps.cpu_based_exec_control & CPU_BASED_TPR_SHADOW ) + caps.cpu_based_exec_control &= ~(CPU_BASED_CR8_LOAD_EXITING | CPU_BASED_CR8_STORE_EXITING); rdmsrl(MSR_IA32_VMX_MISC, _vmx_misc_cap); @@ -321,7 +319,7 @@ static int vmx_init_vmcs_config(bool bsp return -EINVAL; } - if ( _vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS ) + if ( caps.cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS ) { min = 0; opt = (SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | @@ -351,7 +349,7 @@ static int vmx_init_vmcs_config(bool bsp * "APIC Register Virtualization" and "Virtual Interrupt Delivery" * can be set only when "use TPR shadow" is set */ - if ( (_vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW) && + if ( (caps.cpu_based_exec_control & CPU_BASED_TPR_SHADOW) && opt_apicv_enabled ) opt |= SECONDARY_EXEC_APIC_REGISTER_VIRT | SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | @@ -362,7 +360,7 @@ static int vmx_init_vmcs_config(bool bsp MSR_IA32_VMX_PROCBASED_CTLS2, &mismatch); } - if ( _vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS ) + if ( caps.cpu_based_exec_control & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS ) { uint64_t opt = 0; @@ -498,7 +496,6 @@ static int vmx_init_vmcs_config(bool bsp { /* First time through. */ vmx_caps = caps; - vmx_cpu_based_exec_control = _vmx_cpu_based_exec_control; vmx_secondary_exec_control = _vmx_secondary_exec_control; vmx_tertiary_exec_control = _vmx_tertiary_exec_control; vmx_ept_vpid_cap = _vmx_ept_vpid_cap; @@ -531,7 +528,7 @@ static int vmx_init_vmcs_config(bool bsp vmx_caps.pin_based_exec_control, caps.pin_based_exec_control); mismatch |= cap_check( "CPU-Based Exec Control", - vmx_cpu_based_exec_control, _vmx_cpu_based_exec_control); + vmx_caps.cpu_based_exec_control, caps.cpu_based_exec_control); mismatch |= cap_check( "Secondary Exec Control", vmx_secondary_exec_control, _vmx_secondary_exec_control); @@ -1111,7 +1108,7 @@ static int construct_vmcs(struct vcpu *v /* VMCS controls. */ __vmwrite(PIN_BASED_VM_EXEC_CONTROL, vmx_caps.pin_based_exec_control); - v->arch.hvm.vmx.exec_control = vmx_cpu_based_exec_control; + v->arch.hvm.vmx.exec_control = vmx_caps.cpu_based_exec_control; if ( d->arch.vtsc && !cpu_has_vmx_tsc_scaling ) v->arch.hvm.vmx.exec_control |= CPU_BASED_RDTSC_EXITING; @@ -2214,7 +2211,6 @@ int __init vmx_vmcs_init(void) * Make sure all dependent features are off as well. */ memset(&vmx_caps, 0, sizeof(vmx_caps)); - vmx_cpu_based_exec_control = 0; vmx_secondary_exec_control = 0; vmx_tertiary_exec_control = 0; vmx_vmexit_control = 0; --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -210,7 +210,6 @@ void vmx_vmcs_reload(struct vcpu *v); #define CPU_BASED_MONITOR_EXITING 0x20000000U #define CPU_BASED_PAUSE_EXITING 0x40000000U #define CPU_BASED_ACTIVATE_SECONDARY_CONTROLS 0x80000000U -extern u32 vmx_cpu_based_exec_control; #define PIN_BASED_EXT_INTR_MASK 0x00000001 #define PIN_BASED_NMI_EXITING 0x00000008 @@ -297,6 +296,7 @@ extern u64 vmx_ept_vpid_cap; struct vmx_caps { uint64_t basic_msr; uint32_t pin_based_exec_control; + uint32_t cpu_based_exec_control; }; extern struct vmx_caps vmx_caps; @@ -305,15 +305,15 @@ extern struct vmx_caps vmx_caps; #define cpu_has_vmx_virtualize_apic_accesses \ (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) #define cpu_has_vmx_tpr_shadow \ - (vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW) + (vmx_caps.cpu_based_exec_control & CPU_BASED_TPR_SHADOW) #define cpu_has_vmx_vnmi \ (vmx_caps.pin_based_exec_control & PIN_BASED_VIRTUAL_NMIS) #define cpu_has_vmx_msr_bitmap \ - (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_MSR_BITMAP) + (vmx_caps.cpu_based_exec_control & CPU_BASED_ACTIVATE_MSR_BITMAP) #define cpu_has_vmx_secondary_exec_control \ - (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) + (vmx_caps.cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) #define cpu_has_vmx_tertiary_exec_control \ - (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS) + (vmx_caps.cpu_based_exec_control & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS) #define cpu_has_vmx_ept \ (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) #define cpu_has_vmx_dt_exiting \ @@ -323,7 +323,7 @@ extern struct vmx_caps vmx_caps; #define cpu_has_vmx_vpid \ (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID) #define cpu_has_monitor_trap_flag \ - (vmx_cpu_based_exec_control & CPU_BASED_MONITOR_TRAP_FLAG) + (vmx_caps.cpu_based_exec_control & CPU_BASED_MONITOR_TRAP_FLAG) #define cpu_has_vmx_pat \ (vmx_vmentry_control & VM_ENTRY_LOAD_GUEST_PAT) #define cpu_has_vmx_efer \ From patchwork Mon Feb 26 16:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD94EC5478C for ; Mon, 26 Feb 2024 16:44:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685651.1066719 (Exim 4.92) (envelope-from ) id 1ree5X-0001MJ-3o; Mon, 26 Feb 2024 16:44:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685651.1066719; Mon, 26 Feb 2024 16:44:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree5X-0001MC-11; Mon, 26 Feb 2024 16:44:23 +0000 Received: by outflank-mailman (input) for mailman id 685651; Mon, 26 Feb 2024 16:44:21 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree5V-0000BK-Fg for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:44:21 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4a19299a-d4c6-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:44:20 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-55a179f5fa1so3892560a12.0 for ; Mon, 26 Feb 2024 08:44:20 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.44.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:44:20 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4a19299a-d4c6-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965860; x=1709570660; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=SpUvRoudA/jtd2T5mUZMGFquMIbLtsovgL/QnQtxnRs=; b=apbkVH/4M0IOdvpR4ZB5WFHTCLWfO3zS5SVDHDfb52A7eFMlqb2EHUsc6z/gQLysbJ QJMos7nBWZLSgLHzyAQ6onKsD8hziFRNTdr2eJ12ATSnx4S4Pay8mrXActvxTqkMy62g zfyxgfQPgTvbUg4vd23P2dGFTqITLPSIY77f10DBUrxSqoZr2sg6KFxhhdTuqs9HjfSK z/GkXu2mKj9OHvQmiDs3DpIBGUN+2MkK9GcJaXTOmwHimlT1lDZ1RJb35SeRuRyhRwl2 FZ69DhYN4xCTISW/DdXY5QvauRpk6Ef4zeozkCBpoLSULCj52LhXihqh4BD9O9n1mQEe xTRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965860; x=1709570660; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SpUvRoudA/jtd2T5mUZMGFquMIbLtsovgL/QnQtxnRs=; b=pXQBZ/mfvvE0By3+lZZ3ofhnHWNIvQDZBbNJ3iO3OCbzbQsrCzTG9kmtF2zd3rm/qQ 4vWHUUbQuPRmqEfrOTH7ubbcxWbYdwyaGQn5hRXp3lmoG7FYfi+BHKb5WTwyjOd1+q4m /o1mVEnHnmoGxZ8ujtdir7fEb7YKf2roMV+mteV5dr3dkbGTGNThPtNrB+ADshN1AxCu i1FJei8lDk1ixyOrriaHzt452/mYqCyphPJcRlWcxMsXjIOaXEqPpkKIj2nlZNON8qu8 1ONuv44TkNm48l0D4Fg0gTn2/vs/pMwRh3MI7vOQg5y3aLFkSwL+FN7MPKfTYH3i0Bx+ zOog== X-Gm-Message-State: AOJu0YyVakGcBU2YCefazkfPB/9MxSAepGOgq/5ftnjHKnaTbEP9Qtfu Mk7IpF+JcMCKXtXmJKb6je4CV6izxsXF6x6C5CWstyoAYMdW7rHla0VZ3ccKWU6zze4sAEBUODc = X-Google-Smtp-Source: AGHT+IFT3FjGjnzj4OyiinDq6o0Iumj4WCl3H/OgMJ/gI0s9UyiW57ulZMbRpyF6Wtl+t2U1vETXnQ== X-Received: by 2002:a05:6402:1c82:b0:565:9892:a74e with SMTP id cy2-20020a0564021c8200b005659892a74emr4105428edb.21.1708965860318; Mon, 26 Feb 2024 08:44:20 -0800 (PST) Message-ID: <6fecfa2d-3af7-4241-b7ab-1b89817cdf0d@suse.com> Date: Mon, 26 Feb 2024 17:44:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 07/12] VMX: convert vmx_secondary_exec_control Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6Te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aef-8843-461c-bc96-709a605b2680@suse.com> ... to a field in the capability/controls struct. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -162,7 +162,6 @@ static int cf_check parse_ept_param_runt /* Dynamic (run-time adjusted) execution control flags. */ struct vmx_caps __ro_after_init vmx_caps; -u32 vmx_secondary_exec_control __read_mostly; uint64_t vmx_tertiary_exec_control __read_mostly; u32 vmx_vmexit_control __read_mostly; u32 vmx_vmentry_control __read_mostly; @@ -260,7 +259,6 @@ static int vmx_init_vmcs_config(bool bsp { u32 vmx_basic_msr_low, vmx_basic_msr_high, min, opt; struct vmx_caps caps = {}; - u32 _vmx_secondary_exec_control = 0; uint64_t _vmx_tertiary_exec_control = 0; u64 _vmx_ept_vpid_cap = 0; u64 _vmx_misc_cap = 0; @@ -355,7 +353,7 @@ static int vmx_init_vmcs_config(bool bsp SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE; - _vmx_secondary_exec_control = adjust_vmx_controls( + caps.secondary_exec_control = adjust_vmx_controls( "Secondary Exec Control", min, opt, MSR_IA32_VMX_PROCBASED_CTLS2, &mismatch); } @@ -370,7 +368,7 @@ static int vmx_init_vmcs_config(bool bsp } /* The IA32_VMX_EPT_VPID_CAP MSR exists only when EPT or VPID available */ - if ( _vmx_secondary_exec_control & (SECONDARY_EXEC_ENABLE_EPT | + if ( caps.secondary_exec_control & (SECONDARY_EXEC_ENABLE_EPT | SECONDARY_EXEC_ENABLE_VPID) ) { rdmsrl(MSR_IA32_VMX_EPT_VPID_CAP, _vmx_ept_vpid_cap); @@ -392,7 +390,7 @@ static int vmx_init_vmcs_config(bool bsp if ( !(_vmx_ept_vpid_cap & VMX_EPT_MEMORY_TYPE_WB) || !(_vmx_ept_vpid_cap & VMX_EPT_WALK_LENGTH_4_SUPPORTED) || !(_vmx_ept_vpid_cap & VMX_EPT_INVEPT_ALL_CONTEXT) ) - _vmx_secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_EPT; + caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_EPT; /* * the CPU must support INVVPID all context invalidation, because we @@ -401,14 +399,14 @@ static int vmx_init_vmcs_config(bool bsp * Or we just don't use VPID. */ if ( !(_vmx_ept_vpid_cap & VMX_VPID_INVVPID_ALL_CONTEXT) ) - _vmx_secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VPID; + caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VPID; /* EPT A/D bits is required for PML */ if ( !(_vmx_ept_vpid_cap & VMX_EPT_AD_BIT) ) - _vmx_secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_PML; + caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_PML; } - if ( _vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT ) + if ( caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT ) { /* * To use EPT we expect to be able to clear certain intercepts. @@ -421,25 +419,25 @@ static int vmx_init_vmcs_config(bool bsp if ( must_be_one & (CPU_BASED_INVLPG_EXITING | CPU_BASED_CR3_LOAD_EXITING | CPU_BASED_CR3_STORE_EXITING) ) - _vmx_secondary_exec_control &= + caps.secondary_exec_control &= ~(SECONDARY_EXEC_ENABLE_EPT | SECONDARY_EXEC_UNRESTRICTED_GUEST); } /* PML cannot be supported if EPT is not used */ - if ( !(_vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) ) - _vmx_secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_PML; + if ( !(caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) ) + caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_PML; /* Turn off opt_ept_pml if PML feature is not present. */ - if ( !(_vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_PML) ) + if ( !(caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_PML) ) opt_ept_pml = false; - if ( (_vmx_secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) && + if ( (caps.secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) && ple_gap == 0 ) { if ( !vmx_caps.pin_based_exec_control ) printk(XENLOG_INFO "Disable Pause-Loop Exiting.\n"); - _vmx_secondary_exec_control &= ~ SECONDARY_EXEC_PAUSE_LOOP_EXITING; + caps.secondary_exec_control &= ~ SECONDARY_EXEC_PAUSE_LOOP_EXITING; } min = VM_EXIT_ACK_INTR_ON_EXIT; @@ -454,7 +452,7 @@ static int vmx_init_vmcs_config(bool bsp * delivery" and "acknowledge interrupt on exit" is set. For the latter * is a minimal requirement, only check the former, which is optional. */ - if ( !(_vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) ) + if ( !(caps.secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) ) caps.pin_based_exec_control &= ~PIN_BASED_POSTED_INTERRUPT; if ( iommu_intpost && @@ -466,7 +464,7 @@ static int vmx_init_vmcs_config(bool bsp } /* The IA32_VMX_VMFUNC MSR exists only when VMFUNC is available */ - if ( _vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VM_FUNCTIONS ) + if ( caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_VM_FUNCTIONS ) { rdmsrl(MSR_IA32_VMX_VMFUNC, _vmx_vmfunc); @@ -476,12 +474,12 @@ static int vmx_init_vmcs_config(bool bsp * Or we just don't use VMFUNC. */ if ( !(_vmx_vmfunc & VMX_VMFUNC_EPTP_SWITCHING) ) - _vmx_secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VM_FUNCTIONS; + caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VM_FUNCTIONS; } /* Virtualization exceptions are only enabled if VMFUNC is enabled */ - if ( !(_vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VM_FUNCTIONS) ) - _vmx_secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS; + if ( !(caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_VM_FUNCTIONS) ) + caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS; min = 0; opt = (VM_ENTRY_LOAD_GUEST_PAT | VM_ENTRY_LOAD_GUEST_EFER | @@ -496,7 +494,6 @@ static int vmx_init_vmcs_config(bool bsp { /* First time through. */ vmx_caps = caps; - vmx_secondary_exec_control = _vmx_secondary_exec_control; vmx_tertiary_exec_control = _vmx_tertiary_exec_control; vmx_ept_vpid_cap = _vmx_ept_vpid_cap; vmx_vmexit_control = _vmx_vmexit_control; @@ -531,7 +528,7 @@ static int vmx_init_vmcs_config(bool bsp vmx_caps.cpu_based_exec_control, caps.cpu_based_exec_control); mismatch |= cap_check( "Secondary Exec Control", - vmx_secondary_exec_control, _vmx_secondary_exec_control); + vmx_caps.secondary_exec_control, caps.secondary_exec_control); mismatch |= cap_check( "Tertiary Exec Control", vmx_tertiary_exec_control, _vmx_tertiary_exec_control); @@ -1112,7 +1109,7 @@ static int construct_vmcs(struct vcpu *v if ( d->arch.vtsc && !cpu_has_vmx_tsc_scaling ) v->arch.hvm.vmx.exec_control |= CPU_BASED_RDTSC_EXITING; - v->arch.hvm.vmx.secondary_exec_control = vmx_secondary_exec_control; + v->arch.hvm.vmx.secondary_exec_control = vmx_caps.secondary_exec_control; v->arch.hvm.vmx.tertiary_exec_control = vmx_tertiary_exec_control; /* @@ -2211,7 +2208,6 @@ int __init vmx_vmcs_init(void) * Make sure all dependent features are off as well. */ memset(&vmx_caps, 0, sizeof(vmx_caps)); - vmx_secondary_exec_control = 0; vmx_tertiary_exec_control = 0; vmx_vmexit_control = 0; vmx_vmentry_control = 0; --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -258,7 +258,6 @@ extern u32 vmx_vmentry_control; #define SECONDARY_EXEC_TSC_SCALING 0x02000000U #define SECONDARY_EXEC_BUS_LOCK_DETECTION 0x40000000U #define SECONDARY_EXEC_NOTIFY_VM_EXITING 0x80000000U -extern u32 vmx_secondary_exec_control; #define TERTIARY_EXEC_LOADIWKEY_EXITING BIT(0, UL) #define TERTIARY_EXEC_ENABLE_HLAT BIT(1, UL) @@ -297,13 +296,14 @@ struct vmx_caps { uint64_t basic_msr; uint32_t pin_based_exec_control; uint32_t cpu_based_exec_control; + uint32_t secondary_exec_control; }; extern struct vmx_caps vmx_caps; #define cpu_has_wbinvd_exiting \ - (vmx_secondary_exec_control & SECONDARY_EXEC_WBINVD_EXITING) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_WBINVD_EXITING) #define cpu_has_vmx_virtualize_apic_accesses \ - (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) #define cpu_has_vmx_tpr_shadow \ (vmx_caps.cpu_based_exec_control & CPU_BASED_TPR_SHADOW) #define cpu_has_vmx_vnmi \ @@ -315,13 +315,13 @@ extern struct vmx_caps vmx_caps; #define cpu_has_vmx_tertiary_exec_control \ (vmx_caps.cpu_based_exec_control & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS) #define cpu_has_vmx_ept \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) #define cpu_has_vmx_dt_exiting \ - (vmx_secondary_exec_control & SECONDARY_EXEC_DESCRIPTOR_TABLE_EXITING) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_DESCRIPTOR_TABLE_EXITING) #define cpu_has_vmx_rdtscp \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_RDTSCP) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_RDTSCP) #define cpu_has_vmx_vpid \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID) #define cpu_has_monitor_trap_flag \ (vmx_caps.cpu_based_exec_control & CPU_BASED_MONITOR_TRAP_FLAG) #define cpu_has_vmx_pat \ @@ -329,41 +329,41 @@ extern struct vmx_caps vmx_caps; #define cpu_has_vmx_efer \ (vmx_vmentry_control & VM_ENTRY_LOAD_GUEST_EFER) #define cpu_has_vmx_unrestricted_guest \ - (vmx_secondary_exec_control & SECONDARY_EXEC_UNRESTRICTED_GUEST) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_UNRESTRICTED_GUEST) #define vmx_unrestricted_guest(v) \ ((v)->arch.hvm.vmx.secondary_exec_control & \ SECONDARY_EXEC_UNRESTRICTED_GUEST) #define cpu_has_vmx_ple \ - (vmx_secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) #define cpu_has_vmx_invpcid \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_INVPCID) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_INVPCID) #define cpu_has_vmx_apic_reg_virt \ - (vmx_secondary_exec_control & SECONDARY_EXEC_APIC_REGISTER_VIRT) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_APIC_REGISTER_VIRT) #define cpu_has_vmx_virtual_intr_delivery \ - (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) #define cpu_has_vmx_virtualize_x2apic_mode \ - (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE) #define cpu_has_vmx_posted_intr_processing \ (vmx_caps.pin_based_exec_control & PIN_BASED_POSTED_INTERRUPT) #define cpu_has_vmx_vmcs_shadowing \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VMCS_SHADOWING) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_VMCS_SHADOWING) #define cpu_has_vmx_vmfunc \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VM_FUNCTIONS) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_VM_FUNCTIONS) #define cpu_has_vmx_virt_exceptions \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS) #define cpu_has_vmx_pml \ - (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_PML) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_PML) #define cpu_has_vmx_mpx \ ((vmx_vmexit_control & VM_EXIT_CLEAR_BNDCFGS) && \ (vmx_vmentry_control & VM_ENTRY_LOAD_BNDCFGS)) #define cpu_has_vmx_xsaves \ - (vmx_secondary_exec_control & SECONDARY_EXEC_XSAVES) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_XSAVES) #define cpu_has_vmx_tsc_scaling \ - (vmx_secondary_exec_control & SECONDARY_EXEC_TSC_SCALING) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_TSC_SCALING) #define cpu_has_vmx_bus_lock_detection \ - (vmx_secondary_exec_control & SECONDARY_EXEC_BUS_LOCK_DETECTION) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_BUS_LOCK_DETECTION) #define cpu_has_vmx_notify_vm_exiting \ - (vmx_secondary_exec_control & SECONDARY_EXEC_NOTIFY_VM_EXITING) + (vmx_caps.secondary_exec_control & SECONDARY_EXEC_NOTIFY_VM_EXITING) #define VMCS_RID_TYPE_MASK 0x80000000U From patchwork Mon Feb 26 16:44:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81274C5478C for ; Mon, 26 Feb 2024 16:44:51 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685654.1066731 (Exim 4.92) (envelope-from ) id 1ree5s-0001v0-HP; Mon, 26 Feb 2024 16:44:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685654.1066731; Mon, 26 Feb 2024 16:44:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree5s-0001ut-Cm; Mon, 26 Feb 2024 16:44:44 +0000 Received: by outflank-mailman (input) for mailman id 685654; Mon, 26 Feb 2024 16:44:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree5r-0000BK-Qh for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:44:43 +0000 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [2a00:1450:4864:20::12c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 57887c6a-d4c6-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:44:43 +0100 (CET) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-512ed314881so3157563e87.2 for ; Mon, 26 Feb 2024 08:44:43 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.44.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:44:42 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 57887c6a-d4c6-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965883; x=1709570683; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=DpCtM4zMbfCyBbShI+77WKapeO/xVJwq7zqsqI2VmFg=; b=fm8GVAolL6nMFJaAUUU2MWPYmWxqQEPe6O0WQcAVCcQYu1br5shPzIu47AlPKTvaT4 mHG0qJErEQF+VlikQu6TmFO8LZJ3uuah+ch/iYw/YLI14Gl4WO70ZAe9Iqz6/F985oLB 69OA6tKSElezHC5AwcWDEQzxZhHy4QeaQe7bQJHQEjLMATkX4rx0deKUyLPYJRW1W3qf 7x+SRWjvkqyTV1icDeBsvjlvtXOL7IWxXIEZSmBi9tJL29EODIiIIdpqYlHIQY56qzEB qkw/2e4ZECznMVR7RhMGKhhloY/3TvevQSfOgw5nqnOXTut6YvWQF6mdbEufVatDPoA2 z8nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965883; x=1709570683; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DpCtM4zMbfCyBbShI+77WKapeO/xVJwq7zqsqI2VmFg=; b=thdkJ/v/ybchkbTjzzcEg+7s/h9OaBpvM7aA1waPRi450QbZUWcbTAIQ6dF1nJgz9l 968H2QwGH+JFt04+q2M1AmutS8B1GLs/6uxBj3N/wwHysqvEsA0cOyYvuqWtgWIJEtqS PRnlorppMr9mlu/NkC8S9T5HetbxRuRyzNbsoS0K7YfH2iLK5TvWbKOnIoymeSXGNvBT QTxevarNvk7Gr1QeHuKdwKHEoNQBopfnGvACu5Po7YsySXH+ZA9vs+VXf5Vp8v4e2EF1 JUIn8x5sVZsF6weG63Cqm4rbnfIoHfvdz7Tt0Wnnx9Qgm1DU3ghJpGzr3v/gC3wfROm+ HuUA== X-Gm-Message-State: AOJu0YxR3S+0+AFkqiECSbtL512rpyV72LusZvt7sk9XIJ5jsM8zpYvE xPjOaIlTgBqLp/YXlpmNN+9LBwVx/cUT3syLuRawVWGqWkcPDuTAUQfh+skYJL7k9SFNhuvGOCA = X-Google-Smtp-Source: AGHT+IGWMVZE6sGhplj0N1999L5E25vxWGu25pGEjmTVpzLVMIlUPUrCU2rcZGKQHzeM/4seWwncuQ== X-Received: by 2002:a05:6512:159e:b0:512:fda7:2789 with SMTP id bp30-20020a056512159e00b00512fda72789mr2686709lfb.51.1708965882899; Mon, 26 Feb 2024 08:44:42 -0800 (PST) Message-ID: <2bdfb8c2-c5ef-4631-9754-147310f18507@suse.com> Date: Mon, 26 Feb 2024 17:44:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 08/12] VMX: convert vmx_tertiary_exec_control Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2o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RFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> ... to a field in the capability/controls struct. Signed-off-by: Jan Beulich --- v3: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -162,7 +162,6 @@ static int cf_check parse_ept_param_runt /* Dynamic (run-time adjusted) execution control flags. */ struct vmx_caps __ro_after_init vmx_caps; -uint64_t vmx_tertiary_exec_control __read_mostly; u32 vmx_vmexit_control __read_mostly; u32 vmx_vmentry_control __read_mostly; u64 vmx_ept_vpid_cap __read_mostly; @@ -259,7 +258,6 @@ static int vmx_init_vmcs_config(bool bsp { u32 vmx_basic_msr_low, vmx_basic_msr_high, min, opt; struct vmx_caps caps = {}; - uint64_t _vmx_tertiary_exec_control = 0; u64 _vmx_ept_vpid_cap = 0; u64 _vmx_misc_cap = 0; u32 _vmx_vmexit_control; @@ -362,7 +360,7 @@ static int vmx_init_vmcs_config(bool bsp { uint64_t opt = 0; - _vmx_tertiary_exec_control = adjust_vmx_controls2( + caps.tertiary_exec_control = adjust_vmx_controls2( "Tertiary Exec Control", 0, opt, MSR_IA32_VMX_PROCBASED_CTLS3, &mismatch); } @@ -494,7 +492,6 @@ static int vmx_init_vmcs_config(bool bsp { /* First time through. */ vmx_caps = caps; - vmx_tertiary_exec_control = _vmx_tertiary_exec_control; vmx_ept_vpid_cap = _vmx_ept_vpid_cap; vmx_vmexit_control = _vmx_vmexit_control; vmx_vmentry_control = _vmx_vmentry_control; @@ -531,7 +528,7 @@ static int vmx_init_vmcs_config(bool bsp vmx_caps.secondary_exec_control, caps.secondary_exec_control); mismatch |= cap_check( "Tertiary Exec Control", - vmx_tertiary_exec_control, _vmx_tertiary_exec_control); + vmx_caps.tertiary_exec_control, caps.tertiary_exec_control); mismatch |= cap_check( "VMExit Control", vmx_vmexit_control, _vmx_vmexit_control); @@ -1110,7 +1107,7 @@ static int construct_vmcs(struct vcpu *v v->arch.hvm.vmx.exec_control |= CPU_BASED_RDTSC_EXITING; v->arch.hvm.vmx.secondary_exec_control = vmx_caps.secondary_exec_control; - v->arch.hvm.vmx.tertiary_exec_control = vmx_tertiary_exec_control; + v->arch.hvm.vmx.tertiary_exec_control = vmx_caps.tertiary_exec_control; /* * Disable features which we don't want active by default: @@ -2208,7 +2205,6 @@ int __init vmx_vmcs_init(void) * Make sure all dependent features are off as well. */ memset(&vmx_caps, 0, sizeof(vmx_caps)); - vmx_tertiary_exec_control = 0; vmx_vmexit_control = 0; vmx_vmentry_control = 0; vmx_ept_vpid_cap = 0; --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -265,7 +265,6 @@ extern u32 vmx_vmentry_control; #define TERTIARY_EXEC_GUEST_PAGING_VERIFY BIT(3, UL) #define TERTIARY_EXEC_IPI_VIRT BIT(4, UL) #define TERTIARY_EXEC_VIRT_SPEC_CTRL BIT(7, UL) -extern uint64_t vmx_tertiary_exec_control; #define VMX_EPT_EXEC_ONLY_SUPPORTED 0x00000001 #define VMX_EPT_WALK_LENGTH_4_SUPPORTED 0x00000040 @@ -297,6 +296,7 @@ struct vmx_caps { uint32_t pin_based_exec_control; uint32_t cpu_based_exec_control; uint32_t secondary_exec_control; + uint64_t tertiary_exec_control; }; extern struct vmx_caps vmx_caps; From patchwork Mon Feb 26 16:45:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE6ECC48BF6 for ; Mon, 26 Feb 2024 16:45:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685655.1066739 (Exim 4.92) (envelope-from ) id 1ree6C-0002Py-NB; Mon, 26 Feb 2024 16:45:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685655.1066739; Mon, 26 Feb 2024 16:45:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree6C-0002Pr-KP; Mon, 26 Feb 2024 16:45:04 +0000 Received: by outflank-mailman (input) for mailman id 685655; Mon, 26 Feb 2024 16:45:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree6B-0000BK-7r for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:45:03 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 630a19a5-d4c6-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:45:02 +0100 (CET) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-55a8fd60af0so4313635a12.1 for ; Mon, 26 Feb 2024 08:45:02 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.45.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:45:01 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 630a19a5-d4c6-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965902; x=1709570702; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=qlvyaBxTJU8IjuZfhNaBPKvna3qwUHhOtqZ6G2oyic0=; b=Y2w1x6CUqI9wE/GfptBvw1f/ZbhfcI/IyaqOnCX1nQAwwKv0wRZzNcJ8m3sWZu5Vgl vOiNHprok6ftTbCBvJT1SxqhW1ALm0S2iPR12cIIJNuQWHRSf5f3CwqE7YVKE+9ohfP4 T+m8pgDO/MErGLu/XnEKbPoQ4T8zUnVFREoTI50KXWSdbPxNyoVMxD4BAnX6HUwYHDyu zit1XrojLOLL+y6fQ5cuUUCe97h/rAd44CMMG2faPzILzckwGpsYVyoeKXE3bt7pJKGW tMKs6kK4dP7u+U1iAAJoEGkyXq/9IOp4Xft9OhIAJV7UhyDe3EW6DExiHPItd1CPNqiY PRLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965902; x=1709570702; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qlvyaBxTJU8IjuZfhNaBPKvna3qwUHhOtqZ6G2oyic0=; b=vGyXS1VCk1H69KgYsgKcF5iS6AHhzjAi4hbIeWm0NDG+lXlskgPRO9AGEk3X1xFsaV T1YkC2LWoFuIseP7u3s0JdjL+QWPL7ior4bdi8mieTjM3CKfKBzoTK/2FZ/DcTBIX9Sw Rz4t/BMjUqvommSc1rxSQV6eZXLMSPenxmq+IVnymn8HHGxquAsOnpCJQ9h/Fu87MGGN ljNG1rYR6RKcbpNfr3exlgJdN3IeLlXYmcfc7hsGSK3dn8t1gLmhZ92UusrX6sEytQhz 9WDk4tkiFe1vF3Q+QobE9xvEEauwRzRwWBW17SCcprlsz7Z3iadTOchYPtijC90pOGlW ZywA== X-Gm-Message-State: AOJu0YydpZS3XVmrsi8A2uu/tzVuKN99dqubFdOXl7jIG2vjom8lUfSD DqKd9JYidJr5LqNjiFbWaEqPp/3b4UFucND8rzijDPzXQ/nMaBToCoLEa4km7/B2I+3gzfGsSIM = X-Google-Smtp-Source: AGHT+IGmLDwC13pcsL6fhS7ZmCc853YcZ4+1dBnx0uXrFWGkrq1vusQsnSjUr1bG8naqR66JU1KvCw== X-Received: by 2002:aa7:df93:0:b0:565:e294:5119 with SMTP id b19-20020aa7df93000000b00565e2945119mr2370985edy.18.1708965902142; Mon, 26 Feb 2024 08:45:02 -0800 (PST) Message-ID: <6c273891-8232-4de3-97e1-8f39a174ba32@suse.com> Date: Mon, 26 Feb 2024 17:45:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 09/12] VMX: convert vmx_vmexit_control Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptr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reg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> ... to a field in the capability/controls struct. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -162,7 +162,6 @@ static int cf_check parse_ept_param_runt /* Dynamic (run-time adjusted) execution control flags. */ struct vmx_caps __ro_after_init vmx_caps; -u32 vmx_vmexit_control __read_mostly; u32 vmx_vmentry_control __read_mostly; u64 vmx_ept_vpid_cap __read_mostly; static uint64_t __read_mostly vmx_vmfunc; @@ -260,7 +259,6 @@ static int vmx_init_vmcs_config(bool bsp struct vmx_caps caps = {}; u64 _vmx_ept_vpid_cap = 0; u64 _vmx_misc_cap = 0; - u32 _vmx_vmexit_control; u32 _vmx_vmentry_control; u64 _vmx_vmfunc = 0; bool mismatch = false; @@ -442,7 +440,7 @@ static int vmx_init_vmcs_config(bool bsp opt = (VM_EXIT_SAVE_GUEST_PAT | VM_EXIT_LOAD_HOST_PAT | VM_EXIT_LOAD_HOST_EFER | VM_EXIT_CLEAR_BNDCFGS); min |= VM_EXIT_IA32E_MODE; - _vmx_vmexit_control = adjust_vmx_controls( + caps.vmexit_control = adjust_vmx_controls( "VMExit Control", min, opt, MSR_IA32_VMX_EXIT_CTLS, &mismatch); /* @@ -493,7 +491,6 @@ static int vmx_init_vmcs_config(bool bsp /* First time through. */ vmx_caps = caps; vmx_ept_vpid_cap = _vmx_ept_vpid_cap; - vmx_vmexit_control = _vmx_vmexit_control; vmx_vmentry_control = _vmx_vmentry_control; vmx_caps.basic_msr = ((uint64_t)vmx_basic_msr_high << 32) | vmx_basic_msr_low; @@ -531,7 +528,7 @@ static int vmx_init_vmcs_config(bool bsp vmx_caps.tertiary_exec_control, caps.tertiary_exec_control); mismatch |= cap_check( "VMExit Control", - vmx_vmexit_control, _vmx_vmexit_control); + vmx_caps.vmexit_control, caps.vmexit_control); mismatch |= cap_check( "VMEntry Control", vmx_vmentry_control, _vmx_vmentry_control); @@ -1093,7 +1090,7 @@ void nocall vmx_asm_vmexit_handler(void) static int construct_vmcs(struct vcpu *v) { struct domain *d = v->domain; - u32 vmexit_ctl = vmx_vmexit_control; + uint32_t vmexit_ctl = vmx_caps.vmexit_control; u32 vmentry_ctl = vmx_vmentry_control; int rc = 0; @@ -2205,7 +2202,6 @@ int __init vmx_vmcs_init(void) * Make sure all dependent features are off as well. */ memset(&vmx_caps, 0, sizeof(vmx_caps)); - vmx_vmexit_control = 0; vmx_vmentry_control = 0; vmx_ept_vpid_cap = 0; vmx_vmfunc = 0; --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1060,7 +1060,7 @@ static void load_shadow_control(struct v nvmx_update_pin_control(v, vmx_caps.pin_based_exec_control); vmx_update_cpu_exec_control(v); vmx_update_secondary_exec_control(v); - nvmx_update_exit_control(v, vmx_vmexit_control); + nvmx_update_exit_control(v, vmx_caps.vmexit_control); nvmx_update_entry_control(v); vmx_update_exception_bitmap(v); nvmx_update_apic_access_address(v); --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -227,7 +227,6 @@ void vmx_vmcs_reload(struct vcpu *v); #define VM_EXIT_LOAD_HOST_EFER 0x00200000 #define VM_EXIT_SAVE_PREEMPT_TIMER 0x00400000 #define VM_EXIT_CLEAR_BNDCFGS 0x00800000 -extern u32 vmx_vmexit_control; #define VM_ENTRY_IA32E_MODE 0x00000200 #define VM_ENTRY_SMM 0x00000400 @@ -297,6 +296,7 @@ struct vmx_caps { uint32_t cpu_based_exec_control; uint32_t secondary_exec_control; uint64_t tertiary_exec_control; + uint32_t vmexit_control; }; extern struct vmx_caps vmx_caps; @@ -354,7 +354,7 @@ extern struct vmx_caps vmx_caps; #define cpu_has_vmx_pml \ (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_PML) #define cpu_has_vmx_mpx \ - ((vmx_vmexit_control & VM_EXIT_CLEAR_BNDCFGS) && \ + ((vmx_caps.vmexit_control & VM_EXIT_CLEAR_BNDCFGS) && \ (vmx_vmentry_control & VM_ENTRY_LOAD_BNDCFGS)) #define cpu_has_vmx_xsaves \ (vmx_caps.secondary_exec_control & SECONDARY_EXEC_XSAVES) From patchwork Mon Feb 26 16:45:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5097EC48BF6 for ; Mon, 26 Feb 2024 16:49:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685675.1066779 (Exim 4.92) (envelope-from ) id 1reeAV-00052W-Vq; Mon, 26 Feb 2024 16:49:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685675.1066779; Mon, 26 Feb 2024 16:49:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1reeAV-00052P-TL; Mon, 26 Feb 2024 16:49:31 +0000 Received: by outflank-mailman (input) for mailman id 685675; Mon, 26 Feb 2024 16:49:30 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree6R-0000BK-U3 for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:45:19 +0000 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [2a00:1450:4864:20::133]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6cfdc0e4-d4c6-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:45:19 +0100 (CET) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-512bd533be0so3923413e87.0 for ; Mon, 26 Feb 2024 08:45:19 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.45.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:45:18 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6cfdc0e4-d4c6-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965919; x=1709570719; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=XYZOa3J14PwMoF80jvxD0VhtxRYvyB0LOPQq6Y/apVY=; b=RsKSjMVR+mNCv97sPMaKUUhTvDzU+HokmPK7Qg98ElUbHU2RLXdd372r4sEhM1SZgK 7uJsuvlvB/ePqvfF9QhaqFs2OkyJJBWLCajnagiAALsxnqPV/Nyb9j1dzGbP95Ym6aRh ooAxiDaA2vNlj6PbyF+wZ2G/+bIOMlv2Yi5LoTFbjt276IHbOA4PP5oT3MZCdxg/v8C1 5G7kX1l6d3ZCxHHaKT+sqWMNv/pRL60Wzhu8V1EBV2udVpmb+YFn9Fsp8yn0u/EssWmC /BlxvIhko5sKL90XBrLpPAzESYuINEzrPX/yG4yBesQSgtE9NBentBdZKu9UXdQMlYyj mcVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965919; x=1709570719; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XYZOa3J14PwMoF80jvxD0VhtxRYvyB0LOPQq6Y/apVY=; b=KMoSvHppyeC7uUCuX80xl2WNm+DmHUio/WzQHxwnVbJsvqeiRC2mpHZbhRf7n1eR1f Mg0v6Xjfl9cpDGz3waigNW/gijNSiOUchsBiNu4dGRX7HkF37OPYN/0LoMJ1Dqzm9dvx h1z8+O6TidLmatRk2eFckcjdjEWSD6CrSl5Uu29C21AchxJiBvctdZFjekEAyIDHejqp Ayh6UQVO4yeXQNp66+qLc0CyZ4nrz+xLnzpP8llo3fm9vaKx3luiiVdlOWDDMZylEoAo bXV72qD20QGhdc3BrD5BtwMYndaxtpT/tf1CFa3GQtU857GoxjBmE7CZbWbiXL2Q5YUA ImFA== X-Gm-Message-State: AOJu0YwS30+2V3yknpPOPmmrgixh0K7XkFCO7f3pG6hhTOUwdyFQg/20 HZ+2Au9vY39W8RDRKmn2pJT2BpEGNB7tV2r92uPZiFb7scHqC0okqj904P1a5u9+f4D8KaPnJSk = X-Google-Smtp-Source: AGHT+IEJZL8vn/EMuwZRGM3/4zNNuLIusBD3O5kk1RqbEsr4YKFsolMj3+CB5jypecUGTBMBxffYIw== X-Received: by 2002:a05:6512:20c7:b0:512:f69f:fc45 with SMTP id u7-20020a05651220c700b00512f69ffc45mr2912115lfr.27.1708965918966; Mon, 26 Feb 2024 08:45:18 -0800 (PST) Message-ID: Date: Mon, 26 Feb 2024 17:45:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 10/12] VMX: convert vmx_vmentry_control Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> ... to a field in the capability/controls struct. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -162,7 +162,6 @@ static int cf_check parse_ept_param_runt /* Dynamic (run-time adjusted) execution control flags. */ struct vmx_caps __ro_after_init vmx_caps; -u32 vmx_vmentry_control __read_mostly; u64 vmx_ept_vpid_cap __read_mostly; static uint64_t __read_mostly vmx_vmfunc; @@ -259,7 +258,6 @@ static int vmx_init_vmcs_config(bool bsp struct vmx_caps caps = {}; u64 _vmx_ept_vpid_cap = 0; u64 _vmx_misc_cap = 0; - u32 _vmx_vmentry_control; u64 _vmx_vmfunc = 0; bool mismatch = false; @@ -480,7 +478,7 @@ static int vmx_init_vmcs_config(bool bsp min = 0; opt = (VM_ENTRY_LOAD_GUEST_PAT | VM_ENTRY_LOAD_GUEST_EFER | VM_ENTRY_LOAD_BNDCFGS); - _vmx_vmentry_control = adjust_vmx_controls( + caps.vmentry_control = adjust_vmx_controls( "VMEntry Control", min, opt, MSR_IA32_VMX_ENTRY_CTLS, &mismatch); if ( mismatch ) @@ -491,7 +489,6 @@ static int vmx_init_vmcs_config(bool bsp /* First time through. */ vmx_caps = caps; vmx_ept_vpid_cap = _vmx_ept_vpid_cap; - vmx_vmentry_control = _vmx_vmentry_control; vmx_caps.basic_msr = ((uint64_t)vmx_basic_msr_high << 32) | vmx_basic_msr_low; vmx_vmfunc = _vmx_vmfunc; @@ -531,7 +528,7 @@ static int vmx_init_vmcs_config(bool bsp vmx_caps.vmexit_control, caps.vmexit_control); mismatch |= cap_check( "VMEntry Control", - vmx_vmentry_control, _vmx_vmentry_control); + vmx_caps.vmentry_control, caps.vmentry_control); mismatch |= cap_check( "EPT and VPID Capability", vmx_ept_vpid_cap, _vmx_ept_vpid_cap); @@ -1091,7 +1088,7 @@ static int construct_vmcs(struct vcpu *v { struct domain *d = v->domain; uint32_t vmexit_ctl = vmx_caps.vmexit_control; - u32 vmentry_ctl = vmx_vmentry_control; + u32 vmentry_ctl = vmx_caps.vmentry_control; int rc = 0; vmx_vmcs_enter(v); @@ -2202,7 +2199,6 @@ int __init vmx_vmcs_init(void) * Make sure all dependent features are off as well. */ memset(&vmx_caps, 0, sizeof(vmx_caps)); - vmx_vmentry_control = 0; vmx_ept_vpid_cap = 0; vmx_vmfunc = 0; } --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -235,7 +235,6 @@ void vmx_vmcs_reload(struct vcpu *v); #define VM_ENTRY_LOAD_GUEST_PAT 0x00004000 #define VM_ENTRY_LOAD_GUEST_EFER 0x00008000 #define VM_ENTRY_LOAD_BNDCFGS 0x00010000 -extern u32 vmx_vmentry_control; #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001U #define SECONDARY_EXEC_ENABLE_EPT 0x00000002U @@ -297,6 +296,7 @@ struct vmx_caps { uint32_t secondary_exec_control; uint64_t tertiary_exec_control; uint32_t vmexit_control; + uint32_t vmentry_control; }; extern struct vmx_caps vmx_caps; @@ -325,9 +325,9 @@ extern struct vmx_caps vmx_caps; #define cpu_has_monitor_trap_flag \ (vmx_caps.cpu_based_exec_control & CPU_BASED_MONITOR_TRAP_FLAG) #define cpu_has_vmx_pat \ - (vmx_vmentry_control & VM_ENTRY_LOAD_GUEST_PAT) + (vmx_caps.vmentry_control & VM_ENTRY_LOAD_GUEST_PAT) #define cpu_has_vmx_efer \ - (vmx_vmentry_control & VM_ENTRY_LOAD_GUEST_EFER) + (vmx_caps.vmentry_control & VM_ENTRY_LOAD_GUEST_EFER) #define cpu_has_vmx_unrestricted_guest \ (vmx_caps.secondary_exec_control & SECONDARY_EXEC_UNRESTRICTED_GUEST) #define vmx_unrestricted_guest(v) \ @@ -355,7 +355,7 @@ extern struct vmx_caps vmx_caps; (vmx_caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_PML) #define cpu_has_vmx_mpx \ ((vmx_caps.vmexit_control & VM_EXIT_CLEAR_BNDCFGS) && \ - (vmx_vmentry_control & VM_ENTRY_LOAD_BNDCFGS)) + (vmx_caps.vmentry_control & VM_ENTRY_LOAD_BNDCFGS)) #define cpu_has_vmx_xsaves \ (vmx_caps.secondary_exec_control & SECONDARY_EXEC_XSAVES) #define cpu_has_vmx_tsc_scaling \ From patchwork Mon Feb 26 16:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44141C5478C for ; Mon, 26 Feb 2024 16:45:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685658.1066750 (Exim 4.92) (envelope-from ) id 1ree6o-00032g-W1; Mon, 26 Feb 2024 16:45:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685658.1066750; Mon, 26 Feb 2024 16:45:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree6o-00032Z-Sk; Mon, 26 Feb 2024 16:45:42 +0000 Received: by outflank-mailman (input) for mailman id 685658; Mon, 26 Feb 2024 16:45:41 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree6n-0002xA-GV for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:45:41 +0000 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [2a00:1450:4864:20::533]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 79128c5f-d4c6-11ee-98f5-efadbce2ee36; Mon, 26 Feb 2024 17:45:39 +0100 (CET) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-563bb51c36eso3454948a12.2 for ; Mon, 26 Feb 2024 08:45:39 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.45.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:45:38 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 79128c5f-d4c6-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965939; x=1709570739; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=MWVzS/z9C2M+MglkZ5k6DSCrcfyy95qeh7mUQUnz0es=; b=eYgL0tHH4HNv4aJwdyuBfYsA38P86jydDmCgdFI47eEc1mnmFPWbM7sTiBhh/CwQLC sXL1njilJl5sER618ME1FUNXzGuwgCX+d/uiUpI+1bhE74Zj/8DhQDyyAbp+/lWmU9Oq 52R0QnKbpR4a6z8dGnIV19L8IWFdgX/Njht5KHnYgzVPXkEAjRi0huIGN8ybNhJVsZ8u Z8QDisAl7jGwGTLrICR13UAmf4ELgYWyEa/6Zht9E398CbvS4iuBPGCwKSqb7et3jKGx 9oQwri9qqk1FMzVuBJVZs6vDCP/NeYL1kk1Nrik89FS0CoPuU4bN50Yni1Pqk62J6uIG ZvQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965939; x=1709570739; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MWVzS/z9C2M+MglkZ5k6DSCrcfyy95qeh7mUQUnz0es=; b=JAdeL6H8tydfcayWVH1yMRjNS7982WJ0499qbM1j2vtsv7ntm8SWPV+myThNEXzm/d OmP96AZs0CcnS0gXkzuyOIKzWh5jqYVfgM0D3cdvx17Ef7nH/KDJR3kchK5MJyeFnYxi XtoObexJYbQ67SXm1aiZbJjuRyto4aCH3hk4f/rrfNW8LQLT2T90VymE3IJ1cRObs0z9 9hOAISxDiYWJ4mL8oopmbEqUVpvdXGXel1C+SuTWv1qzuWK4KB9GSRFyXtf5r6NkeZ9c MEiV0IsAMUAkADAc3u0tnb9xfragYaPoH7Bs/wG5FVU7ASnMWGE7y0erxizDt6Uj7v3W /ARg== X-Gm-Message-State: AOJu0YxyBphGkKOJsL3sNMzLoibwuILJ75Ju69kU+yO4+k3brGWJYPc0 ULT31JcjbEyGQnHZloYAKJOYwAbemzGMzTG16qGi2IMhkviycxGwDFOZrYBxZDD1Gkbo+yNSlzc = X-Google-Smtp-Source: AGHT+IFaiW5EwwFtgffnDVKX8BnLEM5/5qyGYEMeDX9Hsb4btZCx+5AHYu7RF9I4onhIURplq6pWLA== X-Received: by 2002:aa7:c389:0:b0:566:137e:e076 with SMTP id k9-20020aa7c389000000b00566137ee076mr1201621edq.19.1708965939148; Mon, 26 Feb 2024 08:45:39 -0800 (PST) Message-ID: Date: Mon, 26 Feb 2024 17:45:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 11/12] VMX: convert vmx_ept_vpid_cap Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOyl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3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> ... to fields in the capability/controls struct: Take the opportunity and split the two halves into separate EPT and VPID fields. Signed-off-by: Jan Beulich --- v3: Re-base. v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -162,7 +162,6 @@ static int cf_check parse_ept_param_runt /* Dynamic (run-time adjusted) execution control flags. */ struct vmx_caps __ro_after_init vmx_caps; -u64 vmx_ept_vpid_cap __read_mostly; static uint64_t __read_mostly vmx_vmfunc; static DEFINE_PER_CPU_READ_MOSTLY(paddr_t, vmxon_region); @@ -256,7 +255,6 @@ static int vmx_init_vmcs_config(bool bsp { u32 vmx_basic_msr_low, vmx_basic_msr_high, min, opt; struct vmx_caps caps = {}; - u64 _vmx_ept_vpid_cap = 0; u64 _vmx_misc_cap = 0; u64 _vmx_vmfunc = 0; bool mismatch = false; @@ -365,10 +363,10 @@ static int vmx_init_vmcs_config(bool bsp if ( caps.secondary_exec_control & (SECONDARY_EXEC_ENABLE_EPT | SECONDARY_EXEC_ENABLE_VPID) ) { - rdmsrl(MSR_IA32_VMX_EPT_VPID_CAP, _vmx_ept_vpid_cap); + rdmsr(MSR_IA32_VMX_EPT_VPID_CAP, caps.ept, caps.vpid); if ( !opt_ept_ad ) - _vmx_ept_vpid_cap &= ~VMX_EPT_AD_BIT; + caps.ept &= ~VMX_EPT_AD_BIT; /* * Additional sanity checking before using EPT: @@ -381,9 +379,9 @@ static int vmx_init_vmcs_config(bool bsp * * Or we just don't use EPT. */ - if ( !(_vmx_ept_vpid_cap & VMX_EPT_MEMORY_TYPE_WB) || - !(_vmx_ept_vpid_cap & VMX_EPT_WALK_LENGTH_4_SUPPORTED) || - !(_vmx_ept_vpid_cap & VMX_EPT_INVEPT_ALL_CONTEXT) ) + if ( !(caps.ept & VMX_EPT_MEMORY_TYPE_WB) || + !(caps.ept & VMX_EPT_WALK_LENGTH_4_SUPPORTED) || + !(caps.ept & VMX_EPT_INVEPT_ALL_CONTEXT) ) caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_EPT; /* @@ -392,11 +390,11 @@ static int vmx_init_vmcs_config(bool bsp * * Or we just don't use VPID. */ - if ( !(_vmx_ept_vpid_cap & VMX_VPID_INVVPID_ALL_CONTEXT) ) + if ( !(caps.vpid & VMX_VPID_INVVPID_ALL_CONTEXT) ) caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VPID; /* EPT A/D bits is required for PML */ - if ( !(_vmx_ept_vpid_cap & VMX_EPT_AD_BIT) ) + if ( !(caps.ept & VMX_EPT_AD_BIT) ) caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_PML; } @@ -488,7 +486,6 @@ static int vmx_init_vmcs_config(bool bsp { /* First time through. */ vmx_caps = caps; - vmx_ept_vpid_cap = _vmx_ept_vpid_cap; vmx_caps.basic_msr = ((uint64_t)vmx_basic_msr_high << 32) | vmx_basic_msr_low; vmx_vmfunc = _vmx_vmfunc; @@ -529,9 +526,8 @@ static int vmx_init_vmcs_config(bool bsp mismatch |= cap_check( "VMEntry Control", vmx_caps.vmentry_control, caps.vmentry_control); - mismatch |= cap_check( - "EPT and VPID Capability", - vmx_ept_vpid_cap, _vmx_ept_vpid_cap); + mismatch |= cap_check("EPT Capability", vmx_caps.ept, caps.ept); + mismatch |= cap_check("VPID Capability", vmx_caps.vpid, caps.vpid); mismatch |= cap_check( "VMFUNC Capability", vmx_vmfunc, _vmx_vmfunc); @@ -2199,7 +2195,6 @@ int __init vmx_vmcs_init(void) * Make sure all dependent features are off as well. */ memset(&vmx_caps, 0, sizeof(vmx_caps)); - vmx_ept_vpid_cap = 0; vmx_vmfunc = 0; } --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -274,12 +274,11 @@ void vmx_vmcs_reload(struct vcpu *v); #define VMX_EPT_AD_BIT 0x00200000 #define VMX_EPT_INVEPT_SINGLE_CONTEXT 0x02000000 #define VMX_EPT_INVEPT_ALL_CONTEXT 0x04000000 -#define VMX_VPID_INVVPID_INSTRUCTION 0x00100000000ULL -#define VMX_VPID_INVVPID_INDIVIDUAL_ADDR 0x10000000000ULL -#define VMX_VPID_INVVPID_SINGLE_CONTEXT 0x20000000000ULL -#define VMX_VPID_INVVPID_ALL_CONTEXT 0x40000000000ULL -#define VMX_VPID_INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL 0x80000000000ULL -extern u64 vmx_ept_vpid_cap; +#define VMX_VPID_INVVPID_INSTRUCTION 0x00000001 +#define VMX_VPID_INVVPID_INDIVIDUAL_ADDR 0x00000100 +#define VMX_VPID_INVVPID_SINGLE_CONTEXT 0x00000200 +#define VMX_VPID_INVVPID_ALL_CONTEXT 0x00000400 +#define VMX_VPID_INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL 0x00000800 #define VMX_MISC_ACTIVITY_MASK 0x000001c0 #define VMX_MISC_PROC_TRACE 0x00004000 @@ -297,6 +296,8 @@ struct vmx_caps { uint64_t tertiary_exec_control; uint32_t vmexit_control; uint32_t vmentry_control; + uint32_t ept; + uint32_t vpid; }; extern struct vmx_caps vmx_caps; --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -279,17 +279,17 @@ typedef union cr_access_qual { extern uint8_t posted_intr_vector; #define cpu_has_vmx_ept_exec_only_supported \ - (vmx_ept_vpid_cap & VMX_EPT_EXEC_ONLY_SUPPORTED) + (vmx_caps.ept & VMX_EPT_EXEC_ONLY_SUPPORTED) #define cpu_has_vmx_ept_wl4_supported \ - (vmx_ept_vpid_cap & VMX_EPT_WALK_LENGTH_4_SUPPORTED) -#define cpu_has_vmx_ept_mt_uc (vmx_ept_vpid_cap & VMX_EPT_MEMORY_TYPE_UC) -#define cpu_has_vmx_ept_mt_wb (vmx_ept_vpid_cap & VMX_EPT_MEMORY_TYPE_WB) -#define cpu_has_vmx_ept_2mb (vmx_ept_vpid_cap & VMX_EPT_SUPERPAGE_2MB) -#define cpu_has_vmx_ept_1gb (vmx_ept_vpid_cap & VMX_EPT_SUPERPAGE_1GB) -#define cpu_has_vmx_ept_ad (vmx_ept_vpid_cap & VMX_EPT_AD_BIT) + (vmx_caps.ept & VMX_EPT_WALK_LENGTH_4_SUPPORTED) +#define cpu_has_vmx_ept_mt_uc (vmx_caps.ept & VMX_EPT_MEMORY_TYPE_UC) +#define cpu_has_vmx_ept_mt_wb (vmx_caps.ept & VMX_EPT_MEMORY_TYPE_WB) +#define cpu_has_vmx_ept_2mb (vmx_caps.ept & VMX_EPT_SUPERPAGE_2MB) +#define cpu_has_vmx_ept_1gb (vmx_caps.ept & VMX_EPT_SUPERPAGE_1GB) +#define cpu_has_vmx_ept_ad (vmx_caps.ept & VMX_EPT_AD_BIT) #define cpu_has_vmx_ept_invept_single_context \ - (vmx_ept_vpid_cap & VMX_EPT_INVEPT_SINGLE_CONTEXT) + (vmx_caps.ept & VMX_EPT_INVEPT_SINGLE_CONTEXT) #define EPT_2MB_SHIFT 16 #define EPT_1GB_SHIFT 17 @@ -300,11 +300,11 @@ extern uint8_t posted_intr_vector; #define INVEPT_ALL_CONTEXT 2 #define cpu_has_vmx_vpid_invvpid_individual_addr \ - (vmx_ept_vpid_cap & VMX_VPID_INVVPID_INDIVIDUAL_ADDR) + (vmx_caps.vpid & VMX_VPID_INVVPID_INDIVIDUAL_ADDR) #define cpu_has_vmx_vpid_invvpid_single_context \ - (vmx_ept_vpid_cap & VMX_VPID_INVVPID_SINGLE_CONTEXT) + (vmx_caps.vpid & VMX_VPID_INVVPID_SINGLE_CONTEXT) #define cpu_has_vmx_vpid_invvpid_single_context_retaining_global \ - (vmx_ept_vpid_cap & VMX_VPID_INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL) + (vmx_caps.vpid & VMX_VPID_INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL) #define INVVPID_INDIVIDUAL_ADDR 0 #define INVVPID_SINGLE_CONTEXT 1 From patchwork Mon Feb 26 16:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13572469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C93A2C48BF6 for ; Mon, 26 Feb 2024 16:46:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.685660.1066759 (Exim 4.92) (envelope-from ) id 1ree7A-0003Xp-B9; Mon, 26 Feb 2024 16:46:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 685660.1066759; Mon, 26 Feb 2024 16:46:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree7A-0003Xi-8R; Mon, 26 Feb 2024 16:46:04 +0000 Received: by outflank-mailman (input) for mailman id 685660; Mon, 26 Feb 2024 16:46:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ree78-0003OP-DE for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 16:46:02 +0000 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [2a00:1450:4864:20::52b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 865f386b-d4c6-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 17:46:01 +0100 (CET) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-565b434f90aso2300408a12.3 for ; Mon, 26 Feb 2024 08:46:01 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d18-20020a056402401200b005640022af58sm2509237eda.83.2024.02.26.08.46.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Feb 2024 08:46:01 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 865f386b-d4c6-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708965961; x=1709570761; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=dDYzTd9wYxsVXEBeurRAELomc9weD9fuwjmladT865s=; b=CUbO0BsfOIUCLnCKu9fQhKqjBKAtDo4QJZGwelMu14Z6cgPjCm3pFxv6DGqOpJRJsA bkCe/y6ejFmvKEiJ5NI4lw05NbXy/OCr0hksUPslS6TEB1QquiIaGjTIO9E15OGqUIWL CkrhLwic81YeZlQ40vOMzqZMGIx5n/3W7/06fGf+shv+8p+puN9oaqkWKz7sxmDvzzu0 i3szoA/FvHiZXo2U5NIhb9t8JKhd//LGVP/zg/PJdo+tVuyW30IxSnpNWqd5XbrUDTFT QOhyiZL/v08MDIWDR9XqBIjPeXaLfrhhYshbP7jLEiH+V7+mD3jmXhyqFK28qdE0RRjD E0jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708965961; x=1709570761; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dDYzTd9wYxsVXEBeurRAELomc9weD9fuwjmladT865s=; b=cG6gff/dtVbA7mtQK1iK/pk7CcFkT8fhdPtNYssRTlMr72hEG3zmpfm3NSp63MgctF E7xCSieNNV2jg6dWxt9t2eyuCphJRtQexUCTbY5GH60cWf0exbA/IKy0oxAN/MK4/TF3 SZVO5JgHonl8kiAtew/Gm+XZVVq9Gxc8t+xvK3sQ+BH70m02gzb4wKUYRqPjHDBwDSga 54DWrGO6m3y+DhgpQpzsDaGuECIpwvnbZTiirZcgvSs8jKd3C3LVD5+snNftev8Al8PG V4fZHA7QP6ot6A/D4xJS/mUi8rEeueRF6A4ABny2gkXJvEhIndtPaLuUilZND82PDN6H Rukw== X-Gm-Message-State: AOJu0YxIjZ2n7gSJbz/mRYRRakGHS0S3bzKiy9s9cRsOW0FXoVq1J5Ht /rSEhsSjDwCC+9N54Vx9NbVOPOAXgAsONxNd2u0Ks8xeGhQbVDnXm6Qs9KMUUo0AqwMFfcCEiDA = X-Google-Smtp-Source: AGHT+IEmtrBcVHu3UxTiqUGsoYFdIPDz0EMOfeYv3hTO8JhDlkEH7AAjpMwtSw/ojpcyq6wZQ/avBw== X-Received: by 2002:a50:fb0e:0:b0:565:cda7:4b88 with SMTP id d14-20020a50fb0e000000b00565cda74b88mr3236704edq.37.1708965961529; Mon, 26 Feb 2024 08:46:01 -0800 (PST) Message-ID: <1c94855b-884e-4207-aa52-6398c5b9393a@suse.com> Date: Mon, 26 Feb 2024 17:46:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 12/12] VMX: convert vmx_vmfunc Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com> ... to a field in the capability/controls struct. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -162,7 +162,6 @@ static int cf_check parse_ept_param_runt /* Dynamic (run-time adjusted) execution control flags. */ struct vmx_caps __ro_after_init vmx_caps; -static uint64_t __read_mostly vmx_vmfunc; static DEFINE_PER_CPU_READ_MOSTLY(paddr_t, vmxon_region); static DEFINE_PER_CPU(paddr_t, current_vmcs); @@ -256,7 +255,6 @@ static int vmx_init_vmcs_config(bool bsp u32 vmx_basic_msr_low, vmx_basic_msr_high, min, opt; struct vmx_caps caps = {}; u64 _vmx_misc_cap = 0; - u64 _vmx_vmfunc = 0; bool mismatch = false; rdmsr(MSR_IA32_VMX_BASIC, vmx_basic_msr_low, vmx_basic_msr_high); @@ -458,14 +456,14 @@ static int vmx_init_vmcs_config(bool bsp /* The IA32_VMX_VMFUNC MSR exists only when VMFUNC is available */ if ( caps.secondary_exec_control & SECONDARY_EXEC_ENABLE_VM_FUNCTIONS ) { - rdmsrl(MSR_IA32_VMX_VMFUNC, _vmx_vmfunc); + rdmsrl(MSR_IA32_VMX_VMFUNC, caps.vmfunc); /* * VMFUNC leaf 0 (EPTP switching) must be supported. * * Or we just don't use VMFUNC. */ - if ( !(_vmx_vmfunc & VMX_VMFUNC_EPTP_SWITCHING) ) + if ( !(caps.vmfunc & VMX_VMFUNC_EPTP_SWITCHING) ) caps.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_VM_FUNCTIONS; } @@ -488,7 +486,6 @@ static int vmx_init_vmcs_config(bool bsp vmx_caps = caps; vmx_caps.basic_msr = ((uint64_t)vmx_basic_msr_high << 32) | vmx_basic_msr_low; - vmx_vmfunc = _vmx_vmfunc; vmx_display_features(); @@ -530,7 +527,7 @@ static int vmx_init_vmcs_config(bool bsp mismatch |= cap_check("VPID Capability", vmx_caps.vpid, caps.vpid); mismatch |= cap_check( "VMFUNC Capability", - vmx_vmfunc, _vmx_vmfunc); + vmx_caps.vmfunc, caps.vmfunc); if ( cpu_has_vmx_ins_outs_instr_info != !!(vmx_basic_msr_high & (VMX_BASIC_INS_OUT_INFO >> 32)) ) { @@ -2195,7 +2192,6 @@ int __init vmx_vmcs_init(void) * Make sure all dependent features are off as well. */ memset(&vmx_caps, 0, sizeof(vmx_caps)); - vmx_vmfunc = 0; } return ret; --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h @@ -298,6 +298,7 @@ struct vmx_caps { uint32_t vmentry_control; uint32_t ept; uint32_t vpid; + uint64_t vmfunc; }; extern struct vmx_caps vmx_caps;