qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v1 RFC 4/6] KVM: s390: add ibc api


From: Michael Mueller
Subject: [Qemu-devel] [PATCH v1 RFC 4/6] KVM: s390: add ibc api
Date: Tue, 13 May 2014 16:58:32 +0200

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 <address@hidden>
Acked-by: Cornelia Huck <address@hidden>
Reviewed-by: Christian Borntraeger <address@hidden>
---
 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 <address@hidden>
+ */
+
+#include <asm/sclp.h>
+#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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]