Skip to content

Commit 7b46b61

Browse files
legoaterpaulusmack
authored andcommitted
KVM: PPC: Book3S HV: XIVE: Add a control to sync the sources
This control will be used by the H_INT_SYNC hcall from QEMU to flush event notifications on the XIVE IC owning the source. Signed-off-by: Cédric Le Goater <[email protected]> Reviewed-by: David Gibson <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 5ca8064 commit 7b46b61

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

Documentation/virtual/kvm/devices/xive.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,11 @@ the legacy interrupt mode, referred as XICS (POWER7/8).
9292
-EINVAL: Invalid queue address
9393
-EFAULT: Invalid user pointer for attr->addr.
9494
-EIO: Configuration of the underlying HW failed
95+
96+
5. KVM_DEV_XIVE_GRP_SOURCE_SYNC (write only)
97+
Synchronize the source to flush event notifications
98+
Attributes:
99+
Interrupt source number (64-bit)
100+
Errors:
101+
-ENOENT: Unknown source number
102+
-EINVAL: Not initialized source number

arch/powerpc/include/uapi/asm/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ struct kvm_ppc_cpu_char {
683683
#define KVM_DEV_XIVE_GRP_SOURCE 2 /* 64-bit source identifier */
684684
#define KVM_DEV_XIVE_GRP_SOURCE_CONFIG 3 /* 64-bit source identifier */
685685
#define KVM_DEV_XIVE_GRP_EQ_CONFIG 4 /* 64-bit EQ identifier */
686+
#define KVM_DEV_XIVE_GRP_SOURCE_SYNC 5 /* 64-bit source identifier */
686687

687688
/* Layout of 64-bit XIVE source attribute values */
688689
#define KVM_XIVE_LEVEL_SENSITIVE (1ULL << 0)

arch/powerpc/kvm/book3s_xive_native.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,38 @@ static int kvmppc_xive_native_set_source_config(struct kvmppc_xive *xive,
335335
priority, masked, eisn);
336336
}
337337

338+
static int kvmppc_xive_native_sync_source(struct kvmppc_xive *xive,
339+
long irq, u64 addr)
340+
{
341+
struct kvmppc_xive_src_block *sb;
342+
struct kvmppc_xive_irq_state *state;
343+
struct xive_irq_data *xd;
344+
u32 hw_num;
345+
u16 src;
346+
int rc = 0;
347+
348+
pr_devel("%s irq=0x%lx", __func__, irq);
349+
350+
sb = kvmppc_xive_find_source(xive, irq, &src);
351+
if (!sb)
352+
return -ENOENT;
353+
354+
state = &sb->irq_state[src];
355+
356+
rc = -EINVAL;
357+
358+
arch_spin_lock(&sb->lock);
359+
360+
if (state->valid) {
361+
kvmppc_xive_select_irq(state, &hw_num, &xd);
362+
xive_native_sync_source(hw_num);
363+
rc = 0;
364+
}
365+
366+
arch_spin_unlock(&sb->lock);
367+
return rc;
368+
}
369+
338370
static int xive_native_validate_queue_size(u32 qshift)
339371
{
340372
/*
@@ -670,6 +702,9 @@ static int kvmppc_xive_native_set_attr(struct kvm_device *dev,
670702
case KVM_DEV_XIVE_GRP_EQ_CONFIG:
671703
return kvmppc_xive_native_set_queue_config(xive, attr->attr,
672704
attr->addr);
705+
case KVM_DEV_XIVE_GRP_SOURCE_SYNC:
706+
return kvmppc_xive_native_sync_source(xive, attr->attr,
707+
attr->addr);
673708
}
674709
return -ENXIO;
675710
}
@@ -699,6 +734,7 @@ static int kvmppc_xive_native_has_attr(struct kvm_device *dev,
699734
break;
700735
case KVM_DEV_XIVE_GRP_SOURCE:
701736
case KVM_DEV_XIVE_GRP_SOURCE_CONFIG:
737+
case KVM_DEV_XIVE_GRP_SOURCE_SYNC:
702738
if (attr->attr >= KVMPPC_XIVE_FIRST_IRQ &&
703739
attr->attr < KVMPPC_XIVE_NR_IRQS)
704740
return 0;

0 commit comments

Comments
 (0)