Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3793810rdh; Fri, 29 Sep 2023 02:29:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/CKyva/ID7snp8q0EE9RcMSjjA+aV/O5zXqpoUDmewrU3uFqm3JMjPUGExFIz5d7N2vjF X-Received: by 2002:a17:90a:e002:b0:262:f06d:c0fc with SMTP id u2-20020a17090ae00200b00262f06dc0fcmr3576762pjy.7.1695979761354; Fri, 29 Sep 2023 02:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695979761; cv=none; d=google.com; s=arc-20160816; b=euJwgGnrzdVI+LOjRPSjUMc8oAjZ0j7s0I2a+3LMGWBp4NzxxajOVKY6t4n7bTM4qi X0TVqycaYjGS2B+DT69QRWPilKfMgo0d8ekCkWVSCnQdTaQmtAbVSvksJJAaScl4YceW ryNEwBdm1DGp/iX9uzQk3ENFFLx7YdWSh0eaH+e8WCbT/udHavQg8oxZjoSK2pyYt/e+ HAUMQbSHTkC5+LoHlGvCShPoQnC4NIT1HaxEiMzN8TZOluXZ4FXkcg7xm3fLDc8FV7lS O+FVYCp1c7pjRnjOGq6hN324Unl8Xx7N7sho6NFVRBp4nz9wyAbfXWwQJpe5+3ihr1Tw hwMw== 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=ucuCmLoUk+8GzVTUl2yAHozRPOJ/IjDujtCHTPq4zaw=; fh=e5P3wMiIANlsAl4BArZ+THWI297PpbanstV264ZE+ZM=; b=Pn4V5mefGW/cuLW7/z259c/1FoFXU0G96uaLvx4xsifO73WMnW5nqCQGGoeVluAOsQ 5sO87drazLAakeGd1aZqCrQbVoeM8D9Wkdf8cLAEKp4tDZBXmaoN7+O0p1Nd6EuOBRu3 fXbA+XOKvzTcb8R+gEJRlG51kLSNql+/givF3k/s2KDqTOQ/LGQQDv4e06NWMpsFjCA8 +oWZ1AvUy/GycpKEJbuOO4AYaQmrU5cI/0SR2mDWg35xw0/hlHFMKi3Ym8IlxTuiMbLi pkqHgGWLBxeg9qzfvs5VZLiHdsXbcgtLm8xdywmoyxJ/QYlXy9men3idmT7ZV2A3Ds8y qoug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u+6w+2oo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id p24-20020a17090ad31800b0027748734bb9si1125548pju.148.2023.09.29.02.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 02:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u+6w+2oo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 99E3580990C2; Fri, 29 Sep 2023 02:24:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232732AbjI2JYB (ORCPT + 99 others); Fri, 29 Sep 2023 05:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbjI2JYA (ORCPT ); Fri, 29 Sep 2023 05:24:00 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84B4E195 for ; Fri, 29 Sep 2023 02:23:58 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C499C433C8; Fri, 29 Sep 2023 09:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695979438; bh=QecFZbeAzr1CUj1OPKHsPsEg7gSJ5EihrrYlTpFlMbI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=u+6w+2oo5XFnb1UTRpG9dHyJSRqqHYjtrGMU9i8qjgeVeQ+zRjIr3wlRj/3ZQFCLA oMUR6yatFLC1puWfMi5iyy6SJpE9Ic1UUlb+/DK8grRrMhtnnUgx1B1bezmiQnhFeX b3+dt18EZ26AEtU9i/JWOUQ/5HeNx0e+4bmv+3MlRqCUX050rN4rruLp101ebeWxzU IX1vNSezAOWSJC8IWTQ0nBNPbwOOudxiG5q3UU/cbsKEm7Lh00y5MR4mO6wyxANvHW bCGcFwj8DtLqeQ552SUSria/pGIIocV8HfK4eopDXalliouOL9s4GAuWHn+f7ZjaHQ EVOKPILgo5iRQ== Received: from [85.255.233.37] (helo=wait-a-minute.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 1qm9j1-00HCbM-N5; Fri, 29 Sep 2023 10:23:55 +0100 Date: Fri, 29 Sep 2023 10:23:54 +0100 Message-ID: <87h6ndmixh.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: Kristina Martsenko , 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 Subject: Re: [PATCH v2 1/2] KVM: arm64: Add handler for MOPS exceptions In-Reply-To: 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> 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/28.2 (x86_64-pc-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: 85.255.233.37 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, 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 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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 29 Sep 2023 02:24:08 -0700 (PDT) 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"... M. -- Without deviation from the norm, progress is not possible.