Skip to content

Commit 25b72cf

Browse files
committed
Merge tag 'kvmarm-fixes-6.2-3' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.2, take #3 - Yet another fix for non-CPU accesses to the memory backing the VGICv3 subsystem - A set of fixes for the setlftest checking for the S1PTW behaviour after the fix that went in ealier in the cycle
2 parents c2c46b1 + 08ddbbd commit 25b72cf

File tree

6 files changed

+132
-98
lines changed

6 files changed

+132
-98
lines changed

Documentation/virt/kvm/api.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -8070,9 +8070,13 @@ considering the state as complete. VMM needs to ensure that the dirty
80708070
state is final and avoid missing dirty pages from another ioctl ordered
80718071
after the bitmap collection.
80728072

8073-
NOTE: One example of using the backup bitmap is saving arm64 vgic/its
8074-
tables through KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} command on
8075-
KVM device "kvm-arm-vgic-its" when dirty ring is enabled.
8073+
NOTE: Multiple examples of using the backup bitmap: (1) save vgic/its
8074+
tables through command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} on
8075+
KVM device "kvm-arm-vgic-its". (2) restore vgic/its tables through
8076+
command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} on KVM device
8077+
"kvm-arm-vgic-its". VGICv3 LPI pending status is restored. (3) save
8078+
vgic3 pending table through KVM_DEV_ARM_VGIC_{GRP_CTRL, SAVE_PENDING_TABLES}
8079+
command on KVM device "kvm-arm-vgic-v3".
80768080

80778081
8.30 KVM_CAP_XEN_HVM
80788082
--------------------

arch/arm64/kvm/vgic/vgic-its.c

+5-8
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@ static int vgic_its_save_ite(struct vgic_its *its, struct its_device *dev,
21872187
((u64)ite->irq->intid << KVM_ITS_ITE_PINTID_SHIFT) |
21882188
ite->collection->collection_id;
21892189
val = cpu_to_le64(val);
2190-
return kvm_write_guest_lock(kvm, gpa, &val, ite_esz);
2190+
return vgic_write_guest_lock(kvm, gpa, &val, ite_esz);
21912191
}
21922192

21932193
/**
@@ -2339,7 +2339,7 @@ static int vgic_its_save_dte(struct vgic_its *its, struct its_device *dev,
23392339
(itt_addr_field << KVM_ITS_DTE_ITTADDR_SHIFT) |
23402340
(dev->num_eventid_bits - 1));
23412341
val = cpu_to_le64(val);
2342-
return kvm_write_guest_lock(kvm, ptr, &val, dte_esz);
2342+
return vgic_write_guest_lock(kvm, ptr, &val, dte_esz);
23432343
}
23442344

23452345
/**
@@ -2526,7 +2526,7 @@ static int vgic_its_save_cte(struct vgic_its *its,
25262526
((u64)collection->target_addr << KVM_ITS_CTE_RDBASE_SHIFT) |
25272527
collection->collection_id);
25282528
val = cpu_to_le64(val);
2529-
return kvm_write_guest_lock(its->dev->kvm, gpa, &val, esz);
2529+
return vgic_write_guest_lock(its->dev->kvm, gpa, &val, esz);
25302530
}
25312531

25322532
/*
@@ -2607,7 +2607,7 @@ static int vgic_its_save_collection_table(struct vgic_its *its)
26072607
*/
26082608
val = 0;
26092609
BUG_ON(cte_esz > sizeof(val));
2610-
ret = kvm_write_guest_lock(its->dev->kvm, gpa, &val, cte_esz);
2610+
ret = vgic_write_guest_lock(its->dev->kvm, gpa, &val, cte_esz);
26112611
return ret;
26122612
}
26132613

@@ -2743,7 +2743,6 @@ static int vgic_its_has_attr(struct kvm_device *dev,
27432743
static int vgic_its_ctrl(struct kvm *kvm, struct vgic_its *its, u64 attr)
27442744
{
27452745
const struct vgic_its_abi *abi = vgic_its_get_abi(its);
2746-
struct vgic_dist *dist = &kvm->arch.vgic;
27472746
int ret = 0;
27482747

27492748
if (attr == KVM_DEV_ARM_VGIC_CTRL_INIT) /* Nothing to do */
@@ -2763,9 +2762,7 @@ static int vgic_its_ctrl(struct kvm *kvm, struct vgic_its *its, u64 attr)
27632762
vgic_its_reset(kvm, its);
27642763
break;
27652764
case KVM_DEV_ARM_ITS_SAVE_TABLES:
2766-
dist->save_its_tables_in_progress = true;
27672765
ret = abi->save_tables(its);
2768-
dist->save_its_tables_in_progress = false;
27692766
break;
27702767
case KVM_DEV_ARM_ITS_RESTORE_TABLES:
27712768
ret = abi->restore_tables(its);
@@ -2792,7 +2789,7 @@ bool kvm_arch_allow_write_without_running_vcpu(struct kvm *kvm)
27922789
{
27932790
struct vgic_dist *dist = &kvm->arch.vgic;
27942791

2795-
return dist->save_its_tables_in_progress;
2792+
return dist->table_write_in_progress;
27962793
}
27972794

27982795
static int vgic_its_set_attr(struct kvm_device *dev,

arch/arm64/kvm/vgic/vgic-v3.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ int vgic_v3_lpi_sync_pending_status(struct kvm *kvm, struct vgic_irq *irq)
339339
if (status) {
340340
/* clear consumed data */
341341
val &= ~(1 << bit_nr);
342-
ret = kvm_write_guest_lock(kvm, ptr, &val, 1);
342+
ret = vgic_write_guest_lock(kvm, ptr, &val, 1);
343343
if (ret)
344344
return ret;
345345
}
@@ -434,7 +434,7 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
434434
else
435435
val &= ~(1 << bit_nr);
436436

437-
ret = kvm_write_guest_lock(kvm, ptr, &val, 1);
437+
ret = vgic_write_guest_lock(kvm, ptr, &val, 1);
438438
if (ret)
439439
goto out;
440440
}

arch/arm64/kvm/vgic/vgic.h

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define __KVM_ARM_VGIC_NEW_H__
77

88
#include <linux/irqchip/arm-gic-common.h>
9+
#include <asm/kvm_mmu.h>
910

1011
#define PRODUCT_ID_KVM 0x4b /* ASCII code K */
1112
#define IMPLEMENTER_ARM 0x43b
@@ -131,6 +132,19 @@ static inline bool vgic_irq_is_multi_sgi(struct vgic_irq *irq)
131132
return vgic_irq_get_lr_count(irq) > 1;
132133
}
133134

135+
static inline int vgic_write_guest_lock(struct kvm *kvm, gpa_t gpa,
136+
const void *data, unsigned long len)
137+
{
138+
struct vgic_dist *dist = &kvm->arch.vgic;
139+
int ret;
140+
141+
dist->table_write_in_progress = true;
142+
ret = kvm_write_guest_lock(kvm, gpa, data, len);
143+
dist->table_write_in_progress = false;
144+
145+
return ret;
146+
}
147+
134148
/*
135149
* This struct provides an intermediate representation of the fields contained
136150
* in the GICH_VMCR and ICH_VMCR registers, such that code exporting the GIC

include/kvm/arm_vgic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ struct vgic_dist {
263263
struct vgic_io_device dist_iodev;
264264

265265
bool has_its;
266-
bool save_its_tables_in_progress;
266+
bool table_write_in_progress;
267267

268268
/*
269269
* Contains the attributes and gpa of the LPI configuration table.

0 commit comments

Comments
 (0)