1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (C) 2023 ARM Ltd.
4  */
5 
6 #ifndef ARM_ARCH_CAPABILITIES_H
7 #define ARM_ARCH_CAPABILITIES_H
8 
9 #include <stdint.h>
10 #include <xen/sysctl.h>
11 
12 #include <xen-tools/common-macros.h>
13 
14 static inline
arch_capabilities_arm_sve(unsigned int arch_capabilities)15 unsigned int arch_capabilities_arm_sve(unsigned int arch_capabilities)
16 {
17 #if defined(__arm__) || defined(__aarch64__)
18     unsigned int sve_vl = MASK_EXTR(arch_capabilities,
19                                     XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK);
20 
21     /* Vector length is divided by 128 before storing it in arch_capabilities */
22     return sve_vl * 128U;
23 #else
24     return 0;
25 #endif
26 }
27 
28 #endif /* ARM_ARCH_CAPABILITIES_H */
29