linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci: Fix unaligned accesses in VC code.
@ 2016-06-19  6:52 David Miller
  2016-06-20 18:34 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2016-06-19  6:52 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci


The save/restore buffers for VC state is first composed of a 2-byte
control register, then a bunch of 4-byte words.

This causes unaligned accesses which trap on platform such as sparc.

This is easy to fix by simply moving the buffer pointer forward by 4
bytes instead of 2 after dealing with the control register.  The
length adjustment needs to be changed likewise as well.

Reported-by: Meelis Roos <mroos@linux.ee>
Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/drivers/pci/vc.c b/drivers/pci/vc.c
index dfbab61..1fa3a32 100644
--- a/drivers/pci/vc.c
+++ b/drivers/pci/vc.c
@@ -221,9 +221,9 @@ static int pci_vc_do_save_buffer(struct pci_dev *dev, int pos,
 		else
 			pci_write_config_word(dev, pos + PCI_VC_PORT_CTRL,
 					      *(u16 *)buf);
-		buf += 2;
+		buf += 4;
 	}
-	len += 2;
+	len += 4;
 
 	/*
 	 * If we have any Low Priority VCs and a VC Arbitration Table Offset

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pci: Fix unaligned accesses in VC code.
  2016-06-19  6:52 [PATCH] pci: Fix unaligned accesses in VC code David Miller
@ 2016-06-20 18:34 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2016-06-20 18:34 UTC (permalink / raw)
  To: David Miller; +Cc: bhelgaas, linux-pci

On Sat, Jun 18, 2016 at 11:52:25PM -0700, David Miller wrote:
> 
> The save/restore buffers for VC state is first composed of a 2-byte
> control register, then a bunch of 4-byte words.
> 
> This causes unaligned accesses which trap on platform such as sparc.
> 
> This is easy to fix by simply moving the buffer pointer forward by 4
> bytes instead of 2 after dealing with the control register.  The
> length adjustment needs to be changed likewise as well.
> 
> Reported-by: Meelis Roos <mroos@linux.ee>
> Reported-by: Anatoly Pugachev <matorola@gmail.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>

Applied to for-linus for v4.7, thanks.

I'm pretty sure this problem was introduced by 5f8fc43217a0 ("PCI:
Include pci/pcie/Kconfig directly from pci/Kconfig"), which appeared
in v4.6.  This effectively made PCIe services, including VC, available
on sparc. 

I added a stable tag for v4.6.

> diff --git a/drivers/pci/vc.c b/drivers/pci/vc.c
> index dfbab61..1fa3a32 100644
> --- a/drivers/pci/vc.c
> +++ b/drivers/pci/vc.c
> @@ -221,9 +221,9 @@ static int pci_vc_do_save_buffer(struct pci_dev *dev, int pos,
>  		else
>  			pci_write_config_word(dev, pos + PCI_VC_PORT_CTRL,
>  					      *(u16 *)buf);
> -		buf += 2;
> +		buf += 4;
>  	}
> -	len += 2;
> +	len += 4;
>  
>  	/*
>  	 * If we have any Low Priority VCs and a VC Arbitration Table Offset
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-20 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-19  6:52 [PATCH] pci: Fix unaligned accesses in VC code David Miller
2016-06-20 18:34 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).