Skip to content

Commit 54163a3

Browse files
ssuthiku-amdbonzini
authored andcommitted
KVM: Introduce kvm_make_all_cpus_request_except()
This allows making request to all other vcpus except the one specified in the parameter. Signed-off-by: Suravee Suthikulpanit <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 45981de commit 54163a3

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

arch/x86/kvm/hyperv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,
14271427
*/
14281428
kvm_make_vcpus_request_mask(kvm,
14291429
KVM_REQ_TLB_FLUSH | KVM_REQUEST_NO_WAKEUP,
1430-
vcpu_mask, &hv_vcpu->tlb_flush);
1430+
NULL, vcpu_mask, &hv_vcpu->tlb_flush);
14311431

14321432
ret_success:
14331433
/* We always do full TLB flush, set rep_done = rep_cnt. */

arch/x86/kvm/x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8030,7 +8030,7 @@ void kvm_make_scan_ioapic_request_mask(struct kvm *kvm,
80308030
zalloc_cpumask_var(&cpus, GFP_ATOMIC);
80318031

80328032
kvm_make_vcpus_request_mask(kvm, KVM_REQ_SCAN_IOAPIC,
8033-
vcpu_bitmap, cpus);
8033+
NULL, vcpu_bitmap, cpus);
80348034

80358035
free_cpumask_var(cpus);
80368036
}

include/linux/kvm_host.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,11 @@ void kvm_flush_remote_tlbs(struct kvm *kvm);
813813
void kvm_reload_remote_mmus(struct kvm *kvm);
814814

815815
bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
816+
struct kvm_vcpu *except,
816817
unsigned long *vcpu_bitmap, cpumask_var_t tmp);
817818
bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
819+
bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
820+
struct kvm_vcpu *except);
818821
bool kvm_make_cpus_request_mask(struct kvm *kvm, unsigned int req,
819822
unsigned long *vcpu_bitmap);
820823

virt/kvm/kvm_main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ static inline bool kvm_kick_many_cpus(const struct cpumask *cpus, bool wait)
259259
}
260260

261261
bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
262+
struct kvm_vcpu *except,
262263
unsigned long *vcpu_bitmap, cpumask_var_t tmp)
263264
{
264265
int i, cpu, me;
@@ -268,7 +269,8 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
268269
me = get_cpu();
269270

270271
kvm_for_each_vcpu(i, vcpu, kvm) {
271-
if (vcpu_bitmap && !test_bit(i, vcpu_bitmap))
272+
if ((vcpu_bitmap && !test_bit(i, vcpu_bitmap)) ||
273+
vcpu == except)
272274
continue;
273275

274276
kvm_make_request(req, vcpu);
@@ -288,19 +290,25 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
288290
return called;
289291
}
290292

291-
bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
293+
bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
294+
struct kvm_vcpu *except)
292295
{
293296
cpumask_var_t cpus;
294297
bool called;
295298

296299
zalloc_cpumask_var(&cpus, GFP_ATOMIC);
297300

298-
called = kvm_make_vcpus_request_mask(kvm, req, NULL, cpus);
301+
called = kvm_make_vcpus_request_mask(kvm, req, except, NULL, cpus);
299302

300303
free_cpumask_var(cpus);
301304
return called;
302305
}
303306

307+
bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
308+
{
309+
return kvm_make_all_cpus_request_except(kvm, req, NULL);
310+
}
311+
304312
#ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL
305313
void kvm_flush_remote_tlbs(struct kvm *kvm)
306314
{

0 commit comments

Comments
 (0)