Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3280073lfo; Mon, 23 May 2022 00:34:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhXlKq9cwmBTqKiW1nmXZk97LfPa3yffnF6g/UXmLeGteyHLFYUTjfyVW5XZ7BNZi1jnLp X-Received: by 2002:a17:902:ce8d:b0:161:761f:6999 with SMTP id f13-20020a170902ce8d00b00161761f6999mr21371715plg.125.1653291278033; Mon, 23 May 2022 00:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653291278; cv=none; d=google.com; s=arc-20160816; b=B+VvF0LhS+wGQjOBhgtGx4X0dh5AqLMNE6S36c2rTxw69UNTcBQNglvz5smYyDONfs EDd15ktuSiFgAd2jsfzAHDIxXuV/KQYz9FTGnpJnilBb9KAbKWCblFoL6cu/oNVrHNMF vyD/8qt4Gi+Ik5m5rdnSXL1iUHzADWy31SrEyA0HFp8GsVoxal4eIecOFEf5xAicXmv/ rcpjpQxA4EFuJZNUlV+t2kRIiCc1tz023kppfZV4JXKWhbZ/cRVHIa6I+AXi/QLm/gSM GQcCywqxz2GwLuaf5TWxr5OUBmxcgmsnPMbxrOG4OrFfGnR/LYVlySeeuxQgdZJSZbmS cnYQ== 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=8+1V6EJuVXlTdbMenknaFFe+37ns+KBZpmE7x1/eUmg=; b=Yx6gLOLXl2HDrqj7x5+HcDSuT+qkJgdcpmL9RlgxV6ADDrEg1Pmh7ltuCPkgfRkU+0 /nvvFaxENgQELTA58hv15qzKS+Zn18eel23+LgTam7INoIeLNtcqWRMi3dpuxolrG+71 6svsg/8xrvk2nNh7Z0mB0NK0+LCBy/FwuOuUmwCisKQwJ2PdCDgVJho0PAxGXpeRKXis SO9Mg9RTKjUXrcgQjv36YtU4bijVWH4KWEsvnu02Yr/iDiUVY6OpfbjArRSu6Q/hPDYB PsCY9l/wYrAKa0phHBrbmHshb3FVfQPenWyr9STgVqCGl8+IxYL/j1phY+GCLRUkJUra 7DNQ== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x37-20020a634a25000000b003c65dfad4afsi9753813pga.367.2022.05.23.00.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:34:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4F7291EAF8; Sun, 22 May 2022 23:45:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346809AbiETIJl (ORCPT + 99 others); Fri, 20 May 2022 04:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232487AbiETIJh (ORCPT ); Fri, 20 May 2022 04:09:37 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72DEF8DDEC for ; Fri, 20 May 2022 01:09:36 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id B62ED820; Fri, 20 May 2022 10:09:34 +0200 (CEST) Date: Fri, 20 May 2022 10:09:33 +0200 From: Joerg Roedel To: Suravee Suthikulpanit Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, vasant.hegde@amd.com, jon.grimm@amd.com Subject: Re: [PATCH v2] iommu/amd: Set translation valid bit only when IO page tables are in used Message-ID: References: <20220509074815.11881-1-suravee.suthikulpanit@amd.com> <1dfaf07e-040e-848b-db7c-86a107fd5cb3@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1dfaf07e-040e-848b-db7c-86a107fd5cb3@amd.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Suravee, On Mon, May 16, 2022 at 07:27:51PM +0700, Suravee Suthikulpanit wrote: > Due to the new restriction (please see the IOMMU spec Rev 3.06-PUB - Apr 2021 > https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf) where the use of > DTE[Mode]=0 is not supported on systems that are SNP-enabled (i.e. EFR[SNPSup]=1), > the IOMMU HW looks at the DTE[TV] bit to determine if it needs to handle the v1 page table. > When the HW encounters DTE entry with TV=1, V=1, Mode=0, it would generate > ILLEGAL_DEV_TABLE_ENTRY event. Ah, that is the part I was missing, thanks. > - I am still trying to see what is the best way to force Linux to not allow > Mode=0 (i.e. iommu=pt mode). Any thoughts? I think this needs a general approach. First start in the AMD IOMMU driver: 1) Do not set DTE.TV=1 bit iff SNP-Support is enabled 2) Fail to allocate passthrough domains when SNP support is enabled. Then test how the IOMMU core layer handles that. In fact the IOMMU layer needs to adjust its decisions so that: 1) It uses translated-mode by default 2) passthrough domains are disallowed and can not be chosen, not on the kernel command line and not at runtime. Ideally this needs some kind of arch-callback to set the appropriate defaults. > - Also, it seems that the current iommu v2 page table use case, where GVA->GPA=SPA > will no longer be supported on system w/ SNPSup=1. Any thoughts? Support for that is not upstream yet, it should be easy to disallow this configuration and just use the v1 page-tables when SNP is active. This can be handled entirely inside the AMD IOMMU driver. Regards, Joerg