Skip to content

Commit 6385bba

Browse files
kelleymhSasha Levin
authored andcommitted
arm64: hyperv: Add core Hyper-V include files
hyperv-tlfs.h defines Hyper-V interfaces from the Hyper-V Top Level Functional Spec (TLFS), and #includes the architecture-independent part of hyperv-tlfs.h in include/asm-generic. The published TLFS is distinctly oriented to x86/x64, so the ARM64-specific hyperv-tlfs.h includes information for ARM64 that is not yet formally published. The TLFS is available here: docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs mshyperv.h defines Linux-specific structures and routines for interacting with Hyper-V on ARM64, and #includes the architecture- independent part of mshyperv.h in include/asm-generic. Signed-off-by: Michael Kelley <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 2c85ebc commit 6385bba

File tree

3 files changed

+172
-0
lines changed

3 files changed

+172
-0
lines changed

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8154,6 +8154,8 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
81548154
F: Documentation/ABI/stable/sysfs-bus-vmbus
81558155
F: Documentation/ABI/testing/debugfs-hyperv
81568156
F: Documentation/networking/device_drivers/ethernet/microsoft/netvsc.rst
8157+
F: arch/arm64/include/asm/hyperv-tlfs.h
8158+
F: arch/arm64/include/asm/mshyperv.h
81578159
F: arch/x86/hyperv
81588160
F: arch/x86/include/asm/hyperv-tlfs.h
81598161
F: arch/x86/include/asm/mshyperv.h
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
/*
4+
* This file contains definitions from the Hyper-V Hypervisor Top-Level
5+
* Functional Specification (TLFS):
6+
* https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs
7+
*
8+
* Copyright (C) 2019, Microsoft, Inc.
9+
*
10+
* Author : Michael Kelley <[email protected]>
11+
*/
12+
13+
#ifndef _ASM_HYPERV_TLFS_H
14+
#define _ASM_HYPERV_TLFS_H
15+
16+
#include <linux/types.h>
17+
18+
/*
19+
* All data structures defined in the TLFS that are shared between Hyper-V
20+
* and a guest VM use Little Endian byte ordering. This matches the default
21+
* byte ordering of Linux running on ARM64, so no special handling is required.
22+
*/
23+
24+
/*
25+
* These Hyper-V registers provide information equivalent to the CPUID
26+
* instruction on x86/x64.
27+
*/
28+
#define HV_REGISTER_HYPERVISOR_VERSION 0x00000100 /*CPUID 0x40000002 */
29+
#define HV_REGISTER_FEATURES 0x00000200 /*CPUID 0x40000003 */
30+
#define HV_REGISTER_ENLIGHTENMENTS 0x00000201 /*CPUID 0x40000004 */
31+
32+
/*
33+
* Group C Features. See the asm-generic version of hyperv-tlfs.h
34+
* for a description of Feature Groups.
35+
*/
36+
37+
/* Crash MSRs available */
38+
#define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE BIT(8)
39+
40+
/* STIMER direct mode is available */
41+
#define HV_STIMER_DIRECT_MODE_AVAILABLE BIT(13)
42+
43+
/*
44+
* Synthetic register definitions equivalent to MSRs on x86/x64
45+
*/
46+
#define HV_REGISTER_CRASH_P0 0x00000210
47+
#define HV_REGISTER_CRASH_P1 0x00000211
48+
#define HV_REGISTER_CRASH_P2 0x00000212
49+
#define HV_REGISTER_CRASH_P3 0x00000213
50+
#define HV_REGISTER_CRASH_P4 0x00000214
51+
#define HV_REGISTER_CRASH_CTL 0x00000215
52+
53+
#define HV_REGISTER_GUEST_OSID 0x00090002
54+
#define HV_REGISTER_VPINDEX 0x00090003
55+
#define HV_REGISTER_TIME_REFCOUNT 0x00090004
56+
#define HV_REGISTER_REFERENCE_TSC 0x00090017
57+
58+
#define HV_REGISTER_SINT0 0x000A0000
59+
#define HV_REGISTER_SCONTROL 0x000A0010
60+
#define HV_REGISTER_SIFP 0x000A0012
61+
#define HV_REGISTER_SIPP 0x000A0013
62+
#define HV_REGISTER_EOM 0x000A0014
63+
64+
#define HV_REGISTER_STIMER0_CONFIG 0x000B0000
65+
#define HV_REGISTER_STIMER0_COUNT 0x000B0001
66+
67+
/*
68+
* Define hypervisor message types. These must be
69+
* included in the architecture specific hyperv-tlfs.h
70+
* because there are processor specific values on the
71+
* x86 side.
72+
*/
73+
enum hv_message_type {
74+
HVMSG_NONE = 0x00000000,
75+
76+
/* Memory access messages. */
77+
HVMSG_UNMAPPED_GPA = 0x80000000,
78+
HVMSG_GPA_INTERCEPT = 0x80000001,
79+
80+
/* Timer notification messages. */
81+
HVMSG_TIMER_EXPIRED = 0x80000010,
82+
83+
/* Error messages. */
84+
HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020,
85+
HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021,
86+
HVMSG_UNSUPPORTED_FEATURE = 0x80000022,
87+
88+
/* Trace buffer complete messages. */
89+
HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040,
90+
};
91+
92+
#include <asm-generic/hyperv-tlfs.h>
93+
94+
#endif

arch/arm64/include/asm/mshyperv.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
/*
4+
* Linux-specific definitions for managing interactions with Microsoft's
5+
* Hyper-V hypervisor. The definitions in this file are specific to
6+
* the ARM64 architecture. See include/asm-generic/mshyperv.h for
7+
* definitions are that architecture independent.
8+
*
9+
* Definitions that are specified in the Hyper-V Top Level Functional
10+
* Spec (TLFS) should not go in this file, but should instead go in
11+
* hyperv-tlfs.h.
12+
*
13+
* Copyright (C) 2019, Microsoft, Inc.
14+
*
15+
* Author : Michael Kelley <[email protected]>
16+
*/
17+
18+
#ifndef _ASM_MSHYPERV_H
19+
#define _ASM_MSHYPERV_H
20+
21+
#include <linux/types.h>
22+
#include <linux/interrupt.h>
23+
#include <linux/clocksource.h>
24+
#include <linux/irq.h>
25+
#include <linux/irqdesc.h>
26+
#include <linux/arm-smccc.h>
27+
#include <asm/hyperv-tlfs.h>
28+
29+
/* Access various Hyper-V synthetic registers */
30+
static inline void hv_set_simp(u64 val)
31+
{
32+
hv_set_vpreg(HV_REGISTER_SIPP, val);
33+
}
34+
35+
#define hv_get_simp(val) (val = hv_get_vpreg(HV_REGISTER_SIPP))
36+
37+
static inline void hv_set_siefp(u64 val)
38+
{
39+
hv_set_vpreg(HV_REGISTER_SIFP, val);
40+
}
41+
42+
#define hv_get_siefp(val) (val = hv_get_vpreg(HV_REGISTER_SIFP))
43+
44+
static inline void hv_set_synic_state(u64 val)
45+
{
46+
hv_set_vpreg(HV_REGISTER_SCONTROL, val);
47+
}
48+
49+
#define hv_get_synic_state(val) (val = hv_get_vpreg(HV_REGISTER_SCONTROL))
50+
51+
static inline bool hv_recommend_using_aeoi(void)
52+
{
53+
return false;
54+
}
55+
56+
static inline void hv_signal_eom(void)
57+
{
58+
hv_set_vpreg(HV_REGISTER_EOM, 0);
59+
}
60+
61+
/*
62+
* Hyper-V SINT registers are numbered sequentially, so we can just
63+
* add the SINT number to the register number of SINT0
64+
*/
65+
66+
static inline void hv_set_synint_state(u32 sint_num, u64 val)
67+
{
68+
hv_set_vpreg(HV_REGISTER_SINT0 + sint_num, val);
69+
}
70+
71+
#define hv_get_synint_state(sint_num, val) \
72+
(val = hv_get_vpreg(HV_REGISTER_SINT0 + sint_num))
73+
74+
#include <asm-generic/mshyperv.h>
75+
76+
#endif

0 commit comments

Comments
 (0)