From: mhkelley58@gmail.com
To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com,
lpieralisi@kernel.org, kw@linux.com, mani@kernel.org,
robh@kernel.org, bhelgaas@google.com, arnd@arndb.de
Cc: x86@kernel.org, linux-hyperv@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-arch@vger.kernel.org
Subject: [PATCH v4 5/7] PCI: hv: Use hv_setup_*() to set up hypercall arguments
Date: Thu, 17 Jul 2025 21:55:43 -0700 [thread overview]
Message-ID: <20250718045545.517620-6-mhklinux@outlook.com> (raw)
In-Reply-To: <20250718045545.517620-1-mhklinux@outlook.com>
From: Michael Kelley <mhklinux@outlook.com>
Update hypercall call sites to use the new hv_setup_*() 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@outlook.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
---
Notes:
Changes in v4:
* Rename hv_hvcall_*() functions to hv_setup_*() [Easwar Hariharan]
* Rename hv_hvcall_in_batch_size() to hv_get_input_batch_size()
[Easwar Hariharan]
Changes in v3:
* Removed change to definition of struct hv_mmio_write_input so it remains
consistent with original Hyper-V definitions. Adjusted argument to
hv_hvcall_in_array() accordingly so that the 64 byte 'data' array is
not zero'ed. [Nuno Das Neves]
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 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index d2b7e8ea710b..79de85d1d68b 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -620,7 +620,7 @@ static void hv_irq_retarget_interrupt(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);
@@ -636,8 +636,8 @@ static void hv_irq_retarget_interrupt(struct irq_data *data)
local_irq_save(flags);
- params = *this_cpu_ptr(hyperv_pcpu_input_arg);
- memset(params, 0, sizeof(*params));
+ batch_size = hv_setup_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;
@@ -669,7 +669,7 @@ static void hv_irq_retarget_interrupt(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;
}
@@ -1102,11 +1102,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_setup_inout(&in, sizeof(*in), &out, sizeof(*out));
in->gpa = gpa;
in->size = size;
@@ -1135,9 +1133,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_setup_in_array(&in, offsetof(typeof(*in), data), sizeof(in->data[0]));
in->gpa = gpa;
in->size = size;
switch (size) {
--
2.25.1
next prev parent reply other threads:[~2025-07-18 4:56 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 4:55 [PATCH v4 0/7] hyperv: Introduce new way to manage hypercall args mhkelley58
2025-07-18 4:55 ` [PATCH v4 1/7] Drivers: hv: Introduce hv_setup_*() functions for hypercall arguments mhkelley58
2025-08-14 7:58 ` Tianyu Lan
2025-07-18 4:55 ` [PATCH v4 2/7] x86/hyperv: Use hv_setup_*() to set up hypercall arguments -- part 1 mhkelley58
2025-08-13 0:22 ` Nuno Das Neves
2025-08-13 0:41 ` Wei Liu
2025-08-13 18:22 ` Nuno Das Neves
2025-08-14 18:48 ` Michael Kelley
2025-07-18 4:55 ` [PATCH v4 3/7] x86/hyperv: Use hv_setup_*() to set up hypercall arguments -- part 2 mhkelley58
2025-07-18 4:55 ` [PATCH v4 4/7] Drivers: hv: Use hv_setup_*() to set up hypercall arguments mhkelley58
2025-07-28 17:02 ` Nuno Das Neves
2025-07-29 0:23 ` Michael Kelley
2025-07-18 4:55 ` mhkelley58 [this message]
2025-07-28 17:12 ` [PATCH v4 5/7] PCI: " Nuno Das Neves
2025-07-18 4:55 ` [PATCH v4 6/7] Drivers: hv: Use hv_setup_*() to set up hypercall arguments for mshv code mhkelley58
2025-08-13 22:18 ` Nuno Das Neves
2025-07-18 4:55 ` [PATCH v4 7/7] Drivers: hv: Replace hyperv_pcpu_input/output_arg with hyperv_pcpu_arg mhkelley58
2025-08-13 22:20 ` Nuno Das Neves
2025-07-18 16:33 ` [PATCH v4 0/7] hyperv: Introduce new way to manage hypercall args Easwar Hariharan
2025-07-18 17:13 ` Michael Kelley
2025-07-18 20:25 ` Easwar Hariharan
2025-07-19 1:15 ` Roman Kisel
2025-07-21 2:19 ` Michael Kelley
2025-07-21 17:14 ` Roman Kisel
2025-07-21 19:30 ` Michael Kelley
2025-08-12 23:58 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250718045545.517620-6-mhklinux@outlook.com \
--to=mhkelley58@gmail.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kw@linux.com \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=robh@kernel.org \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox