From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 665EFC433EF for ; Thu, 21 Apr 2022 15:22:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BE8C34B296; Thu, 21 Apr 2022 11:22:11 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A4n65v36-mdP; Thu, 21 Apr 2022 11:22:10 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 84B864B20B; Thu, 21 Apr 2022 11:22:10 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8E0794B206 for ; Thu, 21 Apr 2022 11:22:08 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VWMtMLxDOA2A for ; Thu, 21 Apr 2022 11:22:06 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E19E74B10C for ; Thu, 21 Apr 2022 11:22:06 -0400 (EDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1EBCC1516; Thu, 21 Apr 2022 08:22:06 -0700 (PDT) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AEBFF3F73B; Thu, 21 Apr 2022 08:22:04 -0700 (PDT) Date: Thu, 21 Apr 2022 16:22:00 +0100 From: Alexandru Elisei To: Marc Zyngier Subject: Re: [PATCH v2 5/5] KVM: arm64: uapi: Add kvm_debug_exit_arch.hsr_high Message-ID: References: <20220421100547.873761-1-alexandru.elisei@arm.com> <20220421100547.873761-6-alexandru.elisei@arm.com> <87ee1qa8z7.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87ee1qa8z7.wl-maz@kernel.org> Cc: catalin.marinas@arm.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi, On Thu, Apr 21, 2022 at 01:58:52PM +0100, Marc Zyngier wrote: > On Thu, 21 Apr 2022 11:05:47 +0100, > Alexandru Elisei wrote: > > > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c > > index 93d92130d36c..fd5b6773e3a2 100644 > > --- a/arch/arm64/kvm/handle_exit.c > > +++ b/arch/arm64/kvm/handle_exit.c > > @@ -121,6 +121,8 @@ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu) > > > > run->exit_reason = KVM_EXIT_DEBUG; > > run->debug.arch.hsr = lower_32_bits(esr); > > + run->debug.arch.hsr_high = upper_32_bits(esr); > > + run->flags |= KVM_DEBUG_ARCH_HSR_HIGH_VALID; > > Who will eventually clear this flag? I'm concerned that it could be > misinterpreted by other userspace paths, as once you get a debug exit > on this vcpu, it will always be set. > > Probably only a matter of clearing flags on all the other exit paths. I missed this part, I was under the impression that kvm_run->flags was already cleared on every exit (that's why it's bitwise OR'ed with the flag). kvm_arch_vcpu_ioctl_run() always sets exit_reason = KVM_EXIT_UNKNOWN, so I guess if we want to be consistent, kvm_run->flags should be cleared at the same time. Unless you want KVM to clear flags for all exit reasons *except* KVM_EXIT_UNKNOWN. I prefer clearing flags in kvm_arch_vcpu_ioctl_run() as that looks to me like the least error prone way to do it, and if in the future an exit reason wants to preserve flags across KVM_RUN ioctls we can add a check for that particular situation. > > Also, please document the flag in the API file (only a couple of x86 > flags are there so far). Sure thing, will do. Thanks, Alex _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FC14C433F5 for ; Thu, 21 Apr 2022 15:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=utKqCN5nbynvh/zmluL/E9JINUbPBVI2a2/qOAV7+Xo=; b=JHuLSu2R+zCEiv 9JSkOTIu7sQuStx0g8ONNucHymJWAhzgG+hCKdnyN0LyR0TA+IL0PZtIOC68itqppeRuNxAkCKthL XdDCltmTF+AJ7Tf9s4TcjjhliCSPMOYW8/PmJIhQ/SY2klopsQyYu/IDGK7UzecR004sPyYMCnFph ptGVVx0Fg41fZzSTkNJjIlLHqOy11hrOvDkbuzLGZWJx/2PiOhoP2IQT1iWotFGrJ3/NacKfbC3VA yHtL8AGV714bqiX+Rti1eBzi+9WeoJorZlfht52bO5rpSeab3VJo8DUSY0/zC5kfFGOIwwD+1H5Ao hEd3uheVufcsVke53tFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhYdH-00DzHC-Tq; Thu, 21 Apr 2022 15:22:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhYdF-00DzGL-6D for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 15:22:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1EBCC1516; Thu, 21 Apr 2022 08:22:06 -0700 (PDT) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AEBFF3F73B; Thu, 21 Apr 2022 08:22:04 -0700 (PDT) Date: Thu, 21 Apr 2022 16:22:00 +0100 From: Alexandru Elisei To: Marc Zyngier Cc: catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, kvmarm@lists.cs.columbia.edu, mark.rutland@arm.com Subject: Re: [PATCH v2 5/5] KVM: arm64: uapi: Add kvm_debug_exit_arch.hsr_high Message-ID: References: <20220421100547.873761-1-alexandru.elisei@arm.com> <20220421100547.873761-6-alexandru.elisei@arm.com> <87ee1qa8z7.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87ee1qa8z7.wl-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_082209_310919_C6229744 X-CRM114-Status: GOOD ( 17.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Thu, Apr 21, 2022 at 01:58:52PM +0100, Marc Zyngier wrote: > On Thu, 21 Apr 2022 11:05:47 +0100, > Alexandru Elisei wrote: > > > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c > > index 93d92130d36c..fd5b6773e3a2 100644 > > --- a/arch/arm64/kvm/handle_exit.c > > +++ b/arch/arm64/kvm/handle_exit.c > > @@ -121,6 +121,8 @@ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu) > > > > run->exit_reason = KVM_EXIT_DEBUG; > > run->debug.arch.hsr = lower_32_bits(esr); > > + run->debug.arch.hsr_high = upper_32_bits(esr); > > + run->flags |= KVM_DEBUG_ARCH_HSR_HIGH_VALID; > > Who will eventually clear this flag? I'm concerned that it could be > misinterpreted by other userspace paths, as once you get a debug exit > on this vcpu, it will always be set. > > Probably only a matter of clearing flags on all the other exit paths. I missed this part, I was under the impression that kvm_run->flags was already cleared on every exit (that's why it's bitwise OR'ed with the flag). kvm_arch_vcpu_ioctl_run() always sets exit_reason = KVM_EXIT_UNKNOWN, so I guess if we want to be consistent, kvm_run->flags should be cleared at the same time. Unless you want KVM to clear flags for all exit reasons *except* KVM_EXIT_UNKNOWN. I prefer clearing flags in kvm_arch_vcpu_ioctl_run() as that looks to me like the least error prone way to do it, and if in the future an exit reason wants to preserve flags across KVM_RUN ioctls we can add a check for that particular situation. > > Also, please document the flag in the API file (only a couple of x86 > flags are there so far). Sure thing, will do. Thanks, Alex _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel