Skip to content

Commit e1a6d5c

Browse files
committed
Merge tag 'kvm-x86-generic-6.4' of https://github.com/kvm-x86/linux into HEAD
Common KVM changes for 6.4: - Drop unnecessary casts from "void *" throughout kvm_main.c - Tweak the layout of "struct kvm_mmu_memory_cache" to shrink the struct size by 8 bytes on 64-bit kernels by utilizing a padding hole - Fix a documentation format goof that was introduced when the KVM docs were converted to ReST - Constify MIPS's internal callbacks (a leftover from the hardware enabling rework that landed in 6.3)
2 parents 4f382a7 + b0d2370 commit e1a6d5c

7 files changed

Lines changed: 19 additions & 20 deletions

File tree

Documentation/virt/kvm/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7330,6 +7330,7 @@ and injected exceptions.
73307330
will clear DR6.RTM.
73317331
73327332
7.18 KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
7333+
--------------------------------------
73337334

73347335
:Architectures: x86, arm64, mips
73357336
:Parameters: args[0] whether feature should be enabled or not

Documentation/virt/kvm/locking.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The acquisition orders for mutexes are as follows:
2121
- kvm->mn_active_invalidate_count ensures that pairs of
2222
invalidate_range_start() and invalidate_range_end() callbacks
2323
use the same memslots array. kvm->slots_lock and kvm->slots_arch_lock
24-
are taken on the waiting side in install_new_memslots, so MMU notifiers
24+
are taken on the waiting side when modifying memslots, so MMU notifiers
2525
must not take either kvm->slots_lock or kvm->slots_arch_lock.
2626

2727
For SRCU:

arch/mips/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ struct kvm_mips_callbacks {
757757
int (*vcpu_run)(struct kvm_vcpu *vcpu);
758758
void (*vcpu_reenter)(struct kvm_vcpu *vcpu);
759759
};
760-
extern struct kvm_mips_callbacks *kvm_mips_callbacks;
760+
extern const struct kvm_mips_callbacks * const kvm_mips_callbacks;
761761
int kvm_mips_emulation_init(void);
762762

763763
/* Debug: dump vcpu state */

arch/mips/kvm/vz.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3305,7 +3305,7 @@ static struct kvm_mips_callbacks kvm_vz_callbacks = {
33053305
};
33063306

33073307
/* FIXME: Get rid of the callbacks now that trap-and-emulate is gone. */
3308-
struct kvm_mips_callbacks *kvm_mips_callbacks = &kvm_vz_callbacks;
3308+
const struct kvm_mips_callbacks * const kvm_mips_callbacks = &kvm_vz_callbacks;
33093309

33103310
int kvm_mips_emulation_init(void)
33113311
{

include/linux/kvm_host.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
/*
6060
* Bit 63 of the memslot generation number is an "update in-progress flag",
61-
* e.g. is temporarily set for the duration of install_new_memslots().
61+
* e.g. is temporarily set for the duration of kvm_swap_active_memslots().
6262
* This flag effectively creates a unique generation number that is used to
6363
* mark cached memslot data, e.g. MMIO accesses, as potentially being stale,
6464
* i.e. may (or may not) have come from the previous memslots generation.
@@ -713,7 +713,7 @@ struct kvm {
713713
* use by the VM. To be used under the slots_lock (above) or in a
714714
* kvm->srcu critical section where acquiring the slots_lock would
715715
* lead to deadlock with the synchronize_srcu in
716-
* install_new_memslots.
716+
* kvm_swap_active_memslots().
717717
*/
718718
struct mutex slots_arch_lock;
719719
struct mm_struct *mm; /* userspace tied to this vm */

include/linux/kvm_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ struct gfn_to_pfn_cache {
9191
* is topped up (__kvm_mmu_topup_memory_cache()).
9292
*/
9393
struct kvm_mmu_memory_cache {
94-
int nobjs;
9594
gfp_t gfp_zero;
9695
gfp_t gfp_custom;
9796
struct kmem_cache *kmem_cache;
9897
int capacity;
98+
int nobjs;
9999
void **objects;
100100
};
101101
#endif

virt/kvm/kvm_main.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ static void kvm_destroy_vm(struct kvm *kvm)
12981298
* At this point, pending calls to invalidate_range_start()
12991299
* have completed but no more MMU notifiers will run, so
13001300
* mn_active_invalidate_count may remain unbalanced.
1301-
* No threads can be waiting in install_new_memslots as the
1301+
* No threads can be waiting in kvm_swap_active_memslots() as the
13021302
* last reference on KVM has been dropped, but freeing
13031303
* memslots would deadlock without this manual intervention.
13041304
*/
@@ -1742,13 +1742,13 @@ static void kvm_invalidate_memslot(struct kvm *kvm,
17421742
kvm_arch_flush_shadow_memslot(kvm, old);
17431743
kvm_arch_guest_memory_reclaimed(kvm);
17441744

1745-
/* Was released by kvm_swap_active_memslots, reacquire. */
1745+
/* Was released by kvm_swap_active_memslots(), reacquire. */
17461746
mutex_lock(&kvm->slots_arch_lock);
17471747

17481748
/*
17491749
* Copy the arch-specific field of the newly-installed slot back to the
17501750
* old slot as the arch data could have changed between releasing
1751-
* slots_arch_lock in install_new_memslots() and re-acquiring the lock
1751+
* slots_arch_lock in kvm_swap_active_memslots() and re-acquiring the lock
17521752
* above. Writers are required to retrieve memslots *after* acquiring
17531753
* slots_arch_lock, thus the active slot's data is guaranteed to be fresh.
17541754
*/
@@ -1810,11 +1810,11 @@ static int kvm_set_memslot(struct kvm *kvm,
18101810
int r;
18111811

18121812
/*
1813-
* Released in kvm_swap_active_memslots.
1813+
* Released in kvm_swap_active_memslots().
18141814
*
1815-
* Must be held from before the current memslots are copied until
1816-
* after the new memslots are installed with rcu_assign_pointer,
1817-
* then released before the synchronize srcu in kvm_swap_active_memslots.
1815+
* Must be held from before the current memslots are copied until after
1816+
* the new memslots are installed with rcu_assign_pointer, then
1817+
* released before the synchronize srcu in kvm_swap_active_memslots().
18181818
*
18191819
* When modifying memslots outside of the slots_lock, must be held
18201820
* before reading the pointer to the current memslots until after all
@@ -3866,7 +3866,7 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu)
38663866
#ifdef __KVM_HAVE_ARCH_VCPU_DEBUGFS
38673867
static int vcpu_get_pid(void *data, u64 *val)
38683868
{
3869-
struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
3869+
struct kvm_vcpu *vcpu = data;
38703870
*val = pid_nr(rcu_access_pointer(vcpu->pid));
38713871
return 0;
38723872
}
@@ -5572,8 +5572,7 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
55725572
const char *fmt)
55735573
{
55745574
int ret;
5575-
struct kvm_stat_data *stat_data = (struct kvm_stat_data *)
5576-
inode->i_private;
5575+
struct kvm_stat_data *stat_data = inode->i_private;
55775576

55785577
/*
55795578
* The debugfs files are a reference to the kvm struct which
@@ -5594,8 +5593,7 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
55945593

55955594
static int kvm_debugfs_release(struct inode *inode, struct file *file)
55965595
{
5597-
struct kvm_stat_data *stat_data = (struct kvm_stat_data *)
5598-
inode->i_private;
5596+
struct kvm_stat_data *stat_data = inode->i_private;
55995597

56005598
simple_attr_release(inode, file);
56015599
kvm_put_kvm(stat_data->kvm);
@@ -5644,7 +5642,7 @@ static int kvm_clear_stat_per_vcpu(struct kvm *kvm, size_t offset)
56445642
static int kvm_stat_data_get(void *data, u64 *val)
56455643
{
56465644
int r = -EFAULT;
5647-
struct kvm_stat_data *stat_data = (struct kvm_stat_data *)data;
5645+
struct kvm_stat_data *stat_data = data;
56485646

56495647
switch (stat_data->kind) {
56505648
case KVM_STAT_VM:
@@ -5663,7 +5661,7 @@ static int kvm_stat_data_get(void *data, u64 *val)
56635661
static int kvm_stat_data_clear(void *data, u64 val)
56645662
{
56655663
int r = -EFAULT;
5666-
struct kvm_stat_data *stat_data = (struct kvm_stat_data *)data;
5664+
struct kvm_stat_data *stat_data = data;
56675665

56685666
if (val)
56695667
return -EINVAL;

0 commit comments

Comments
 (0)