From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864558152334.6336843115761; Wed, 12 Jul 2017 06:02:38 -0700 (PDT) Received: from localhost ([::1]:52635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHHj-00020K-Hs for importer@patchew.org; Wed, 12 Jul 2017 09:02:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDL-0006Vm-2R for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDG-0000zh-8F for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:32833) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDF-0000ys-VB for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:54 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCs5vO063414 for ; Wed, 12 Jul 2017 08:57:51 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncjassut-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:51 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:49 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:46 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvklp3670422; Wed, 12 Jul 2017 12:57:46 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D9B952049; Wed, 12 Jul 2017 12:54:05 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 4CCD152047; Wed, 12 Jul 2017 12:54:05 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id B3C6120F69D; Wed, 12 Jul 2017 14:57:45 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:35 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0008-0000-0000-0000047F703F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0009-0000-0000-00001E0A9174 Message-Id: <1499864265-144136-2-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 01/11] s390x/kvm: Rework cmma management X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Janosch Frank , Cornelia Huck , Alexander Graf , Christian Borntraeger , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Janosch Frank Let's keep track of cmma enablement and move the mem_path check into the actual enablement. This now also warns users that do not use cpu-models about disabled cmma when using huge pages. Signed-off-by: Janosch Frank Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- target/s390x/cpu.h | 1 + target/s390x/kvm.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index bdb9bdb..8ab75c0 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -1158,6 +1158,7 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *no= tifier, uint32_t sch, int vq, bool assign); int kvm_s390_cpu_restart(S390CPU *cpu); int kvm_s390_get_memslot_count(KVMState *s); +int kvm_s390_cmma_active(void); void kvm_s390_cmma_reset(void); int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state); void kvm_s390_reset_vcpu(S390CPU *cpu); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index a3d0019..7a2a7c0 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -140,6 +140,8 @@ static int cap_mem_op; static int cap_s390_irq; static int cap_ri; =20 +static int active_cmma; + static void *legacy_s390_alloc(size_t size, uint64_t *align); =20 static int kvm_s390_query_mem_limit(KVMState *s, uint64_t *memory_limit) @@ -177,6 +179,11 @@ int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_l= imit, uint64_t *hw_limit) return kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr); } =20 +int kvm_s390_cmma_active(void) +{ + return active_cmma; +} + static bool kvm_s390_cmma_available(void) { static bool initialized, value; @@ -197,7 +204,7 @@ void kvm_s390_cmma_reset(void) .attr =3D KVM_S390_VM_MEM_CLR_CMMA, }; =20 - if (mem_path || !kvm_s390_cmma_available()) { + if (!kvm_s390_cmma_active()) { return; } =20 @@ -213,7 +220,13 @@ static void kvm_s390_enable_cmma(void) .attr =3D KVM_S390_VM_MEM_ENABLE_CMMA, }; =20 + if (mem_path) { + error_report("Warning: CMM will not be enabled because it is not " + "compatible to hugetlbfs."); + return; + } rc =3D kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); + active_cmma =3D !rc; trace_kvm_enable_cmma(rc); } =20 @@ -2641,7 +2654,7 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mod= el, Error **errp) =20 if (!model) { /* compatibility handling if cpu models are disabled */ - if (kvm_s390_cmma_available() && !mem_path) { + if (kvm_s390_cmma_available()) { kvm_s390_enable_cmma(); } return; @@ -2672,13 +2685,8 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mo= del, Error **errp) error_setg(errp, "KVM: Error configuring CPU subfunctions: %d", rc= ); return; } - /* enable CMM via CMMA - disable on hugetlbfs */ + /* enable CMM via CMMA */ if (test_bit(S390_FEAT_CMM, model->features)) { - if (mem_path) { - error_report("Warning: CMM will not be enabled because it is n= ot " - "compatible to hugetlbfs."); - } else { - kvm_s390_enable_cmma(); - } + kvm_s390_enable_cmma(); } } --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499865646997865.4422846328627; Wed, 12 Jul 2017 06:20:46 -0700 (PDT) Received: from localhost ([::1]:52808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHZL-00013x-A3 for importer@patchew.org; Wed, 12 Jul 2017 09:20:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDL-0006Vv-6R for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDG-0000zm-9N for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDF-0000yw-VJ for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:54 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCsXAe006433 for ; Wed, 12 Jul 2017 08:57:52 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncjb9uw1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:51 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:49 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:46 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvkJH40894688; Wed, 12 Jul 2017 12:57:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28FC4AE051; Wed, 12 Jul 2017 13:54:24 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DB97AE04D; Wed, 12 Jul 2017 13:54:24 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:54:24 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 0DFDE20F69C; Wed, 12 Jul 2017 14:57:46 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:36 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0008-0000-0000-0000047F7040 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0009-0000-0000-00001E0A9175 Message-Id: <1499864265-144136-3-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 02/11] linux-headers: update to 4.13-rc0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Cornelia Huck , Alexander Graf , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" commit af3c8d98508d37541d4bf57f13a984a7f73a328c Merge tag 'drm-for-v4.13' of git://people.freedesktop.org/~airlied/linux will be replaced with a header-sync against v4.13-rc1 Signed-off-by: Christian Borntraeger --- include/standard-headers/asm-x86/hyperv.h | 21 +++++++------ include/standard-headers/linux/input-event-codes.h | 1 + include/standard-headers/linux/pci_regs.h | 1 + linux-headers/asm-arm/kvm.h | 8 +++++ linux-headers/asm-arm64/kvm.h | 3 ++ linux-headers/asm-powerpc/kvm.h | 6 ++++ linux-headers/asm-s390/kvm.h | 12 ++++++++ linux-headers/linux/kvm.h | 35 ++++++++++++++++++= ++++ 8 files changed, 78 insertions(+), 9 deletions(-) diff --git a/include/standard-headers/asm-x86/hyperv.h b/include/standard-h= eaders/asm-x86/hyperv.h index d0c6e0a..fac7651 100644 --- a/include/standard-headers/asm-x86/hyperv.h +++ b/include/standard-headers/asm-x86/hyperv.h @@ -34,16 +34,10 @@ #define HV_X64_MSR_REFERENCE_TSC 0x40000021 =20 /* - * There is a single feature flag that signifies the presence of the MSR - * that can be used to retrieve both the local APIC Timer frequency as - * well as the TSC frequency. + * There is a single feature flag that signifies if the partition has acce= ss + * to MSRs with local APIC and TSC frequencies. */ - -/* Local APIC timer frequency MSR (HV_X64_MSR_APIC_FREQUENCY) is available= */ -#define HV_X64_MSR_APIC_FREQUENCY_AVAILABLE (1 << 11) - -/* TSC frequency MSR (HV_X64_MSR_TSC_FREQUENCY) is available */ -#define HV_X64_MSR_TSC_FREQUENCY_AVAILABLE (1 << 11) +#define HV_X64_ACCESS_FREQUENCY_MSRS (1 << 11) =20 /* * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM @@ -73,6 +67,9 @@ */ #define HV_X64_MSR_STAT_PAGES_AVAILABLE (1 << 8) =20 +/* Frequency MSRs available */ +#define HV_FEATURE_FREQUENCY_MSRS_AVAILABLE (1 << 8) + /* Crash MSR available */ #define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE (1 << 10) =20 @@ -153,6 +150,12 @@ #define HV_X64_DEPRECATING_AEOI_RECOMMENDED (1 << 9) =20 /* + * HV_VP_SET available + */ +#define HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED (1 << 11) + + +/* * Crash notification flag. */ #define HV_CRASH_CTL_CRASH_NOTIFY (1ULL << 63) diff --git a/include/standard-headers/linux/input-event-codes.h b/include/s= tandard-headers/linux/input-event-codes.h index 29d463a..2fa0f4e 100644 --- a/include/standard-headers/linux/input-event-codes.h +++ b/include/standard-headers/linux/input-event-codes.h @@ -600,6 +600,7 @@ #define KEY_APPSELECT 0x244 /* AL Select Task/Application */ #define KEY_SCREENSAVER 0x245 /* AL Screen Saver */ #define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */ +#define KEY_ASSISTANT 0x247 /* AL Context-aware desktop assistant */ =20 #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index d56bb00..c22d3eb 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -517,6 +517,7 @@ #define PCI_EXP_LNKCAP_SLS 0x0000000f /* Supported Link Speeds */ #define PCI_EXP_LNKCAP_SLS_2_5GB 0x00000001 /* LNKCAP2 SLS Vector bit 0 */ #define PCI_EXP_LNKCAP_SLS_5_0GB 0x00000002 /* LNKCAP2 SLS Vector bit 1 */ +#define PCI_EXP_LNKCAP_SLS_8_0GB 0x00000003 /* LNKCAP2 SLS Vector bit 2 */ #define PCI_EXP_LNKCAP_MLW 0x000003f0 /* Maximum Link Width */ #define PCI_EXP_LNKCAP_ASPMS 0x00000c00 /* ASPM Support */ #define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */ diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h index 7258a00..fa9fae8 100644 --- a/linux-headers/asm-arm/kvm.h +++ b/linux-headers/asm-arm/kvm.h @@ -203,6 +203,14 @@ struct kvm_arch_memory_slot { #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INTID_MASK 0x3ff #define VGIC_LEVEL_INFO_LINE_LEVEL 0 =20 +/* Device Control API on vcpu fd */ +#define KVM_ARM_VCPU_PMU_V3_CTRL 0 +#define KVM_ARM_VCPU_PMU_V3_IRQ 0 +#define KVM_ARM_VCPU_PMU_V3_INIT 1 +#define KVM_ARM_VCPU_TIMER_CTRL 1 +#define KVM_ARM_VCPU_TIMER_IRQ_VTIMER 0 +#define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1 + #define KVM_DEV_ARM_VGIC_CTRL_INIT 0 #define KVM_DEV_ARM_ITS_SAVE_TABLES 1 #define KVM_DEV_ARM_ITS_RESTORE_TABLES 2 diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index 31bb1dd..d254700 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -232,6 +232,9 @@ struct kvm_arch_memory_slot { #define KVM_ARM_VCPU_PMU_V3_CTRL 0 #define KVM_ARM_VCPU_PMU_V3_IRQ 0 #define KVM_ARM_VCPU_PMU_V3_INIT 1 +#define KVM_ARM_VCPU_TIMER_CTRL 1 +#define KVM_ARM_VCPU_TIMER_IRQ_VTIMER 0 +#define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1 =20 /* KVM_IRQ_LINE irq field index values */ #define KVM_ARM_IRQ_TYPE_SHIFT 24 diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kv= m.h index 07fbeb9..8cf8f0c 100644 --- a/linux-headers/asm-powerpc/kvm.h +++ b/linux-headers/asm-powerpc/kvm.h @@ -60,6 +60,12 @@ struct kvm_regs { =20 #define KVM_SREGS_E_FSL_PIDn (1 << 0) /* PID1/PID2 */ =20 +/* flags for kvm_run.flags */ +#define KVM_RUN_PPC_NMI_DISP_MASK (3 << 0) +#define KVM_RUN_PPC_NMI_DISP_FULLY_RECOV (1 << 0) +#define KVM_RUN_PPC_NMI_DISP_LIMITED_RECOV (2 << 0) +#define KVM_RUN_PPC_NMI_DISP_NOT_RECOV (3 << 0) + /* * Feature bits indicate which sections of the sregs struct are valid, * both in KVM_GET_SREGS and KVM_SET_SREGS. On KVM_SET_SREGS, registers diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index 243f195..8387d71 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -28,6 +28,7 @@ #define KVM_DEV_FLIC_CLEAR_IO_IRQ 8 #define KVM_DEV_FLIC_AISM 9 #define KVM_DEV_FLIC_AIRQ_INJECT 10 +#define KVM_DEV_FLIC_AISM_ALL 11 /* * We can have up to 4*64k pending subchannels + 8 adapter interrupts, * as well as up to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupt= s. @@ -53,6 +54,11 @@ struct kvm_s390_ais_req { __u16 mode; }; =20 +struct kvm_s390_ais_all { + __u8 simm; + __u8 nimm; +}; + #define KVM_S390_IO_ADAPTER_MASK 1 #define KVM_S390_IO_ADAPTER_MAP 2 #define KVM_S390_IO_ADAPTER_UNMAP 3 @@ -70,6 +76,7 @@ struct kvm_s390_io_adapter_req { #define KVM_S390_VM_TOD 1 #define KVM_S390_VM_CRYPTO 2 #define KVM_S390_VM_CPU_MODEL 3 +#define KVM_S390_VM_MIGRATION 4 =20 /* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0 @@ -151,6 +158,11 @@ struct kvm_s390_vm_cpu_subfunc { #define KVM_S390_VM_CRYPTO_DISABLE_AES_KW 2 #define KVM_S390_VM_CRYPTO_DISABLE_DEA_KW 3 =20 +/* kvm attributes for migration mode */ +#define KVM_S390_VM_MIGRATION_STOP 0 +#define KVM_S390_VM_MIGRATION_START 1 +#define KVM_S390_VM_MIGRATION_STATUS 2 + /* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs { /* general purpose regs for s390 */ diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index d2892da..43e2d82 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -155,6 +155,35 @@ struct kvm_s390_skeys { __u32 reserved[9]; }; =20 +#define KVM_S390_CMMA_PEEK (1 << 0) + +/** + * kvm_s390_cmma_log - Used for CMMA migration. + * + * Used both for input and output. + * + * @start_gfn: Guest page number to start from. + * @count: Size of the result buffer. + * @flags: Control operation mode via KVM_S390_CMMA_* flags + * @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty + * pages are still remaining. + * @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set + * in the PGSTE. + * @values: Pointer to the values buffer. + * + * Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls. + */ +struct kvm_s390_cmma_log { + __u64 start_gfn; + __u32 count; + __u32 flags; + union { + __u64 remaining; + __u64 mask; + }; + __u64 values; +}; + struct kvm_hyperv_exit { #define KVM_EXIT_HYPERV_SYNIC 1 #define KVM_EXIT_HYPERV_HCALL 2 @@ -895,6 +924,9 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_SPAPR_TCE_VFIO 142 #define KVM_CAP_X86_GUEST_MWAIT 143 #define KVM_CAP_ARM_USER_IRQ 144 +#define KVM_CAP_S390_CMMA_MIGRATION 145 +#define KVM_CAP_PPC_FWNMI 146 +#define KVM_CAP_PPC_SMT_POSSIBLE 147 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -1318,6 +1350,9 @@ struct kvm_s390_ucas_mapping { #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_sta= te) /* Available with KVM_CAP_X86_SMM */ #define KVM_SMI _IO(KVMIO, 0xb7) +/* Available with KVM_CAP_S390_CMMA_MIGRATION */ +#define KVM_S390_GET_CMMA_BITS _IOW(KVMIO, 0xb8, struct kvm_s390_cmma= _log) +#define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma= _log) =20 #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149986521220874.32538114886586; Wed, 12 Jul 2017 06:13:32 -0700 (PDT) Received: from localhost ([::1]:52686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHSG-0002qx-Kk for importer@patchew.org; Wed, 12 Jul 2017 09:13:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDL-0006WO-Lk for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDH-00010u-H3 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59372) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDH-0000zt-4B for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:55 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCs4Ex139484 for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncj51vyh-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:51 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:47 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvkeQ40894690; Wed, 12 Jul 2017 12:57:46 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 134204C044; Wed, 12 Jul 2017 13:55:31 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC1D44C040; Wed, 12 Jul 2017 13:55:30 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:30 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 635D320F69D; Wed, 12 Jul 2017 14:57:46 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:37 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0040-0000-0000-000003C26EC3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0041-0000-0000-000025BD97EA Message-Id: <1499864265-144136-4-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 03/11] s390x/migration: Storage attributes device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Claudio Imbrenda , Cornelia Huck , Alexander Graf , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Claudio Imbrenda Storage attributes device, like we have for storage keys. Signed-off-by: Claudio Imbrenda Signed-off-by: Christian Borntraeger --- hw/s390x/Makefile.objs | 2 + hw/s390x/s390-stattrib-kvm.c | 178 +++++++++++++++++ hw/s390x/s390-stattrib.c | 348 ++++++++++++++++++++++++++++++= ++++ hw/s390x/s390-virtio-ccw.c | 10 +- include/hw/s390x/storage-attributes.h | 68 +++++++ 5 files changed, 605 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-stattrib-kvm.c create mode 100644 hw/s390x/s390-stattrib.c create mode 100644 include/hw/s390x/storage-attributes.h diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs index a8e5575..b2aade2 100644 --- a/hw/s390x/Makefile.objs +++ b/hw/s390x/Makefile.objs @@ -13,5 +13,7 @@ obj-y +=3D css-bridge.o obj-y +=3D ccw-device.o obj-y +=3D s390-pci-bus.o s390-pci-inst.o obj-y +=3D s390-skeys.o +obj-y +=3D s390-stattrib.o obj-$(CONFIG_KVM) +=3D s390-skeys-kvm.o +obj-$(CONFIG_KVM) +=3D s390-stattrib-kvm.o obj-y +=3D s390-ccw.o diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c new file mode 100644 index 0000000..2e7f144 --- /dev/null +++ b/hw/s390x/s390-stattrib-kvm.c @@ -0,0 +1,178 @@ +/* + * s390 storage attributes device -- KVM object + * + * Copyright 2016 IBM Corp. + * Author(s): Claudio Imbrenda + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#include "qemu/osdep.h" +#include "hw/boards.h" +#include "qmp-commands.h" +#include "migration/qemu-file.h" +#include "hw/s390x/storage-attributes.h" +#include "qemu/error-report.h" +#include "sysemu/kvm.h" +#include "exec/ram_addr.h" +#include "cpu.h" + +static void kvm_s390_stattrib_instance_init(Object *obj) +{ + KVMS390StAttribState *sas =3D KVM_S390_STATTRIB(obj); + + sas->still_dirty =3D 0; +} + +static int kvm_s390_stattrib_read_helper(S390StAttribState *sa, + uint64_t *start_gfn, + uint32_t count, + uint8_t *values, + uint32_t flags) +{ + KVMS390StAttribState *sas =3D KVM_S390_STATTRIB(sa); + int r; + struct kvm_s390_cmma_log clog =3D { + .values =3D (uint64_t)values, + .start_gfn =3D *start_gfn, + .count =3D count, + .flags =3D flags, + }; + + r =3D kvm_vm_ioctl(kvm_state, KVM_S390_GET_CMMA_BITS, &clog); + if (r < 0) { + error_report("Error: %s", strerror(-r)); + return r; + } + + *start_gfn =3D clog.start_gfn; + sas->still_dirty =3D clog.remaining; + return clog.count; +} + +static int kvm_s390_stattrib_get_stattr(S390StAttribState *sa, + uint64_t *start_gfn, + uint32_t count, + uint8_t *values) +{ + return kvm_s390_stattrib_read_helper(sa, start_gfn, count, values, 0); +} + +static int kvm_s390_stattrib_peek_stattr(S390StAttribState *sa, + uint64_t start_gfn, + uint32_t count, + uint8_t *values) +{ + return kvm_s390_stattrib_read_helper(sa, &start_gfn, count, values, + KVM_S390_CMMA_PEEK); +} + +static int kvm_s390_stattrib_set_stattr(S390StAttribState *sa, + uint64_t start_gfn, + uint32_t count, + uint8_t *values) +{ + KVMS390StAttribState *sas =3D KVM_S390_STATTRIB(sa); + MachineState *machine =3D MACHINE(qdev_get_machine()); + unsigned long max =3D machine->maxram_size / TARGET_PAGE_SIZE; + + if (start_gfn + count > max) { + error_report("Error: invalid address."); + return -1; + } + if (!sas->incoming_buffer) { + sas->incoming_buffer =3D g_malloc0(max); + } + + memcpy(sas->incoming_buffer + start_gfn, values, count); + + return 0; +} + +static void kvm_s390_stattrib_synchronize(S390StAttribState *sa) +{ + KVMS390StAttribState *sas =3D KVM_S390_STATTRIB(sa); + MachineState *machine =3D MACHINE(qdev_get_machine()); + unsigned long max =3D machine->maxram_size / TARGET_PAGE_SIZE; + unsigned long cx, len =3D 1 << 19; + int r; + struct kvm_s390_cmma_log clog =3D { + .flags =3D 0, + .mask =3D ~0ULL, + }; + + if (sas->incoming_buffer) { + for (cx =3D 0; cx + len <=3D max; cx +=3D len) { + clog.start_gfn =3D cx; + clog.count =3D len; + clog.values =3D (uint64_t)(sas->incoming_buffer + cx * len); + r =3D kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog); + if (r) { + return; + } + } + if (cx < max) { + clog.start_gfn =3D cx; + clog.count =3D max - cx; + clog.values =3D (uint64_t)(sas->incoming_buffer + cx * len); + r =3D kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog); + } + g_free(sas->incoming_buffer); + sas->incoming_buffer =3D NULL; + } +} + +static int kvm_s390_stattrib_set_migrationmode(S390StAttribState *sa, bool= val) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_S390_VM_MIGRATION, + .attr =3D val, + .addr =3D 0, + }; + return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); +} + +static long long kvm_s390_stattrib_get_dirtycount(S390StAttribState *sa) +{ + KVMS390StAttribState *sas =3D KVM_S390_STATTRIB(sa); + uint8_t val[8]; + + kvm_s390_stattrib_peek_stattr(sa, 0, 1, val); + return sas->still_dirty; +} + +static int kvm_s390_stattrib_get_active(S390StAttribState *sa) +{ + return kvm_s390_cmma_active() && sa->migration_enabled; +} + +static void kvm_s390_stattrib_class_init(ObjectClass *oc, void *data) +{ + S390StAttribClass *sac =3D S390_STATTRIB_CLASS(oc); + + sac->get_stattr =3D kvm_s390_stattrib_get_stattr; + sac->peek_stattr =3D kvm_s390_stattrib_peek_stattr; + sac->set_stattr =3D kvm_s390_stattrib_set_stattr; + sac->set_migrationmode =3D kvm_s390_stattrib_set_migrationmode; + sac->get_dirtycount =3D kvm_s390_stattrib_get_dirtycount; + sac->synchronize =3D kvm_s390_stattrib_synchronize; + sac->get_active =3D kvm_s390_stattrib_get_active; +} + +static const TypeInfo kvm_s390_stattrib_info =3D { + .name =3D TYPE_KVM_S390_STATTRIB, + .parent =3D TYPE_S390_STATTRIB, + .instance_init =3D kvm_s390_stattrib_instance_init, + .instance_size =3D sizeof(KVMS390StAttribState), + .class_init =3D kvm_s390_stattrib_class_init, + .class_size =3D sizeof(S390StAttribClass), +}; + +static void kvm_s390_stattrib_register_types(void) +{ + type_register_static(&kvm_s390_stattrib_info); +} + +type_init(kvm_s390_stattrib_register_types) diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c new file mode 100644 index 0000000..eb41fe9 --- /dev/null +++ b/hw/s390x/s390-stattrib.c @@ -0,0 +1,348 @@ +/* + * s390 storage attributes device + * + * Copyright 2016 IBM Corp. + * Author(s): Claudio Imbrenda + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#include "qemu/osdep.h" +#include "hw/boards.h" +#include "migration/qemu-file.h" +#include "migration/register.h" +#include "hw/s390x/storage-attributes.h" +#include "qemu/error-report.h" +#include "sysemu/kvm.h" +#include "exec/ram_addr.h" +#include "qapi/error.h" + +#define CMMA_BLOCK_SIZE (1 << 10) + +#define STATTR_FLAG_EOS 0x01ULL +#define STATTR_FLAG_MORE 0x02ULL +#define STATTR_FLAG_ERROR 0x04ULL +#define STATTR_FLAG_DONE 0x08ULL + +void s390_stattrib_init(void) +{ + Object *obj; + +#ifdef CONFIG_KVM + if (kvm_enabled() && + kvm_check_extension(kvm_state, KVM_CAP_S390_CMMA_MIGRATION)) { + obj =3D object_new(TYPE_KVM_S390_STATTRIB); + } else { + obj =3D object_new(TYPE_QEMU_S390_STATTRIB); + } +#else + obj =3D object_new(TYPE_QEMU_S390_STATTRIB); +#endif + + object_property_add_child(qdev_get_machine(), TYPE_S390_STATTRIB, + obj, NULL); + object_unref(obj); + + qdev_init_nofail(DEVICE(obj)); +} + +/* Migration support: */ + +static int cmma_load(QEMUFile *f, void *opaque, int version_id) +{ + S390StAttribState *sas =3D S390_STATTRIB(opaque); + S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); + uint64_t count, cur_gfn; + int flags, ret =3D 0; + ram_addr_t addr; + uint8_t *buf; + + while (!ret) { + addr =3D qemu_get_be64(f); + flags =3D addr & ~TARGET_PAGE_MASK; + addr &=3D TARGET_PAGE_MASK; + + switch (flags) { + case STATTR_FLAG_MORE: { + cur_gfn =3D addr / TARGET_PAGE_SIZE; + count =3D qemu_get_be64(f); + buf =3D g_try_malloc(count); + if (!buf) { + error_report("cmma_load could not allocate memory"); + ret =3D -ENOMEM; + break; + } + + qemu_get_buffer(f, buf, count); + ret =3D sac->set_stattr(sas, cur_gfn, count, buf); + if (ret < 0) { + error_report("Error %d while setting storage attributes", = ret); + } + g_free(buf); + break; + } + case STATTR_FLAG_ERROR: { + error_report("Storage attributes data is incomplete"); + ret =3D -EINVAL; + break; + } + case STATTR_FLAG_DONE: + /* This is after the last pre-copied value has been sent, noth= ing + * more will be sent after this. Pre-copy has finished, and we + * are done flushing all the remaining values. Now the target + * system is about to take over. We synchronize the buffer to + * apply the actual correct values where needed. + */ + sac->synchronize(sas); + break; + case STATTR_FLAG_EOS: + /* Normal exit */ + return 0; + default: + error_report("Unexpected storage attribute flag data: %#x", fl= ags); + ret =3D -EINVAL; + } + } + + return ret; +} + +static int cmma_save_setup(QEMUFile *f, void *opaque) +{ + S390StAttribState *sas =3D S390_STATTRIB(opaque); + S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); + int res; + /* + * Signal that we want to start a migration, thus needing PGSTE dirty + * tracking. + */ + res =3D sac->set_migrationmode(sas, 1); + if (res) { + return res; + } + qemu_put_be64(f, STATTR_FLAG_EOS); + return 0; +} + +static void cmma_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, + uint64_t *non_postcopiable_pending, + uint64_t *postcopiable_pending) +{ + S390StAttribState *sas =3D S390_STATTRIB(opaque); + S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); + long long res =3D sac->get_dirtycount(sas); + + if (res >=3D 0) { + *non_postcopiable_pending +=3D res; + } +} + +static int cmma_save(QEMUFile *f, void *opaque, int final) +{ + S390StAttribState *sas =3D S390_STATTRIB(opaque); + S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); + uint8_t *buf; + int r, cx, reallen =3D 0, ret =3D 0; + uint32_t buflen =3D 1 << 19; /* 512kB cover 2GB of guest memory */ + uint64_t start_gfn =3D sas->migration_cur_gfn; + + buf =3D g_try_malloc(buflen); + if (!buf) { + error_report("Could not allocate memory to save storage attributes= "); + return -ENOMEM; + } + + while (final ? 1 : qemu_file_rate_limit(f) =3D=3D 0) { + reallen =3D sac->get_stattr(sas, &start_gfn, buflen, buf); + if (reallen < 0) { + g_free(buf); + return reallen; + } + + ret =3D 1; + if (0 =3D=3D reallen) { + break; + } + qemu_put_be64(f, (start_gfn << TARGET_PAGE_BITS) | STATTR_FLAG_MOR= E); + qemu_put_be64(f, reallen); + for (cx =3D 0; cx < reallen; cx++) { + qemu_put_byte(f, buf[cx]); + } + if (!sac->get_dirtycount(sas)) { + break; + } + } + + sas->migration_cur_gfn =3D start_gfn + reallen; + g_free(buf); + if (final) { + qemu_put_be64(f, STATTR_FLAG_DONE); + } + qemu_put_be64(f, STATTR_FLAG_EOS); + + r =3D qemu_file_get_error(f); + if (r < 0) { + return r; + } + + return ret; +} + +static int cmma_save_iterate(QEMUFile *f, void *opaque) +{ + return cmma_save(f, opaque, 0); +} + +static int cmma_save_complete(QEMUFile *f, void *opaque) +{ + return cmma_save(f, opaque, 1); +} + +static void cmma_save_cleanup(void *opaque) +{ + S390StAttribState *sas =3D S390_STATTRIB(opaque); + S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); + sac->set_migrationmode(sas, 0); +} + +static bool cmma_active(void *opaque) +{ + S390StAttribState *sas =3D S390_STATTRIB(opaque); + S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); + return sac->get_active(sas); +} + +/* QEMU object: */ + +static void qemu_s390_stattrib_instance_init(Object *obj) +{ +} + +static int qemu_s390_peek_stattr_stub(S390StAttribState *sa, uint64_t star= t_gfn, + uint32_t count, uint8_t *values) +{ + return 0; +} +static void qemu_s390_synchronize_stub(S390StAttribState *sa) +{ +} +static int qemu_s390_get_stattr_stub(S390StAttribState *sa, uint64_t *star= t_gfn, + uint32_t count, uint8_t *values) +{ + return 0; +} +static long long qemu_s390_get_dirtycount_stub(S390StAttribState *sa) +{ + return 0; +} +static int qemu_s390_set_migrationmode_stub(S390StAttribState *sa, bool va= lue) +{ + return 0; +} + +static int qemu_s390_get_active(S390StAttribState *sa) +{ + return sa->migration_enabled; +} + +static void qemu_s390_stattrib_class_init(ObjectClass *oc, void *data) +{ + S390StAttribClass *sa_cl =3D S390_STATTRIB_CLASS(oc); + + sa_cl->synchronize =3D qemu_s390_synchronize_stub; + sa_cl->get_stattr =3D qemu_s390_get_stattr_stub; + sa_cl->set_stattr =3D qemu_s390_peek_stattr_stub; + sa_cl->peek_stattr =3D qemu_s390_peek_stattr_stub; + sa_cl->set_migrationmode =3D qemu_s390_set_migrationmode_stub; + sa_cl->get_dirtycount =3D qemu_s390_get_dirtycount_stub; + sa_cl->get_active =3D qemu_s390_get_active; +} + +static const TypeInfo qemu_s390_stattrib_info =3D { + .name =3D TYPE_QEMU_S390_STATTRIB, + .parent =3D TYPE_S390_STATTRIB, + .instance_init =3D qemu_s390_stattrib_instance_init, + .instance_size =3D sizeof(QEMUS390StAttribState), + .class_init =3D qemu_s390_stattrib_class_init, + .class_size =3D sizeof(S390StAttribClass), +}; + +/* Generic abstract object: */ + +static void s390_stattrib_realize(DeviceState *dev, Error **errp) +{ + bool ambiguous =3D false; + + object_resolve_path_type("", TYPE_S390_STATTRIB, &ambiguous); + if (ambiguous) { + error_setg(errp, "storage_attributes device already exists"); + } +} + +static void s390_stattrib_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + + dc->hotpluggable =3D false; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + dc->realize =3D s390_stattrib_realize; +} + +static inline bool s390_stattrib_get_migration_enabled(Object *obj, Error = **e) +{ + S390StAttribState *s =3D S390_STATTRIB(obj); + + return s->migration_enabled; +} + +static inline void s390_stattrib_set_migration_enabled(Object *obj, bool v= alue, + Error **errp) +{ + S390StAttribState *s =3D S390_STATTRIB(obj); + + s->migration_enabled =3D value; +} + +static void s390_stattrib_instance_init(Object *obj) +{ + S390StAttribState *sas =3D S390_STATTRIB(obj); + SaveVMHandlers *ops; + + /* ops will always be freed by qemu when unregistering */ + ops =3D g_new0(SaveVMHandlers, 1); + + ops->save_setup =3D cmma_save_setup; + ops->save_live_iterate =3D cmma_save_iterate; + ops->save_live_complete_precopy =3D cmma_save_complete; + ops->save_live_pending =3D cmma_save_pending; + ops->save_cleanup =3D cmma_save_cleanup; + ops->load_state =3D cmma_load; + ops->is_active =3D cmma_active; + register_savevm_live(NULL, TYPE_S390_STATTRIB, 0, 0, ops, sas); + + object_property_add_bool(obj, "migration-enabled", + s390_stattrib_get_migration_enabled, + s390_stattrib_set_migration_enabled, NULL); + object_property_set_bool(obj, true, "migration-enabled", NULL); + sas->migration_cur_gfn =3D 0; +} + +static const TypeInfo s390_stattrib_info =3D { + .name =3D TYPE_S390_STATTRIB, + .parent =3D TYPE_DEVICE, + .instance_init =3D s390_stattrib_instance_init, + .instance_size =3D sizeof(S390StAttribState), + .class_init =3D s390_stattrib_class_init, + .class_size =3D sizeof(S390StAttribClass), + .abstract =3D true, +}; + +static void s390_stattrib_register_types(void) +{ + type_register_static(&s390_stattrib_info); + type_register_static(&qemu_s390_stattrib_info); +} + +type_init(s390_stattrib_register_types) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 41ca666..0c8f758 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -24,6 +24,7 @@ #include "qemu/config-file.h" #include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" +#include "hw/s390x/storage-attributes.h" #include "hw/compat.h" #include "ipl.h" #include "hw/s390x/s390-virtio-ccw.h" @@ -103,6 +104,8 @@ void s390_memory_init(ram_addr_t mem_size) =20 /* Initialize storage key device */ s390_skeys_init(); + /* Initialize storage attributes device */ + s390_stattrib_init(); } =20 static SaveVMHandlers savevm_gtod =3D { @@ -406,7 +409,12 @@ static const TypeInfo ccw_machine_info =3D { type_init(ccw_machine_register_##suffix) =20 #define CCW_COMPAT_2_9 \ - HW_COMPAT_2_9 + HW_COMPAT_2_9 \ + {\ + .driver =3D TYPE_S390_STATTRIB,\ + .property =3D "migration-enabled",\ + .value =3D "off",\ + }, =20 #define CCW_COMPAT_2_8 \ HW_COMPAT_2_8 \ diff --git a/include/hw/s390x/storage-attributes.h b/include/hw/s390x/stora= ge-attributes.h new file mode 100644 index 0000000..161440b --- /dev/null +++ b/include/hw/s390x/storage-attributes.h @@ -0,0 +1,68 @@ +/* + * s390 storage attributes device + * + * Copyright 2016 IBM Corp. + * Author(s): Claudio Imbrenda + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#ifndef S390_STORAGE_ATTRIBUTES_H +#define S390_STORAGE_ATTRIBUTES_H + +#include + +#define TYPE_S390_STATTRIB "s390-storage_attributes" +#define TYPE_QEMU_S390_STATTRIB "s390-storage_attributes-qemu" +#define TYPE_KVM_S390_STATTRIB "s390-storage_attributes-kvm" + +#define S390_STATTRIB(obj) \ + OBJECT_CHECK(S390StAttribState, (obj), TYPE_S390_STATTRIB) + +typedef struct S390StAttribState { + DeviceState parent_obj; + uint64_t migration_cur_gfn; + bool migration_enabled; +} S390StAttribState; + +#define S390_STATTRIB_CLASS(klass) \ + OBJECT_CLASS_CHECK(S390StAttribClass, (klass), TYPE_S390_STATTRIB) +#define S390_STATTRIB_GET_CLASS(obj) \ + OBJECT_GET_CLASS(S390StAttribClass, (obj), TYPE_S390_STATTRIB) + +typedef struct S390StAttribClass { + DeviceClass parent_class; + /* Return value: < 0 on error, or new count */ + int (*get_stattr)(S390StAttribState *sa, uint64_t *start_gfn, + uint32_t count, uint8_t *values); + int (*peek_stattr)(S390StAttribState *sa, uint64_t start_gfn, + uint32_t count, uint8_t *values); + int (*set_stattr)(S390StAttribState *sa, uint64_t start_gfn, + uint32_t count, uint8_t *values); + void (*synchronize)(S390StAttribState *sa); + int (*set_migrationmode)(S390StAttribState *sa, bool value); + int (*get_active)(S390StAttribState *sa); + long long (*get_dirtycount)(S390StAttribState *sa); +} S390StAttribClass; + +#define QEMU_S390_STATTRIB(obj) \ + OBJECT_CHECK(QEMUS390StAttribState, (obj), TYPE_QEMU_S390_STATTRIB) + +typedef struct QEMUS390StAttribState { + S390StAttribState parent_obj; +} QEMUS390StAttribState; + +#define KVM_S390_STATTRIB(obj) \ + OBJECT_CHECK(KVMS390StAttribState, (obj), TYPE_KVM_S390_STATTRIB) + +typedef struct KVMS390StAttribState { + S390StAttribState parent_obj; + uint64_t still_dirty; + uint8_t *incoming_buffer; +} KVMS390StAttribState; + +void s390_stattrib_init(void); + +#endif /* S390_STORAGE_ATTRIBUTES_H */ --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499865373508117.679619124321; Wed, 12 Jul 2017 06:16:13 -0700 (PDT) Received: from localhost ([::1]:52711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHUt-0005Kw-38 for importer@patchew.org; Wed, 12 Jul 2017 09:16:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDN-0006ZP-9M for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDH-00010m-Fp for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:01 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDH-0000zx-5q for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:55 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCsRl2087089 for ; Wed, 12 Jul 2017 08:57:54 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncj51wjy-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:51 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:47 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvlqx34013188; Wed, 12 Jul 2017 12:57:47 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 097A64203F; Wed, 12 Jul 2017 13:55:11 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E5FFB42047; Wed, 12 Jul 2017 13:55:10 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:10 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id B3C3720F69C; Wed, 12 Jul 2017 14:57:46 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:38 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0040-0000-0000-000003E27179 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0041-0000-0000-0000207D9890 Message-Id: <1499864265-144136-5-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 04/11] s390x/migration: Monitor commands for storage attributes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Claudio Imbrenda , Cornelia Huck , Alexander Graf , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Claudio Imbrenda Add an "info" monitor command to non-destructively inspect the state of the storage attributes of the guest, and a normal command to toggle migration mode (useful for debugging). Signed-off-by: Claudio Imbrenda Acked-by: Cornelia Huck Signed-off-by: Christian Borntraeger --- hmp-commands-info.hx | 16 +++++++++ hmp-commands.hx | 16 +++++++++ hw/s390x/s390-stattrib.c | 62 +++++++++++++++++++++++++++++++= ++++ include/hw/s390x/storage-attributes.h | 4 +++ monitor.c | 1 + 5 files changed, 99 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 07500ef..d9df238 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -777,6 +777,22 @@ STEXI Display the value of a storage key (s390 only) ETEXI =20 +#if defined(TARGET_S390X) + { + .name =3D "cmma", + .args_type =3D "addr:l,count:l?", + .params =3D "address [count]", + .help =3D "Display the values of the CMMA storage attributes= for a range of pages", + .cmd =3D hmp_info_cmma, + }, +#endif + +STEXI +@item info cmma @var{address} +@findex cmma +Display the values of the CMMA storage attributes for a range of pages (s3= 90 only) +ETEXI + { .name =3D "dump", .args_type =3D "", diff --git a/hmp-commands.hx b/hmp-commands.hx index 275ccdf..eec9cc2 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1153,6 +1153,22 @@ STEXI Save guest storage keys to a file. ETEXI =20 +#if defined(TARGET_S390X) + { + .name =3D "migration_mode", + .args_type =3D "mode:i", + .params =3D "mode", + .help =3D "Enables or disables migration mode\n", + .cmd =3D hmp_migrationmode, + }, +#endif + +STEXI +@item migration_mode @var{mode} +@findex migration_mode +Enables or disables migration mode. +ETEXI + { .name =3D "snapshot_blkdev", .args_type =3D "reuse:-n,device:B,snapshot-file:s?,format:s?", diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index eb41fe9..0729882 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -11,6 +11,7 @@ =20 #include "qemu/osdep.h" #include "hw/boards.h" +#include "qmp-commands.h" #include "migration/qemu-file.h" #include "migration/register.h" #include "hw/s390x/storage-attributes.h" @@ -26,6 +27,15 @@ #define STATTR_FLAG_ERROR 0x04ULL #define STATTR_FLAG_DONE 0x08ULL =20 +static S390StAttribState *s390_get_stattrib_device(void) +{ + S390StAttribState *sas; + + sas =3D S390_STATTRIB(object_resolve_path_type("", TYPE_S390_STATTRIB,= NULL)); + assert(sas); + return sas; +} + void s390_stattrib_init(void) { Object *obj; @@ -48,6 +58,58 @@ void s390_stattrib_init(void) qdev_init_nofail(DEVICE(obj)); } =20 +/* Console commands: */ + +void hmp_migrationmode(Monitor *mon, const QDict *qdict) +{ + S390StAttribState *sas =3D s390_get_stattrib_device(); + S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); + uint64_t what =3D qdict_get_int(qdict, "mode"); + int r; + + r =3D sac->set_migrationmode(sas, what); + if (r < 0) { + monitor_printf(mon, "Error: %s", strerror(-r)); + } +} + +void hmp_info_cmma(Monitor *mon, const QDict *qdict) +{ + S390StAttribState *sas =3D s390_get_stattrib_device(); + S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); + uint64_t addr =3D qdict_get_int(qdict, "addr"); + uint64_t buflen =3D qdict_get_try_int(qdict, "count", 8); + uint8_t *vals; + int cx, len; + + vals =3D g_try_malloc(buflen); + if (!vals) { + monitor_printf(mon, "Error: %s\n", strerror(errno)); + return; + } + + len =3D sac->peek_stattr(sas, addr / TARGET_PAGE_SIZE, buflen, vals); + if (len < 0) { + monitor_printf(mon, "Error: %s", strerror(-len)); + goto out; + } + + monitor_printf(mon, " CMMA attributes, " + "pages %" PRIu64 "+%d (0x%" PRIx64 "):\n", + addr / TARGET_PAGE_SIZE, len, addr & ~TARGET_PAGE_MASK); + for (cx =3D 0; cx < len; cx++) { + if (cx % 8 =3D=3D 7) { + monitor_printf(mon, "%02x\n", vals[cx]); + } else { + monitor_printf(mon, "%02x", vals[cx]); + } + } + monitor_printf(mon, "\n"); + +out: + g_free(vals); +} + /* Migration support: */ =20 static int cmma_load(QEMUFile *f, void *opaque, int version_id) diff --git a/include/hw/s390x/storage-attributes.h b/include/hw/s390x/stora= ge-attributes.h index 161440b..ccf4aa1 100644 --- a/include/hw/s390x/storage-attributes.h +++ b/include/hw/s390x/storage-attributes.h @@ -13,6 +13,7 @@ #define S390_STORAGE_ATTRIBUTES_H =20 #include +#include "monitor/monitor.h" =20 #define TYPE_S390_STATTRIB "s390-storage_attributes" #define TYPE_QEMU_S390_STATTRIB "s390-storage_attributes-qemu" @@ -65,4 +66,7 @@ typedef struct KVMS390StAttribState { =20 void s390_stattrib_init(void); =20 +void hmp_info_cmma(Monitor *mon, const QDict *qdict); +void hmp_migrationmode(Monitor *mon, const QDict *qdict); + #endif /* S390_STORAGE_ATTRIBUTES_H */ diff --git a/monitor.c b/monitor.c index d8ac20f..8e084f5 100644 --- a/monitor.c +++ b/monitor.c @@ -81,6 +81,7 @@ =20 #if defined(TARGET_S390X) #include "hw/s390x/storage-keys.h" +#include "hw/s390x/storage-attributes.h" #endif =20 /* --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499865542402987.5125578955369; Wed, 12 Jul 2017 06:19:02 -0700 (PDT) Received: from localhost ([::1]:52797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHXd-0007oP-22 for importer@patchew.org; Wed, 12 Jul 2017 09:18:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDN-0006ZX-F4 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDG-00010D-Ql for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:01 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52518) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDG-0000zF-GF for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:54 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCs7AS127297 for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncj5hqjx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:52 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:50 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:47 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvle834013194; Wed, 12 Jul 2017 12:57:47 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B13AF4C04E; Wed, 12 Jul 2017 13:55:31 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 963014C044; Wed, 12 Jul 2017 13:55:31 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:31 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 0672D20F69D; Wed, 12 Jul 2017 14:57:47 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:39 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0040-0000-0000-000003C26EC4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0041-0000-0000-000025BD97EB Message-Id: <1499864265-144136-6-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 05/11] s390x/cpumodel: clean up spacing and comments X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Cornelia Huck , Alexander Graf , "Jason J. Herne" , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Jason J. Herne" Clean up spacing and add comments to clarify difference between base, full = and default models. Not having spacing around the model definitions in gen-features.c is particularly frustrating as the reader tends to misinterpret which model th= ey are looking at or editing. Signed-off-by: Jason J. Herne Acked-by: Christian Borntraeger Acked-by: Cornelia Huck Signed-off-by: Christian Borntraeger --- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features_def.h | 35 +++++++++++++++++++++++++ target/s390x/gen-features.c | 58 +++++++++++++++++++++++++++++++++++++= +--- 3 files changed, 93 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index 42fd9d7..0436dc2 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -83,9 +83,11 @@ static const S390FeatDef s390_features[] =3D { FEAT_INIT("dfppc", S390_FEAT_TYPE_STFL, 80, "Decimal-floating-point pa= cked-conversion facility"), FEAT_INIT("vx", S390_FEAT_TYPE_STFL, 129, "Vector facility"), =20 + /* SCLP SCCB Byte 80 - 98 (bit numbers relative to byte-80) */ FEAT_INIT("gsls", S390_FEAT_TYPE_SCLP_CONF_CHAR, 40, "SIE: Guest-stora= ge-limit-suppression facility"), FEAT_INIT("esop", S390_FEAT_TYPE_SCLP_CONF_CHAR, 46, "Enhanced-suppres= sion-on-protection facility"), =20 + /* SCLP SCCB Byte 116 - 119 (bit numbers relative to byte-116) */ FEAT_INIT("64bscao", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 0, "SIE: 64-bi= t-SCAO facility"), FEAT_INIT("cmma", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 1, "SIE: Collabor= ative-memory-management assist"), FEAT_INIT("pfmfi", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 9, "SIE: PFMF in= terpretation facility"), @@ -183,6 +185,7 @@ static const S390FeatDef s390_features[] =3D { FEAT_INIT("kimd-sha-256", S390_FEAT_TYPE_KIMD, 2, "KIMD SHA-256"), FEAT_INIT("kimd-sha-512", S390_FEAT_TYPE_KIMD, 3, "KIMD SHA-512"), FEAT_INIT("kimd-ghash", S390_FEAT_TYPE_KIMD, 65, "KIMD GHASH"), + FEAT_INIT("klmd-sha-1", S390_FEAT_TYPE_KLMD, 1, "KLMD SHA-1"), FEAT_INIT("klmd-sha-256", S390_FEAT_TYPE_KLMD, 2, "KLMD SHA-256"), FEAT_INIT("klmd-sha-512", S390_FEAT_TYPE_KLMD, 3, "KLMD SHA-512"), diff --git a/target/s390x/cpu_features_def.h b/target/s390x/cpu_features_de= f.h index aa5ab8d..f5bb7ed 100644 --- a/target/s390x/cpu_features_def.h +++ b/target/s390x/cpu_features_def.h @@ -15,6 +15,7 @@ #define TARGET_S390X_CPU_FEATURES_DEF_H =20 typedef enum { + /* Stfle */ S390_FEAT_ESAN3 =3D 0, S390_FEAT_ZARCH, S390_FEAT_DAT_ENH, @@ -72,12 +73,18 @@ typedef enum { S390_FEAT_EDAT_2, S390_FEAT_DFP_PACKED_CONVERSION, S390_FEAT_VECTOR, + + /* Sclp Conf Char */ S390_FEAT_SIE_GSLS, S390_FEAT_ESOP, + + /* Sclp Conf Char Ext */ S390_FEAT_SIE_64BSCAO, S390_FEAT_SIE_CMMA, S390_FEAT_SIE_PFMFI, S390_FEAT_SIE_IBS, + + /* Sclp Cpu */ S390_FEAT_SIE_F2, S390_FEAT_SIE_SKEY, S390_FEAT_SIE_GPERE, @@ -85,8 +92,12 @@ typedef enum { S390_FEAT_SIE_SIGPIF, S390_FEAT_SIE_IB, S390_FEAT_SIE_CEI, + + /* Misc */ S390_FEAT_DAT_ENH_2, S390_FEAT_CMM, + + /* PLO */ S390_FEAT_PLO_CL, S390_FEAT_PLO_CLG, S390_FEAT_PLO_CLGR, @@ -111,6 +122,8 @@ typedef enum { S390_FEAT_PLO_CSTSTG, S390_FEAT_PLO_CSTSTGR, S390_FEAT_PLO_CSTSTX, + + /* PTFF */ S390_FEAT_PTFF_QTO, S390_FEAT_PTFF_QSI, S390_FEAT_PTFF_QPT, @@ -118,6 +131,8 @@ typedef enum { S390_FEAT_PTFF_QTOU, S390_FEAT_PTFF_STO, S390_FEAT_PTFF_STOU, + + /* KMAC */ S390_FEAT_KMAC_DEA, S390_FEAT_KMAC_TDEA_128, S390_FEAT_KMAC_TDEA_192, @@ -130,6 +145,8 @@ typedef enum { S390_FEAT_KMAC_EAES_128, S390_FEAT_KMAC_EAES_192, S390_FEAT_KMAC_EAES_256, + + /* KMC */ S390_FEAT_KMC_DEA, S390_FEAT_KMC_TDEA_128, S390_FEAT_KMC_TDEA_192, @@ -143,6 +160,8 @@ typedef enum { S390_FEAT_KMC_EAES_192, S390_FEAT_KMC_EAES_256, S390_FEAT_KMC_PRNG, + + /* KM */ S390_FEAT_KM_DEA, S390_FEAT_KM_TDEA_128, S390_FEAT_KM_TDEA_192, @@ -159,19 +178,27 @@ typedef enum { S390_FEAT_KM_XTS_AES_256, S390_FEAT_KM_XTS_EAES_128, S390_FEAT_KM_XTS_EAES_256, + + /* KIMD */ S390_FEAT_KIMD_SHA_1, S390_FEAT_KIMD_SHA_256, S390_FEAT_KIMD_SHA_512, S390_FEAT_KIMD_GHASH, + + /* KLMD */ S390_FEAT_KLMD_SHA_1, S390_FEAT_KLMD_SHA_256, S390_FEAT_KLMD_SHA_512, + + /* PCKMO */ S390_FEAT_PCKMO_EDEA, S390_FEAT_PCKMO_ETDEA_128, S390_FEAT_PCKMO_ETDEA_256, S390_FEAT_PCKMO_AES_128, S390_FEAT_PCKMO_AES_192, S390_FEAT_PCKMO_AES_256, + + /* KMCTR */ S390_FEAT_KMCTR_DEA, S390_FEAT_KMCTR_TDEA_128, S390_FEAT_KMCTR_TDEA_192, @@ -184,6 +211,8 @@ typedef enum { S390_FEAT_KMCTR_EAES_128, S390_FEAT_KMCTR_EAES_192, S390_FEAT_KMCTR_EAES_256, + + /* KMF */ S390_FEAT_KMF_DEA, S390_FEAT_KMF_TDEA_128, S390_FEAT_KMF_TDEA_192, @@ -196,6 +225,8 @@ typedef enum { S390_FEAT_KMF_EAES_128, S390_FEAT_KMF_EAES_192, S390_FEAT_KMF_EAES_256, + + /* KMO */ S390_FEAT_KMO_DEA, S390_FEAT_KMO_TDEA_128, S390_FEAT_KMO_TDEA_192, @@ -208,6 +239,8 @@ typedef enum { S390_FEAT_KMO_EAES_128, S390_FEAT_KMO_EAES_192, S390_FEAT_KMO_EAES_256, + + /* PCC */ S390_FEAT_PCC_CMAC_DEA, S390_FEAT_PCC_CMAC_TDEA_128, S390_FEAT_PCC_CMAC_TDEA_192, @@ -224,6 +257,8 @@ typedef enum { S390_FEAT_PCC_XTS_AES_256, S390_FEAT_PCC_XTS_EAES_128, S390_FEAT_PCC_XTS_EAES_256, + + /* PPNO */ S390_FEAT_PPNO_SHA_512_DRNG, S390_FEAT_MAX, } S390Feat; diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index e674738..8ca2b47 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -211,14 +211,20 @@ static uint16_t group_MSA_EXT_5[] =3D { S390_FEAT_GROUP_MSA_EXT_5, }; =20 -/* base features in order of release */ +/* Base features (in order of release) + * Only non-hypervisor managed features belong here. + * Base feature sets are static meaning they do not change in future QEMU + * releases. + */ static uint16_t base_GEN7_GA1[] =3D { S390_FEAT_GROUP_PLO, S390_FEAT_ESAN3, S390_FEAT_ZARCH, }; + #define base_GEN7_GA2 EmptyFeat #define base_GEN7_GA3 EmptyFeat + static uint16_t base_GEN8_GA1[] =3D { S390_FEAT_DAT_ENH, S390_FEAT_EXTENDED_TRANSLATION_2, @@ -227,10 +233,12 @@ static uint16_t base_GEN8_GA1[] =3D { S390_FEAT_LONG_DISPLACEMENT_FAST, S390_FEAT_HFP_MADDSUB, }; + #define base_GEN8_GA2 EmptyFeat #define base_GEN8_GA3 EmptyFeat #define base_GEN8_GA4 EmptyFeat #define base_GEN8_GA5 EmptyFeat + static uint16_t base_GEN9_GA1[] =3D { S390_FEAT_IDTE_SEGMENT, S390_FEAT_ASN_LX_REUSE, @@ -245,8 +253,10 @@ static uint16_t base_GEN9_GA1[] =3D { S390_FEAT_ETF3_ENH, S390_FEAT_DAT_ENH_2, }; + #define base_GEN9_GA2 EmptyFeat #define base_GEN9_GA3 EmptyFeat + static uint16_t base_GEN10_GA1[] =3D { S390_FEAT_CONDITIONAL_SSKE, S390_FEAT_PARSING_ENH, @@ -263,6 +273,7 @@ static uint16_t base_GEN10_GA1[] =3D { }; #define base_GEN10_GA2 EmptyFeat #define base_GEN10_GA3 EmptyFeat + static uint16_t base_GEN11_GA1[] =3D { S390_FEAT_NONQ_KEY_SETTING, S390_FEAT_ENHANCED_MONITOR, @@ -272,21 +283,30 @@ static uint16_t base_GEN11_GA1[] =3D { S390_FEAT_CMPSC_ENH, S390_FEAT_INTERLOCKED_ACCESS_2, }; + #define base_GEN11_GA2 EmptyFeat + static uint16_t base_GEN12_GA1[] =3D { S390_FEAT_DFP_ZONED_CONVERSION, S390_FEAT_STFLE_49, S390_FEAT_LOCAL_TLB_CLEARING, }; + #define base_GEN12_GA2 EmptyFeat + static uint16_t base_GEN13_GA1[] =3D { S390_FEAT_STFLE_53, S390_FEAT_DFP_PACKED_CONVERSION, S390_FEAT_GROUP_GEN13_PTFF, }; + #define base_GEN13_GA2 EmptyFeat =20 -/* full features differing to the base in order of release */ +/* Full features (in order of release) + * Automatically includes corresponding base features. + * Full features are all features this hardware supports even if kvm/QEMU = do not + * support these features yet. + */ static uint16_t full_GEN7_GA1[] =3D { S390_FEAT_SIE_F2, S390_FEAT_SIE_SKEY, @@ -294,30 +314,38 @@ static uint16_t full_GEN7_GA1[] =3D { S390_FEAT_SIE_IB, S390_FEAT_SIE_CEI, }; + static uint16_t full_GEN7_GA2[] =3D { S390_FEAT_EXTENDED_TRANSLATION_2, }; + static uint16_t full_GEN7_GA3[] =3D { S390_FEAT_LONG_DISPLACEMENT, S390_FEAT_SIE_SIIF, }; + static uint16_t full_GEN8_GA1[] =3D { S390_FEAT_SIE_GSLS, S390_FEAT_SIE_64BSCAO, }; + #define full_GEN8_GA2 EmptyFeat + static uint16_t full_GEN8_GA3[] =3D { S390_FEAT_ASN_LX_REUSE, S390_FEAT_EXTENDED_TRANSLATION_3, }; + #define full_GEN8_GA4 EmptyFeat #define full_GEN8_GA5 EmptyFeat + static uint16_t full_GEN9_GA1[] =3D { S390_FEAT_STORE_HYPERVISOR_INFO, S390_FEAT_GROUP_MSA_EXT_1, S390_FEAT_CMM, S390_FEAT_SIE_CMMA, }; + static uint16_t full_GEN9_GA2[] =3D { S390_FEAT_MOVE_WITH_OPTIONAL_SPEC, S390_FEAT_EXTRACT_CPU_TIME, @@ -325,10 +353,12 @@ static uint16_t full_GEN9_GA2[] =3D { S390_FEAT_FLOATING_POINT_SUPPPORT_ENH, S390_FEAT_DFP, }; + static uint16_t full_GEN9_GA3[] =3D { S390_FEAT_CONDITIONAL_SSKE, S390_FEAT_PFPO, }; + static uint16_t full_GEN10_GA1[] =3D { S390_FEAT_EDAT, S390_FEAT_CONFIGURATION_TOPOLOGY, @@ -337,34 +367,46 @@ static uint16_t full_GEN10_GA1[] =3D { S390_FEAT_SIE_PFMFI, S390_FEAT_SIE_SIGPIF, }; + static uint16_t full_GEN10_GA2[] =3D { S390_FEAT_SET_PROGRAM_PARAMETERS, S390_FEAT_SIE_IBS, }; + static uint16_t full_GEN10_GA3[] =3D { S390_FEAT_GROUP_MSA_EXT_3, }; + static uint16_t full_GEN11_GA1[] =3D { S390_FEAT_IPTE_RANGE, S390_FEAT_ACCESS_EXCEPTION_FS_INDICATION, S390_FEAT_GROUP_MSA_EXT_4, }; + #define full_GEN11_GA2 EmptyFeat + static uint16_t full_GEN12_GA1[] =3D { S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE, S390_FEAT_TRANSACTIONAL_EXE, S390_FEAT_RUNTIME_INSTRUMENTATION, S390_FEAT_EDAT_2, }; + static uint16_t full_GEN12_GA2[] =3D { S390_FEAT_GROUP_MSA_EXT_5, }; + static uint16_t full_GEN13_GA1[] =3D { S390_FEAT_VECTOR, }; + #define full_GEN13_GA2 EmptyFeat =20 -/* default features differing to the base in order of release */ +/* Default features (in order of release) + * Automatically includes corresponding base features. + * Default features are all features this version of QEMU supports for this + * hardware model. Default feature sets can grow with new QEMU releases. + */ #define default_GEN7_GA1 EmptyFeat #define default_GEN7_GA2 EmptyFeat #define default_GEN7_GA3 EmptyFeat @@ -373,37 +415,47 @@ static uint16_t full_GEN13_GA1[] =3D { #define default_GEN8_GA3 EmptyFeat #define default_GEN8_GA4 EmptyFeat #define default_GEN8_GA5 EmptyFeat + static uint16_t default_GEN9_GA1[] =3D { S390_FEAT_STORE_HYPERVISOR_INFO, S390_FEAT_GROUP_MSA_EXT_1, S390_FEAT_CMM, }; + #define default_GEN9_GA2 EmptyFeat #define default_GEN9_GA3 EmptyFeat + static uint16_t default_GEN10_GA1[] =3D { S390_FEAT_EDAT, S390_FEAT_GROUP_MSA_EXT_2, }; + #define default_GEN10_GA2 EmptyFeat #define default_GEN10_GA3 EmptyFeat + static uint16_t default_GEN11_GA1[] =3D { S390_FEAT_GROUP_MSA_EXT_3, S390_FEAT_IPTE_RANGE, S390_FEAT_ACCESS_EXCEPTION_FS_INDICATION, S390_FEAT_GROUP_MSA_EXT_4, }; + #define default_GEN11_GA2 EmptyFeat + static uint16_t default_GEN12_GA1[] =3D { S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE, S390_FEAT_TRANSACTIONAL_EXE, S390_FEAT_RUNTIME_INSTRUMENTATION, S390_FEAT_EDAT_2, }; + #define default_GEN12_GA2 EmptyFeat + static uint16_t default_GEN13_GA1[] =3D { S390_FEAT_GROUP_MSA_EXT_5, S390_FEAT_VECTOR, }; + #define default_GEN13_GA2 EmptyFeat =20 /****** END FEATURE DEFS ******/ --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864877068251.63882694380413; Wed, 12 Jul 2017 06:07:57 -0700 (PDT) Received: from localhost ([::1]:52659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHMt-0006Ss-Lb for importer@patchew.org; Wed, 12 Jul 2017 09:07:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDL-0006WY-Ra for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDH-00010R-20 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDG-0000zO-PA for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:54 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCs5ba127160 for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncj5hqkb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:51 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:48 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvluc35913836; Wed, 12 Jul 2017 12:57:47 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 73FF4A4051; Wed, 12 Jul 2017 13:55:06 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6275EA4040; Wed, 12 Jul 2017 13:55:06 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:06 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 571E220F69C; Wed, 12 Jul 2017 14:57:47 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:40 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0040-0000-0000-000003C26EC6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0041-0000-0000-000025BD97EC Message-Id: <1499864265-144136-7-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 06/11] s390x/cpumodel: provide compat handling for new cpu features X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Cornelia Huck , Alexander Graf , "Jason J. Herne" , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Jason J. Herne" Provide a mechanism to disable features in compatibility machines. Signed-off-by: Jason J. Herne Acked-by: Christian Borntraeger Signed-off-by: Christian Borntraeger Acked-by: Cornelia Huck --- target/s390x/cpu_models.c | 26 ++++++++++++++++++++++++++ target/s390x/cpu_models.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 7cb55dc..fd3f459 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -77,6 +77,32 @@ static S390CPUDef s390_cpu_defs[] =3D { CPUDEF_INIT(0x2965, 13, 2, 47, 0x08000000U, "z13s", "IBM z13s GA1"), }; =20 +void s390_cpudef_featoff(uint8_t gen, uint8_t ec_ga, S390Feat feat) +{ + const S390CPUDef *def; + + def =3D s390_find_cpu_def(0, gen, ec_ga, NULL); + clear_bit(feat, (unsigned long *)&def->default_feat); +} + +void s390_cpudef_featoff_greater(uint8_t gen, uint8_t ec_ga, S390Feat feat) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(s390_cpu_defs); i++) { + const S390CPUDef *def =3D &s390_cpu_defs[i]; + + if (def->gen < gen) { + continue; + } + if (def->gen =3D=3D gen && def->ec_ga < ec_ga) { + continue; + } + + clear_bit(feat, (unsigned long *)&def->default_feat); + } +} + uint32_t s390_get_hmfai(void) { static S390CPU *cpu; diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index d41f8d6..c0bee15 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -72,6 +72,8 @@ typedef struct S390CPUModel { #define ibc_gen(x) (x =3D=3D 0 ? 0 : ((x >> 4) + S390_GEN_Z10)) #define ibc_ec_ga(x) (x & 0xf) =20 +void s390_cpudef_featoff(uint8_t gen, uint8_t ec_ga, S390Feat feat); +void s390_cpudef_featoff_greater(uint8_t gen, uint8_t ec_ga, S390Feat feat= ); uint32_t s390_get_hmfai(void); uint8_t s390_get_mha_pow(void); uint32_t s390_get_ibc_val(void); --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864725254363.023829386271; Wed, 12 Jul 2017 06:05:25 -0700 (PDT) Received: from localhost ([::1]:52644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHKS-0004MP-U7 for importer@patchew.org; Wed, 12 Jul 2017 09:05:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDL-0006W9-EP for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDG-000103-JM for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55807) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDG-0000z8-A1 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:54 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCs5wS037639 for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncj8hm9q-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:52 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:50 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:48 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvmIQ36306944; Wed, 12 Jul 2017 12:57:48 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D05F111C04C; Wed, 12 Jul 2017 13:55:14 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8B8A11C04A; Wed, 12 Jul 2017 13:55:14 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:14 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id A556420F69D; Wed, 12 Jul 2017 14:57:47 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:41 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0020-0000-0000-000003A07048 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0021-0000-0000-000042257CB4 Message-Id: <1499864265-144136-8-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 07/11] s390x: add flags field for registering I/O adapter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Cornelia Huck , Alexander Graf , Fei Li , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fei Li Introduce a new 'flags' field to IoAdapter to contain further characteristics of the adapter, like whether the adapter is subject to adapter-interruption suppression. For the kvm case, pass this value in the 'flags' field when registering an adapter. Signed-off-by: Fei Li Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- hw/intc/s390_flic.c | 2 +- hw/intc/s390_flic_kvm.c | 3 ++- hw/s390x/css-bridge.c | 2 +- hw/s390x/css.c | 8 ++++++-- hw/s390x/s390-pci-bus.c | 3 ++- include/hw/s390x/css.h | 8 +++++++- include/hw/s390x/s390_flic.h | 2 +- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index 837158b..d3938b3 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -48,7 +48,7 @@ void s390_flic_init(void) =20 static int qemu_s390_register_io_adapter(S390FLICState *fs, uint32_t id, uint8_t isc, bool swap, - bool is_maskable) + bool is_maskable, uint8_t flags) { /* nothing to do */ return 0; diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 0bcd49f..15ff534 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -186,13 +186,14 @@ static int __get_all_irqs(KVMS390FLICState *flic, =20 static int kvm_s390_register_io_adapter(S390FLICState *fs, uint32_t id, uint8_t isc, bool swap, - bool is_maskable) + bool is_maskable, uint8_t flags) { struct kvm_s390_io_adapter adapter =3D { .id =3D id, .isc =3D isc, .maskable =3D is_maskable, .swap =3D swap, + .flags =3D flags, }; KVMS390FLICState *flic =3D KVM_S390_FLIC(fs); int r; diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c index 823747f..c4a9735 100644 --- a/hw/s390x/css-bridge.c +++ b/hw/s390x/css-bridge.c @@ -110,7 +110,7 @@ VirtualCssBus *virtual_css_bus_init(void) qbus_set_hotplug_handler(bus, dev, &error_abort); =20 css_register_io_adapters(CSS_IO_ADAPTER_VIRTIO, true, false, - &error_abort); + 0, &error_abort); =20 return cbus; } diff --git a/hw/s390x/css.c b/hw/s390x/css.c index d67fffa..1fcbc84 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -225,6 +225,7 @@ typedef struct IoAdapter { uint32_t id; uint8_t type; uint8_t isc; + uint8_t flags; } IoAdapter; =20 typedef struct ChannelSubSys { @@ -392,10 +393,12 @@ uint32_t css_get_adapter_id(CssIoAdapterType type, ui= nt8_t isc) * * @swap: an indication if byte swap is needed. * @maskable: an indication if the adapter is subject to the mask operatio= n. + * @flags: further characteristics of the adapter. + * e.g. suppressible, an indication if the adapter is subject to A= IS. * @errp: location to store error information. */ void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maska= ble, - Error **errp) + uint8_t flags, Error **errp) { uint32_t id; int ret, isc; @@ -413,12 +416,13 @@ void css_register_io_adapters(CssIoAdapterType type, = bool swap, bool maskable, =20 for (isc =3D 0; isc <=3D MAX_ISC; isc++) { id =3D (type << 3) | isc; - ret =3D fsc->register_io_adapter(fs, id, isc, swap, maskable); + ret =3D fsc->register_io_adapter(fs, id, isc, swap, maskable, flag= s); if (ret =3D=3D 0) { adapter =3D g_new0(IoAdapter, 1); adapter->id =3D id; adapter->isc =3D isc; adapter->type =3D type; + adapter->flags =3D flags; channel_subsys.io_adapters[type][isc] =3D adapter; } else { error_setg_errno(errp, -ret, "Unexpected error %d when " diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 5651483..b9603e7 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -582,7 +582,8 @@ static int s390_pcihost_init(SysBusDevice *dev) QTAILQ_INIT(&s->pending_sei); QTAILQ_INIT(&s->zpci_devs); =20 - css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false, &error_abort= ); + css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false, + S390_ADAPTER_SUPPRESSIBLE, &error_abort); =20 return 0; } diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index eb0e26f..e028960 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -167,7 +167,13 @@ typedef enum { =20 uint32_t css_get_adapter_id(CssIoAdapterType type, uint8_t isc); void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maska= ble, - Error **errp); + uint8_t flags, Error **errp); + +#ifndef CONFIG_KVM +#define S390_ADAPTER_SUPPRESSIBLE 0x01 +#else +#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE +#endif =20 #ifndef CONFIG_USER_ONLY SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid, diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h index caa6fc6..d4145ad 100644 --- a/include/hw/s390x/s390_flic.h +++ b/include/hw/s390x/s390_flic.h @@ -56,7 +56,7 @@ typedef struct S390FLICStateClass { DeviceClass parent_class; =20 int (*register_io_adapter)(S390FLICState *fs, uint32_t id, uint8_t isc, - bool swap, bool maskable); + bool swap, bool maskable, uint8_t flags); int (*io_adapter_map)(S390FLICState *fs, uint32_t id, uint64_t map_add= r, bool do_map); int (*add_adapter_routes)(S390FLICState *fs, AdapterRoutes *routes); --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499865481841153.77304886608272; Wed, 12 Jul 2017 06:18:01 -0700 (PDT) Received: from localhost ([::1]:52716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHWf-0006q2-AZ for importer@patchew.org; Wed, 12 Jul 2017 09:17:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDL-0006W7-E2 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDH-00010K-1K for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34666) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDG-0000zM-Mu for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:54 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCsLCa005518 for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncjb9uwr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:50 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:48 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvmod3670428; Wed, 12 Jul 2017 12:57:48 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 17B40A4040; Wed, 12 Jul 2017 13:55:07 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F02B3A4053; Wed, 12 Jul 2017 13:55:06 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:06 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id E6FDD20F69C; Wed, 12 Jul 2017 14:57:47 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:42 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0016-0000-0000-000004D579C7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0017-0000-0000-00002809A568 Message-Id: <1499864265-144136-9-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 08/11] s390x/flic: introduce modify_ais_mode callback X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yi Min Zhao , Cornelia Huck , Alexander Graf , Christian Borntraeger , Fei Li , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fei Li In order to emulate the adapter interruption suppression (AIS) facility properly, the guest needs to be able to modify the AIS mask. Interrupt suppression will be handled via the flic (for kvm, via a recently introduced kernel backend; for !kvm, in the flic code), so let's introduce a method to change the mode via the flic interface. Co-authored-by: Yi Min Zhao Signed-off-by: Yi Min Zhao Signed-off-by: Fei Li Signed-off-by: Christian Borntraeger --- hw/intc/s390_flic.c | 37 ++++++++++++++++++++++++++++++++++++- hw/intc/s390_flic_kvm.c | 36 ++++++++++++++++++++++++++++++++++++ include/hw/s390x/s390_flic.h | 9 ++++++++- 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index d3938b3..ce7f355 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -79,15 +79,47 @@ static int qemu_s390_clear_io_flic(S390FLICState *fs, u= int16_t subchannel_id, return -ENOSYS; } =20 +static int qemu_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc, + uint16_t mode) +{ + QEMUS390FLICState *flic =3D QEMU_S390_FLIC(fs); + + switch (mode) { + case SIC_IRQ_MODE_ALL: + flic->simm &=3D ~AIS_MODE_MASK(isc); + flic->nimm &=3D ~AIS_MODE_MASK(isc); + break; + case SIC_IRQ_MODE_SINGLE: + flic->simm |=3D AIS_MODE_MASK(isc); + flic->nimm &=3D ~AIS_MODE_MASK(isc); + break; + default: + return -EINVAL; + } + + return 0; +} + +static void qemu_s390_flic_reset(DeviceState *dev) +{ + QEMUS390FLICState *flic =3D QEMU_S390_FLIC(dev); + + flic->simm =3D 0; + flic->nimm =3D 0; +} + static void qemu_s390_flic_class_init(ObjectClass *oc, void *data) { + DeviceClass *dc =3D DEVICE_CLASS(oc); S390FLICStateClass *fsc =3D S390_FLIC_COMMON_CLASS(oc); =20 + dc->reset =3D qemu_s390_flic_reset; fsc->register_io_adapter =3D qemu_s390_register_io_adapter; fsc->io_adapter_map =3D qemu_s390_io_adapter_map; fsc->add_adapter_routes =3D qemu_s390_add_adapter_routes; fsc->release_adapter_routes =3D qemu_s390_release_adapter_routes; fsc->clear_io_irq =3D qemu_s390_clear_io_flic; + fsc->modify_ais_mode =3D qemu_s390_modify_ais_mode; } =20 static Property s390_flic_common_properties[] =3D { @@ -98,12 +130,15 @@ static Property s390_flic_common_properties[] =3D { =20 static void s390_flic_common_realize(DeviceState *dev, Error **errp) { - uint32_t max_batch =3D S390_FLIC_COMMON(dev)->adapter_routes_max_batch; + S390FLICState *fs =3D S390_FLIC_COMMON(dev); + uint32_t max_batch =3D fs->adapter_routes_max_batch; =20 if (max_batch > ADAPTER_ROUTES_MAX_GSI) { error_setg(errp, "flic property adapter_routes_max_batch too big" " (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI); } + + fs->ais_supported =3D true; } =20 static void s390_flic_class_init(ObjectClass *oc, void *data) diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 15ff534..55aa35f 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -20,6 +20,7 @@ #include "sysemu/kvm.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/adapter.h" +#include "hw/s390x/css.h" #include "trace.h" =20 #define FLIC_SAVE_INITIAL_SIZE getpagesize() @@ -149,6 +150,26 @@ static int kvm_s390_clear_io_flic(S390FLICState *fs, u= int16_t subchannel_id, return rc ? -errno : 0; } =20 +static int kvm_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc, + uint16_t mode) +{ + KVMS390FLICState *flic =3D KVM_S390_FLIC(fs); + struct kvm_s390_ais_req req =3D { + .isc =3D isc, + .mode =3D mode, + }; + struct kvm_device_attr attr =3D { + .group =3D KVM_DEV_FLIC_AISM, + .addr =3D (uint64_t)&req, + }; + + if (!fs->ais_supported) { + return -ENOSYS; + } + + return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; +} + /** * __get_all_irqs - store all pending irqs in buffer * @flic: pointer to flic device state @@ -406,6 +427,7 @@ typedef struct KVMS390FLICStateClass { =20 static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) { + S390FLICState *fs =3D S390_FLIC_COMMON(dev); KVMS390FLICState *flic_state =3D KVM_S390_FLIC(dev); struct kvm_create_device cd =3D {0}; struct kvm_device_attr test_attr =3D {0}; @@ -438,6 +460,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Err= or **errp) flic_state->clear_io_supported =3D !ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr= ); =20 + fs->ais_supported =3D false; return; fail: error_propagate(errp, errp_local); @@ -446,10 +469,12 @@ fail: static void kvm_s390_flic_reset(DeviceState *dev) { KVMS390FLICState *flic =3D KVM_S390_FLIC(dev); + S390FLICState *fs =3D S390_FLIC_COMMON(dev); struct kvm_device_attr attr =3D { .group =3D KVM_DEV_FLIC_CLEAR_IRQS, }; int rc =3D 0; + uint8_t isc; =20 if (flic->fd =3D=3D -1) { return; @@ -457,6 +482,16 @@ static void kvm_s390_flic_reset(DeviceState *dev) =20 flic_disable_wait_pfault(flic); =20 + if (fs->ais_supported) { + for (isc =3D 0; isc <=3D MAX_ISC; isc++) { + rc =3D kvm_s390_modify_ais_mode(fs, isc, SIC_IRQ_MODE_ALL); + if (rc) { + error_report("Failed to reset ais mode for isc %d: %s", + isc, strerror(-rc)); + } + } + } + rc =3D ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr); if (rc) { trace_flic_reset_failed(errno); @@ -479,6 +514,7 @@ static void kvm_s390_flic_class_init(ObjectClass *oc, v= oid *data) fsc->add_adapter_routes =3D kvm_s390_add_adapter_routes; fsc->release_adapter_routes =3D kvm_s390_release_adapter_routes; fsc->clear_io_irq =3D kvm_s390_clear_io_flic; + fsc->modify_ais_mode =3D kvm_s390_modify_ais_mode; } =20 static const TypeInfo kvm_s390_flic_info =3D { diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h index d4145ad..f500184 100644 --- a/include/hw/s390x/s390_flic.h +++ b/include/hw/s390x/s390_flic.h @@ -44,7 +44,7 @@ typedef struct S390FLICState { SysBusDevice parent_obj; /* to limit AdapterRoutes.num_routes for compat */ uint32_t adapter_routes_max_batch; - + bool ais_supported; } S390FLICState; =20 #define S390_FLIC_COMMON_CLASS(klass) \ @@ -63,6 +63,7 @@ typedef struct S390FLICStateClass { void (*release_adapter_routes)(S390FLICState *fs, AdapterRoutes *route= s); int (*clear_io_irq)(S390FLICState *fs, uint16_t subchannel_id, uint16_t subchannel_nr); + int (*modify_ais_mode)(S390FLICState *fs, uint8_t isc, uint16_t mode); } S390FLICStateClass; =20 #define TYPE_KVM_S390_FLIC "s390-flic-kvm" @@ -73,8 +74,14 @@ typedef struct S390FLICStateClass { #define QEMU_S390_FLIC(obj) \ OBJECT_CHECK(QEMUS390FLICState, (obj), TYPE_QEMU_S390_FLIC) =20 +#define SIC_IRQ_MODE_ALL 0 +#define SIC_IRQ_MODE_SINGLE 1 +#define AIS_MODE_MASK(isc) (0x80 >> isc) + typedef struct QEMUS390FLICState { S390FLICState parent_obj; + uint8_t simm; + uint8_t nimm; } QEMUS390FLICState; =20 void s390_flic_init(void); --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499865050161631.3777801211587; Wed, 12 Jul 2017 06:10:50 -0700 (PDT) Received: from localhost ([::1]:52675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHPe-0000hh-PC for importer@patchew.org; Wed, 12 Jul 2017 09:10:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDL-0006WA-Eg for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDI-00011N-7t for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDH-00010Z-U1 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:56 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCs7Yp037838 for ; Wed, 12 Jul 2017 08:57:54 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncj8hmaw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:54 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:52 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:49 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvmQX40698058; Wed, 12 Jul 2017 12:57:48 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E10E952043; Wed, 12 Jul 2017 12:54:07 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id C9F4F5203F; Wed, 12 Jul 2017 12:54:07 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 460F320F69D; Wed, 12 Jul 2017 14:57:48 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:43 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0020-0000-0000-000003A0704A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0021-0000-0000-000042257CB7 Message-Id: <1499864265-144136-10-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 09/11] s390x/flic: introduce inject_airq callback X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yi Min Zhao , Cornelia Huck , Alexander Graf , Christian Borntraeger , Fei Li , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Yi Min Zhao Let's introduce a specialized way to inject adapter interrupts that, unlike the common interrupt injection method, allows to take the characteristics of the adapter into account. For adapters subject to AIS facility: - for non-kvm case, we handle the suppression for a given ISC in QEMU. - for kvm case, we pass adapter id to kvm to do airq injection. Add add tracepoint for suppressed airq and suppressing airq. Signed-off-by: Yi Min Zhao Signed-off-by: Fei Li Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- hw/intc/s390_flic.c | 27 +++++++++++++++++++++++++++ hw/intc/s390_flic_kvm.c | 18 ++++++++++++++++++ hw/intc/trace-events | 4 ++++ include/hw/s390x/s390_flic.h | 2 ++ 4 files changed, 51 insertions(+) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index ce7f355..efcb1dd 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -13,8 +13,11 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "hw/sysbus.h" +#include "hw/s390x/ioinst.h" #include "hw/s390x/s390_flic.h" +#include "hw/s390x/css.h" #include "trace.h" +#include "cpu.h" #include "hw/qdev.h" #include "qapi/error.h" #include "hw/s390x/s390-virtio-ccw.h" @@ -100,6 +103,29 @@ static int qemu_s390_modify_ais_mode(S390FLICState *fs= , uint8_t isc, return 0; } =20 +static int qemu_s390_inject_airq(S390FLICState *fs, uint8_t type, + uint8_t isc, uint8_t flags) +{ + QEMUS390FLICState *flic =3D QEMU_S390_FLIC(fs); + bool flag =3D flags & S390_ADAPTER_SUPPRESSIBLE; + uint32_t io_int_word =3D (isc << 27) | IO_INT_WORD_AI; + + if (flag && (flic->nimm & AIS_MODE_MASK(isc))) { + trace_qemu_s390_airq_suppressed(type, isc); + return 0; + } + + s390_io_interrupt(0, 0, 0, io_int_word); + + if (flag && (flic->simm & AIS_MODE_MASK(isc))) { + flic->nimm |=3D AIS_MODE_MASK(isc); + trace_qemu_s390_suppress_airq(isc, "Single-Interruption Mode", + "NO-Interruptions Mode"); + } + + return 0; +} + static void qemu_s390_flic_reset(DeviceState *dev) { QEMUS390FLICState *flic =3D QEMU_S390_FLIC(dev); @@ -120,6 +146,7 @@ static void qemu_s390_flic_class_init(ObjectClass *oc, = void *data) fsc->release_adapter_routes =3D qemu_s390_release_adapter_routes; fsc->clear_io_irq =3D qemu_s390_clear_io_flic; fsc->modify_ais_mode =3D qemu_s390_modify_ais_mode; + fsc->inject_airq =3D qemu_s390_inject_airq; } =20 static Property s390_flic_common_properties[] =3D { diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 55aa35f..a587ace 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -170,6 +170,23 @@ static int kvm_s390_modify_ais_mode(S390FLICState *fs,= uint8_t isc, return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; } =20 +static int kvm_s390_inject_airq(S390FLICState *fs, uint8_t type, + uint8_t isc, uint8_t flags) +{ + KVMS390FLICState *flic =3D KVM_S390_FLIC(fs); + uint32_t id =3D css_get_adapter_id(type, isc); + struct kvm_device_attr attr =3D { + .group =3D KVM_DEV_FLIC_AIRQ_INJECT, + .attr =3D id, + }; + + if (!fs->ais_supported) { + return -ENOSYS; + } + + return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; +} + /** * __get_all_irqs - store all pending irqs in buffer * @flic: pointer to flic device state @@ -515,6 +532,7 @@ static void kvm_s390_flic_class_init(ObjectClass *oc, v= oid *data) fsc->release_adapter_routes =3D kvm_s390_release_adapter_routes; fsc->clear_io_irq =3D kvm_s390_clear_io_flic; fsc->modify_ais_mode =3D kvm_s390_modify_ais_mode; + fsc->inject_airq =3D kvm_s390_inject_airq; } =20 static const TypeInfo kvm_s390_flic_info =3D { diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 729c128..c586714 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -73,6 +73,10 @@ flic_create_device(int err) "flic: create device failed = %d" flic_no_device_api(int err) "flic: no Device Contral API support %d" flic_reset_failed(int err) "flic: reset failed %d" =20 +# hw/intc/s390_flic.c +qemu_s390_airq_suppressed(uint8_t type, uint8_t isc) "flic: adapter I/O in= terrupt suppressed (type %x isc %x)" +qemu_s390_suppress_airq(uint8_t isc, const char *from, const char *to) "fl= ic: for isc %x, suppress airq by modifying ais mode from %s to %s" + # hw/intc/aspeed_vic.c aspeed_vic_set_irq(int irq, int level) "Enabling IRQ %d: %d" aspeed_vic_update_fiq(int flags) "Raising FIQ: %d" diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h index f500184..2f173d9 100644 --- a/include/hw/s390x/s390_flic.h +++ b/include/hw/s390x/s390_flic.h @@ -64,6 +64,8 @@ typedef struct S390FLICStateClass { int (*clear_io_irq)(S390FLICState *fs, uint16_t subchannel_id, uint16_t subchannel_nr); int (*modify_ais_mode)(S390FLICState *fs, uint8_t isc, uint16_t mode); + int (*inject_airq)(S390FLICState *fs, uint8_t type, uint8_t isc, + uint8_t flags); } S390FLICStateClass; =20 #define TYPE_KVM_S390_FLIC "s390-flic-kvm" --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864701649970.4370298693427; Wed, 12 Jul 2017 06:05:01 -0700 (PDT) Received: from localhost ([::1]:52641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHK3-00040M-1Z for importer@patchew.org; Wed, 12 Jul 2017 09:04:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDK-0006VZ-W6 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDG-0000zY-6f for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:59 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55034 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDG-0000zD-0Q for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:54 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCs6Xv131818 for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bncj59qbj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:51 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:49 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvnCf3670436; Wed, 12 Jul 2017 12:57:49 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F2874C044; Wed, 12 Jul 2017 13:55:33 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 283134C046; Wed, 12 Jul 2017 13:55:33 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:33 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 93EAC20F69C; Wed, 12 Jul 2017 14:57:48 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:44 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0008-0000-0000-0000047F7043 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0009-0000-0000-00001E0A917A Message-Id: <1499864265-144136-11-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 10/11] s390x/sic: realize SIC handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yi Min Zhao , Cornelia Huck , Alexander Graf , Christian Borntraeger , Fei Li , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fei Li Currently, we do nothing for the SIC instruction, but we need to implement it properly. Let's add proper handling in the backend code. Co-authored-by: Yi Min Zhao Signed-off-by: Yi Min Zhao Signed-off-by: Fei Li Signed-off-by: Christian Borntraeger --- hw/s390x/css.c | 26 ++++++++++++++++++++++++++ hw/s390x/trace-events | 1 + include/hw/s390x/css.h | 2 ++ target/s390x/kvm.c | 16 +++++++++++++++- 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 1fcbc84..7b82176 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -521,6 +521,32 @@ void css_conditional_io_interrupt(SubchDev *sch) } } =20 +int css_do_sic(CPUS390XState *env, uint8_t isc, uint16_t mode) +{ + S390FLICState *fs =3D s390_get_flic(); + S390FLICStateClass *fsc =3D S390_FLIC_COMMON_GET_CLASS(fs); + int r; + + if (env->psw.mask & PSW_MASK_PSTATE) { + r =3D -PGM_PRIVILEGED; + goto out; + } + + trace_css_do_sic(mode, isc); + switch (mode) { + case SIC_IRQ_MODE_ALL: + case SIC_IRQ_MODE_SINGLE: + break; + default: + r =3D -PGM_OPERAND; + goto out; + } + + r =3D fsc->modify_ais_mode(fs, isc, mode) ? -PGM_OPERATION : 0; +out: + return r; +} + void css_adapter_interrupt(uint8_t isc) { uint32_t io_int_word =3D (isc << 27) | IO_INT_WORD_AI; diff --git a/hw/s390x/trace-events b/hw/s390x/trace-events index 84ea964..f07e974 100644 --- a/hw/s390x/trace-events +++ b/hw/s390x/trace-events @@ -8,6 +8,7 @@ css_new_image(uint8_t cssid, const char *default_cssid) "CS= S: add css image %02x css_assign_subch(const char *do_assign, uint8_t cssid, uint8_t ssid, uint1= 6_t schid, uint16_t devno) "CSS: %s %x.%x.%04x (devno %04x)" css_io_interrupt(int cssid, int ssid, int schid, uint32_t intparm, uint8_t= isc, const char *conditional) "CSS: I/O interrupt on sch %x.%x.%04x (intpa= rm %08x, isc %x) %s" css_adapter_interrupt(uint8_t isc) "CSS: adapter I/O interrupt (isc %x)" +css_do_sic(uint16_t mode, uint8_t isc) "CSS: set interruption mode %x on i= sc %x" =20 # hw/s390x/virtio-ccw.c virtio_ccw_interpret_ccw(int cssid, int ssid, int schid, int cmd_code) "VI= RTIO-CCW: %x.%x.%04x: interpret command %x" diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index e028960..5ee6d52 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -12,6 +12,7 @@ #ifndef CSS_H #define CSS_H =20 +#include "cpu.h" #include "hw/s390x/adapter.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/ioinst.h" @@ -165,6 +166,7 @@ typedef enum { CSS_IO_ADAPTER_TYPE_NUMS, } CssIoAdapterType; =20 +int css_do_sic(CPUS390XState *env, uint8_t isc, uint16_t mode); uint32_t css_get_adapter_id(CssIoAdapterType type, uint8_t isc); void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maska= ble, uint8_t flags, Error **errp); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 7a2a7c0..78ebe83 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1206,7 +1206,21 @@ static int kvm_stpcifc_service_call(S390CPU *cpu, st= ruct kvm_run *run) =20 static int kvm_sic_service_call(S390CPU *cpu, struct kvm_run *run) { - /* NOOP */ + CPUS390XState *env =3D &cpu->env; + uint8_t r1 =3D (run->s390_sieic.ipa & 0x00f0) >> 4; + uint8_t r3 =3D run->s390_sieic.ipa & 0x000f; + uint8_t isc; + uint16_t mode; + int r; + + cpu_synchronize_state(CPU(cpu)); + mode =3D env->regs[r1] & 0xffff; + isc =3D (env->regs[r3] >> 27) & 0x7; + r =3D css_do_sic(env, isc, mode); + if (r) { + enter_pgmcheck(cpu, -r); + } + return 0; } =20 --=20 2.7.4 From nobody Sat May 4 00:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864918693643.4861461206488; Wed, 12 Jul 2017 06:08:38 -0700 (PDT) Received: from localhost ([::1]:52661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHNW-0006tb-DK for importer@patchew.org; Wed, 12 Jul 2017 09:08:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDM-0006Xb-Qb for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDH-00010h-FZ for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:32902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDH-0000zv-5d for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:55 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCs5Aj063340 for ; Wed, 12 Jul 2017 08:57:54 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncjasswa-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:51 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:49 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvn3N39387288; Wed, 12 Jul 2017 12:57:49 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0ED8CA4053; Wed, 12 Jul 2017 13:55:08 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB285A4040; Wed, 12 Jul 2017 13:55:07 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:07 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id E230520F69D; Wed, 12 Jul 2017 14:57:48 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:45 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0040-0000-0000-000003E27181 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0041-0000-0000-0000207D9896 Message-Id: <1499864265-144136-12-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 11/11] s390x/css: update css_adapter_interrupt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yi Min Zhao , Cornelia Huck , Alexander Graf , Christian Borntraeger , Fei Li , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Yi Min Zhao Let's use the new inject_airq callback of flic to inject adapter interrupts. For kvm case, if the kernel flic doesn't support the new interface, the irq routine remains unchanged. For non-kvm case, qemu-flic handles the suppression process. Signed-off-by: Yi Min Zhao Signed-off-by: Fei Li Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- hw/s390x/css.c | 18 ++++++++++++++++-- hw/s390x/s390-pci-bus.c | 2 +- hw/s390x/virtio-ccw.c | 2 +- include/hw/s390x/css.h | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 7b82176..ee4ebbf 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -547,12 +547,26 @@ out: return r; } =20 -void css_adapter_interrupt(uint8_t isc) +void css_adapter_interrupt(CssIoAdapterType type, uint8_t isc) { + S390FLICState *fs =3D s390_get_flic(); + S390FLICStateClass *fsc =3D S390_FLIC_COMMON_GET_CLASS(fs); uint32_t io_int_word =3D (isc << 27) | IO_INT_WORD_AI; + IoAdapter *adapter =3D channel_subsys.io_adapters[type][isc]; + + if (!adapter) { + return; + } =20 trace_css_adapter_interrupt(isc); - s390_io_interrupt(0, 0, 0, io_int_word); + if (fs->ais_supported) { + if (fsc->inject_airq(fs, type, isc, adapter->flags)) { + fprintf(stderr, "Failed to inject airq with AIS supported\n"); + exit(1); + } + } else { + s390_io_interrupt(0, 0, 0, io_int_word); + } } =20 static void sch_handle_clear_func(SubchDev *sch) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index b9603e7..2de4435 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -504,7 +504,7 @@ static void s390_msi_ctrl_write(void *opaque, hwaddr ad= dr, uint64_t data, 0x80 >> ((ind_bit + vec) % 8)); if (!set_ind_atomic(pbdev->routes.adapter.summary_addr + sum_bit / 8, 0x80 >> (sum_bit % 8))) { - css_adapter_interrupt(pbdev->isc); + css_adapter_interrupt(CSS_IO_ADAPTER_PCI, pbdev->isc); } } =20 diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index e18fd26..5afd9bb 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1074,7 +1074,7 @@ static void virtio_ccw_notify(DeviceState *d, uint16_= t vector) 0x80 >> ((ind_bit + vector) % 8)); if (!virtio_set_ind_atomic(sch, dev->summary_indicator->addr, 0x01)) { - css_adapter_interrupt(dev->thinint_isc); + css_adapter_interrupt(CSS_IO_ADAPTER_VIRTIO, dev->thinint_= isc); } } else { indicators =3D address_space_ldq(&address_space_memory, diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 5ee6d52..dd36d39 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -155,7 +155,6 @@ void css_generate_sch_crws(uint8_t cssid, uint8_t ssid,= uint16_t schid, void css_generate_chp_crws(uint8_t cssid, uint8_t chpid); void css_generate_css_crws(uint8_t cssid); void css_clear_sei_pending(void); -void css_adapter_interrupt(uint8_t isc); int s390_ccw_cmd_request(ORB *orb, SCSW *scsw, void *data); int do_subchannel_work_virtual(SubchDev *sub, ORB *orb); int do_subchannel_work_passthrough(SubchDev *sub, ORB *orb); @@ -166,6 +165,7 @@ typedef enum { CSS_IO_ADAPTER_TYPE_NUMS, } CssIoAdapterType; =20 +void css_adapter_interrupt(CssIoAdapterType type, uint8_t isc); int css_do_sic(CPUS390XState *env, uint8_t isc, uint16_t mode); uint32_t css_get_adapter_id(CssIoAdapterType type, uint8_t isc); void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maska= ble, --=20 2.7.4