Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/google/cpu_features.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarquitos0119 <111894523+marquitos0119@users.noreply.github.com>2022-11-02 11:38:13 +0300
committerGitHub <noreply@github.com>2022-11-02 11:38:13 +0300
commit981fbe391454da866f1df57be72c4441b6396117 (patch)
treeccd7454f29a88b249e0188d718dffeb58e57bffb /include
parentbddcc3721c7ab1f88094617fb28572b771e77d6f (diff)
S390X Support (#274)
* support for s390x * added z15 T01, T02 model checking * removed z15 checking * removed empty strings * added s390x unit tests * added reference url for hwcaps * moved documentation to S390XFeatures struct, updated copyright date, removed unused include statement * changed num_processors to int * removed newlines from test inputs * scripts: Add bootlin s390x support * cmake(ci): Add s390x support * ci: Add s390x workflow Co-authored-by: Marcos <marcos.araque.fiallos@ibm.com> Co-authored-by: Corentin Le Molgat <corentinl@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/cpu_features_macros.h4
-rw-r--r--include/cpuinfo_s390x.h108
-rw-r--r--include/internal/hwcaps.h28
3 files changed, 140 insertions, 0 deletions
diff --git a/include/cpu_features_macros.h b/include/cpu_features_macros.h
index 09f8297..b759220 100644
--- a/include/cpu_features_macros.h
+++ b/include/cpu_features_macros.h
@@ -63,6 +63,10 @@
#define CPU_FEATURES_ARCH_PPC
#endif
+#if defined(__s390x__)
+#define CPU_FEATURES_ARCH_S390X
+#endif
+
#if defined(__riscv)
#define CPU_FEATURES_ARCH_RISCV
#endif
diff --git a/include/cpuinfo_s390x.h b/include/cpuinfo_s390x.h
new file mode 100644
index 0000000..48864de
--- /dev/null
+++ b/include/cpuinfo_s390x.h
@@ -0,0 +1,108 @@
+// Copyright 2022 IBM
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef CPU_FEATURES_INCLUDE_CPUINFO_S390X_H_
+#define CPU_FEATURES_INCLUDE_CPUINFO_S390X_H_
+
+#include "cpu_features_cache_info.h"
+#include "cpu_features_macros.h"
+
+CPU_FEATURES_START_CPP_NAMESPACE
+
+typedef struct {
+ int esan3: 1; // instructions named N3, "backported" to esa-mode
+ int zarch: 1; // z/Architecture mode active
+ int stfle: 1; // store-facility-list-extended
+ int msa: 1; // message-security assist
+ int ldisp: 1; // long-displacement
+ int eimm: 1; // extended-immediate
+ int dfp: 1; // decimal floating point & perform floating point operation
+ int edat: 1; // huge page support
+ int etf3eh: 1; // extended-translation facility 3 enhancement
+ int highgprs: 1; // 64-bit register support for 31-bit processes
+ int te: 1; // transactional execution
+ int vx: 1; // vector extension facility
+ int vxd: 1; // vector-packed-decimal facility
+ int vxe: 1; // vector-enhancement facility 1
+ int gs: 1; // guarded-storage facility
+ int vxe2: 1; // vector-enhancements facility 2
+ int vxp: 1; // vector-packed-decimal-enhancement facility
+ int sort: 1; // enhanced-sort facility
+ int dflt: 1; // deflate-conversion facility
+ int vxp2: 1; // vector-packed-decimal-enhancement facility 2
+ int nnpa: 1; // neural network processing assist facility
+ int pcimio: 1; // PCI mio facility
+ int sie: 1; // virtualization support
+
+ // Make sure to update S390XFeaturesEnum below if you add a field here.
+} S390XFeatures;
+
+typedef struct {
+ S390XFeatures features;
+} S390XInfo;
+
+S390XInfo GetS390XInfo(void);
+
+typedef struct {
+ char platform[64]; // 0 terminated string
+} S390XPlatformTypeStrings;
+
+typedef struct {
+ int num_processors; // -1 if N/A
+ S390XPlatformTypeStrings type;
+} S390XPlatformStrings;
+
+S390XPlatformStrings GetS390XPlatformStrings(void);
+
+////////////////////////////////////////////////////////////////////////////////
+// Introspection functions
+
+typedef enum {
+ S390_ESAN3,
+ S390_ZARCH,
+ S390_STFLE,
+ S390_MSA,
+ S390_LDISP,
+ S390_EIMM,
+ S390_DFP,
+ S390_EDAT,
+ S390_ETF3EH,
+ S390_HIGHGPRS,
+ S390_TE,
+ S390_VX,
+ S390_VXD,
+ S390_VXE,
+ S390_GS,
+ S390_VXE2,
+ S390_VXP,
+ S390_SORT,
+ S390_DFLT,
+ S390_VXP2,
+ S390_NNPA,
+ S390_PCIMIO,
+ S390_SIE,
+ S390X_LAST_,
+} S390XFeaturesEnum;
+
+int GetS390XFeaturesEnumValue(const S390XFeatures* features, S390XFeaturesEnum value);
+
+const char* GetS390XFeaturesEnumName(S390XFeaturesEnum);
+
+CPU_FEATURES_END_CPP_NAMESPACE
+
+#if !defined(CPU_FEATURES_ARCH_S390X)
+#error "Including cpuinfo_s390x.h from a non-s390x target."
+#endif
+
+#endif // CPU_FEATURES_INCLUDE_CPUINFO_S390X_H_
diff --git a/include/internal/hwcaps.h b/include/internal/hwcaps.h
index f916b81..5030582 100644
--- a/include/internal/hwcaps.h
+++ b/include/internal/hwcaps.h
@@ -176,6 +176,34 @@ CPU_FEATURES_START_CPP_NAMESPACE
#define PPC_FEATURE2_HTM_NO_SUSPEND 0x00080000
#endif
+// https://elixir.bootlin.com/linux/v6.0-rc6/source/arch/s390/include/asm/elf.h
+#define HWCAP_S390_ESAN3 1
+#define HWCAP_S390_ZARCH 2
+#define HWCAP_S390_STFLE 4
+#define HWCAP_S390_MSA 8
+#define HWCAP_S390_LDISP 16
+#define HWCAP_S390_EIMM 32
+#define HWCAP_S390_DFP 64
+#define HWCAP_S390_HPAGE 128
+#define HWCAP_S390_ETF3EH 256
+#define HWCAP_S390_HIGH_GPRS 512
+#define HWCAP_S390_TE 1024
+#define HWCAP_S390_VX 2048
+#define HWCAP_S390_VXRS HWCAP_S390_VX
+#define HWCAP_S390_VXD 4096
+#define HWCAP_S390_VXRS_BCD HWCAP_S390_VXD
+#define HWCAP_S390_VXE 8192
+#define HWCAP_S390_VXRS_EXT HWCAP_S390_VXE
+#define HWCAP_S390_GS 16384
+#define HWCAP_S390_VXRS_EXT2 32768
+#define HWCAP_S390_VXRS_PDE 65536
+#define HWCAP_S390_SORT 131072
+#define HWCAP_S390_DFLT 262144
+#define HWCAP_S390_VXRS_PDE2 524288
+#define HWCAP_S390_NNPA 1048576
+#define HWCAP_S390_PCI_MIO 2097152
+#define HWCAP_S390_SIE 4194304
+
// https://elixir.bootlin.com/linux/latest/source/arch/riscv/include/uapi/asm/hwcap.h
#define RISCV_HWCAP_A (1UL << ('A' - 'A'))
#define RISCV_HWCAP_C (1UL << ('C' - 'A'))