[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 16/17] target-s390x: Introduce S390 CPU facility
From: |
Michael Mueller |
Subject: |
[Qemu-devel] [PATCH v6 16/17] target-s390x: Introduce S390 CPU facility test routine |
Date: |
Mon, 27 Apr 2015 16:53:30 +0200 |
The patch introduces routine s390_facility_test() which allows to
verify if a specific facility bit is set.
Signed-off-by: Michael Mueller <address@hidden>
Acked-by: Christian Borntraeger <address@hidden>
---
target-s390x/cpu-models.c | 29 +++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index 7efb3e7..b70b7e1 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -715,3 +715,32 @@ void s390_cpu_model_init(S390CPUClass *cc)
kvm_s390_set_processor_props(&proc);
}
}
+
+static inline int test_facility(uint64_t *fac_list, uint16_t nr)
+{
+ uint16_t word = nr / BITS_PER_LONG;
+ uint16_t be_bit = (BITS_PER_LONG - 1) - (nr % BITS_PER_LONG);
+
+ return (nr < FAC_LIST_CPU_S390_SIZE_UINT1) ?
+ (fac_list[word] >> be_bit) & __UINT64_C(1) : 0;
+}
+
+/**
+ * s390_test_facility:
+ * @nr: facility bit number to test
+ * @cc: cpu class to test
+ *
+ * The functions tests if the cpu facility identified by bit @nr is available
+ * to the cpu class @cc.
+ *
+ * Returns: a boolean value.
+ *
+ * Since: 2.4
+ */
+bool s390_test_facility(S390CPUClass *cc, uint16_t nr)
+{
+ if (!cc) {
+ return false;
+ }
+ return test_facility(cc->fac_list[ACCEL_CURRENT], nr) ? true : false;
+}
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index 76673f4..23242aa 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -93,6 +93,7 @@ bool s390_cpu_classes_initialized(void);
uint64_t *s390_fac_list_mask_by_machine(const char *name);
uint64_t *s390_current_fac_list_mask(void);
void s390_cpu_model_init(S390CPUClass *cc);
+bool s390_test_facility(S390CPUClass *cc, uint16_t nr);
#ifdef CONFIG_KVM
int kvm_s390_get_machine_props(KVMState *s, S390MachineProps *prop);
--
1.8.3.1
- [Qemu-devel] [PATCH v6 09/17] target-s390x: Define S390 CPU model specific facility lists, (continued)
- [Qemu-devel] [PATCH v6 09/17] target-s390x: Define S390 CPU model specific facility lists, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 08/17] target-s390x: Introduce S390 CPU models, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 07/17] target-s390x: Generate facility defines per S390 CPU model, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 10/17] target-s390x: Add S390 CPU model alias definition routines, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 11/17] target-s390x: Add KVM VM attribute interface for S390 CPU models, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 14/17] target-s390x: Initialize S390 CPU model name in CPUState, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 15/17] target-s390x: Extend arch specific QMP command query-cpu-definitions, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 13/17] target-s390x: Prepare accelerator during S390 CPU object realization, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 12/17] target-s390x: Add S390 CPU class initialization routines, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 17/17] target-s390x: Enable S390 CPU model usage, Michael Mueller, 2015/04/27
- [Qemu-devel] [PATCH v6 16/17] target-s390x: Introduce S390 CPU facility test routine,
Michael Mueller <=