Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5793005rwl; Tue, 4 Apr 2023 03:51:58 -0700 (PDT) X-Google-Smtp-Source: AKy350b+KBnMzWOmWsjc4U+KfEUvN9EylOSyTVe2+NmwccgcffXkJVZY4TuW9zlswzjh6ILGtpLp X-Received: by 2002:a05:6a20:be14:b0:d9:e1b:652b with SMTP id ge20-20020a056a20be1400b000d90e1b652bmr1623751pzb.59.1680605518009; Tue, 04 Apr 2023 03:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605517; cv=none; d=google.com; s=arc-20160816; b=PQzQit/vxrCflS6gAXkcaDf1znFVkbZztRq837xDMIHQP0IPsZeCEEZGBqlWqpmWK2 xh0WZ6WkvkfnXAU3jq/SKhuUe+8F3uKmOFTb6g/SqAWn2NwAsoV15aOanH8FITY037kk FTVTUemX6hnKxY7ZslR2HWsoMSpw1Pm9xXHrlFKpJIYSuTJC9qXqe9ucEwhBqD/ub5+P 6UH4H5u6OZgIP5bHqm13GgawHO7SHDcIdiHkX3gHcAw/APlh3xEc64GjqeGntrIA+HIl wG3fRcPiIg8VUGzv/z+lZUrexOOrB4VJuSYcajC6PKXIwhXDq4Sk9VqPy/6qsq15AoHS NYMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=L/yRBD00i+YQPkpgtsdWlsW/x0ED7ch9ymVFooKsa6I=; b=JGKE9QLyQrgtiD7YpIXPnqPlEDSAqAvH3NurenEer0nZuHApjZWui91B/yq90HZUsv FTEsOAIYMtblIVzWheNU+w8d+blJjIDjE4hQon72wiJ1IFcBPmTs4xu9h4y/6pDRKKli /BoIFIHRClf9cxgTG+WbJ38SPvAE3dKzh4afJe6uCvuqOJrA9vrAZRypBOqcJXh3BsQD 7h40pl/KhYHh6CDUGpTX9qg/nZuQRf0F8JlRA2usotQzyWlhBilCegGAoSJhAuctVd7M WfglUriUsmi0wQqEzTkuJ34qn6d2q4XgJ/10o/6chlYwzi33LOcG7aT9dQDN4g6lB8o8 yjGw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020aa795ab000000b0062505afda08si10066727pfk.113.2023.04.04.03.51.46; Tue, 04 Apr 2023 03:51:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234665AbjDDKvS (ORCPT + 99 others); Tue, 4 Apr 2023 06:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234653AbjDDKu4 (ORCPT ); Tue, 4 Apr 2023 06:50:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5332030EB for ; Tue, 4 Apr 2023 03:50:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DEE2A6318E for ; Tue, 4 Apr 2023 10:50:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED4CDC4339B; Tue, 4 Apr 2023 10:50:37 +0000 (UTC) Date: Tue, 4 Apr 2023 11:50:34 +0100 From: Catalin Marinas To: Kristina Martsenko Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Mark Rutland , Mark Brown , Luis Machado , Vladimir Murzin , linux-kernel@vger.kernel.org Subject: Re: [PATCH 04/10] arm64: mops: document boot requirements for MOPS Message-ID: References: <20230216160012.272345-1-kristina.martsenko@arm.com> <20230216160012.272345-5-kristina.martsenko@arm.com> <61b0e30a-568c-d7f6-7b67-e9fc8b68de25@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <61b0e30a-568c-d7f6-7b67-e9fc8b68de25@arm.com> X-Spam-Status: No, score=-4.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 24, 2023 at 01:00:43AM +0000, Kristina Martsenko wrote: > On 17/03/2023 15:07, Catalin Marinas wrote: > > On Thu, Feb 16, 2023 at 04:00:06PM +0000, Kristina Martsenko wrote: > >> + For CPUs with Memory Copy and Memory Set instructions (FEAT_MOPS): > >> + > >> + - If the kernel is entered at EL1 and EL2 is present: > >> + > >> + - HCRX_EL2.MSCEn (bit 11) must be initialised to 0b1. > >> + > >> + - HCRX_EL2.MCE2 (bit 10) must be initialised to 0b0. > > > > Regarding MCE2, does EL1 actually care if EL2 wants to handle all the > > memcpy/memset exceptions? > > No, EL1 does not need to handle the exceptions itself, but I don't see any > current use case for allowing EL2 to handle it. > > If it was allowed, I think booting.txt would need to specify exactly what Linux > expects EL2 to do if MCE2 is set (eg, that EL2 handles the exception by > reformatting registers, modifying single step state, etc). What I meant is that an EL1 kernel shouldn't care if MCE2 is 0 or 1. We could clarify that if set to 1, it is expected that the hypervisor handles the memory copy/set exceptions accordingly. > > There may even be a valid case to do this at > > EL2 if you run a guest that uses these instructions but has no clue on > > how to deal with the specific exception like WrongOption. > > Not sure I follow - this series adds the exception handling, so how can a Linux > guest not know how to handle the exception? The guest may not always be Linux (e.g. some microkernel) and may not expect the hardware implementation to change underneath. > Or do you mean that there may be times when EL1 can't take the exception but > EL2 may move it to another CPU, and so EL2 would need to handle the exception? I haven't thought of this but it's actually a good point. Are there any cases where Linux can't handle a memcpy exception? I guess we need to be careful with taking such exception in an atomic context (e.g. no rescheduling on the return path). > I'm not sure if Linux ever uses mops instructions at times like that. The compiler may generate a memcpy() call by simply assigning a structure to another. So we can't control where those instructions are used. > Note that this series does not add support for mops in guests yet. You mean there's no KVM support. But Linux may be run under a different hypervisor (e.g. Hyper-V) as a guest. > I think booting.txt can be updated when that support is added. In booting.txt, when you say the kernel entered at EL1, it implies that it may be run as a guest under a random hypervisor. So maybe we should detail the MCE2 requirement a bit, saying that it can be either 0 or 1 but, for the latter, the hypervisor must handle the corresponding exceptions. -- Catalin