Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2879806rwo; Mon, 24 Jul 2023 02:47:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcX2Gm6ZudQHTH9rJo9jKMvTOZz2vUuoiAs9LkR+cggHa8OlJhQ8MGSGUI2MGbM43nOO5t X-Received: by 2002:a17:906:59:b0:993:f744:d235 with SMTP id 25-20020a170906005900b00993f744d235mr10641044ejg.6.1690192043496; Mon, 24 Jul 2023 02:47:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690192043; cv=none; d=google.com; s=arc-20160816; b=vffvK8AmoDmA7Q3e9weY46ovpNpka89ygTW6nFWObQbC4jnJ8fbPU6n2eeCgU+dU4y 87t67srKYkKH/QVBT2JSod4QhGFkc4pSmzHWGMrY58PJw4XGFRZojfVvhcnbFASDQOSF n63caWPKmumf1YSGyGkU/dinbZPkZ0+yaU0sLogXJYxL9QaCMnJ5lvV86VrCMUTniUM+ +vJhzHuZBiUuDmGGHKRjEVpvXACQnyqC6QpclGtwxoq8FOFmIAD2lLV5ahrlJE6jmgat q8z+4pj4VLZSM/V1qVDG9lVo2urbFNdNEL5h8s/9yWIeR7nFmsxAxmMe+taawG9jjVrD HlDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=pqVPx2T65FEY/gXsUV2SoZ8UzlYeQwEk4kcTv3TVfeE=; fh=vvVWumKuo1HbA32aw4Zn8422B5gzj0CM3wLsIcYKGQE=; b=dYRZESXXaEibb0939A/X1oHmAfGLXx2nMdZxH3klw0tltn38uhJGEXcZJqS35XsGbR Gd4/ECI4ykcT87zVioSDeIuOk8/Y37DI9nTJ9fhZ/1cnuVLlq14e0QjVd3fUkNJWuqPq GEAsHMuhuB2MKHClqmBMHLnzxx7b6MxFsofhy6XMyN4r5+BOg6qtSjWR3feNp+Hr08Pf Gb6BhAJgTGR/vTLwlSgujqv2hPHdsYJaHB5e5hxhWOsa8NBJP87xYWgBxSJyhTr6vzAD 7mHa4jV7oUvySRd2iHkfzQbd4ru5pvO9MXNWsm42KLudyLETy+kSfcZ6BDNMQZcCac6u D2dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QOemp78Y; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a170906915400b00991b9b54b2asi6201244ejw.135.2023.07.24.02.46.59; Mon, 24 Jul 2023 02:47:23 -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=@redhat.com header.s=mimecast20190719 header.b=QOemp78Y; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbjGXI2J (ORCPT + 99 others); Mon, 24 Jul 2023 04:28:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231675AbjGXI16 (ORCPT ); Mon, 24 Jul 2023 04:27:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A04119AD for ; Mon, 24 Jul 2023 01:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690187183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pqVPx2T65FEY/gXsUV2SoZ8UzlYeQwEk4kcTv3TVfeE=; b=QOemp78YMRLGd7KsT+pV8mh7ilpDH+upNP4jUFo7HbCeJ1Nj2aETs53Q/izEQeLq83ytFH GlBOQMqFzWPORQqX//xne8jsbu/ucIu67DrcXigu6h/4QcLBDqDBmrHibi8gMQmIaKOcS6 FlV20kpSOKyKtQwkOsEI7QfX7sLvbBs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-161-DtSS6FXKMVWkdfl3P0h3hA-1; Mon, 24 Jul 2023 04:26:21 -0400 X-MC-Unique: DtSS6FXKMVWkdfl3P0h3hA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3faabd8fd33so19623555e9.0 for ; Mon, 24 Jul 2023 01:26:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690187180; x=1690791980; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pqVPx2T65FEY/gXsUV2SoZ8UzlYeQwEk4kcTv3TVfeE=; b=EOhR3qqiIsrlRf3ApSL0UESzhhd+J1dOOE4IQTFuhKfaqKrorNNc/ROEDN4ffwy/ls L8LU2iOtF1/STtmeikW3hgOigaekzoYZ/50O0JCC/tXPnHaYWRRkO8U2KFfjUQQZdpKk D+aF8Frg0tyhTIJG0n4YZk5d12/CRYkeuVlZqdkU/EEO3yM8O2yhBZvdxpmIR6cZGgXs gNFqgG7SwZ9tRJRedQC6CclfqPV7leK2Prs6uzam+OF6lib/OP2ckTQmPtGUro1eCq+Y vHuhFIbguDV6kBXGMKvmbE4MIfdQgSwetmyCTQbugOVvlElQDMKPkCpBZRH5aukcC8JA QyDQ== X-Gm-Message-State: ABy/qLZIanbXomP9iKOE3Yx8cNjXxsEvh0NWgRd6biCsKb16lospQunE FY5ccXULjGWle16dX/RIsnpSHJdujtgOzYjFbBpO5/yP8GV2HDnuxQG7C95IbpOluRGC0fpGNe3 aaadAARBF80QQV2bueyOP5+s1 X-Received: by 2002:a7b:cb17:0:b0:3fc:3f31:422f with SMTP id u23-20020a7bcb17000000b003fc3f31422fmr6181988wmj.3.1690187180412; Mon, 24 Jul 2023 01:26:20 -0700 (PDT) X-Received: by 2002:a7b:cb17:0:b0:3fc:3f31:422f with SMTP id u23-20020a7bcb17000000b003fc3f31422fmr6181967wmj.3.1690187180039; Mon, 24 Jul 2023 01:26:20 -0700 (PDT) Received: from ?IPV6:2003:d8:2f45:d000:62f2:4df0:704a:e859? (p200300d82f45d00062f24df0704ae859.dip0.t-ipconnect.de. [2003:d8:2f45:d000:62f2:4df0:704a:e859]) by smtp.gmail.com with ESMTPSA id j5-20020adff005000000b0031764e85b91sm363145wro.68.2023.07.24.01.26.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jul 2023 01:26:19 -0700 (PDT) Message-ID: Date: Mon, 24 Jul 2023 10:26:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2 2/6] KVM: s390: interrupt: Fix single-stepping into program interrupt handlers Content-Language: en-US To: Ilya Leoshkevich , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Alexander Gordeev Cc: Sven Schnelle , kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Jens Freimann References: <20230721120046.2262291-1-iii@linux.ibm.com> <20230721120046.2262291-3-iii@linux.ibm.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230721120046.2262291-3-iii@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 21.07.23 13:57, Ilya Leoshkevich wrote: > Currently, after single-stepping an instruction that generates 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 954d39adf85c..7cdd927541b0 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(const 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; Reviewed-by: David Hildenbrand -- Cheers, David / dhildenb