Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp10672pxk; Tue, 1 Sep 2020 14:40:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGltSmVAkY35UgeQujvKmgDuWXSTvxxg9nmhMv9+WQly2ZdfpNHOzEOmwNarqmsw5qthBS X-Received: by 2002:a17:906:7204:: with SMTP id m4mr3364851ejk.342.1598996406165; Tue, 01 Sep 2020 14:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598996406; cv=none; d=google.com; s=arc-20160816; b=O92KxeEUGDN49wx35/cb9UI+JDPpZXDUHh551B+B3D5smk3uJtv15/rAnzrKCdeotW LBk3q1dCmWv4wkwsUQiuy0jzLt/mGEuKLe5qAbZ5EpL0ylQ/d55IlJuoCezdGS5L1cut I/ocvgDmI5ehiQHZXt86kja0JEhlPtvTiEU9GpWRtgtBxuYTrPrkymGvCkMsbnSCv1PE vH+UaldDtsPiW/eaAI91LdHaxPoHgj3nZqleuIcMd8gE1skuT61MW7Sd5VV8TSZxqUq0 Y0XBp2mRn8w6CfN/crnesnEpsgeANXKxwHSEbL+pRzpNv1JXrP5FsmytCf13XnOjP9+Y ZbkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=0wt0Kuaq0tmnkhHuwXET4PhGnm4atGZXoNq5U4y8d/M=; b=IAh5L8YI4jKCrxWrRi4AaKkzFaWlYJ7zBiVATwuqshiw/wIr3/PmycgrEvqbBi8fNf DHJaaG8z0t6SL3R21wmGBKvAyn2QN9ntBLT15POfcFJs/tVly0GTAZnwquVTXRcU3GiT khUjbqSakZtpfJaOXuQ8sovTDn8FhdPajinUQNyAmehQkoo0WLYdfiwKRSDt0sDOqPr1 xLT8QQC1XfO91cc4nh56tMhPMW9ddUSfh8+bNAouJrQW8Y69Zq+zj3qD7CZnlZTT0CgG 6IVI9fxmc4bUFcuK7v6lbQBLmde1o/R1wIG7YS9PLX7MGVIewRIJITlg71ukwY4tLHI7 2xog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mgq/rdcG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n21si1275348edt.580.2020.09.01.14.39.42; Tue, 01 Sep 2020 14:40:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mgq/rdcG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbgIAVjA (ORCPT + 99 others); Tue, 1 Sep 2020 17:39:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbgIAVi5 (ORCPT ); Tue, 1 Sep 2020 17:38:57 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00E95C061244 for ; Tue, 1 Sep 2020 14:38:57 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id e5so2121879qth.5 for ; Tue, 01 Sep 2020 14:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:user-agent:mime-version:content-transfer-encoding; bh=0wt0Kuaq0tmnkhHuwXET4PhGnm4atGZXoNq5U4y8d/M=; b=mgq/rdcGU4bevby5Hlt3CzlEdoPTc7IOr4f0kpKR036Ghpq41mvUUOV242Sb4pegiq nItSycVWuRj25AVkilg7HiVX6yWHtvNqKc/xbxvV1DVxpzy6WEV5s+Op6iI2ERv6TKd3 elYYhmNlsAaDgytzwWaXoAZtR6uVG2I9R7IKUfAlWxHZQwNJK01PR+jSMz3WHrc/PG0p SfDA3/1pDqN0mFjHMNwRCoN4uzhqQyfM447D4H8D7T9zJw7xrSy97m3UyzDhMnngAqw6 E7ZlZF5hrX/SNnYanNGI8StgNmz9T+pBsqXw9fhKB7QNn0E1oPBDwqNWdm8cXcmagOMJ KKJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:organization:user-agent:mime-version :content-transfer-encoding; bh=0wt0Kuaq0tmnkhHuwXET4PhGnm4atGZXoNq5U4y8d/M=; b=Xsp3iIvBUV3qVHE/YLOnPXkHp8CvWLtPXpDmOjUxC/L4wCBd8mZPIinhKen0NehUnC bV3KQDdfAm2HmOjThfw7AjkAmSWmfaYS60EULKrkuwGrNNa2DBJrn3zG+bPdANFvpMKJ bVJErz4+t1y1/fvhckoNIIWKGxbqHNYAMiJ8GJfqyXQJf0nVB4t5+gXdCJJaZHUXTHKu HZHhVZz6JwICa1nqd7Wmjs+qkBipnr3IDKFb4mhY37bPTXAQAVED5IaJeJMGrRqWTEYD ZDf9TszYLHLBneHrac1PpreEqRZQUIGG0OtTFr1CyAXP4ib4YwJOBmaNcFEFMtbAdJYZ a1zA== X-Gm-Message-State: AOAM533VOzBouYfSGPdH6YgBlUa1HPJAtuYI2HzYXlZdiaMDZst8NBvn VzLVwyKdVKyKhCjEHkLDOS8= X-Received: by 2002:ac8:7246:: with SMTP id l6mr1816360qtp.145.1598996336093; Tue, 01 Sep 2020 14:38:56 -0700 (PDT) Received: from LeoBras (179-125-130-62.dynamic.desktop.com.br. [179.125.130.62]) by smtp.gmail.com with ESMTPSA id w20sm2865190qki.108.2020.09.01.14.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:38:55 -0700 (PDT) Message-ID: Subject: Re: [PATCH v1 01/10] powerpc/pseries/iommu: Replace hard-coded page shift From: Leonardo Bras To: Alexey Kardashevskiy , Oliver O'Halloran Cc: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Christophe Leroy , Joel Stanley , Thiago Jung Bauermann , Ram Pai , Brian King , Murilo Fossa Vicentini , David Dai , linuxppc-dev , Linux Kernel Mailing List Date: Tue, 01 Sep 2020 18:38:48 -0300 In-Reply-To: <1bba12c6-f1ec-9f1e-1d3e-c1efa5ceb7c7@ozlabs.ru> References: <20200817234033.442511-1-leobras.c@gmail.com> <20200817234033.442511-2-leobras.c@gmail.com> <6232948f-033d-8322-e656-544f12c5f784@ozlabs.ru> <31e913d842693b6e107cb2b8e51fd45118b1bd2c.camel@gmail.com> <1e77a3d9-dff9-f58b-45be-77be7cbea41a@ozlabs.ru> <93037398c7afaabc0411890998f3f29f741c8aff.camel@gmail.com> <1bba12c6-f1ec-9f1e-1d3e-c1efa5ceb7c7@ozlabs.ru> Organization: IBM Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-08-31 at 13:48 +1000, Alexey Kardashevskiy wrote: > > > > Well, I created this TCE_RPN_BITS = 52 because the previous mask was a > > > > hardcoded 40-bit mask (0xfffffffffful), for hard-coded 12-bit (4k) > > > > pagesize, and on PAPR+/LoPAR also defines TCE as having bits 0-51 > > > > described as RPN, as described before. > > > > > > > > IODA3 Revision 3.0_prd1 (OpenPowerFoundation), Figure 3.4 and 3.5. > > > > shows system memory mapping into a TCE, and the TCE also has bits 0-51 > > > > for the RPN (52 bits). "Table 3.6. TCE Definition" also shows it. > > > > In fact, by the looks of those figures, the RPN_MASK should always be a > > > > 52-bit mask, and RPN = (page >> tceshift) & RPN_MASK. > > > > > > I suspect the mask is there in the first place for extra protection > > > against too big addresses going to the TCE table (or/and for virtial vs > > > physical addresses). Using 52bit mask makes no sense for anything, you > > > could just drop the mask and let c compiler deal with 64bit "uint" as it > > > is basically a 4K page address anywhere in the 64bit space. Thanks, > > > > Assuming 4K pages you need 52 RPN bits to cover the whole 64bit > > physical address space. The IODA3 spec does explicitly say the upper > > bits are optional and the implementation only needs to support enough > > to cover up to the physical address limit, which is 56bits of P9 / > > PHB4. If you want to validate that the address will fit inside of > > MAX_PHYSMEM_BITS then fine, but I think that should be done as a > > WARN_ON or similar rather than just silently masking off the bits. > > We can do this and probably should anyway but I am also pretty sure we > can just ditch the mask and have the hypervisor return an error which > will show up in dmesg. Ok then, ditching the mask. Thanks!