Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5047737rwl; Mon, 10 Apr 2023 22:57:27 -0700 (PDT) X-Google-Smtp-Source: AKy350aB8P3wj/zKPxhD4bS67lRLyQXKC/8yI/A7WNlS1N2jcRKkmiwirHo06lnIMDsiKrJn2eBu X-Received: by 2002:a17:906:eea:b0:931:d36f:8965 with SMTP id x10-20020a1709060eea00b00931d36f8965mr10160164eji.13.1681192647309; Mon, 10 Apr 2023 22:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681192647; cv=none; d=google.com; s=arc-20160816; b=PfOg3wWGGrZ6sbfTZ45GpbJ5ZU9f+tFBI3E/jA3DWwPi9LWigYhV7qxPvjlj8wWxJp 1aUPFOvy+w7Ng47TH22en1wAzY3WobO7BQ6qEkwlQAUnhZB5KitQbHLlYZyOOHWyIqbq nwhQ8hICo4z09DF7xhyvUHgd5D94rovUsO9ZVK2voUG/10SqGHfze7c+XJFm+Vju9j+e kLOLzN0QiuXIP8dDwdfVxBEOtRtu3arhkdiTePjZL7ub/nR3IJOuVk0hCmrBRRoFUXig pi34Dt4Ju0Pb1OMJyz2It2x0t5hEQMyKDj4yUDDIamCr75BQX3CifclxG6cG5UwriGxx yjYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter; bh=KkJORnzMR+CBheAYPQesJLR4S70FDAPfCyfgXX/hmQw=; b=VtV+BtCW4uUZAcpGQ1Ax4YBgh9IhEGLsWzXmnokr5dGOJM6nrqDQGNeQDwobhStOez xtxQ1++hmC+0dBy/1kgYkifNsUCPiPdQq5E+k+PFBQzVDWSYWZZ3ZkMkeGP+FClF/dHz ZuK2e0N8yiVZ/nnS9BVrSnenWjxHYqg8GE91ioD7kA7GOQbfNBLPSOE5lPbn9AW8BNvO 562TVJOQJ5x6DAvVR7NXRQ985YcXLjWMMjOB4X+GaHt0/dfBndcXOkc1koxGOEH1dIAI 6ZtPZH+Xb8ac2jwaqSiuFvR8A7d2qO/gSpZcwkCGE7Z3iRZH1ATm71THcFX9ws0b6aKo 7oxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=OapdhksH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ov2-20020a170906fc0200b0094cb040cd6dsi1874105ejb.226.2023.04.10.22.57.02; Mon, 10 Apr 2023 22:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=OapdhksH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230108AbjDKFzx (ORCPT + 99 others); Tue, 11 Apr 2023 01:55:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbjDKFzj (ORCPT ); Tue, 11 Apr 2023 01:55:39 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E3EE5E7A; Mon, 10 Apr 2023 22:55:37 -0700 (PDT) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 2C2C42174E4E; Mon, 10 Apr 2023 22:55:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2C2C42174E4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1681192536; bh=KkJORnzMR+CBheAYPQesJLR4S70FDAPfCyfgXX/hmQw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OapdhksHiAtrdnMXpvnfZMVKRMw6PPD1nbRuG7X1WL4uLwvObFAkC/T3gyXx+YVwd FwCqp1/wHyMuZ89jBfGyzIAiK1Vl/bJlsr3ZCK2bF62oSz6Hd8/KgOL4/TsGEsGDLZ DrYhYGvJJwUVsp4wd3C4Ob7ieWS0csMe1zy8ZtOg= From: Saurabh Sengar To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, arnd@arndb.de, tiala@microsoft.com, mikelley@microsoft.com, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-arch@vger.kernel.org, jgross@suse.com, mat.jonczyk@o2.pl Subject: [PATCH v5 2/5] x86/hyperv: Add VTL specific structs and hypercalls Date: Mon, 10 Apr 2023 22:55:29 -0700 Message-Id: <1681192532-15460-3-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1681192532-15460-1-git-send-email-ssengar@linux.microsoft.com> References: <1681192532-15460-1-git-send-email-ssengar@linux.microsoft.com> X-Spam-Status: No, score=-17.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add structs and hypercalls required to enable VTL support on x86. Signed-off-by: Saurabh Sengar Reviewed-by: Michael Kelley Reviewed-by: Stanislav Kinsburskii --- [V5] - __u64/__u16 -> u64/u16 arch/x86/include/asm/hyperv-tlfs.h | 75 ++++++++++++++++++++++++++++++ include/asm-generic/hyperv-tlfs.h | 4 ++ 2 files changed, 79 insertions(+) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index 0b73a809e9e1..a493fbdb38ef 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -713,6 +713,81 @@ union hv_msi_entry { } __packed; }; +struct hv_x64_segment_register { + u64 base; + u32 limit; + u16 selector; + union { + struct { + u16 segment_type : 4; + u16 non_system_segment : 1; + u16 descriptor_privilege_level : 2; + u16 present : 1; + u16 reserved : 4; + u16 available : 1; + u16 _long : 1; + u16 _default : 1; + u16 granularity : 1; + } __packed; + u16 attributes; + }; +} __packed; + +struct hv_x64_table_register { + u16 pad[3]; + u16 limit; + u64 base; +} __packed; + +struct hv_init_vp_context { + u64 rip; + u64 rsp; + u64 rflags; + + struct hv_x64_segment_register cs; + struct hv_x64_segment_register ds; + struct hv_x64_segment_register es; + struct hv_x64_segment_register fs; + struct hv_x64_segment_register gs; + struct hv_x64_segment_register ss; + struct hv_x64_segment_register tr; + struct hv_x64_segment_register ldtr; + + struct hv_x64_table_register idtr; + struct hv_x64_table_register gdtr; + + u64 efer; + u64 cr0; + u64 cr3; + u64 cr4; + u64 msr_cr_pat; +} __packed; + +union hv_input_vtl { + u8 as_uint8; + struct { + u8 target_vtl: 4; + u8 use_target_vtl: 1; + u8 reserved_z: 3; + }; +} __packed; + +struct hv_enable_vp_vtl { + u64 partition_id; + u32 vp_index; + union hv_input_vtl target_vtl; + u8 mbz0; + u16 mbz1; + struct hv_init_vp_context vp_context; +} __packed; + +struct hv_get_vp_from_apic_id_in { + u64 partition_id; + union hv_input_vtl target_vtl; + u8 res[7]; + u32 apic_ids[]; +} __packed; + #include #endif diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h index b870983596b9..87258341fd7c 100644 --- a/include/asm-generic/hyperv-tlfs.h +++ b/include/asm-generic/hyperv-tlfs.h @@ -146,6 +146,7 @@ union hv_reference_tsc_msr { /* Declare the various hypercall operations. */ #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002 #define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003 +#define HVCALL_ENABLE_VP_VTL 0x000f #define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 #define HVCALL_SEND_IPI 0x000b #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 @@ -165,6 +166,8 @@ union hv_reference_tsc_msr { #define HVCALL_MAP_DEVICE_INTERRUPT 0x007c #define HVCALL_UNMAP_DEVICE_INTERRUPT 0x007d #define HVCALL_RETARGET_INTERRUPT 0x007e +#define HVCALL_START_VP 0x0099 +#define HVCALL_GET_VP_ID_FROM_APIC_ID 0x009a #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0 #define HVCALL_MODIFY_SPARSE_GPA_PAGE_HOST_VISIBILITY 0x00db @@ -218,6 +221,7 @@ enum HV_GENERIC_SET_FORMAT { #define HV_STATUS_INVALID_PORT_ID 17 #define HV_STATUS_INVALID_CONNECTION_ID 18 #define HV_STATUS_INSUFFICIENT_BUFFERS 19 +#define HV_STATUS_VTL_ALREADY_ENABLED 134 /* * The Hyper-V TimeRefCount register and the TSC -- 2.34.1