From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcagS-0005BH-88 for qemu-devel@nongnu.org; Mon, 30 Mar 2015 10:29:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YcagM-0006o1-W5 for qemu-devel@nongnu.org; Mon, 30 Mar 2015 10:28:56 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:44350) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcagM-0006nX-Nj for qemu-devel@nongnu.org; Mon, 30 Mar 2015 10:28:50 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 30 Mar 2015 15:28:49 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id CC59217D8068 for ; Mon, 30 Mar 2015 15:29:16 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2UESlM963963342 for ; Mon, 30 Mar 2015 14:28:47 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2UESkIE015420 for ; Mon, 30 Mar 2015 08:28:46 -0600 From: Michael Mueller Date: Mon, 30 Mar 2015 16:28:27 +0200 Message-Id: <1427725708-52100-15-git-send-email-mimu@linux.vnet.ibm.com> In-Reply-To: <1427725708-52100-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1427725708-52100-1-git-send-email-mimu@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v4 14/15] target-s390x: Introduce facility test routine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.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 a specific facility bit is set. Signed-off-by: Michael Mueller --- 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 aba44dd..a9f7372 100644 --- a/target-s390x/cpu-models.c +++ b/target-s390x/cpu-models.c @@ -736,3 +736,32 @@ bool s390_cpu_models_used(void) { return cpu_models_used; } + +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 4734c58..eb0476f 100644 --- a/target-s390x/cpu-models.h +++ b/target-s390x/cpu-models.h @@ -120,6 +120,7 @@ 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_cpu_models_used(void); +bool s390_test_facility(S390CPUClass *cc, uint16_t nr); extern uint64_t qemu_s390_fac_list_mask[]; -- 1.8.3.1