Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1362660rdb; Mon, 2 Oct 2023 07:24:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0zz2LeXs/HMhfh+SmvAUYGQHfbvmk7+pcgYLemWWTN4+xumE5OMat5F+mq9ad4oVdq7v9 X-Received: by 2002:a17:90a:c28b:b0:279:57d:f6fc with SMTP id f11-20020a17090ac28b00b00279057df6fcmr9105854pjt.44.1696256690429; Mon, 02 Oct 2023 07:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696256690; cv=none; d=google.com; s=arc-20160816; b=hhdo9iJVHDBZ41RN3AOppX3fKkmwLe6yXcE27gjsgP/49qxO6tY3275U9Wpc8mL7km FPu2ADMl7jB+QzEMBkrEEGDpEJB8/NxdWjLzs8r80fXOaBl9CZfInUxFTrXaYbMm2I5d Wu4MDHL9SK5V/Ih529jQzJIlBV8wJQt/6+h2GYXU7TiLkBdGk5e87e3zsSIuO5lXnroG lcqFgHjFLJvEauCIP8mHGwwCSu28WmTz0EtTxLz7eOHGt234x6xz8ODAhdcTYnFAfJry OEGvGgqxOo4o0qm5LbrZlkcDF+0ouA5KVDeV0OgUhwb9aVgjJlAx1yKRi+Pw9wXSThPR CWoA== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=lWPF5mHNwiFkkRhDdFTjfnmDjAaXJ8zZt5cQuqGcKkM=; fh=alJabTXUJO82EsWZ7Gd7Sw4rE3ki40M6dAMewMbSUsY=; b=UER9/oj45k3G+mdj3BtduRgaWpevqcWTHTUmCS4Iw1axEaRfElW+wlsPYneoqbzb03 jAFfnDUzICZVYQHC5Ac38YNDSQGGom8iRThVkylQOnchbqSEEKDRXT07psLJ7vKth3U0 a7yiMth2BN9AYnBIPaKi3L1TLTUP8VsAdeoQZv8U3WjK9UgHnrvR0Yp3kLdnC0cmdASo jtmwMx8JD0kWDTHyeEQcuZSDGi5gXokEOxHDSM4zvATL8AXLzJ2lOHiNOsSDoYF9WYEc 22N3UeJQ/L0Zz9E3B/oZh5F+1fG/tXG2Dr9prKmaY4dYTVKCrsPSNYCtD12cP6kjRSW9 0kRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id z18-20020a17090ad79200b0027681e3a57fsi7546080pju.162.2023.10.02.07.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 07:24:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 28F158045BF5; Mon, 2 Oct 2023 07:07:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237643AbjJBOGw (ORCPT + 99 others); Mon, 2 Oct 2023 10:06:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237452AbjJBOGu (ORCPT ); Mon, 2 Oct 2023 10:06:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D9900B0 for ; Mon, 2 Oct 2023 07:06:46 -0700 (PDT) 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 18D4CC15; Mon, 2 Oct 2023 07:07:25 -0700 (PDT) Received: from [10.57.66.29] (unknown [10.57.66.29]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E30873F762; Mon, 2 Oct 2023 07:06:43 -0700 (PDT) Message-ID: <0f99fa65-c8c1-5d5c-d9b0-5436b7592656@arm.com> Date: Mon, 2 Oct 2023 15:06:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2 1/2] KVM: arm64: Add handler for MOPS exceptions Content-Language: en-US To: Marc Zyngier Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Vladimir Murzin , Colton Lewis , linux-kernel@vger.kernel.org, Oliver Upton References: <20230922112508.1774352-1-kristina.martsenko@arm.com> <20230922112508.1774352-2-kristina.martsenko@arm.com> <87sf734ofv.wl-maz@kernel.org> <9f731870-ed36-d2e4-378b-f7fbf338ebd6@arm.com> <87h6ndmixh.wl-maz@kernel.org> From: Kristina Martsenko In-Reply-To: <87h6ndmixh.wl-maz@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 07:07:05 -0700 (PDT) On 29/09/2023 10:23, Marc Zyngier wrote: > On Wed, 27 Sep 2023 09:28:20 +0100, > Oliver Upton wrote: >> >> On Mon, Sep 25, 2023 at 04:16:06PM +0100, Kristina Martsenko wrote: >> >> [...] >> >>>> What is the rationale for advancing the state machine? Shouldn't we >>>> instead return to the guest and immediately get the SS exception, >>>> which in turn gets reported to userspace? Is it because we rollback >>>> the PC to a previous instruction? >>> >>> Yes, because we rollback the PC to the prologue instruction. We advance the >>> state machine so that the SS exception is taken immediately upon returning to >>> the guest at the prologue instruction. If we didn't advance it then we would >>> return to the guest, execute the prologue instruction, and then take the SS >>> exception on the middle instruction. Which would be surprising as userspace >>> would see the middle and epilogue instructions executed multiple times but not >>> the prologue. >> >> I agree with Kristina that taking the SS exception on the prologue is >> likely the best course of action. Especially since it matches the >> behavior of single-stepping an EL0 MOPS sequence with an intervening CPU >> migration. >> >> This behavior might throw an EL1 that single-steps itself for a loop, >> but I think it is impossible for a hypervisor to hide the consequences >> of vCPU migration with MOPS in the first place. >> >> Marc, I'm guessing you were most concerned about the former case where >> the VMM was debugging the guest. Is there something you're concerned >> about I missed? > > My concern is not only the VMM, but any userspace that perform > single-stepping. Imagine the debugger tracks PC by itself, and simply > increments it by 4 on a non-branch, non-fault instruction. > > Move the vcpu or the userspace around, rewind PC, and now the debugger > is out of whack with what is executing. While I agree that there is > not much a hypervisor can do about that, I'm a bit worried that we are > going to break existing SW with this. > > Now the obvious solution is "don't do that"... If the debugger can handle the PC changing on branching or faulting instructions, then why can't it handle it on MOPS instructions? Wouldn't such a debugger need to be updated any time the architecture adds new branching or faulting instructions? What's different here? Confused, Kristina