From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
kernel-team@lists.ubuntu.com
Cc: Gleb Natapov <gleb@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.16.y-ckt 007/104] kvm: factor out core eventfd assign/deassign logic
Date: Mon, 26 Oct 2015 13:41:49 +0000 [thread overview]
Message-ID: <1445867006-18048-8-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1445867006-18048-1-git-send-email-luis.henriques@canonical.com>
3.16.7-ckt19 -stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Wang <jasowang@redhat.com>
commit 85da11ca587c8eb73993a1b503052391a73586f9 upstream.
This patch factors out core eventfd assign/deassign logic and leaves
the argument checking and bus index selection to callers.
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
virt/kvm/eventfd.c | 85 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 50 insertions(+), 35 deletions(-)
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 47e48e2c7d1a..5a62748c49b9 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -703,40 +703,14 @@ static enum kvm_bus ioeventfd_bus_from_flags(__u32 flags)
return KVM_MMIO_BUS;
}
-static int
-kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
+static int kvm_assign_ioeventfd_idx(struct kvm *kvm,
+ enum kvm_bus bus_idx,
+ struct kvm_ioeventfd *args)
{
- enum kvm_bus bus_idx;
- struct _ioeventfd *p;
- struct eventfd_ctx *eventfd;
- int ret;
-
- bus_idx = ioeventfd_bus_from_flags(args->flags);
- /* must be natural-word sized, or 0 to ignore length */
- switch (args->len) {
- case 0:
- case 1:
- case 2:
- case 4:
- case 8:
- break;
- default:
- return -EINVAL;
- }
-
- /* check for range overflow */
- if (args->addr + args->len < args->addr)
- return -EINVAL;
- /* check for extra flags that we don't understand */
- if (args->flags & ~KVM_IOEVENTFD_VALID_FLAG_MASK)
- return -EINVAL;
-
- /* ioeventfd with no length can't be combined with DATAMATCH */
- if (!args->len &&
- args->flags & (KVM_IOEVENTFD_FLAG_PIO |
- KVM_IOEVENTFD_FLAG_DATAMATCH))
- return -EINVAL;
+ struct eventfd_ctx *eventfd;
+ struct _ioeventfd *p;
+ int ret;
eventfd = eventfd_ctx_fdget(args->fd);
if (IS_ERR(eventfd))
@@ -805,14 +779,13 @@ fail:
}
static int
-kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
+kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx,
+ struct kvm_ioeventfd *args)
{
- enum kvm_bus bus_idx;
struct _ioeventfd *p, *tmp;
struct eventfd_ctx *eventfd;
int ret = -ENOENT;
- bus_idx = ioeventfd_bus_from_flags(args->flags);
eventfd = eventfd_ctx_fdget(args->fd);
if (IS_ERR(eventfd))
return PTR_ERR(eventfd);
@@ -850,6 +823,48 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
return ret;
}
+static int kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
+{
+ enum kvm_bus bus_idx = ioeventfd_bus_from_flags(args->flags);
+
+ return kvm_deassign_ioeventfd_idx(kvm, bus_idx, args);
+}
+
+static int
+kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
+{
+ enum kvm_bus bus_idx;
+
+ bus_idx = ioeventfd_bus_from_flags(args->flags);
+ /* must be natural-word sized, or 0 to ignore length */
+ switch (args->len) {
+ case 0:
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ /* check for range overflow */
+ if (args->addr + args->len < args->addr)
+ return -EINVAL;
+
+ /* check for extra flags that we don't understand */
+ if (args->flags & ~KVM_IOEVENTFD_VALID_FLAG_MASK)
+ return -EINVAL;
+
+ /* ioeventfd with no length can't be combined with DATAMATCH */
+ if (!args->len &&
+ args->flags & (KVM_IOEVENTFD_FLAG_PIO |
+ KVM_IOEVENTFD_FLAG_DATAMATCH))
+ return -EINVAL;
+
+ return kvm_assign_ioeventfd_idx(kvm, bus_idx, args);
+}
+
int
kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
{
next prev parent reply other threads:[~2015-10-26 13:43 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 002/104] CIFS: fix type confusion in copy offload ioctl Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 003/104] hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 004/104] x86/apic: Serialize LVTT and TSC_DEADLINE writes Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 005/104] arm64: head.S: initialise mdcr_el2 in el2_setup Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 006/104] kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd Luis Henriques
2015-10-26 13:41 ` Luis Henriques [this message]
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 008/104] kvm: fix double free for fast " Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 009/104] kvm: fix zero length mmio searching Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 010/104] ARM: fix Thumb2 signal handling when ARMv6 is enabled Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 011/104] powerpc/boot: Specify ABI v2 when building an LE boot wrapper Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 012/104] powerpc/mm: Recompute hash value after a failed update Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 013/104] x86/platform: Fix Geode LX timekeeping in the generic x86 build Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 014/104] arm64: compat: fix vfp save/restore across signal handlers in big-endian Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 015/104] arm64: errata: add module build workaround for erratum #843419 Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 016/104] arm64: KVM: Disable virtual timer even if the guest is not using it Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 017/104] arm: " Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 018/104] hp-wmi: Add missing __init annotations to initialization code Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 019/104] hp-wmi: limit hotkey enable Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 020/104] zram: fix possible use after free in zcomp_create() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 021/104] perf header: Fixup reading of HEADER_NRCPUS feature Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 022/104] dcache: Handle escaped paths in prepend_path Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 023/104] vfs: Test for and handle paths that are unreachable from their mnt_root Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 024/104] spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 025/104] spi: Fix documentation of spi_alloc_master() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 026/104] USB: option: add ZTE PIDs Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 027/104] drm/vmwgfx: Fix up user_dmabuf refcounting Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 028/104] ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 029/104] Btrfs: fix read corruption of compressed and shared extents Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 030/104] btrfs: skip waiting on ordered range for special files Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 031/104] usb: chipidea: udc: using the correct stall implementation Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 032/104] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 033/104] iser-target: remove command with state ISTATE_REMOVE Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 034/104] staging: ion: fix corruption of ion_import_dma_buf Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 035/104] KVM: x86: trap AMD MSRs for the TSeg base and mask Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 036/104] usb: Use the USB_SS_MULT() macro to get the burst multiplier Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 037/104] xhci: give command abortion one more chance before killing xhci Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 038/104] usb: xhci: Clear XHCI_STATE_DYING on start Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 039/104] usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 040/104] xhci: change xhci 1.0 only restrictions to support xhci 1.1 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 041/104] xhci-mem: Use setup_timer Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 042/104] xhci: init command timeout timer earlier to avoid deleting it uninitialized Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 043/104] spi: xtensa-xtfpga: fix register endianness Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 044/104] disabling oplocks/leases via module parm enable_oplocks broken for SMB3 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 045/104] cifs: use server timestamp for ntlmv2 authentication Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 046/104] x86/paravirt: Replace the paravirt nop with a bona fide empty function Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 047/104] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 048/104] ASoC: pxa: pxa2xx-ac97: fix dma requestor lines Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 049/104] ocfs2/dlm: fix deadlock when dispatch assert master Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 050/104] drm/i915/bios: handle MIPI Sequence Block v3+ gracefully Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 051/104] USB: whiteheat: fix potential null-deref at probe Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 052/104] drm/qxl: only report first monitor as connected if we have no state Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 053/104] PCI: Fix devfn for VPD access through function 0 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 054/104] PCI: Use function 0 VPD for identical functions, regular VPD for others Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 055/104] netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 056/104] ASoC: fix broken pxa SoC support Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 057/104] ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 058/104] vxlan: set needed headroom correctly Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 059/104] Revert "ARM: orion5x: fix legacy orion5x IRQ numbers" Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 060/104] jbd2: avoid infinite loop when destroying aborted journal Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 061/104] asix: Don't reset PHY on if_up for ASIX 88772 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 062/104] asix: Do full reset during ax88772_bind Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 063/104] fib_rules: Fix dump_rules() not to exit early Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 064/104] net/xen-netfront: only napi_synchronize() if running Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 065/104] cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 066/104] intel_pstate: Fix overflow in busy_scaled due to long delay Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 067/104] tools lib traceevent: Fix string handling in heterogeneous arch environments Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 068/104] perf tools: Fix copying of /proc/kcore Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 069/104] m68k: Define asmlinkage_protect Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 070/104] UBI: Validate data_size Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 071/104] UBI: return ENOSPC if no enough space available Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx) Luis Henriques
2015-10-27 2:10 ` Michel Dänzer
2015-10-28 10:45 ` Luis Henriques
2015-11-02 7:52 ` Michel Dänzer
2015-11-11 15:43 ` Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 073/104] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 074/104] MIPS: CPS: Stop dangling delay slot from has_mt Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 075/104] MIPS: CPS: Don't include MT code in non-MT kernels Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 076/104] MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 077/104] Initialize msg/shm IPC objects before doing ipc_addid() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 078/104] drm/qxl: recreate the primary surface when the bo is not primary Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 079/104] genirq: Fix race in register_irq_proc() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 080/104] x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 081/104] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 082/104] mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 083/104] x86/mm: Set NX on gap between __ex_table and rodata Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 084/104] clocksource: Fix abs() usage w/ 64bit values Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 085/104] dmaengine: dw: properly read DWC_PARAMS register Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 086/104] mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1) Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 087/104] drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 088/104] fs: if a coredump already exists, unlink and recreate with O_EXCL Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 089/104] sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 090/104] ipc/sem.c: fully initialize sem_array before making it visible Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 091/104] drivers: usb :fsl: Implement Workaround for USB Erratum A007792 Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 092/104] drivers: usb: fsl: Workaround for USB erratum-A005275 Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 093/104] l2tp: protect tunnel->del_work by ref_count Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 094/104] af_unix: Convert the unix_sk macro to an inline function for type safety Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 095/104] af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 096/104] net/unix: fix logic about sk_peek_offset Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 097/104] skbuff: Fix skb checksum flag on skb pull Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 098/104] skbuff: Fix skb checksum partial check Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 099/104] net: add pfmemalloc check in sk_add_backlog() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 100/104] ppp: don't override sk->sk_state in pppoe_flush_dev() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 101/104] ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 102/104] ovs: do not allocate memory from offline numa node Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 103/104] netlink: Trim skb to alloc size to avoid MSG_TRUNC Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 104/104] net: add length argument to skb_copy_and_csum_datagram_iovec Luis Henriques
2015-10-26 19:02 ` [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
2015-10-28 16:51 ` Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 105/107] KEYS: Fix race between key destruction and finding a keyring by name Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 106/107] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 107/107] KEYS: Don't permit request_key() to construct a new keyring Luis Henriques
2015-10-28 16:52 ` [PATCH 3.16.y-ckt 108/108] Btrfs: update fix for read corruption of compressed and shared extents Luis Henriques
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=1445867006-18048-8-git-send-email-luis.henriques@canonical.com \
--to=luis.henriques@canonical.com \
--cc=gleb@kernel.org \
--cc=jasowang@redhat.com \
--cc=kernel-team@lists.ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=stable@vger.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
all inboxes | Powered by JetHome®