From patchwork Mon Mar 30 14:28:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Mueller X-Patchwork-Id: 456204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B72A214008F for ; Tue, 31 Mar 2015 01:31:49 +1100 (AEDT) Received: from localhost ([::1]:34296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcajD-0001rt-Rb for incoming@patchwork.ozlabs.org; Mon, 30 Mar 2015 10:31:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcagR-00059T-AV for qemu-devel@nongnu.org; Mon, 30 Mar 2015 10:29:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YcagK-0006lr-60 for qemu-devel@nongnu.org; Mon, 30 Mar 2015 10:28:55 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:40417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcagJ-0006la-Tv for qemu-devel@nongnu.org; Mon, 30 Mar 2015 10:28:48 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 30 Mar 2015 15:28:46 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 30 Mar 2015 15:28:44 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 6AEF72190056 for ; Mon, 30 Mar 2015 15:28:32 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2UESin564159938 for ; Mon, 30 Mar 2015 14:28:44 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 t2UEShvX015232 for ; Mon, 30 Mar 2015 08:28:44 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t2UESdiA014992; Mon, 30 Mar 2015 08:28:43 -0600 From: Michael Mueller To: qemu-devel@nongnu.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 30 Mar 2015 16:28:21 +0200 Message-Id: <1427725708-52100-9-git-send-email-mimu@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.4 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> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15033014-0021-0000-0000-000003684D4F X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.111 Cc: Eduardo Habkost , Gleb Natapov , Alexander Graf , Christian Borntraeger , Daniel Hansel , "Jason J. Herne" , Cornelia Huck , Paolo Bonzini , Richard Henderson , Andreas Faerber , Michael Mueller Subject: [Qemu-devel] [PATCH v4 08/15] target-s390x: Add KVM VM attribute interface for cpu models X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The patch implements routines to set and retrieve processor configuration data and to retrieve machine configuration data. The machine related data is used together with the cpu model facility lists to determine the list of supported cpu models of this host. The above mentioned routines have QEMU trace point instrumentation. Signed-off-by: Michael Mueller --- target-s390x/cpu-models.h | 34 ++++++++++++++++++++ target-s390x/kvm.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 3 ++ 3 files changed, 116 insertions(+) diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h index 562464f..3b75236 100644 --- a/target-s390x/cpu-models.h +++ b/target-s390x/cpu-models.h @@ -46,6 +46,40 @@ typedef struct S390CPUAlias { char *model; } S390CPUAlias; +typedef struct S390ProcessorProps { + uint64_t cpuid; + uint16_t ibc; + uint8_t pad[6]; + uint64_t fac_list[FAC_LIST_ARCH_S390_SIZE_UINT64]; +} S390ProcessorProps; + +typedef struct S390MachineProps { + uint64_t cpuid; + uint32_t ibc_range; + uint8_t pad[4]; + uint64_t fac_list_mask[FAC_LIST_ARCH_S390_SIZE_UINT64]; + uint64_t fac_list[FAC_LIST_ARCH_S390_SIZE_UINT64]; +} S390MachineProps; + +#ifdef CONFIG_KVM +int kvm_s390_get_processor_props(S390ProcessorProps *prop); +int kvm_s390_set_processor_props(S390ProcessorProps *prop); +bool kvm_s390_cpu_classes_initialized(void); +#else +static inline int kvm_s390_get_processor_props(S390ProcessorProps *prop) +{ + return -ENOSYS; +} +static inline int kvm_s390_set_processor_props(S390ProcessorProps *prop) +{ + return -ENOSYS; +} +static inline bool kvm_s390_cpu_classes_initialized(void) +{ + return false; +} +#endif + /* * bits 0-7 : CMOS generation * bits 8-9 : reserved diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index b48c643..bde4aaa 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -44,6 +44,7 @@ #include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-bus.h" #include "hw/s390x/ipl.h" +#include "cpu-models.h" /* #define DEBUG_KVM */ @@ -122,6 +123,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { static int cap_sync_regs; static int cap_async_pf; +static bool cpu_classes_initialized; static void *legacy_s390_alloc(size_t size, uint64_t *align); @@ -242,6 +244,59 @@ static void kvm_s390_init_crypto(void) kvm_s390_init_dea_kw(); } +static int cpu_model_get(KVMState *s, uint64_t attr, uint64_t addr) +{ + int rc = -ENOSYS; + struct kvm_device_attr dev_attr = { + .group = KVM_S390_VM_CPU_MODEL, + .attr = attr, + .addr = addr, + }; + + if (kvm_vm_check_attr(s, dev_attr.group, dev_attr.attr)) { + rc = kvm_vm_ioctl(s, KVM_GET_DEVICE_ATTR, &dev_attr); + } + + return rc; +} + +static int cpu_model_set(KVMState *s, uint64_t attr, uint64_t addr) +{ + int rc = -ENOSYS; + struct kvm_device_attr dev_attr = { + .group = KVM_S390_VM_CPU_MODEL, + .attr = attr, + .addr = addr, + }; + + if (kvm_vm_check_attr(s, dev_attr.group, dev_attr.attr)) { + rc = kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &dev_attr); + } + + return rc; +} + +static int kvm_s390_get_machine_props(KVMState *s, S390MachineProps *prop) +{ + int rc = -EFAULT; + + if (s) { + rc = cpu_model_get(s, KVM_S390_VM_CPU_MACHINE, (uint64_t) prop); + } + trace_kvm_get_machine_props(rc, prop->cpuid, prop->ibc_range); + + return rc; +} + +static void kvm_setup_cpu_classes(KVMState *s) +{ + S390MachineProps mach; + + if (!kvm_s390_get_machine_props(s, &mach)) { + cpu_classes_initialized = false; + } +} + int kvm_arch_init(MachineState *ms, KVMState *s) { cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS); @@ -255,6 +310,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } kvm_vm_enable_cap(s, KVM_CAP_S390_USER_SIGP, 0); + kvm_setup_cpu_classes(s); return 0; } @@ -1940,3 +1996,26 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, route->u.adapter.adapter_id = pbdev->routes.adapter.adapter_id; return 0; } + +int kvm_s390_get_processor_props(S390ProcessorProps *prop) +{ + int rc; + + rc = cpu_model_get(kvm_state, KVM_S390_VM_CPU_PROCESSOR, (uint64_t) prop); + trace_kvm_get_processor_props(rc, prop->cpuid, prop->ibc); + return rc; +} + +int kvm_s390_set_processor_props(S390ProcessorProps *prop) +{ + int rc; + + rc = cpu_model_set(kvm_state, KVM_S390_VM_CPU_PROCESSOR, (uint64_t) prop); + trace_kvm_set_processor_props(rc); + return rc; +} + +bool kvm_s390_cpu_classes_initialized(void) +{ + return cpu_classes_initialized; +} diff --git a/trace-events b/trace-events index 30eba92..2f1d734 100644 --- a/trace-events +++ b/trace-events @@ -1582,6 +1582,9 @@ kvm_enable_cmma(int rc) "CMMA: enabling with result code %d" kvm_clear_cmma(int rc) "CMMA: clearing with result code %d" kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) "Warning: Unable to set cpu %d state %" PRIu8 " to KVM: %s" kvm_sigp_finished(uint8_t order, int cpu_index, int dst_index, int cc) "SIGP: Finished order %u on cpu %d -> cpu %d with cc=%d" +kvm_get_machine_props(int rc, uint64_t cpuid, uint16_t ibc) "CPU-MODEL: fetching machine properties rc=%d cpuid=0x%"PRIx64" ibc=0x%"PRIx16 +kvm_get_processor_props(int rc, uint64_t cpuid, uint32_t ibc_range) "CPU-MODEL: fetching processor properties rc=%d cpuid=0x%"PRIx64" ibc_range=0x%"PRIx32 +kvm_set_processor_props(int rc) "CPU-MODEL: requesting processor properties rc=%d" # hw/dma/i8257.c i8257_unregistered_dma(int nchan, int dma_pos, int dma_len) "unregistered DMA channel used nchan=%d dma_pos=%d dma_len=%d"