From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkEB2-0005LU-2S for qemu-devel@nongnu.org; Tue, 13 May 2014 10:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkEAs-0001nT-25 for qemu-devel@nongnu.org; Tue, 13 May 2014 10:59:32 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:43894) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkEAr-0001n2-Qn for qemu-devel@nongnu.org; Tue, 13 May 2014 10:59:22 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 May 2014 15:59:20 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 73C7517D805A for ; Tue, 13 May 2014 15:59:56 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4DEwmSX61014152 for ; Tue, 13 May 2014 14:58:48 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 s4DEwlia000872 for ; Tue, 13 May 2014 08:58:47 -0600 From: Michael Mueller Date: Tue, 13 May 2014 16:58:32 +0200 Message-Id: <1399993114-15333-5-git-send-email-mimu@linux.vnet.ibm.com> In-Reply-To: <1399993114-15333-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1399993114-15333-1-git-send-email-mimu@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v1 RFC 4/6] KVM: s390: add ibc api 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: mimu@linux.vnet.ibm.com, Gleb Natapov , Alexander Graf , Christian Borntraeger , "Jason J. Herne" , Cornelia Huck , Paolo Bonzini , Andreas Faerber , Richard Henderson The patch addds an internal KVM API to access instruction blocking control. It offers the following functions: - has_ibc() : tests if the system offers instruction blocking control - lowest_ibc() : first level supported - latest_ibc() : latest level supported Signed-off-by: Michael Mueller Acked-by: Cornelia Huck Reviewed-by: Christian Borntraeger --- arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/ibc.c | 29 +++++++++++++++++++++++++++++ arch/s390/kvm/kvm-s390.h | 8 ++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 arch/s390/kvm/ibc.c diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index f0072bc..88aa28b 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -12,6 +12,6 @@ common-objs = $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/async_pf.o $(KVM)/irqch ccflags-y := -Ivirt/kvm -Iarch/s390/kvm kvm-objs := $(common-objs) kvm-s390.o intercept.o interrupt.o priv.o sigp.o -kvm-objs += diag.o config.o gaccess.o guestdbg.o +kvm-objs += diag.o config.o gaccess.o guestdbg.o ibc.o obj-$(CONFIG_KVM) += kvm.o diff --git a/arch/s390/kvm/ibc.c b/arch/s390/kvm/ibc.c new file mode 100644 index 0000000..8171b02 --- /dev/null +++ b/arch/s390/kvm/ibc.c @@ -0,0 +1,29 @@ +/* + * Instruction Blocking related functions + * + * Copyright IBM Corp. 2014 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (version 2 only) + * as published by the Free Software Foundation. + * + * Author(s): Michael Mueller + */ + +#include +#include "kvm-s390.h" + +unsigned short kvm_s390_lowest_ibc(void) +{ + return (sclp_get_ibc() & IBC_MODE_MASK) >> 16; +} + +unsigned short kvm_s390_latest_ibc(void) +{ + return sclp_get_ibc() & IBC_MODE_MASK; +} + +bool kvm_s390_has_ibc(void) +{ + return kvm_s390_lowest_ibc() != 0; +} diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index ecadc8a..3715917 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -32,6 +32,9 @@ int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu); #define S390_ARCH_FAC_MASK_SIZE_U64 \ (S390_ARCH_FAC_MASK_SIZE_BYTE / sizeof(u64)) +/* mask non defined IBC bits from SCLP read data */ +#define IBC_MODE_MASK 0x0fff0fffu + /* Transactional Memory Execution related macros */ #define IS_TE_ENABLED(vcpu) ((vcpu->arch.sie_block->ecb & 0x10)) #define TDB_FORMAT1 1 @@ -253,4 +256,9 @@ void kvm_s390_clear_bp_data(struct kvm_vcpu *vcpu); void kvm_s390_prepare_debug_exit(struct kvm_vcpu *vcpu); void kvm_s390_handle_per_event(struct kvm_vcpu *vcpu); +/* implemented in ibc.c */ +unsigned short kvm_s390_lowest_ibc(void); +unsigned short kvm_s390_latest_ibc(void); +bool kvm_s390_has_ibc(void); + #endif -- 1.8.3.1