From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmkQR-0007sY-KP for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmkQN-00019f-Kt for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:54:23 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:58696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmkQN-00019V-CL for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:54:19 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Apr 2015 15:54:18 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id A4F5C17D805D for ; Mon, 27 Apr 2015 15:54:49 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3REs8tE36765700 for ; Mon, 27 Apr 2015 14:54:08 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t3REs6wl025290 for ; Mon, 27 Apr 2015 08:54:08 -0600 From: Michael Mueller Date: Mon, 27 Apr 2015 16:53:30 +0200 Message-Id: <1430146411-34632-17-git-send-email-mimu@linux.vnet.ibm.com> In-Reply-To: <1430146411-34632-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1430146411-34632-1-git-send-email-mimu@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v6 16/17] target-s390x: Introduce S390 CPU facility test routine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Gleb Natapov , Alexander Graf , Christian Borntraeger , Daniel Hansel , "Jason J. Herne" , Cornelia Huck , Paolo Bonzini , Richard Henderson , Andreas Faerber , Michael Mueller The patch introduces routine s390_facility_test() which allows to verify if a specific facility bit is set. Signed-off-by: Michael Mueller Acked-by: Christian Borntraeger --- 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