[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<SN6PR02MB415761B853808B7865125CD0D4A22@SN6PR02MB4157.namprd02.prod.outlook.com>
Date: Sun, 30 Mar 2025 21:53:57 +0000
From: Michael Kelley <mhklinux@...look.com>
To: Nuno Das Neves <nunodasneves@...ux.microsoft.com>, "kys@...rosoft.com"
<kys@...rosoft.com>, "haiyangz@...rosoft.com" <haiyangz@...rosoft.com>,
"wei.liu@...nel.org" <wei.liu@...nel.org>, "decui@...rosoft.com"
<decui@...rosoft.com>, "tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...hat.com" <mingo@...hat.com>, "bp@...en8.de" <bp@...en8.de>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>, "hpa@...or.com"
<hpa@...or.com>, "lpieralisi@...nel.org" <lpieralisi@...nel.org>,
"kw@...ux.com" <kw@...ux.com>, "manivannan.sadhasivam@...aro.org"
<manivannan.sadhasivam@...aro.org>, "robh@...nel.org" <robh@...nel.org>,
"bhelgaas@...gle.com" <bhelgaas@...gle.com>, "arnd@...db.de" <arnd@...db.de>
CC: "x86@...nel.org" <x86@...nel.org>, "linux-hyperv@...r.kernel.org"
<linux-hyperv@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "linux-pci@...r.kernel.org"
<linux-pci@...r.kernel.org>, "linux-arch@...r.kernel.org"
<linux-arch@...r.kernel.org>
Subject: RE: [PATCH v2 5/6] PCI: hv: Use hv_hvcall_*() to set up hypercall
arguments
From: Nuno Das Neves <nunodasneves@...ux.microsoft.com> Sent: Friday, March 21, 2025 1:19 PM
>
> On 3/12/2025 11:19 PM, mhkelley58@...il.com wrote:
> > From: Michael Kelley <mhklinux@...look.com>
> >
> > Update hypercall call sites to use the new hv_hvcall_*() functions
> > to set up hypercall arguments. Since these functions zero the
> > fixed portion of input memory, remove now redundant calls to memset().
> >
> > Signed-off-by: Michael Kelley <mhklinux@...look.com>
> > Acked-by: Bjorn Helgaas <bhelgaas@...gle.com>
> > ---
> >
> > Notes:
> > Changes in v2:
> > * In hv_arch_irq_unmask(), added check of the number of computed banks
> > in the hv_vpset against the batch_size. Since an hv_vpset currently
> > represents a maximum of 4096 CPUs, the hv_vpset size does not exceed
> > 512 bytes and there should always be sufficent space. But do the
> > check just in case something changes. [Nuno Das Neves]
> >
> > drivers/pci/controller/pci-hyperv.c | 18 ++++++++----------
> > include/hyperv/hvgdk_mini.h | 2 +-
> > 2 files changed, 9 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
> > index ac27bda5ba26..82ac0e09943b 100644
> > --- a/drivers/pci/controller/pci-hyperv.c
> > +++ b/drivers/pci/controller/pci-hyperv.c
> > @@ -622,7 +622,7 @@ static void hv_arch_irq_unmask(struct irq_data *data)
> > struct pci_dev *pdev;
> > unsigned long flags;
> > u32 var_size = 0;
> > - int cpu, nr_bank;
> > + int cpu, nr_bank, batch_size;
> > u64 res;
> >
> > dest = irq_data_get_effective_affinity_mask(data);
> > @@ -638,8 +638,8 @@ static void hv_arch_irq_unmask(struct irq_data *data)
> >
> > local_irq_save(flags);
> >
> > - params = *this_cpu_ptr(hyperv_pcpu_input_arg);
> > - memset(params, 0, sizeof(*params));
> > + batch_size = hv_hvcall_in_array(¶ms, sizeof(*params),
> > + sizeof(params->int_target.vp_set.bank_contents[0]));
> > params->partition_id = HV_PARTITION_ID_SELF;
> > params->int_entry.source = HV_INTERRUPT_SOURCE_MSI;
> > params->int_entry.msi_entry.address.as_uint32 = int_desc->address & 0xffffffff;
> > @@ -671,7 +671,7 @@ static void hv_arch_irq_unmask(struct irq_data *data)
> > nr_bank = cpumask_to_vpset(¶ms->int_target.vp_set, tmp);
> > free_cpumask_var(tmp);
> >
> > - if (nr_bank <= 0) {
> > + if (nr_bank <= 0 || nr_bank > batch_size) {
> > res = 1;
> > goto out;
> > }
> > @@ -1034,11 +1034,9 @@ static void hv_pci_read_mmio(struct device *dev, phys_addr_t gpa, int size, u32
> >
> > /*
> > * Must be called with interrupts disabled so it is safe
> > - * to use the per-cpu input argument page. Use it for
> > - * both input and output.
> > + * to use the per-cpu argument page.
> > */
> > - in = *this_cpu_ptr(hyperv_pcpu_input_arg);
> > - out = *this_cpu_ptr(hyperv_pcpu_input_arg) + sizeof(*in);
> > + hv_hvcall_inout(&in, sizeof(*in), &out, sizeof(*out));
> > in->gpa = gpa;
> > in->size = size;
> >
> > @@ -1067,9 +1065,9 @@ static void hv_pci_write_mmio(struct device *dev, phys_addr_t gpa, int size, u32
> >
> > /*
> > * Must be called with interrupts disabled so it is safe
> > - * to use the per-cpu input argument memory.
> > + * to use the per-cpu argument page.
> > */
> > - in = *this_cpu_ptr(hyperv_pcpu_input_arg);
> > + hv_hvcall_in_array(&in, sizeof(*in), sizeof(in->data[0]));
> > in->gpa = gpa;
> > in->size = size;
> > switch (size) {
> > diff --git a/include/hyperv/hvgdk_mini.h b/include/hyperv/hvgdk_mini.h
> > index 70e5d7ee40c8..cb25ac1e3ac5 100644
> > --- a/include/hyperv/hvgdk_mini.h
> > +++ b/include/hyperv/hvgdk_mini.h
> > @@ -1342,7 +1342,7 @@ struct hv_mmio_write_input {
> > u64 gpa;
> > u32 size;
> > u32 reserved;
> > - u8 data[HV_HYPERCALL_MMIO_MAX_DATA_LENGTH];
> > + u8 data[];
>
> As with the prior patch, I don't think this is worth changing. The
> code in hv_pci_write_mmio() is more complicated as a result, and
> changing the array means the struct no longer matches the Hyper-V
> struct 1:1.
>
Given the goal of matching the Hyper-V structure definitions, I
can see that changing the "data" field to be a flexible array is
problematic. But what are the additional complications in
hv_pci_write_mmio() are you referring to? There's only a one
line change. Again, I'd like to not leave cases where use of
hyperv_input_arg is open coded. I think hv_hvcall_*() can still
be used even if the "data" field is a fixed-size array.
Michael
Powered by blists - more mailing lists