[PATCH v1 RFC 5/6] KVM: s390: initial implementation of soft facilities

From: Michael Mueller
Date: Tue May 13 2014 - 10:59:53 EST


This patch implements the new state soft_fac_bits. This state
defines which facilities are emulated in kernel and not in processor
or millicode. Currently all bits are cleared.

Signed-off-by: Michael Mueller <mimu@xxxxxxxxxxxxxxxxxx>
---
arch/s390/kvm/Makefile | 2 +-
arch/s390/kvm/kvm-s390.h | 3 +++
arch/s390/kvm/softfac.c | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 arch/s390/kvm/softfac.c

diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile
index 88aa28b..586f686 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 ibc.o
+kvm-objs += diag.o config.o gaccess.o guestdbg.o ibc.o softfac.o

obj-$(CONFIG_KVM) += kvm.o
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index 3715917..10de678 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -261,4 +261,7 @@ unsigned short kvm_s390_lowest_ibc(void);
unsigned short kvm_s390_latest_ibc(void);
bool kvm_s390_has_ibc(void);

+/* implemented in softfac.c */
+unsigned int stsfle(unsigned long *fac, unsigned long size);
+
#endif
diff --git a/arch/s390/kvm/softfac.c b/arch/s390/kvm/softfac.c
new file mode 100644
index 0000000..1c489d8
--- /dev/null
+++ b/arch/s390/kvm/softfac.c
@@ -0,0 +1,38 @@
+/*
+ * Registration of KVM emulated facilities
+ *
+ * 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 <mimu@xxxxxxxxxxxxxxxxxx>
+ */
+
+#include "kvm-s390.h"
+
+/*
+ * The soft facilities define which of the facilities are emulatable
+ * in KVM. The size must be identical to the size of the cpu facility
+ * list.
+ */
+static unsigned long soft_fac_bits[S390_ARCH_FAC_LIST_SIZE_U64];
+
+/**
+ * stsfle():
+ * store soft facility list extended, copies a subset of the
+ * soft facility list
+ * @fac address of buffer where the facilities should be stored
+ * @size number of double words + 1 to store in @fac
+ * @returns number of bytes being copied
+ */
+unsigned int stsfle(unsigned long *fac, unsigned long size)
+{
+ if (size >= S390_ARCH_FAC_LIST_SIZE_U64)
+ size = S390_ARCH_FAC_LIST_SIZE_U64 - 1;
+ size = (!test_facility(7)) ? 4 : (size + 1) * sizeof(*fac);
+ memcpy(fac, soft_fac_bits, size);
+
+ return size;
+}
--
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/