Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1397970rdb; Mon, 2 Oct 2023 08:22:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0Men7Jg3GhmP41l7MZaWD12nwxAWm6wghZDGilEY126zqizpjc27EA3OuSFQstFs89n1X X-Received: by 2002:a17:902:ce84:b0:1c5:f5a9:4ad6 with SMTP id f4-20020a170902ce8400b001c5f5a94ad6mr12307517plg.1.1696260143015; Mon, 02 Oct 2023 08:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696260142; cv=none; d=google.com; s=arc-20160816; b=BIrZnIsHLThfng8998I0Xd+X15+uwIVQluMAu8ZrZTGKmLwcIGmMH2dBSbeca674yl nWOFPpwgAuT4AcejQsLMPRgJQsNeAjfSLrZNtz59bEt2YjVDyOXs4fmCkynIxuQi/A9r ZZ2+Z90fJKm2OKGn3OiTOz+68ln/vdjQaFeluPO1kzG86qqhXnF+x0Em4VJ5A3+LSIr4 ixYVNm240zCSKnT+sx2+U6kMUNlxCNwT2UXe5okTv2F8i0i0tKcn3adbFRA9GDW62V3i xYKyPAglTFPXe//1dLsDbHpmQMLCG0iEtFz87Cg6VJFWyYaRDf1qiLXLw3bGbCuz82J8 MdEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=aX6WkElIfe/fONaI+lRzRzePmqeASaC347y++4Fqwgs=; fh=RO8C/G6P4bWcPMmmypF1EsyBdnifURlg1zEP2IHXsl8=; b=u8TgX35hT5jJWBn2oQSsH5gE1Jv62LKrO+mzq26l5qEWroXSGV3cs+gyWRo6UTcige KbW0f3O7aR4fHJcm8m+MM5HodIwWxyqx9Mof2//+w/32xXX/YJL/zrxdd/YSWz8IorVS GuQvpg782eMOIWutj0yN+tLqEkFV/vYGZuFKzkZG6HD5/KYJgdxYZVPSU2hvfaYGzlCo BJQ3D91t/cXZvve6vOnCyoniYJTw40pYLSzkO/WNSTuIVnKXUDDaN9z0VhaGspARSlkx vc1pNee8+d4iqNldfHBNmAOELbBuz4uc/G/4m8iBTV7XJFBk/bOoOF8jBPxzdg7HjYSc 0nhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lun3LhDi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id c7-20020a170902d48700b001b9da7af2c0si30092387plg.214.2023.10.02.08.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:22:22 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lun3LhDi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8605580763DB; Mon, 2 Oct 2023 07:55:50 -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 S237886AbjJBOzm (ORCPT + 99 others); Mon, 2 Oct 2023 10:55:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237893AbjJBOzl (ORCPT ); Mon, 2 Oct 2023 10:55:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D882CB7 for ; Mon, 2 Oct 2023 07:55:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74BC1C433C7; Mon, 2 Oct 2023 14:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696258537; bh=NokVBFgadEMtni2M3l2Wq2/V/A/PnSV8/FfvIvc8qnI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Lun3LhDiSwy+IaXqQIP5v6vQrj+p1s61oajuHSfBoe4WwL9jrPm85DAmi3qh2HDxX WNdf5G6AmO1QRce0CabOJEgTOtYYt6rnmDahUDF3fcWPqtdgk7XOnrlhf5Zi8uWS4n 33Tz6sbH38hnSgbBvOqhW0QMoBL0ZArjevNNpn811aKKbVOZDPvOWVPKZhasUYTXEG 0wZpTSH2s8Ry0KE+dsK+tIDl3a+WlVs4ou1J88OwettgZ2wNNpORiB2puK2V4FWvbD X6DBIym9BHJRNq2KyhdmDmJqRnIfppOuiTbVFuqZuvlhaMfr95CNRcInNUvv4hr43S bR54RIzEnvG2g== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qnKKd-000Om2-6U; Mon, 02 Oct 2023 15:55:35 +0100 Date: Mon, 02 Oct 2023 15:55:33 +0100 Message-ID: <86ttr9nkey.wl-maz@kernel.org> From: Marc Zyngier To: Kristina Martsenko 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 Subject: Re: [PATCH v2 1/2] KVM: arm64: Add handler for MOPS exceptions In-Reply-To: <0f99fa65-c8c1-5d5c-d9b0-5436b7592656@arm.com> 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> <0f99fa65-c8c1-5d5c-d9b0-5436b7592656@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kristina.martsenko@arm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, vladimir.murzin@arm.com, coltonlewis@google.com, linux-kernel@vger.kernel.org, oliver.upton@linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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:55:50 -0700 (PDT) On Mon, 02 Oct 2023 15:06:33 +0100, Kristina Martsenko wrote: > > 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? What is different is that we *go back* in the instruction stream, which is a first. I'm not saying that the debugger I describe above would be a very clever piece of SW, quite the opposite. But the way the architecture works results in some interesting side-effects, and I'm willing to bet that some SW will break (rr?). But again, asymmetric systems are such a bad idea that I can't say I care. Thanks, M. -- Without deviation from the norm, progress is not possible.