Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp70064lqp; Mon, 10 Jun 2024 19:01:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8mpmfzSSe1hBnDEc7frvQEJjgL2WiGLqSCAQ0rXny5rL6vQS2Dea60E0g0uiiZdimx744ZOEaNz5/gW+37LTx9pZJWUZzDfUmd1ItJQ== X-Google-Smtp-Source: AGHT+IE9m4yevhv8AjZwi5OuZYoSlfNpQw0+zjpAr/fIF6jgEuomBkbek9TN+GtovkwKi0XDYzAN X-Received: by 2002:a05:6a20:2444:b0:1b4:82db:26f4 with SMTP id adf61e73a8af0-1b482db2895mr8779721637.21.1718071272215; Mon, 10 Jun 2024 19:01:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718071272; cv=pass; d=google.com; s=arc-20160816; b=p7ZV0oEsvjA+au7tB1jGH+osr1yZQ79x+sEwD8Zs2mq7/6/Lc5btfXQ9XuMfN/c2rF 4zFCvSLnFQrYEPebwJi9dt6W69ZlDZsAZim/kTFOgk9njHnZhT6TrMKoCyHZNIt/qF18 z/bquFOFIOj0zbFtQI+phvF4dSq21pD062rlK5pqZcL/Vhf2gka11mYn9G3d+hP4ZatA a/uUWlTxgVHIol81SaNP6EXijWGojKTHJqIBfXX4iog6YrUEo1bxW0GciSvY3Xx4/8rD gcMzUGzw7TgI1QQK/kNHiFOWROypvGZUR/a2WCsaPElTOoPdGLxnqHPowhTXtEeKL6Wp EZhg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=+DSf+TQt/ykv0XritXEDrZm1XQB4nWMsT88cdtUciK4=; fh=RPEMM2rsG5GlC0fd/iamhSw6dt0npLL1JdLtcad7EZE=; b=XfqYfwdrYPw+jk8O1SQb1z2lGMEHdlOUwc46mcxR6tp6PfyfaAKGNZG30gp7EVna4g n8akP8QJZNO2CP1TEjMxAGhgKY72OPZOMXcCZ1nYqw2RNU1s1x2U3S6+6apBqgTAjtlG /y4tOkFcc3HSF1/HvGpbl8+lCKUli01cVdsdbdBfGn70LWJ/0LwktEMMc5sPH+RKrErG k9RutUomGUinvcNY3nps5vgL2//b2yZ3SP0X69xbUOKjRhwmAhLZyyM3akprpSxmbqsy aTRPod9rJsvyh8SE+AFr/pE0ejiRrtt++ImXvqHraMnAJEIsUigmYH7M1v1Qq3QTi9SQ IJYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=lHUN7OiI; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-209167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209167-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-7043acb8667si3304930b3a.182.2024.06.10.19.01.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 19:01:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=lHUN7OiI; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-209167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209167-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8D593284FAB for ; Tue, 11 Jun 2024 02:00:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F8AEBA34; Tue, 11 Jun 2024 02:00:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="lHUN7OiI" Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D31175661 for ; Tue, 11 Jun 2024 02:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718071247; cv=none; b=BEev54P/epFt1aqzLZK36I6uvByXFjPLnJeN2QfyKLSgxmnxaE1dnqWNmewFnb+mpNqZ7Fo2JguhotgS5/fkTEmwRmEXXCglAxRvFP6paKT3d7Fn6SrDW6LX6wkqVQjER41mp52nJ/TNaofOlKPB10p04kKgrnk13S0fcQ10ovs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718071247; c=relaxed/simple; bh=+DSf+TQt/ykv0XritXEDrZm1XQB4nWMsT88cdtUciK4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=cUFLWzH3ebfsyUFdyeyTiamISY/kA5U1swRqG13exKbZocU4zuwciXLxMclbzFYQ9PssyPkG+KjP/zMBngp8y8DCklh3fgyM8TxuLKjWV1nMqVRZaNhYwdQi8BeWCOIQ2QOfRkZFNIf3vB9mjkJZnAh8bchXSN9zKwwgqujdkUs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=lHUN7OiI; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2c19bba897bso4161812a91.2 for ; Mon, 10 Jun 2024 19:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1718071245; x=1718676045; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+DSf+TQt/ykv0XritXEDrZm1XQB4nWMsT88cdtUciK4=; b=lHUN7OiIIYLra2o+vI//EAgcxdKhKdA0sNjputGNmY0MWDVyftbRczZYO6Qgu9YA7r m+cwItEMs5vzR8QK4BpEgRtEGlnkPz4F2SsOsVsCi51OS7wD4C/kPjdb+ID+2FVgI3gv Y41LZaPxo8Hq4Asbwypc0IhX5X/IZiViy21IOtVGt4jeAtxQVgBWG+2mktUsVfUR5v8S oO1Ab9Hmqy3fSithVorbhaMw/whBzGqs8MM9IZBUfsgDZYEokCEP4jYDsWZy4pwhSPoe OTmKOAWhGlPAf8/IGxNAx1Xz4d6BG/PtQ3GNr5zP8CcBNTTc6nm5TeKFJXh9ystGvXmA 7tQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718071245; x=1718676045; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+DSf+TQt/ykv0XritXEDrZm1XQB4nWMsT88cdtUciK4=; b=vqSUJM3Q3AIvzH2PXlgFnaLeKgFNNamzJEaYb3W+ve96aMV62uW3S4J0DVV9Y0cD0V Ivi6YDXze6GP85daAtoGtT9aCWPol91FdlAoY5RFOrmGzy+WjmlvtpMepflzGXGVByhi GOCY1befGcHZmi+iln1fyqlJi767g8se7zbssaZiFfv7iB7vIsa7Tid4uDbgH0B6EZf/ BGZ8XvdJYdtiy50Fi03oCxvnf8rvIaHCsBDnbZgB8Bb6Wze10q83V9/54zFFF3Cull4t ymjsrT3SIrFdvxuhbr1mTnWW7jKGFrWjjG30IEMZ3L7e7egwh0z6HbLWUH0PXZot/I0f Lyzw== X-Forwarded-Encrypted: i=1; AJvYcCUG93kEYXx/yoZX9XnTPHfjzakPvXPi70ofHYEGG7APHPN0fg1i/4YZQQOQfTq5HeBXhYja39K0mr3LI2ULOJ7zSwNJhXBFWy99nf1R X-Gm-Message-State: AOJu0Yxocoz4QcQUbp7A0/j4U3L5WAQDbdMrp97EYmpLWYcLDG89+Sbx c1jS8D9BXmz7ofPSj7hlubFClKEGki+56eaP90FqPQN4//M1eaqUe2vcaHPe8Jykqv6NiU3HEC1 7XqFm5dwv09te6sYMudkKid7q0QrEmszSldnmxg== X-Received: by 2002:a17:90a:12c2:b0:2c2:5341:7ed6 with SMTP id 98e67ed59e1d1-2c2bcc5a26emr10217116a91.38.1718071245048; Mon, 10 Jun 2024 19:00:45 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240610174934.GM791043@ziepe.ca> <20240610222051.GO791043@ziepe.ca> In-Reply-To: <20240610222051.GO791043@ziepe.ca> From: Tomasz Jeznach Date: Mon, 10 Jun 2024 19:00:34 -0700 Message-ID: Subject: Re: [PATCH v6 5/7] iommu/riscv: Device directory management. To: Jason Gunthorpe Cc: Zong Li , Joerg Roedel , Will Deacon , Robin Murphy , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Sunil V L , Nick Kossifidis , Sebastien Boeuf , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, iommu@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux@rivosinc.com, Lu Baolu , Jim Shu , Vincent Chen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 10, 2024 at 3:20=E2=80=AFPM Jason Gunthorpe wrot= e: > > On Mon, Jun 10, 2024 at 11:48:23AM -0700, Tomasz Jeznach wrote: > > > Right, this is why I asked about negative caching. > > > > > > The VMMs are a prime example of negative caching, in something like > > > the SMMU implementation the VMM will cache the V=3D0 STE until they s= ee > > > an invalidation. > > > > > > Driving the VMM shadowing/caching entirely off of the standard > > > invalidation mechanism is so much better than any other option. > > > > > > IMHO you should have the RISCV spec revised to allow negative caching > > > in any invalidated data structure to permit the typical VMM design > > > driven off of shadowing triggered by invalidation commands. > > > > > > Once the spec permits negative caching then the software would have t= o > > > invalidate after going V=3D0 -> V=3D1. > > > > > > Jason > > > > Allowing negative cacheing by the spec (e.g. for VMM use cases) and > > documenting required invalidation sequences would definitely help > > here. > > Yes, you probably should really do that. > > > I'm hesitating adding IODIR.INVAL that is not required by the > > spec [1], > > If you expect to rapidly revise the spec then you should add it right > now so that all SW implementations that exist are > conforming. Otherwise you'll have compatability problems when you come > to implement nesting. > > Obviously the VMM can't rely on a negative caching technique unless > the spec says it can. > > > but this is something that can be controlled by a > > capabilities/feature bit once added to the specification or based on > > VID:DID of the emulated Risc-V IOMMU. > > I'm not sure it really can. Once you start shipping SW people will run > it in a VM and the VMM will have to forever work without negative > caching. > > My strong advice is to not expect the VMM trap random pages in guest > memory, that is a huge mess to implement and will delay your VMM side. > > > Another option to consider for VMM is to utilize the WARL property of > > DDTP, and provide fixed location of the single level DDTP, pointing to > > MMIO region, where DDTE updates will result in vmm exit / fault > > handler. This will likely not be as efficient as IODIR.INVAL issued > > for any DDTE updates. > > I don't know what all those things mean, but if you mean to have the > VMM supply faulting MMIO space that the VM is forced to put the DDTE > table into, then that would be better. It is still quite abnormal from > the VMM side.. > > My strong advice is to fix this. It is trivial to add the negative > caching language to the spec and will cause insignificant extra work > in this driver. > > The gains on at least the ease of VMM implementation and architectural > similarity to other arches are well worth the effort. Otherwise I fear > it will be a struggle to get nesting support completed :( > > Jason > Thanks for the comments, it definitely makes sense. We will revise the wording in the RISC-V IOMMU spec to note that certain implementations may require invalidating commands to be issued when making DDT entries valid, and device tree / ACPI may be used to report such requirement. For now, I'll change the implementation to assume negative caching for DDTE and will follow up with device tree / driver updates to make the invalidation optional when revised specifications will be available. Best, - Tomasz > -- > You received this message because you are subscribed to the Google Groups= "linux" group. > To unsubscribe from this group and stop receiving emails from it, send an= email to linux+unsubscribe@rivosinc.com. > To view this discussion on the web visit https://groups.google.com/a/rivo= sinc.com/d/msgid/linux/20240610222051.GO791043%40ziepe.ca. > For more options, visit https://groups.google.com/a/rivosinc.com/d/optout= .