RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
From: Jake Oshins
Date: Thu Nov 10 2016 - 15:02:29 EST
> -----Original Message-----
> From: Dexuan Cui
> Sent: Wednesday, November 9, 2016 11:18 PM
> To: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>; linux-pci@xxxxxxxxxxxxxxx;
> devel@xxxxxxxxxxxxxxxxxxxxxx
> Cc: gregkh@xxxxxxxxxxxxxxxxxxx; KY Srinivasan <kys@xxxxxxxxxxxxx>;
> Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>; Stephen Hemminger
> <sthemmin@xxxxxxxxxxxxx>; Jake Oshins <jakeo@xxxxxxxxxxxxx>; Hadden
> Hoppert <haddenh@xxxxxxxxxxxxx>; Vitaly Kuznetsov
> <vkuznets@xxxxxxxxxx>; jasowang@xxxxxxxxxx; apw@xxxxxxxxxxxxx;
> olaf@xxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: [PATCH 1/3] PCI: hv: use the correct buffer size in
> new_pcichild_device()
>
> We don't really need such a big on-stack buffer.
> vmbus_sendpacket() here only uses sizeof(struct pci_child_message).
>
> Signed-off-by: Dexuan Cui <decui@xxxxxxxxxxxxx>
> CC: Jake Oshins <jakeo@xxxxxxxxxxxxx>
> Cc: KY Srinivasan <kys@xxxxxxxxxxxxx>
> CC: Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>
> CC: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
> ---
> drivers/pci/host/pci-hyperv.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
> index 763ff87..93ed64a 100644
> --- a/drivers/pci/host/pci-hyperv.c
> +++ b/drivers/pci/host/pci-hyperv.c
> @@ -1271,9 +1271,9 @@ static struct hv_pci_dev
> *new_pcichild_device(struct hv_pcibus_device *hbus,
> struct hv_pci_dev *hpdev;
> struct pci_child_message *res_req;
> struct q_res_req_compl comp_pkt;
> - union {
> - struct pci_packet init_packet;
> - u8 buffer[0x100];
> + struct {
> + struct pci_packet init_packet;
> + u8 buffer[sizeof(struct pci_child_message)];
> } pkt;
> unsigned long flags;
> int ret;
> --
> 2.7.4
This change seems good to me, in that it's always a bad idea to use too much stack. But this won't fix the problem with VMAP_STACK. The buffer could still end up spanning two pages and the physical addresses of those pages would possibly be discontiguous. Do you want to just refactor this so that it uses a fixed buffer, one that will work with VMAP_STACK? Or is that coming in a future patch?
-- Jake Oshins