lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 10 Jul 2023 14:35:49 +0800
From:   Xu Yilun <yilun.xu@...el.com>
To:     Peter Colberg <peter.colberg@...el.com>
Cc:     hao.wu@...el.com, gregkh@...uxfoundation.org,
        linux-fpga@...r.kernel.org, linux-kernel@...r.kernel.org,
        aaron.j.grier@...el.com, tianfei.zhang@...el.com,
        russell.h.weight@...el.com, matthew.gerlach@...ux.intel.com,
        marpagan@...hat.com, lgoncalv@...hat.com,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: Re: [PATCH v3] fpga: dfl: afu: use PFN_DOWN() helper macro

On 2023-06-28 at 20:22:55 -0400, Peter Colberg wrote:
> Replace right shifts by PAGE_SHIFT with PFN_DOWN() helper macro to convert
> from physical addresses to page frame numbers.
> 
> These changes are cosmetic only; no functional changes.
> 
> Suggested-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Signed-off-by: Peter Colberg <peter.colberg@...el.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> v3:
> - Revert afu_mmap(), which calculates file offsets, not physical pages
> v2:
> - Comment in commit message that changes are cosmetic only
> ---
>  drivers/fpga/dfl-afu-dma-region.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c
> index 02b60fde0430..e8d54cfbb301 100644
> --- a/drivers/fpga/dfl-afu-dma-region.c
> +++ b/drivers/fpga/dfl-afu-dma-region.c
> @@ -10,6 +10,7 @@
>   */
>  
>  #include <linux/dma-mapping.h>
> +#include <linux/pfn.h>
>  #include <linux/sched/signal.h>
>  #include <linux/uaccess.h>
>  #include <linux/mm.h>
> @@ -34,7 +35,7 @@ void afu_dma_region_init(struct dfl_feature_platform_data *pdata)
>  static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
>  			     struct dfl_afu_dma_region *region)
>  {
> -	int npages = region->length >> PAGE_SHIFT;
> +	int npages = PFN_DOWN(region->length);
>  	struct device *dev = &pdata->dev->dev;
>  	int ret, pinned;
>  
> @@ -82,7 +83,7 @@ static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
>  static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata,
>  				struct dfl_afu_dma_region *region)
>  {
> -	long npages = region->length >> PAGE_SHIFT;
> +	long npages = PFN_DOWN(region->length);
>  	struct device *dev = &pdata->dev->dev;
>  
>  	unpin_user_pages(region->pages, npages);
> @@ -101,7 +102,7 @@ static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata,
>   */
>  static bool afu_dma_check_continuous_pages(struct dfl_afu_dma_region *region)
>  {
> -	int npages = region->length >> PAGE_SHIFT;
> +	int npages = PFN_DOWN(region->length);
>  	int i;
>  
>  	for (i = 0; i < npages - 1; i++)



@@ -837,7 +838,7 @@ static int afu_mmap(struct file *filp, struct vm_area_struct *vma)
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);

        return remap_pfn_range(vma, vma->vm_start,
-                       (region.phys + (offset - region.offset)) >> PAGE_SHIFT,
+                       PFN_DOWN(region.phys + (offset - region.offset)),
                        size, vma->vm_page_prot);


Why is this change also dropped? Maybe use PHYS_PFN() instead?

Thanks,
Yilun

> -- 
> 2.28.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ