Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp256251pxk; Wed, 2 Sep 2020 21:31:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcWSsjtcNWkrP7WnepJBz5OraeigKVKwYP4veTRgk3tClEHX4qUOWSEZVovNmN3iTjL2Gv X-Received: by 2002:a17:906:250a:: with SMTP id i10mr259878ejb.202.1599107467611; Wed, 02 Sep 2020 21:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599107467; cv=none; d=google.com; s=arc-20160816; b=x1rfEthkZfxInlTkwvowVtgS8+WKf5mMEEUchv2xlkbZOIyCxY3u7EwfbakR44OjlM m41eOpavT5uFu2wSVozGXCIfr7RN6K6FuA6YEgyqyhr9vp3HaCy8K57iFj6fXqZV/IpG 21gHwUHyQ8ppS6FXD7uRIGcHXvynC5cSaCXm0QoFpj+III8+jkdE7lxSMEVLJsbSv5A8 8Ymka7eoejGyQuUU/OVTvluNISJu0GEMK4gvjcDcoZ2PgOWXJzKfecJct6TXEhNOsYGv UmMk268Nf9DSDRoZXnvXLtHSiSoC2mhHfAkjk/Sf7Zv/V9MIGFWsWonveOH6BTi5IXcQ igCg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=vNNQnTB2bzzVVpKwB6qXlFTaOV9Itbw7rVnGe9BKXq4=; b=W0zeZqPodOjpT4yZZz/c8Yin0BTfWmG547f2QruYqB5PombGC8YvQ/qxviRuTO6l63 9kWPqPOCld+BckhWwHbScPoHNs3C936Vr6+709Jnae2X+9f+DcF5CSBw5jwQ/LUqExbo bLjuDgKlPBNxN5MoqXTNcWuEb3FUkstJWqRJRnjQtL1fTS4XY8VhP33QgIkNTU+Pdhd/ WHS/ySFz2OJoiLG3IFSyXoRq6eYec/rov+DyP2QpW5cv6RYVKVspCZzNoWnTJ40EoNoG JMpo4JXqG5nmpQxVv+wHC0CaJqkDyBfVmoFoGaiRw0QLsNYpxDGalfwDPdK2eyWFHybp WeGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ozlabs-ru.20150623.gappssmtp.com header.s=20150623 header.b=sJlfa0FJ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz19si1221061ejb.716.2020.09.02.21.30.27; Wed, 02 Sep 2020 21:31:07 -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=@ozlabs-ru.20150623.gappssmtp.com header.s=20150623 header.b=sJlfa0FJ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725967AbgICE0X (ORCPT + 99 others); Thu, 3 Sep 2020 00:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725851AbgICE0W (ORCPT ); Thu, 3 Sep 2020 00:26:22 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E343FC061244 for ; Wed, 2 Sep 2020 21:26:21 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id np15so3118914pjb.0 for ; Wed, 02 Sep 2020 21:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs-ru.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vNNQnTB2bzzVVpKwB6qXlFTaOV9Itbw7rVnGe9BKXq4=; b=sJlfa0FJy0iGf9Yz8+LLYpkmIRerR+3vw9ref3rCuEZFVw3shlzY5WxXBPCJLQClXC EXzOD4lRvMwyHMtYa2H+FZXE+YhQkpHoSQTiXybdDd2NGAELqWlw3ErulpozjdyzT3nG AeP43JnaytbUXYFNBYmKxXWrfW6OAID8E7SKHR0hHUQ5rOiLdPGUVrZKlgAXaPBIgUrh qhlxtTxgU+dM7jzIKD+tPNpxTwPJrMx3+9SkjGhmF08CUqm6SPcqJUQkWBZpk+1NHZo7 C6ZR81iQGjiZbvKYU0hxY2fblbEpYtOcZ70lVMPuyjdMgv/jI08pZvA15Ih+cV97ahXw LG7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vNNQnTB2bzzVVpKwB6qXlFTaOV9Itbw7rVnGe9BKXq4=; b=KAQVr3bFSihIfjQshm0rCb57AwWv33pYlPfFKPyXp8wv2DBXdMaEFPZ19/NQXKjabA /IQom0/TFKuLOr3qbQ3FcsV+lEGYC7pDKlQOtZh4etJ88AVL+RoPfX3miiNT/QypKoSN HisKj+Qnmh5S9hrpR9Vu7RWkNcrKL6uStDVd9yZ663Z7pNAg/c2dLRFFcPsVKu5jIbpU T4aZ39+Qg5YsXg15+Ze7pcFf9CEtS4X+DrI1BusWFq/KN0nRIM4yKIb+fTnahUDOPIhP uTjHbtPJ6YzLhx+++FYJOg9djuYzF2XeIGkARBIUp9QjyLf/+BEXD9aoJkQMx2OJ7Ekv iofQ== X-Gm-Message-State: AOAM5315bwk1JlmHeuSTBYfGZmOR71sLNHSFIy38JtDaotVASHUpGRjg E09nR9HGlg2ELviA+F7uN7GMHzud5AVWaKnc X-Received: by 2002:a17:90a:de09:: with SMTP id m9mr1249438pjv.231.1599107180628; Wed, 02 Sep 2020 21:26:20 -0700 (PDT) Received: from [192.168.10.94] (124-171-83-152.dyn.iinet.net.au. [124.171.83.152]) by smtp.gmail.com with ESMTPSA id n67sm888007pgn.14.2020.09.02.21.26.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Sep 2020 21:26:19 -0700 (PDT) Subject: Re: [PATCH v1 01/10] powerpc/pseries/iommu: Replace hard-coded page shift To: Leonardo Bras , 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 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> From: Alexey Kardashevskiy Message-ID: Date: Thu, 3 Sep 2020 14:26:12 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/09/2020 07:38, Leonardo Bras wrote: > 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. Well, you could run a little experiment and set some bits above that old mask and see how phyp reacts :) > Thanks! > -- Alexey