From patchwork Fri Nov 4 16:18:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13032306 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 F3EAEC433FE for ; Fri, 4 Nov 2022 16:18:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.437761.692226 (Exim 4.92) (envelope-from ) id 1oqzP2-0007zW-7u; Fri, 04 Nov 2022 16:18:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 437761.692226; Fri, 04 Nov 2022 16:18: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 1oqzP2-0007zP-4x; Fri, 04 Nov 2022 16:18:44 +0000 Received: by outflank-mailman (input) for mailman id 437761; Fri, 04 Nov 2022 16:18:42 +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 1oqzP0-0007zJ-4O for xen-devel@lists.xenproject.org; Fri, 04 Nov 2022 16:18:42 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 56e35880-5c5c-11ed-8fd1-01056ac49cbb; Fri, 04 Nov 2022 17:18:40 +0100 (CET) Received: from mail-bn7nam10lp2108.outbound.protection.outlook.com (HELO NAM10-BN7-obe.outbound.protection.outlook.com) ([104.47.70.108]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 04 Nov 2022 12:18:35 -0400 Received: from SJ0PR03MB6360.namprd03.prod.outlook.com (2603:10b6:a03:395::11) by SA1PR03MB6609.namprd03.prod.outlook.com (2603:10b6:806:1c8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22; Fri, 4 Nov 2022 16:18:30 +0000 Received: from SJ0PR03MB6360.namprd03.prod.outlook.com ([fe80::d197:992c:4dca:3c4c]) by SJ0PR03MB6360.namprd03.prod.outlook.com ([fe80::d197:992c:4dca:3c4c%6]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 16:18:30 +0000 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: 56e35880-5c5c-11ed-8fd1-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1667578720; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=OZIy73XHDNh7huyG+lccw757BxYenNLRo+6EmZBz0Tw=; b=h/boivSYnjOdVVHKJTsqs0QGC77nmaDQKFG3uGB7T4ew5TYDaO6YXy/y 4srMSDZkvjhdqkqgNVLTCUNmkdtQQUWU58jt3nvuSdI37iq1zXfvUMnpa tAQJypfk/jKRdRf3PfDtqeeAMSwocEnaz1Pouqn6wLndAfFtka/1tow2n M=; X-IronPort-RemoteIP: 104.47.70.108 X-IronPort-MID: 83793898 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:hqFpXa4nNpAzPo4hyi5OLwxRtM/GchMFZxGqfqrLsTDasY5as4F+v mcfWziDa/rbMWqneIt/OoXl8hlV78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Aa0+41MHftLqUwLzM2dKYRJd 653I5qtjCgcXMYYoCSAWQEZfHKo5numIj9aRALKhY74E3W5AnYoYLSIly95FMzQjlPybAt/S zslBH43Lyqt7WexgXH32HewpxKkJ/Ky8dFBuaLls8JQw+c/DqAVcBEYfmvrTo1qOag5BIDl8 TNmQ4pO4BJ53bYbgiO0GnQ8jil9Axrx27pyFeej3emi9f+XigGB81Igp8cWgfF6mI71esMnZ 5j7ia8jd56HBnAlCPy65zjTBdxjHe5pnIkjKo6k2Ffa40Dc7VcxLZvtn+9KK1wUx4S1bpXXt WHVKrnlbdrmBKhHjvkV1BUsZCRti9ZJGbHfqAA0vbloAS+0koJjHfw//Zv4EvoxKhNN6Ws2N 60TZiA7Is+KPP+TZgNcdvpEvHHflDlcFbrDF+4B2jBOeUuB0/twqSHkIndotvaMKA18A== X-IronPort-AV: E=Sophos;i="5.96,138,1665460800"; d="scan'208";a="83793898" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=exWmJua65++5Cd6SFkgFrnoG+PYxtJhLH+4ODBTJlSM3AJ/BT2/FmvEs3Yq0d9KyaMfbpxEjvLjg1yrU4yrwtIM3M2nCqMtm1gptHQDs5bWFoNXI87E6JvBoLPwXFOw3xlbIsfSJOHkgz9VXgW/FmCuhaC+KeUVIcLeZM5gcdNQeKUCQGH8ZX3Z0/S4MNG5T2l+okjhhpEK56V1PIDfVYIcNpJzyiQHuf9S4Va64F/ZJkQJWYjjLmRqYYyy9qY93O8MCDIQlyMDG6ElsweCJLRlm1Xcoztav6EizOPQDqpDTgBAPT/lXeLPsn5zICYcEnc5/qv/C/Oz7kQM9wiDppw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fley6Y90v1no9pEdEhWt6kG4s5fyBU09mWCBmGOap2k=; b=MEf5pSdlOESh+IKpi4CHqszLv8u5eeLeBPw5yBFB0XLAnIWilXnkdJne1dWmdcNJzGDWRQMuNu4Vywg3Pd7M5wF4aw8nAtgzH9Mi2JOtQldgYR5iVGY5wCgq+NP3zOLCzMP2hUr9boxBWIrc3aN++K+zI7tYm4lv1rwu5uVGiHusXiIcxwtOq65RFAybN6sFL0JtbtFesQEWKK/Hhpcsh8E8N0S1dem42JqBu48uVCP7GeAbayErORbJ5wL68AdThJkj9ubwdzQ0Zm9Y8S9ETG4BjakxdYuRNOG6NG0XxDyKsTSgHnQ19qNbgV9x68XY/ad17MbFw6zFSK8iswQhQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fley6Y90v1no9pEdEhWt6kG4s5fyBU09mWCBmGOap2k=; b=Fs8RXrb5J+8ZNsI6UPPGKfJeD+hVbWIcwavwhpZ+CNpOzFSyM/OQOBBwjfeLjQk9/Oo5y7LqCMTfsHU9FIT4giLF7NMXoDCgUmn0pp1FL7GyM/uIcNSqMyvHsGPJdclg3YREKjD6dJ7ipeKsKoy6pP6nxkUT4O3owpEjLp+ya2o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Henry.Wang@arm.com, Roger Pau Monne , Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , Jun Nakajima , Kevin Tian Subject: [PATCH for-4.17 v2] hvm/apic: repurpose the reporting of the APIC assist options Date: Fri, 4 Nov 2022 17:18:15 +0100 Message-Id: <20221104161815.38007-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.37.3 X-ClientProxiedBy: LO4P123CA0321.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:197::20) To SJ0PR03MB6360.namprd03.prod.outlook.com (2603:10b6:a03:395::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6360:EE_|SA1PR03MB6609:EE_ X-MS-Office365-Filtering-Correlation-Id: 9255d589-4c0c-4c5c-d308-08dabe803606 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OUxlaN267uBb+r/ZK1RN9p7IZYzu9bATwkE4ZiCpfkiA5wgQndHtT538Vxhwjls9hA9Fixm4k2S1nosX5JaMYIEbq6bKjHB52fludS5TWlBmrb86nJHv4K0ZGuQ6g4I8xJI82jcr6XMQBddlhl0hhVG9Kqq+VwLCwr0jNe/9n3r5CJLt8pvIu6jNzvbXQdVEM1GikK3WTYvD+504fsVM33FsOXtmsx++neSK7D5BRfHFIOVnY5TFcdcbuPJulu5Om64DjRufjY7plOCokSEeTJy+ryzpbKp+Na12gwJxiQF78MNhv69VWkyvn6hTxsRYwpwO0vEx4N+ZbsFeeckjKmp3WgncB/OFPeJaAyVAiYU6rDfIVdjYW0oopLgg51DPO+Nsa9Avhf0FkMB4RAUjJkl9WFBmE1LlqTgsQ0Pjqx8Onhzrhfa/hZ+yT8BWbD0dzMPhazN7Sdl/RoKkhRwXpfPrswyvRy51fI7WmqtogQMJLNBd853NipzUVZHnt0nWCJJ5PbYaMdGj0qZuXCzTEIsS2+ITJmUaZrvVP9BKPR13d7wgROh/LYFk6OfnVWVmQvcTipT5OionXRvNUolzEwbj1VaPDmrYSda6k14Yj34trNZSV/110g9mlS9zwB3F1MLz67NsNxedaR9zLO5ys1d87t+EpIExMSYFIENwdY5ba+MIk1bP+cp/o70F/uxoQzxxH5kzBwwE32h76mQaIg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6360.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(366004)(376002)(346002)(136003)(451199015)(38100700002)(36756003)(86362001)(4326008)(82960400001)(41300700001)(66556008)(5660300002)(66946007)(478600001)(8936002)(54906003)(8676002)(66476007)(316002)(6916009)(186003)(2906002)(2616005)(1076003)(83380400001)(6486002)(26005)(6506007)(6512007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?JvEIxImXqm6kT6DzIoRwxujzhJhK?= =?utf-8?q?m+k1Fw7BIo+4rjN0ijnEWWCZ7zO10gZAgQi2RJuF1m9SrR03+7yC69TSKSpwDETRz?= =?utf-8?q?mVveUmolDC0gxFUAHqUJ0J9r/I6UXr2Vkfc6qMYEQwhAYbbnLw4OKt96yT2OMVrjQ?= =?utf-8?q?jba8uzoEJ/F7niVAE3arMwZO2d/o68cNyxffvSsIXeaHwxJlL0HuRndLQveVnP1z1?= =?utf-8?q?fR7H5qgsQ3YGfnABLIzMg71K0r1/GDZ72jaaczM2uf94UAr5wCq4seJeEHoEa2y3E?= =?utf-8?q?Y2ihJSEXwfjrOZFHurFVP3gU1ef6xkKsGOAuIbQX1IAM2uIOCuipWs042jI8bB085?= =?utf-8?q?V2Ag17cLJaP8l/LbyILUZGvt+MyIkGuZxAY7VH3f8Pbjuj6BuUfteM82IN4dd82WO?= =?utf-8?q?KgHNoi/uEm1EGhrVGugUPcylF43JXlUs68zgUwSsRXlsdeAegGY8K2ll/7TrRkXS0?= =?utf-8?q?OwdmUOv1wp/tYRIDJC7DzbJAmYo7Wb4BD3oEFIt1G18e/vrwVYND/tOJF6Z+7fnq9?= =?utf-8?q?Vm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xo0IH/rQliJmG7ydeDkU3NZFJgkJ/mtjjY7A6Jn47rInIVBt4+ArFE1bvgibb1?= =?utf-8?q?c7mDb6Uj39/yCZlDnfZeB8Oemt4QexLcuUrTDyshqN/VsmnG4VjfhQT6q6tkMULFu?= =?utf-8?q?zItfanOLZuda5GDgaSVVFHJynquM1WM1mQ=3D=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9255d589-4c0c-4c5c-d308-08dabe803606 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6360.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 16:18:29.9885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sJLhJzBLc1LdqKKoZR9IAOfNWZOuDSH2E+4w+m7gucqiaaFQRVdiGKc9BZxZDskGuGXLs/gwHRe9+so3OiGTGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR03MB6609 The current reporting of the hardware assisted APIC options is done by checking "virtualize APIC accesses" which is not very helpful, as that feature doesn't avoid a vmexit, instead it does provide some help in order to detect APIC MMIO accesses in vmexit processing. Repurpose the current reporting of xAPIC assistance to instead report such feature as present when there's support for "TPR shadow" and "APIC register virtualization" because in that case some xAPIC MMIO register accesses are handled directly by the hardware, without requiring a vmexit. For symetry also change assisted x2APIC reporting to require "virtualize x2APIC mode" and "APIC register virtualization", dropping the option to also be reported when "virtual interrupt delivery" is available. Presence of the "virtual interrupt delivery" feature will be reported using a different option. Fixes: 2ce11ce249 ('x86/HVM: allow per-domain usage of hardware virtualized APIC') Signed-off-by: Roger Pau Monné Reviewed-by: Paul Durrant --- I find the logic in vmx_vlapic_msr_changed() hard to follow, but I don't want to rewrite the function logic at this point. --- Changes since v1: - Fix Viridian MSR tip conditions. --- xen/arch/x86/hvm/viridian/viridian.c | 2 +- xen/arch/x86/hvm/vmx/vmcs.c | 8 ++++---- xen/arch/x86/hvm/vmx/vmx.c | 25 ++++++++++++++++++------- xen/arch/x86/traps.c | 4 +--- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridian/viridian.c index 25dca93e8b..44eb3d0519 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -197,7 +197,7 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf, res->a = CPUID4A_RELAX_TIMER_INT; if ( viridian_feature_mask(d) & HVMPV_hcall_remote_tlb_flush ) res->a |= CPUID4A_HCALL_REMOTE_TLB_FLUSH; - if ( !cpu_has_vmx_apic_reg_virt ) + if ( !has_assisted_xapic(d) ) res->a |= CPUID4A_MSR_BASED_APIC; if ( viridian_feature_mask(d) & HVMPV_hcall_ipi ) res->a |= CPUID4A_SYNTHETIC_CLUSTER_IPI; diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index a1aca1ec04..7bb96e1a8e 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -1136,7 +1136,7 @@ static int construct_vmcs(struct vcpu *v) if ( !has_assisted_xapic(d) ) v->arch.hvm.vmx.secondary_exec_control &= - ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; + ~SECONDARY_EXEC_APIC_REGISTER_VIRT; if ( cpu_has_vmx_secondary_exec_control ) __vmwrite(SECONDARY_VM_EXEC_CONTROL, @@ -2156,10 +2156,10 @@ int __init vmx_vmcs_init(void) if ( !ret ) { /* Check whether hardware supports accelerated xapic and x2apic. */ - assisted_xapic_available = cpu_has_vmx_virtualize_apic_accesses; + assisted_xapic_available = cpu_has_vmx_tpr_shadow && + cpu_has_vmx_apic_reg_virt; assisted_x2apic_available = cpu_has_vmx_virtualize_x2apic_mode && - (cpu_has_vmx_apic_reg_virt || - cpu_has_vmx_virtual_intr_delivery); + cpu_has_vmx_apic_reg_virt; register_keyhandler('v', vmcs_dump, "dump VT-x VMCSs", 1); } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index e624b415c9..bf0fe3355c 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3405,25 +3405,29 @@ static void vmx_install_vlapic_mapping(struct vcpu *v) void vmx_vlapic_msr_changed(struct vcpu *v) { + bool virtualize_x2apic_mode = has_assisted_x2apic(v->domain) || + (cpu_has_vmx_virtualize_x2apic_mode && + cpu_has_vmx_virtual_intr_delivery); struct vlapic *vlapic = vcpu_vlapic(v); unsigned int msr; - if ( !has_assisted_xapic(v->domain) && - !has_assisted_x2apic(v->domain) ) + if ( !cpu_has_vmx_virtualize_apic_accesses && + !virtualize_x2apic_mode ) return; vmx_vmcs_enter(v); v->arch.hvm.vmx.secondary_exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | - SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE); + SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE | + SECONDARY_EXEC_APIC_REGISTER_VIRT); if ( !vlapic_hw_disabled(vlapic) && (vlapic_base_address(vlapic) == APIC_DEFAULT_PHYS_BASE) ) { - if ( has_assisted_x2apic(v->domain) && vlapic_x2apic_mode(vlapic) ) + if ( virtualize_x2apic_mode && vlapic_x2apic_mode(vlapic) ) { v->arch.hvm.vmx.secondary_exec_control |= SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE; - if ( cpu_has_vmx_apic_reg_virt ) + if ( has_assisted_x2apic(v->domain) ) { for ( msr = MSR_X2APIC_FIRST; msr <= MSR_X2APIC_LAST; msr++ ) @@ -3432,6 +3436,10 @@ void vmx_vlapic_msr_changed(struct vcpu *v) vmx_set_msr_intercept(v, MSR_X2APIC_PPR, VMX_MSR_R); vmx_set_msr_intercept(v, MSR_X2APIC_TMICT, VMX_MSR_R); vmx_set_msr_intercept(v, MSR_X2APIC_TMCCT, VMX_MSR_R); + + v->arch.hvm.vmx.secondary_exec_control |= + SECONDARY_EXEC_APIC_REGISTER_VIRT; + } if ( cpu_has_vmx_virtual_intr_delivery ) { @@ -3440,9 +3448,12 @@ void vmx_vlapic_msr_changed(struct vcpu *v) vmx_clear_msr_intercept(v, MSR_X2APIC_SELF, VMX_MSR_W); } } - else if ( has_assisted_xapic(v->domain) ) + else if ( vlapic_xapic_mode(vlapic) ) v->arch.hvm.vmx.secondary_exec_control |= - SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; + (cpu_has_vmx_virtualize_apic_accesses ? + SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES : 0) | + (has_assisted_xapic(v->domain) ? + SECONDARY_EXEC_APIC_REGISTER_VIRT : 0); } if ( !(v->arch.hvm.vmx.secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE) ) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 7207390118..5c0aabe8a3 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1124,8 +1124,7 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf, if ( !is_hvm_domain(d) || subleaf != 0 ) break; - if ( cpu_has_vmx_apic_reg_virt && - has_assisted_xapic(d) ) + if ( has_assisted_xapic(d) ) res->a |= XEN_HVM_CPUID_APIC_ACCESS_VIRT; /* @@ -1135,7 +1134,6 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf, * vmx_vlapic_msr_changed()). */ if ( has_assisted_x2apic(d) && - cpu_has_vmx_apic_reg_virt && cpu_has_vmx_virtual_intr_delivery ) res->a |= XEN_HVM_CPUID_X2APIC_VIRT;