Skip to content

Commit 515f714

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm fixes from Paolo Bonzini: - Check for invalid flags to KVM_CAP_X86_USER_SPACE_MSR - Fix use of sched_setaffinity in selftests - Sync kernel headers to tools - Fix KVM_STATS_UNIT_MAX * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: x86: Protect the unused bits in MSR exiting flags tools headers UAPI: Sync linux/kvm.h with the kernel sources KVM: selftests: Fix target thread to be migrated in rseq_test KVM: stats: Fix value for KVM_STATS_UNIT_MAX for boolean stats
2 parents 301c894 + cf5029d commit 515f714

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5658,7 +5658,7 @@ by a string of size ``name_size``.
56585658
#define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
56595659
#define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
56605660
#define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)
5661-
#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES
5661+
#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN
56625662

56635663
#define KVM_STATS_BASE_SHIFT 8
56645664
#define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT)

arch/x86/kvm/x86.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6029,6 +6029,11 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
60296029
r = 0;
60306030
break;
60316031
case KVM_CAP_X86_USER_SPACE_MSR:
6032+
r = -EINVAL;
6033+
if (cap->args[0] & ~(KVM_MSR_EXIT_REASON_INVAL |
6034+
KVM_MSR_EXIT_REASON_UNKNOWN |
6035+
KVM_MSR_EXIT_REASON_FILTER))
6036+
break;
60326037
kvm->arch.user_space_msr_mask = cap->args[0];
60336038
r = 0;
60346039
break;
@@ -6183,6 +6188,9 @@ static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm, void __user *argp)
61836188
if (copy_from_user(&filter, user_msr_filter, sizeof(filter)))
61846189
return -EFAULT;
61856190

6191+
if (filter.flags & ~KVM_MSR_FILTER_DEFAULT_DENY)
6192+
return -EINVAL;
6193+
61866194
for (i = 0; i < ARRAY_SIZE(filter.ranges); i++)
61876195
empty &= !filter.ranges[i].nmsrs;
61886196

include/uapi/linux/kvm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ struct kvm_stats_header {
20842084
#define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
20852085
#define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
20862086
#define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)
2087-
#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES
2087+
#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN
20882088

20892089
#define KVM_STATS_BASE_SHIFT 8
20902090
#define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT)

tools/include/uapi/linux/kvm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ struct kvm_stats_header {
20842084
#define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
20852085
#define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
20862086
#define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)
2087-
#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES
2087+
#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN
20882088

20892089
#define KVM_STATS_BASE_SHIFT 8
20902090
#define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT)

tools/testing/selftests/kvm/rseq_test.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ static int next_cpu(int cpu)
8282
return cpu;
8383
}
8484

85-
static void *migration_worker(void *ign)
85+
static void *migration_worker(void *__rseq_tid)
8686
{
87+
pid_t rseq_tid = (pid_t)(unsigned long)__rseq_tid;
8788
cpu_set_t allowed_mask;
8889
int r, i, cpu;
8990

@@ -106,7 +107,7 @@ static void *migration_worker(void *ign)
106107
* stable, i.e. while changing affinity is in-progress.
107108
*/
108109
smp_wmb();
109-
r = sched_setaffinity(0, sizeof(allowed_mask), &allowed_mask);
110+
r = sched_setaffinity(rseq_tid, sizeof(allowed_mask), &allowed_mask);
110111
TEST_ASSERT(!r, "sched_setaffinity failed, errno = %d (%s)",
111112
errno, strerror(errno));
112113
smp_wmb();
@@ -231,7 +232,8 @@ int main(int argc, char *argv[])
231232
vm = vm_create_default(VCPU_ID, 0, guest_code);
232233
ucall_init(vm, NULL);
233234

234-
pthread_create(&migration_thread, NULL, migration_worker, 0);
235+
pthread_create(&migration_thread, NULL, migration_worker,
236+
(void *)(unsigned long)gettid());
235237

236238
for (i = 0; !done; i++) {
237239
vcpu_run(vm, VCPU_ID);

0 commit comments

Comments
 (0)