Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20418061rwd; Thu, 29 Jun 2023 01:54:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4e8fwHTEI5LaaLaAvSA6EQKLLmS//NR8ecK3LyiO9lhW2/B7UN17q+v9Xy0ciV/YkuyC3B X-Received: by 2002:a05:6a20:2454:b0:10b:ca02:1a5e with SMTP id t20-20020a056a20245400b0010bca021a5emr42828940pzc.55.1688028855169; Thu, 29 Jun 2023 01:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688028855; cv=none; d=google.com; s=arc-20160816; b=dH6c1xnY03XRwfIt/0KaxzK7vdQRCofSJIfyknVfEQ4RFae/8M3CxIa1cBvemVt6nC mtnTAxF4vU2rNAGCaEPP6ymSCXlPeL6ZwkivLVBjS/0eaSvAfVgaJvgNpC4Rf+A74HMQ SfhkGu7+3c3kuaHjCta2hbE31Zp9nQL0aLK1w1TeshAJoSBwcauUV3feFsy9ufrkEj22 cGkq7meB5ejLsIneZ/264xvBdjMVrpSxDwURdhAvgz7hwp1XLKNk5YbI10uCyCL93aFg LFYDxCmFAJaH89s/lIx4iSDIavrMr+u5OucxgRLgs5RoF2FL2X/Up9Q3nCXbMExsUac6 3EmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cqMrso5gDfwZnB5bV5MvQaY76I7xoNI1XdhiY44LtCY=; fh=gHcTkaRruKuCoNKJrhDWrp4+Ah5F5Oad2CKpxX1Lrts=; b=dCV9qgTWD19Fx7u2tCdnQnIYPedP0AZoua0tFo3iV0iIBTGJbWzM8m5GI+hnTNVwxY QmsUAmMJmoAkwCBfZPropHyuTip7ohuD/rMZWZpkLXLwU+hqbiNOCuMcAMTBGwD+lzqj Umj87L87Gz6WBw0Ir5b2pSONChFrCmkc9x+LDzECweVy717FLjODu5T8E3Q9BSVc3Lwj XDyJYgVjHAZnPFZTzu4mozjYCIPdONJD63XaS1+Mm+nECRwy/yFTT8u5ktjun6U7anNh BN8mK45G90DSi8UJXtgy1W4yCu1NBh8gYv/XOftfAvs9KxEOMhYKapuK3gfYz1co6tJD NdVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Gr7Oj9sH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020aa78882000000b0065dba8cc3a6si2217380pfe.376.2023.06.29.01.54.01; Thu, 29 Jun 2023 01:54:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Gr7Oj9sH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231768AbjF2Ilb (ORCPT + 99 others); Thu, 29 Jun 2023 04:41:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230330AbjF2Ik3 (ORCPT ); Thu, 29 Jun 2023 04:40:29 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 620BD3AAB; Thu, 29 Jun 2023 01:35:12 -0700 (PDT) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35T8QGBL027444; Thu, 29 Jun 2023 08:35:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=cqMrso5gDfwZnB5bV5MvQaY76I7xoNI1XdhiY44LtCY=; b=Gr7Oj9sH7Y9YSnvYhNMA6+INdN9Ss9FKLSxik7yeS9sB0J1UIU6EcAfR0K2aLKH6SAtR D1Ui+X0U4skLZJ9Wb8cpbQc4TzN3aZ8UPL7zE2QQKabnkYOU4KoMuFknLL5FhoUuprMM IMLSniEBI5VGuqhCta4gvOn7ZN+M+HkuQfbGMFzmyoZ4/GQ88lyQCxTt5c/LQH3yIzD2 WBmp9Pvsb0SEwZdRIE+m8xc9z4o4TAR+c8hiqIh1Nb85Z/uMpsWNR+4pOuyPTig2b1wW HCT9AKlMBqT2nWB26uYbygVZ3IpsERIMkuUzyaBcELPbYAAFXvOLOPD2Kj0wa6W7YbL8 jA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rh6ef85b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 08:35:11 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35T8WdDM015841; Thu, 29 Jun 2023 08:35:11 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rh6ef85a9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 08:35:11 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35T2n9FI027820; Thu, 29 Jun 2023 08:35:09 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3rdr452e4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 08:35:08 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35T8Z5od18023090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 08:35:05 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C76020043; Thu, 29 Jun 2023 08:35:05 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E25520040; Thu, 29 Jun 2023 08:35:04 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.179.0.51]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Jun 2023 08:35:04 +0000 (GMT) From: Ilya Leoshkevich To: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Alexander Gordeev Cc: David Hildenbrand , Sven Schnelle , kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Jens Freimann , Ilya Leoshkevich Subject: [PATCH 2/2] KVM: s390: interrupt: Fix stepping into program interrupt handlers Date: Thu, 29 Jun 2023 10:32:05 +0200 Message-ID: <20230629083452.183274-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230629083452.183274-1-iii@linux.ibm.com> References: <20230629083452.183274-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2GEORKLc245hTKcr8UttZE8pANq5V8c_ X-Proofpoint-GUID: MLAmbj7ajNvYbtBDP7noeNjwMBaakXqN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_14,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306290075 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, after single-stepping an instruction that causes a specification exception, GDB ends up on the instruction immediately following it. The reason is that vcpu_post_run() injects the interrupt and sets KVM_GUESTDBG_EXIT_PENDING, causing a KVM_SINGLESTEP exit. The interrupt is not delivered, however, therefore userspace sees the address of the next instruction. Fix by letting the __vcpu_run() loop go into the next iteration, where vcpu_pre_run() delivers the interrupt and sets KVM_GUESTDBG_EXIT_PENDING. Signed-off-by: Ilya Leoshkevich --- arch/s390/kvm/intercept.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c index 0ee02dae14b2..f8adb64ebda1 100644 --- a/arch/s390/kvm/intercept.c +++ b/arch/s390/kvm/intercept.c @@ -226,7 +226,22 @@ static int handle_itdb(struct kvm_vcpu *vcpu) return 0; } -#define per_event(vcpu) (vcpu->arch.sie_block->iprcc & PGM_PER) +static bool should_handle_per_event(struct kvm_vcpu *vcpu) +{ + if (!guestdbg_enabled(vcpu)) + return false; + if (!(vcpu->arch.sie_block->iprcc & PGM_PER)) + return false; + if (guestdbg_sstep_enabled(vcpu) && + vcpu->arch.sie_block->iprcc != PGM_PER) { + /* + * __vcpu_run() will exit after delivering the concurrently + * indicated condition. + */ + return false; + } + return true; +} static int handle_prog(struct kvm_vcpu *vcpu) { @@ -242,7 +257,7 @@ static int handle_prog(struct kvm_vcpu *vcpu) if (kvm_s390_pv_cpu_is_protected(vcpu)) return -EOPNOTSUPP; - if (guestdbg_enabled(vcpu) && per_event(vcpu)) { + if (should_handle_per_event(vcpu)) { rc = kvm_s390_handle_per_event(vcpu); if (rc) return rc; -- 2.41.0