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] [thread-next>] [day] [month] [year] [list]
Message-ID: <85b2c818-1c43-e633-8179-ec694214ce77@linux.intel.com>
Date:   Wed, 11 Oct 2023 14:20:12 +0300 (EEST)
From:   Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To:     Bjorn Helgaas <helgaas@...nel.org>
cc:     linux-pci@...r.kernel.org,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        Krzysztof Wilczyński <kw@...ux.com>,
        Lorenzo Pieralisi <lpieralisi@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Bjorn Helgaas <bhelgaas@...gle.com>
Subject: Re: [PATCH 05/10] PCI/ATS: Use FIELD_GET()

On Tue, 10 Oct 2023, Bjorn Helgaas wrote:

> From: Bjorn Helgaas <bhelgaas@...gle.com>
> 
> Use FIELD_GET() to remove dependences on the field position, i.e., the
> shift value.  No functional change intended.
> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@...gle.com>
> ---
>  drivers/pci/ats.c             | 7 ++-----
>  include/uapi/linux/pci_regs.h | 1 +
>  2 files changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
> index f9cc2e10b676..c570892b2090 100644
> --- a/drivers/pci/ats.c
> +++ b/drivers/pci/ats.c
> @@ -9,6 +9,7 @@
>   * Copyright (C) 2011 Advanced Micro Devices,
>   */
>  
> +#include <linux/bitfield.h>
>  #include <linux/export.h>
>  #include <linux/pci-ats.h>
>  #include <linux/pci.h>
> @@ -480,8 +481,6 @@ int pci_pasid_features(struct pci_dev *pdev)
>  }
>  EXPORT_SYMBOL_GPL(pci_pasid_features);
>  
> -#define PASID_NUMBER_SHIFT	8
> -#define PASID_NUMBER_MASK	(0x1f << PASID_NUMBER_SHIFT)
>  /**
>   * pci_max_pasids - Get maximum number of PASIDs supported by device
>   * @pdev: PCI device structure
> @@ -503,9 +502,7 @@ int pci_max_pasids(struct pci_dev *pdev)
>  
>  	pci_read_config_word(pdev, pasid + PCI_PASID_CAP, &supported);
>  
> -	supported = (supported & PASID_NUMBER_MASK) >> PASID_NUMBER_SHIFT;
> -
> -	return (1 << supported);
> +	return (1 << FIELD_GET(PCI_PASID_CAP_WIDTH, supported));
>  }
>  EXPORT_SYMBOL_GPL(pci_max_pasids);
>  #endif /* CONFIG_PCI_PASID */
> diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
> index 6af1f8d53e97..833e5fb40ea5 100644
> --- a/include/uapi/linux/pci_regs.h
> +++ b/include/uapi/linux/pci_regs.h
> @@ -932,6 +932,7 @@
>  #define PCI_PASID_CAP		0x04    /* PASID feature register */
>  #define  PCI_PASID_CAP_EXEC	0x0002	/* Exec permissions Supported */
>  #define  PCI_PASID_CAP_PRIV	0x0004	/* Privilege Mode Supported */
> +#define  PCI_PASID_CAP_WIDTH	0x1f00
>  #define PCI_PASID_CTRL		0x06    /* PASID control register */
>  #define  PCI_PASID_CTRL_ENABLE	0x0001	/* Enable bit */
>  #define  PCI_PASID_CTRL_EXEC	0x0002	/* Exec permissions Enable */

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>

-- 
 i.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ