2022-01-25 14:35:48

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 00/19] KVM: x86: Bulk removal of unused function parameters

From: Like Xu <[email protected]>

Hi,

This patch set is a follow up to a similar patch [1], and may
hopefully help to improve the code quality of KVM.

Basically, the cleanup is triggered by a compiler feature[2], but obviously
there are a lot of false positives here, and so far we may apply at least
this changset, which also helps the related developers to think more
carefully about why these functions were declared that way in the first
place or what is left after a series of loosely-coupled clean-ups.

[1] https://lore.kernel.org/kvm/[email protected]/
[2] ccflags-y += -Wunused-parameter

Thanks,
Like Xu

Jinrong Liang (19):
KVM: x86/mmu: Remove unused "kvm" of kvm_mmu_unlink_parents()
KVM: x86/mmu: Remove unused "kvm" of __rmap_write_protect()
KVM: x86/mmu: Remove unused "vcpu" of
reset_{tdp,ept}_shadow_zero_bits_mask()
KVM: x86/tdp_mmu: Remove unused "kvm" of kvm_tdp_mmu_get_root()
KVM: x86/mmu_audit: Remove unused "level" of audit_spte_after_sync()
KVM: x86/svm: Remove unused "vcpu" of svm_check_exit_valid()
KVM: x86/svm: Remove unused "vcpu" of nested_svm_check_tlb_ctl()
KVM: x86/svm: Remove unused "vcpu" of kvm_after_interrupt()
KVM: x86/sev: Remove unused "svm" of sev_es_prepare_guest_switch()
KVM: x86/sev: Remove unused "kvm" of sev_unbind_asid()
KVM: x86/sev: Remove unused "vector" of sev_vcpu_deliver_sipi_vector()
KVM: x86/i8259: Remove unused "addr" of elcr_ioport_{read,write}()
KVM: x86/ioapic: Remove unused "addr" and "length" of
ioapic_read_indirect()
KVM: x86/emulate: Remove unused "ctxt" of setup_syscalls_segments()
KVM: x86/emulate: Remove unused "ctxt" of task_switch_{16, 32}()
KVM: x86: Remove unused "vcpu" of kvm_arch_tsc_has_attr()
KVM: x86: Remove unused "vcpu" of kvm_scale_tsc()
KVM: Remove unused "kvm" of kvm_make_vcpu_request()
KVM: Remove unused "flags" of kvm_pv_kick_cpu_op()

arch/x86/include/asm/kvm_host.h | 2 +-
arch/x86/kvm/emulate.c | 20 ++++++++------------
arch/x86/kvm/i8259.c | 8 ++++----
arch/x86/kvm/ioapic.c | 6 ++----
arch/x86/kvm/mmu/mmu.c | 23 ++++++++++-------------
arch/x86/kvm/mmu/mmu_audit.c | 4 ++--
arch/x86/kvm/mmu/tdp_mmu.c | 4 ++--
arch/x86/kvm/mmu/tdp_mmu.h | 3 +--
arch/x86/kvm/svm/nested.c | 4 ++--
arch/x86/kvm/svm/sev.c | 12 ++++++------
arch/x86/kvm/svm/svm.c | 10 +++++-----
arch/x86/kvm/svm/svm.h | 4 ++--
arch/x86/kvm/vmx/vmx.c | 2 +-
arch/x86/kvm/x86.c | 25 ++++++++++++-------------
arch/x86/kvm/x86.h | 2 +-
virt/kvm/kvm_main.c | 9 ++++-----
16 files changed, 63 insertions(+), 75 deletions(-)

--
2.33.1


2022-01-25 14:36:00

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 01/19] KVM: x86/mmu: Remove unused "kvm" of kvm_mmu_unlink_parents()

From: Jinrong Liang <[email protected]>

The "struct kvm *kvm" parameter of kvm_mmu_unlink_parents()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/mmu/mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 593093b52395..305aa0c5026f 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -2307,7 +2307,7 @@ static int kvm_mmu_page_unlink_children(struct kvm *kvm,
return zapped;
}

-static void kvm_mmu_unlink_parents(struct kvm *kvm, struct kvm_mmu_page *sp)
+static void kvm_mmu_unlink_parents(struct kvm_mmu_page *sp)
{
u64 *sptep;
struct rmap_iterator iter;
@@ -2351,7 +2351,7 @@ static bool __kvm_mmu_prepare_zap_page(struct kvm *kvm,
++kvm->stat.mmu_shadow_zapped;
*nr_zapped = mmu_zap_unsync_children(kvm, sp, invalid_list);
*nr_zapped += kvm_mmu_page_unlink_children(kvm, sp, invalid_list);
- kvm_mmu_unlink_parents(kvm, sp);
+ kvm_mmu_unlink_parents(sp);

/* Zapping children means active_mmu_pages has become unstable. */
list_unstable = *nr_zapped;
--
2.33.1

2022-01-25 14:36:48

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 03/19] KVM: x86/mmu: Remove unused "vcpu" of reset_{tdp,ept}_shadow_zero_bits_mask()

From: Jinrong Liang <[email protected]>

The "struct kvm_vcpu *vcpu" parameter of reset_ept_shadow_zero_bits_mask()
and reset_tdp_shadow_zero_bits_mask() is not used, so remove it.

No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/mmu/mmu.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index bb9791564ca9..b29fc88b51b4 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -4473,8 +4473,7 @@ static inline bool boot_cpu_is_amd(void)
* possible, however, kvm currently does not do execution-protection.
*/
static void
-reset_tdp_shadow_zero_bits_mask(struct kvm_vcpu *vcpu,
- struct kvm_mmu *context)
+reset_tdp_shadow_zero_bits_mask(struct kvm_mmu *context)
{
struct rsvd_bits_validate *shadow_zero_check;
int i;
@@ -4505,8 +4504,7 @@ reset_tdp_shadow_zero_bits_mask(struct kvm_vcpu *vcpu,
* is the shadow page table for intel nested guest.
*/
static void
-reset_ept_shadow_zero_bits_mask(struct kvm_vcpu *vcpu,
- struct kvm_mmu *context, bool execonly)
+reset_ept_shadow_zero_bits_mask(struct kvm_mmu *context, bool execonly)
{
__reset_rsvds_bits_mask_ept(&context->shadow_zero_check,
reserved_hpa_bits(), execonly,
@@ -4793,7 +4791,7 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
context->gva_to_gpa = paging32_gva_to_gpa;

reset_guest_paging_metadata(vcpu, context);
- reset_tdp_shadow_zero_bits_mask(vcpu, context);
+ reset_tdp_shadow_zero_bits_mask(context);
}

static union kvm_mmu_role
@@ -4947,7 +4945,7 @@ void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly,
update_permission_bitmask(context, true);
context->pkru_mask = 0;
reset_rsvds_bits_mask_ept(vcpu, context, execonly, huge_page_level);
- reset_ept_shadow_zero_bits_mask(vcpu, context, execonly);
+ reset_ept_shadow_zero_bits_mask(context, execonly);
}
EXPORT_SYMBOL_GPL(kvm_init_shadow_ept_mmu);

--
2.33.1

2022-01-25 14:36:51

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 02/19] KVM: x86/mmu: Remove unused "kvm" of __rmap_write_protect()

From: Jinrong Liang <[email protected]>

The "struct kvm *kvm" parameter of __rmap_write_protect()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/mmu/mmu.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 305aa0c5026f..bb9791564ca9 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -1229,8 +1229,7 @@ static bool spte_write_protect(u64 *sptep, bool pt_protect)
return mmu_spte_update(sptep, spte);
}

-static bool __rmap_write_protect(struct kvm *kvm,
- struct kvm_rmap_head *rmap_head,
+static bool __rmap_write_protect(struct kvm_rmap_head *rmap_head,
bool pt_protect)
{
u64 *sptep;
@@ -1311,7 +1310,7 @@ static void kvm_mmu_write_protect_pt_masked(struct kvm *kvm,
while (mask) {
rmap_head = gfn_to_rmap(slot->base_gfn + gfn_offset + __ffs(mask),
PG_LEVEL_4K, slot);
- __rmap_write_protect(kvm, rmap_head, false);
+ __rmap_write_protect(rmap_head, false);

/* clear the first set bit */
mask &= mask - 1;
@@ -1410,7 +1409,7 @@ bool kvm_mmu_slot_gfn_write_protect(struct kvm *kvm,
if (kvm_memslots_have_rmaps(kvm)) {
for (i = min_level; i <= KVM_MAX_HUGEPAGE_LEVEL; ++i) {
rmap_head = gfn_to_rmap(gfn, i, slot);
- write_protected |= __rmap_write_protect(kvm, rmap_head, true);
+ write_protected |= __rmap_write_protect(rmap_head, true);
}
}

@@ -5802,7 +5801,7 @@ static bool slot_rmap_write_protect(struct kvm *kvm,
struct kvm_rmap_head *rmap_head,
const struct kvm_memory_slot *slot)
{
- return __rmap_write_protect(kvm, rmap_head, false);
+ return __rmap_write_protect(rmap_head, false);
}

void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
--
2.33.1

2022-01-25 14:36:52

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 04/19] KVM: x86/tdp_mmu: Remove unused "kvm" of kvm_tdp_mmu_get_root()

From: Jinrong Liang <[email protected]>

The "struct kvm *kvm" parameter of kvm_tdp_mmu_get_root() is not used,
so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/mmu/tdp_mmu.c | 4 ++--
arch/x86/kvm/mmu/tdp_mmu.h | 3 +--
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index bc9e3553fba2..d0c85d114574 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
@@ -121,7 +121,7 @@ static struct kvm_mmu_page *tdp_mmu_next_root(struct kvm *kvm,
next_root = list_first_or_null_rcu(&kvm->arch.tdp_mmu_roots,
typeof(*next_root), link);

- while (next_root && !kvm_tdp_mmu_get_root(kvm, next_root))
+ while (next_root && !kvm_tdp_mmu_get_root(next_root))
next_root = list_next_or_null_rcu(&kvm->arch.tdp_mmu_roots,
&next_root->link, typeof(*next_root), link);

@@ -203,7 +203,7 @@ hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(struct kvm_vcpu *vcpu)
/* Check for an existing root before allocating a new one. */
for_each_tdp_mmu_root(kvm, root, kvm_mmu_role_as_id(role)) {
if (root->role.word == role.word &&
- kvm_tdp_mmu_get_root(kvm, root))
+ kvm_tdp_mmu_get_root(root))
goto out;
}

diff --git a/arch/x86/kvm/mmu/tdp_mmu.h b/arch/x86/kvm/mmu/tdp_mmu.h
index 3899004a5d91..599714de67c3 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.h
+++ b/arch/x86/kvm/mmu/tdp_mmu.h
@@ -7,8 +7,7 @@

hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(struct kvm_vcpu *vcpu);

-__must_check static inline bool kvm_tdp_mmu_get_root(struct kvm *kvm,
- struct kvm_mmu_page *root)
+__must_check static inline bool kvm_tdp_mmu_get_root(struct kvm_mmu_page *root)
{
if (root->role.invalid)
return false;
--
2.33.1

2022-01-25 14:36:59

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 05/19] KVM: x86/mmu_audit: Remove unused "level" of audit_spte_after_sync()

From: Jinrong Liang <[email protected]>

The "int level" parameter of audit_spte_after_sync() is not used,
so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/mmu/mmu_audit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu_audit.c b/arch/x86/kvm/mmu/mmu_audit.c
index 9e7dcf999f08..f31fdb874f1f 100644
--- a/arch/x86/kvm/mmu/mmu_audit.c
+++ b/arch/x86/kvm/mmu/mmu_audit.c
@@ -163,7 +163,7 @@ static void audit_sptes_have_rmaps(struct kvm_vcpu *vcpu, u64 *sptep, int level)
inspect_spte_has_rmap(vcpu->kvm, sptep);
}

-static void audit_spte_after_sync(struct kvm_vcpu *vcpu, u64 *sptep, int level)
+static void audit_spte_after_sync(struct kvm_vcpu *vcpu, u64 *sptep)
{
struct kvm_mmu_page *sp = sptep_to_sp(sptep);

@@ -225,7 +225,7 @@ static void audit_spte(struct kvm_vcpu *vcpu, u64 *sptep, int level)
{
audit_sptes_have_rmaps(vcpu, sptep, level);
audit_mappings(vcpu, sptep, level);
- audit_spte_after_sync(vcpu, sptep, level);
+ audit_spte_after_sync(vcpu, sptep);
}

static void audit_vcpu_spte(struct kvm_vcpu *vcpu)
--
2.33.1

2022-01-25 14:37:45

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 07/19] KVM: x86/svm: Remove unused "vcpu" of nested_svm_check_tlb_ctl()

From: Jinrong Liang <[email protected]>

The "struct kvm_vcpu *vcpu" parameter of nested_svm_check_tlb_ctl()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/svm/nested.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index cf206855ebf0..5a1a2678a2b1 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -209,7 +209,7 @@ static bool nested_svm_check_bitmap_pa(struct kvm_vcpu *vcpu, u64 pa, u32 size)
kvm_vcpu_is_legal_gpa(vcpu, addr + size - 1);
}

-static bool nested_svm_check_tlb_ctl(struct kvm_vcpu *vcpu, u8 tlb_ctl)
+static bool nested_svm_check_tlb_ctl(u8 tlb_ctl)
{
/* Nested FLUSHBYASID is not supported yet. */
switch(tlb_ctl) {
@@ -240,7 +240,7 @@ static bool __nested_vmcb_check_controls(struct kvm_vcpu *vcpu,
IOPM_SIZE)))
return false;

- if (CC(!nested_svm_check_tlb_ctl(vcpu, control->tlb_ctl)))
+ if (CC(!nested_svm_check_tlb_ctl(control->tlb_ctl)))
return false;

return true;
--
2.33.1

2022-01-25 14:39:26

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 09/19] KVM: x86/svm: Remove unused "svm" of sev_es_prepare_guest_switch()

From: Jinrong Liang <[email protected]>

The "struct vcpu_svm *svm" parameter of sev_es_prepare_guest_switch()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/svm/sev.c | 2 +-
arch/x86/kvm/svm/svm.c | 2 +-
arch/x86/kvm/svm/svm.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 6a22798eaaee..eae234afe04e 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -2902,7 +2902,7 @@ void sev_es_vcpu_reset(struct vcpu_svm *svm)
sev_enc_bit));
}

-void sev_es_prepare_guest_switch(struct vcpu_svm *svm, unsigned int cpu)
+void sev_es_prepare_guest_switch(unsigned int cpu)
{
struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
struct vmcb_save_area *hostsa;
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 744ddc7ad6ad..3e75ae834412 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -1276,7 +1276,7 @@ static void svm_prepare_guest_switch(struct kvm_vcpu *vcpu)
* or subsequent vmload of host save area.
*/
if (sev_es_guest(vcpu->kvm)) {
- sev_es_prepare_guest_switch(svm, vcpu->cpu);
+ sev_es_prepare_guest_switch(vcpu->cpu);
} else {
vmsave(__sme_page_pa(sd->save_area));
}
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index 47ef8f4a9358..0a749bbda738 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -622,7 +622,7 @@ int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in);
void sev_es_init_vmcb(struct vcpu_svm *svm);
void sev_es_vcpu_reset(struct vcpu_svm *svm);
void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
-void sev_es_prepare_guest_switch(struct vcpu_svm *svm, unsigned int cpu);
+void sev_es_prepare_guest_switch(unsigned int cpu);
void sev_es_unmap_ghcb(struct vcpu_svm *svm);

/* vmenter.S */
--
2.33.1

2022-01-25 14:39:34

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 08/19] KVM: x86: Remove unused "vcpu" of kvm_after_interrupt()

From: Jinrong Liang <[email protected]>

The "struct kvm_vcpu *vcpu" parameter of kvm_after_interrupt() is not used,
so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/svm/svm.c | 2 +-
arch/x86/kvm/vmx/vmx.c | 2 +-
arch/x86/kvm/x86.c | 2 +-
arch/x86/kvm/x86.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index bc733dbadbdd..744ddc7ad6ad 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3737,7 +3737,7 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
/* Any pending NMI will happen here */

if (unlikely(svm->vmcb->control.exit_code == SVM_EXIT_NMI))
- kvm_after_interrupt(vcpu);
+ kvm_after_interrupt();

sync_cr8_to_lapic(vcpu);

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index a02a28ce7cc3..62b0335d9ae2 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6453,7 +6453,7 @@ static void handle_interrupt_nmi_irqoff(struct kvm_vcpu *vcpu,
{
kvm_before_interrupt(vcpu);
vmx_do_interrupt_nmi_irqoff(entry);
- kvm_after_interrupt(vcpu);
+ kvm_after_interrupt();
}

static void handle_nm_fault_irqoff(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 55518b7d3b96..df46d0737b85 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -10094,7 +10094,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
local_irq_enable();
++vcpu->stat.exits;
local_irq_disable();
- kvm_after_interrupt(vcpu);
+ kvm_after_interrupt();

/*
* Wait until after servicing IRQs to account guest time so that any
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 1ebd5a7594da..651aa7ed5200 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -399,7 +399,7 @@ static inline void kvm_before_interrupt(struct kvm_vcpu *vcpu)
__this_cpu_write(current_vcpu, vcpu);
}

-static inline void kvm_after_interrupt(struct kvm_vcpu *vcpu)
+static inline void kvm_after_interrupt(void)
{
__this_cpu_write(current_vcpu, NULL);
}
--
2.33.1

2022-01-25 14:40:01

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 06/19] KVM: x86/svm: Remove unused "vcpu" of svm_check_exit_valid()

From: Jinrong Liang <[email protected]>

The "struct kvm_vcpu *vcpu" parameter of svm_check_exit_valid()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/svm/svm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 6d31d357a83b..bc733dbadbdd 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3120,7 +3120,7 @@ static void dump_vmcb(struct kvm_vcpu *vcpu)
"excp_to:", save->last_excp_to);
}

-static bool svm_check_exit_valid(struct kvm_vcpu *vcpu, u64 exit_code)
+static bool svm_check_exit_valid(u64 exit_code)
{
return (exit_code < ARRAY_SIZE(svm_exit_handlers) &&
svm_exit_handlers[exit_code]);
@@ -3140,7 +3140,7 @@ static int svm_handle_invalid_exit(struct kvm_vcpu *vcpu, u64 exit_code)

int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code)
{
- if (!svm_check_exit_valid(vcpu, exit_code))
+ if (!svm_check_exit_valid(exit_code))
return svm_handle_invalid_exit(vcpu, exit_code);

#ifdef CONFIG_RETPOLINE
--
2.33.1

2022-01-25 14:40:05

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 10/19] KVM: x86/sev: Remove unused "kvm" of sev_unbind_asid()

From: Jinrong Liang <[email protected]>

The "struct kvm *kvm" parameter of sev_unbind_asid() is not used,
so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/svm/sev.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index eae234afe04e..0727ac7221d7 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -217,7 +217,7 @@ static void sev_decommission(unsigned int handle)
sev_guest_decommission(&decommission, NULL);
}

-static void sev_unbind_asid(struct kvm *kvm, unsigned int handle)
+static void sev_unbind_asid(unsigned int handle)
{
struct sev_data_deactivate deactivate;

@@ -363,7 +363,7 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
/* return handle to userspace */
params.handle = start.handle;
if (copy_to_user((void __user *)(uintptr_t)argp->data, &params, sizeof(params))) {
- sev_unbind_asid(kvm, start.handle);
+ sev_unbind_asid(start.handle);
ret = -EFAULT;
goto e_free_session;
}
@@ -1426,7 +1426,7 @@ static int sev_receive_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
if (copy_to_user((void __user *)(uintptr_t)argp->data,
&params, sizeof(struct kvm_sev_receive_start))) {
ret = -EFAULT;
- sev_unbind_asid(kvm, start.handle);
+ sev_unbind_asid(start.handle);
goto e_free_session;
}

@@ -2078,7 +2078,7 @@ void sev_vm_destroy(struct kvm *kvm)
}
}

- sev_unbind_asid(kvm, sev->handle);
+ sev_unbind_asid(sev->handle);
sev_asid_free(sev);
}

--
2.33.1

2022-01-25 14:40:09

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 11/19] KVM: x86/svm: Remove unused "vector" of sev_vcpu_deliver_sipi_vector()

From: Jinrong Liang <[email protected]>

The "struct kvm_vcpu *vcpu" parameter of sev_vcpu_deliver_sipi_vector()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/svm/sev.c | 2 +-
arch/x86/kvm/svm/svm.c | 2 +-
arch/x86/kvm/svm/svm.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 0727ac7221d7..2fd1e91054b3 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -2925,7 +2925,7 @@ void sev_es_prepare_guest_switch(unsigned int cpu)
hostsa->xss = host_xss;
}

-void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
+void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu)
{
struct vcpu_svm *svm = to_svm(vcpu);

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 3e75ae834412..aead235a90ee 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -4348,7 +4348,7 @@ static void svm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
if (!sev_es_guest(vcpu->kvm))
return kvm_vcpu_deliver_sipi_vector(vcpu, vector);

- sev_vcpu_deliver_sipi_vector(vcpu, vector);
+ sev_vcpu_deliver_sipi_vector(vcpu);
}

static void svm_vm_destroy(struct kvm *kvm)
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index 0a749bbda738..61c96f4a7006 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -621,7 +621,7 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu);
int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in);
void sev_es_init_vmcb(struct vcpu_svm *svm);
void sev_es_vcpu_reset(struct vcpu_svm *svm);
-void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
+void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu);
void sev_es_prepare_guest_switch(unsigned int cpu);
void sev_es_unmap_ghcb(struct vcpu_svm *svm);

--
2.33.1

2022-01-25 14:40:35

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 15/19] KVM: x86/emulate: Remove unused "ctxt" of task_switch_{16, 32}()

From: Jinrong Liang <[email protected]>

The "struct x86_emulate_ctxt *ctxt" parameter of task_switch_{16, 32}()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/emulate.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index c2d9fe6449c2..9e4a00d04532 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3020,8 +3020,7 @@ static int load_state_from_tss16(struct x86_emulate_ctxt *ctxt,
return X86EMUL_CONTINUE;
}

-static int task_switch_16(struct x86_emulate_ctxt *ctxt,
- u16 tss_selector, u16 old_tss_sel,
+static int task_switch_16(struct x86_emulate_ctxt *ctxt, u16 old_tss_sel,
ulong old_tss_base, struct desc_struct *new_desc)
{
struct tss_segment_16 tss_seg;
@@ -3159,8 +3158,7 @@ static int load_state_from_tss32(struct x86_emulate_ctxt *ctxt,
return ret;
}

-static int task_switch_32(struct x86_emulate_ctxt *ctxt,
- u16 tss_selector, u16 old_tss_sel,
+static int task_switch_32(struct x86_emulate_ctxt *ctxt, u16 old_tss_sel,
ulong old_tss_base, struct desc_struct *new_desc)
{
struct tss_segment_32 tss_seg;
@@ -3268,10 +3266,9 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
old_tss_sel = 0xffff;

if (next_tss_desc.type & 8)
- ret = task_switch_32(ctxt, tss_selector, old_tss_sel,
- old_tss_base, &next_tss_desc);
+ ret = task_switch_32(ctxt, old_tss_sel, old_tss_base, &next_tss_desc);
else
- ret = task_switch_16(ctxt, tss_selector, old_tss_sel,
+ ret = task_switch_16(ctxt, old_tss_sel,
old_tss_base, &next_tss_desc);
if (ret != X86EMUL_CONTINUE)
return ret;
--
2.33.1

2022-01-25 14:40:35

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 16/19] KVM: x86: Remove unused "vcpu" of kvm_arch_tsc_has_attr()

From: Jinrong Liang <[email protected]>

The "struct kvm_vcpu *vcpu" parameter of kvm_arch_tsc_has_attr()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/x86.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index df46d0737b85..22b73b918884 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5003,8 +5003,7 @@ static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
return 0;
}

-static int kvm_arch_tsc_has_attr(struct kvm_vcpu *vcpu,
- struct kvm_device_attr *attr)
+static int kvm_arch_tsc_has_attr(struct kvm_device_attr *attr)
{
int r;

@@ -5099,7 +5098,7 @@ static int kvm_vcpu_ioctl_device_attr(struct kvm_vcpu *vcpu,

switch (ioctl) {
case KVM_HAS_DEVICE_ATTR:
- r = kvm_arch_tsc_has_attr(vcpu, &attr);
+ r = kvm_arch_tsc_has_attr(&attr);
break;
case KVM_GET_DEVICE_ATTR:
r = kvm_arch_tsc_get_attr(vcpu, &attr);
--
2.33.1

2022-01-25 14:40:36

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 13/19] KVM: x86/ioapic: Remove unused "addr" and "length" of ioapic_read_indirect()

From: Jinrong Liang <[email protected]>

The "unsigned long addr" and "unsigned long length" parameter of
ioapic_read_indirect() is not used, so remove it.

No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/ioapic.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index decfa36b7891..765943d7cfa5 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -54,9 +54,7 @@ static void kvm_ioapic_update_eoi_one(struct kvm_vcpu *vcpu,
int trigger_mode,
int pin);

-static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
- unsigned long addr,
- unsigned long length)
+static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic)
{
unsigned long result = 0;

@@ -593,7 +591,7 @@ static int ioapic_mmio_read(struct kvm_vcpu *vcpu, struct kvm_io_device *this,
break;

case IOAPIC_REG_WINDOW:
- result = ioapic_read_indirect(ioapic, addr, len);
+ result = ioapic_read_indirect(ioapic);
break;

default:
--
2.33.1

2022-01-25 14:40:41

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 14/19] KVM: x86/emulate: Remove unused "ctxt" of setup_syscalls_segments()

From: Jinrong Liang <[email protected]>

The "struct x86_emulate_ctxt *ctxt" parameter of setup_syscalls_segments()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/emulate.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 166a145fc1e6..c2d9fe6449c2 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2608,8 +2608,7 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
}

static void
-setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
- struct desc_struct *cs, struct desc_struct *ss)
+setup_syscalls_segments(struct desc_struct *cs, struct desc_struct *ss)
{
cs->l = 0; /* will be adjusted later */
set_desc_base(cs, 0); /* flat segment */
@@ -2698,7 +2697,7 @@ static int em_syscall(struct x86_emulate_ctxt *ctxt)
if (!(efer & EFER_SCE))
return emulate_ud(ctxt);

- setup_syscalls_segments(ctxt, &cs, &ss);
+ setup_syscalls_segments(&cs, &ss);
ops->get_msr(ctxt, MSR_STAR, &msr_data);
msr_data >>= 32;
cs_sel = (u16)(msr_data & 0xfffc);
@@ -2766,7 +2765,7 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
if ((msr_data & 0xfffc) == 0x0)
return emulate_gp(ctxt, 0);

- setup_syscalls_segments(ctxt, &cs, &ss);
+ setup_syscalls_segments(&cs, &ss);
ctxt->eflags &= ~(X86_EFLAGS_VM | X86_EFLAGS_IF);
cs_sel = (u16)msr_data & ~SEGMENT_RPL_MASK;
ss_sel = cs_sel + 8;
@@ -2803,7 +2802,7 @@ static int em_sysexit(struct x86_emulate_ctxt *ctxt)
ctxt->mode == X86EMUL_MODE_VM86)
return emulate_gp(ctxt, 0);

- setup_syscalls_segments(ctxt, &cs, &ss);
+ setup_syscalls_segments(&cs, &ss);

if ((ctxt->rex_prefix & 0x8) != 0x0)
usermode = X86EMUL_MODE_PROT64;
--
2.33.1

2022-01-25 14:40:55

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 17/19] KVM: x86: Remove unused "vcpu" of kvm_scale_tsc()

From: Jinrong Liang <[email protected]>

The "struct kvm_vcpu *vcpu" parameter of kvm_scale_tsc() is not used,
so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/include/asm/kvm_host.h | 2 +-
arch/x86/kvm/x86.c | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 682ad02a4e58..ebd5a1e8db77 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1871,7 +1871,7 @@ static inline bool kvm_is_supported_user_return_msr(u32 msr)
return kvm_find_user_return_msr(msr) >= 0;
}

-u64 kvm_scale_tsc(struct kvm_vcpu *vcpu, u64 tsc, u64 ratio);
+u64 kvm_scale_tsc(u64 tsc, u64 ratio);
u64 kvm_read_l1_tsc(struct kvm_vcpu *vcpu, u64 host_tsc);
u64 kvm_calc_nested_tsc_offset(u64 l1_offset, u64 l2_offset, u64 l2_multiplier);
u64 kvm_calc_nested_tsc_multiplier(u64 l1_multiplier, u64 l2_multiplier);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 22b73b918884..4e438e009ba9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2397,7 +2397,7 @@ static inline u64 __scale_tsc(u64 ratio, u64 tsc)
return mul_u64_u64_shr(tsc, ratio, kvm_tsc_scaling_ratio_frac_bits);
}

-u64 kvm_scale_tsc(struct kvm_vcpu *vcpu, u64 tsc, u64 ratio)
+u64 kvm_scale_tsc(u64 tsc, u64 ratio)
{
u64 _tsc = tsc;

@@ -2412,7 +2412,7 @@ static u64 kvm_compute_l1_tsc_offset(struct kvm_vcpu *vcpu, u64 target_tsc)
{
u64 tsc;

- tsc = kvm_scale_tsc(vcpu, rdtsc(), vcpu->arch.l1_tsc_scaling_ratio);
+ tsc = kvm_scale_tsc(rdtsc(), vcpu->arch.l1_tsc_scaling_ratio);

return target_tsc - tsc;
}
@@ -2420,7 +2420,7 @@ static u64 kvm_compute_l1_tsc_offset(struct kvm_vcpu *vcpu, u64 target_tsc)
u64 kvm_read_l1_tsc(struct kvm_vcpu *vcpu, u64 host_tsc)
{
return vcpu->arch.l1_tsc_offset +
- kvm_scale_tsc(vcpu, host_tsc, vcpu->arch.l1_tsc_scaling_ratio);
+ kvm_scale_tsc(host_tsc, vcpu->arch.l1_tsc_scaling_ratio);
}
EXPORT_SYMBOL_GPL(kvm_read_l1_tsc);

@@ -2623,7 +2623,7 @@ static inline void adjust_tsc_offset_host(struct kvm_vcpu *vcpu, s64 adjustment)
{
if (vcpu->arch.l1_tsc_scaling_ratio != kvm_default_tsc_scaling_ratio)
WARN_ON(adjustment < 0);
- adjustment = kvm_scale_tsc(vcpu, (u64) adjustment,
+ adjustment = kvm_scale_tsc((u64) adjustment,
vcpu->arch.l1_tsc_scaling_ratio);
adjust_tsc_offset_guest(vcpu, adjustment);
}
@@ -3043,7 +3043,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
/* With all the info we got, fill in the values */

if (kvm_has_tsc_control)
- tgt_tsc_khz = kvm_scale_tsc(v, tgt_tsc_khz,
+ tgt_tsc_khz = kvm_scale_tsc(tgt_tsc_khz,
v->arch.l1_tsc_scaling_ratio);

if (unlikely(vcpu->hw_tsc_khz != tgt_tsc_khz)) {
@@ -3854,7 +3854,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
ratio = vcpu->arch.tsc_scaling_ratio;
}

- msr_info->data = kvm_scale_tsc(vcpu, rdtsc(), ratio) + offset;
+ msr_info->data = kvm_scale_tsc(rdtsc(), ratio) + offset;
break;
}
case MSR_MTRRcap:
@@ -5067,7 +5067,7 @@ static int kvm_arch_tsc_set_attr(struct kvm_vcpu *vcpu,
kvm->arch.last_tsc_khz == vcpu->arch.virtual_tsc_khz &&
kvm->arch.last_tsc_offset == offset);

- tsc = kvm_scale_tsc(vcpu, rdtsc(), vcpu->arch.l1_tsc_scaling_ratio) + offset;
+ tsc = kvm_scale_tsc(rdtsc(), vcpu->arch.l1_tsc_scaling_ratio) + offset;
ns = get_kvmclock_base_ns();

__kvm_synchronize_tsc(vcpu, offset, tsc, ns, matched);
--
2.33.1

2022-01-25 14:41:29

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 18/19] KVM: Remove unused "kvm" of kvm_make_vcpu_request()

From: Jinrong Liang <[email protected]>

The "struct kvm *kvm" parameter of kvm_make_vcpu_request() is not used,
so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
virt/kvm/kvm_main.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5a1164483e6c..1c98a47c8908 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -246,9 +246,8 @@ static inline bool kvm_kick_many_cpus(struct cpumask *cpus, bool wait)
return true;
}

-static void kvm_make_vcpu_request(struct kvm *kvm, struct kvm_vcpu *vcpu,
- unsigned int req, struct cpumask *tmp,
- int current_cpu)
+static void kvm_make_vcpu_request(struct kvm_vcpu *vcpu, unsigned int req,
+ struct cpumask *tmp, int current_cpu)
{
int cpu;

@@ -291,7 +290,7 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
vcpu = kvm_get_vcpu(kvm, i);
if (!vcpu)
continue;
- kvm_make_vcpu_request(kvm, vcpu, req, cpus, me);
+ kvm_make_vcpu_request(vcpu, req, cpus, me);
}

called = kvm_kick_many_cpus(cpus, !!(req & KVM_REQUEST_WAIT));
@@ -317,7 +316,7 @@ bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
kvm_for_each_vcpu(i, vcpu, kvm) {
if (vcpu == except)
continue;
- kvm_make_vcpu_request(kvm, vcpu, req, cpus, me);
+ kvm_make_vcpu_request(vcpu, req, cpus, me);
}

called = kvm_kick_many_cpus(cpus, !!(req & KVM_REQUEST_WAIT));
--
2.33.1

2022-01-25 14:41:49

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 12/19] KVM: x86/i8259: Remove unused "addr" of elcr_ioport_{read,write}()

From: Jinrong Liang <[email protected]>

The "u32 addr" parameter of elcr_ioport_write() and elcr_ioport_read()
is not used, so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/i8259.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 814064d06016..be99dc86293d 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -437,13 +437,13 @@ static u32 pic_ioport_read(void *opaque, u32 addr)
return ret;
}

-static void elcr_ioport_write(void *opaque, u32 addr, u32 val)
+static void elcr_ioport_write(void *opaque, u32 val)
{
struct kvm_kpic_state *s = opaque;
s->elcr = val & s->elcr_mask;
}

-static u32 elcr_ioport_read(void *opaque, u32 addr1)
+static u32 elcr_ioport_read(void *opaque)
{
struct kvm_kpic_state *s = opaque;
return s->elcr;
@@ -474,7 +474,7 @@ static int picdev_write(struct kvm_pic *s,
case 0x4d0:
case 0x4d1:
pic_lock(s);
- elcr_ioport_write(&s->pics[addr & 1], addr, data);
+ elcr_ioport_write(&s->pics[addr & 1], data);
pic_unlock(s);
break;
default:
@@ -505,7 +505,7 @@ static int picdev_read(struct kvm_pic *s,
case 0x4d0:
case 0x4d1:
pic_lock(s);
- *data = elcr_ioport_read(&s->pics[addr & 1], addr);
+ *data = elcr_ioport_read(&s->pics[addr & 1]);
pic_unlock(s);
break;
default:
--
2.33.1

2022-01-25 14:44:31

by Jinrong Liang

[permalink] [raw]
Subject: [PATCH 19/19] KVM: Remove unused "flags" of kvm_pv_kick_cpu_op()

From: Jinrong Liang <[email protected]>

The "unsigned long flags" parameter of kvm_pv_kick_cpu_op() is not used,
so remove it. No functional change intended.

Signed-off-by: Jinrong Liang <[email protected]>
---
arch/x86/kvm/x86.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4e438e009ba9..acd34adc097f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8940,7 +8940,7 @@ static int kvm_pv_clock_pairing(struct kvm_vcpu *vcpu, gpa_t paddr,
*
* @apicid - apicid of vcpu to be kicked.
*/
-static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid)
+static void kvm_pv_kick_cpu_op(struct kvm *kvm, int apicid)
{
struct kvm_lapic_irq lapic_irq;

@@ -9059,7 +9059,7 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
if (!guest_pv_has(vcpu, KVM_FEATURE_PV_UNHALT))
break;

- kvm_pv_kick_cpu_op(vcpu->kvm, a0, a1);
+ kvm_pv_kick_cpu_op(vcpu->kvm, a1);
kvm_sched_yield(vcpu, a1);
ret = 0;
break;
--
2.33.1

2022-01-25 22:55:56

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 07/19] KVM: x86/svm: Remove unused "vcpu" of nested_svm_check_tlb_ctl()

On 1/25/22 10:58, Jinrong Liang wrote:
> From: Jinrong Liang <[email protected]>
>
> The "struct kvm_vcpu *vcpu" parameter of nested_svm_check_tlb_ctl()
> is not used, so remove it. No functional change intended.
>
> Signed-off-by: Jinrong Liang <[email protected]>

This might be useful later if the code needs to check guest CPUID bits.
Leaving it in for now.

Paolo

> ---
> arch/x86/kvm/svm/nested.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> index cf206855ebf0..5a1a2678a2b1 100644
> --- a/arch/x86/kvm/svm/nested.c
> +++ b/arch/x86/kvm/svm/nested.c
> @@ -209,7 +209,7 @@ static bool nested_svm_check_bitmap_pa(struct kvm_vcpu *vcpu, u64 pa, u32 size)
> kvm_vcpu_is_legal_gpa(vcpu, addr + size - 1);
> }
>
> -static bool nested_svm_check_tlb_ctl(struct kvm_vcpu *vcpu, u8 tlb_ctl)
> +static bool nested_svm_check_tlb_ctl(u8 tlb_ctl)
> {
> /* Nested FLUSHBYASID is not supported yet. */
> switch(tlb_ctl) {
> @@ -240,7 +240,7 @@ static bool __nested_vmcb_check_controls(struct kvm_vcpu *vcpu,
> IOPM_SIZE)))
> return false;
>
> - if (CC(!nested_svm_check_tlb_ctl(vcpu, control->tlb_ctl)))
> + if (CC(!nested_svm_check_tlb_ctl(control->tlb_ctl)))
> return false;
>
> return true;

2022-01-25 23:02:08

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 11/19] KVM: x86/svm: Remove unused "vector" of sev_vcpu_deliver_sipi_vector()

On 1/25/22 10:59, Jinrong Liang wrote:
> From: Jinrong Liang <[email protected]>
>
> The "struct kvm_vcpu *vcpu" parameter of sev_vcpu_deliver_sipi_vector()
> is not used, so remove it. No functional change intended.
>
> Signed-off-by: Jinrong Liang <[email protected]>
> ---
> arch/x86/kvm/svm/sev.c | 2 +-
> arch/x86/kvm/svm/svm.c | 2 +-
> arch/x86/kvm/svm/svm.h | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 0727ac7221d7..2fd1e91054b3 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -2925,7 +2925,7 @@ void sev_es_prepare_guest_switch(unsigned int cpu)
> hostsa->xss = host_xss;
> }
>
> -void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
> +void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 3e75ae834412..aead235a90ee 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -4348,7 +4348,7 @@ static void svm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
> if (!sev_es_guest(vcpu->kvm))
> return kvm_vcpu_deliver_sipi_vector(vcpu, vector);
>
> - sev_vcpu_deliver_sipi_vector(vcpu, vector);
> + sev_vcpu_deliver_sipi_vector(vcpu);
> }
>
> static void svm_vm_destroy(struct kvm *kvm)
> diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
> index 0a749bbda738..61c96f4a7006 100644
> --- a/arch/x86/kvm/svm/svm.h
> +++ b/arch/x86/kvm/svm/svm.h
> @@ -621,7 +621,7 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu);
> int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in);
> void sev_es_init_vmcb(struct vcpu_svm *svm);
> void sev_es_vcpu_reset(struct vcpu_svm *svm);
> -void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
> +void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu);
> void sev_es_prepare_guest_switch(unsigned int cpu);
> void sev_es_unmap_ghcb(struct vcpu_svm *svm);
>

For this one and patch 10, even if the argument is not used, the code
seems more natural if it is there. It is more of an implementation
detail that it is not used.

Paolo

2022-01-25 23:05:30

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 09/19] KVM: x86/svm: Remove unused "svm" of sev_es_prepare_guest_switch()

On 1/25/22 10:58, Jinrong Liang wrote:
> From: Jinrong Liang <[email protected]>
>
> The "struct vcpu_svm *svm" parameter of sev_es_prepare_guest_switch()
> is not used, so remove it. No functional change intended.
>
> Signed-off-by: Jinrong Liang <[email protected]>
> ---
> arch/x86/kvm/svm/sev.c | 2 +-
> arch/x86/kvm/svm/svm.c | 2 +-
> arch/x86/kvm/svm/svm.h | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 6a22798eaaee..eae234afe04e 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -2902,7 +2902,7 @@ void sev_es_vcpu_reset(struct vcpu_svm *svm)
> sev_enc_bit));
> }
>
> -void sev_es_prepare_guest_switch(struct vcpu_svm *svm, unsigned int cpu)
> +void sev_es_prepare_guest_switch(unsigned int cpu)
> {
> struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
> struct vmcb_save_area *hostsa;
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 744ddc7ad6ad..3e75ae834412 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -1276,7 +1276,7 @@ static void svm_prepare_guest_switch(struct kvm_vcpu *vcpu)
> * or subsequent vmload of host save area.
> */
> if (sev_es_guest(vcpu->kvm)) {
> - sev_es_prepare_guest_switch(svm, vcpu->cpu);
> + sev_es_prepare_guest_switch(vcpu->cpu);
> } else {
> vmsave(__sme_page_pa(sd->save_area));
> }
> diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
> index 47ef8f4a9358..0a749bbda738 100644
> --- a/arch/x86/kvm/svm/svm.h
> +++ b/arch/x86/kvm/svm/svm.h
> @@ -622,7 +622,7 @@ int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in);
> void sev_es_init_vmcb(struct vcpu_svm *svm);
> void sev_es_vcpu_reset(struct vcpu_svm *svm);
> void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
> -void sev_es_prepare_guest_switch(struct vcpu_svm *svm, unsigned int cpu);
> +void sev_es_prepare_guest_switch(unsigned int cpu);
> void sev_es_unmap_ghcb(struct vcpu_svm *svm);
>
> /* vmenter.S */

This should instead receive a struct vmcb_save_area *, since the vmsave
part is common between sev_es_prepare_guest_switch and the "else" branch
in svm_prepare_guest_switch. I'll send a patch - thanks for the report.

Paolo

2022-01-25 23:09:56

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 15/19] KVM: x86/emulate: Remove unused "ctxt" of task_switch_{16, 32}()

On 1/25/22 10:59, Jinrong Liang wrote:
> From: Jinrong Liang <[email protected]>
>
> The "struct x86_emulate_ctxt *ctxt" parameter of task_switch_{16, 32}()
> is not used, so remove it. No functional change intended.

This is actually removing tss_selector, but it's okay.

Paolo

> Signed-off-by: Jinrong Liang <[email protected]>
> ---
> arch/x86/kvm/emulate.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index c2d9fe6449c2..9e4a00d04532 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -3020,8 +3020,7 @@ static int load_state_from_tss16(struct x86_emulate_ctxt *ctxt,
> return X86EMUL_CONTINUE;
> }
>
> -static int task_switch_16(struct x86_emulate_ctxt *ctxt,
> - u16 tss_selector, u16 old_tss_sel,
> +static int task_switch_16(struct x86_emulate_ctxt *ctxt, u16 old_tss_sel,
> ulong old_tss_base, struct desc_struct *new_desc)
> {
> struct tss_segment_16 tss_seg;
> @@ -3159,8 +3158,7 @@ static int load_state_from_tss32(struct x86_emulate_ctxt *ctxt,
> return ret;
> }
>
> -static int task_switch_32(struct x86_emulate_ctxt *ctxt,
> - u16 tss_selector, u16 old_tss_sel,
> +static int task_switch_32(struct x86_emulate_ctxt *ctxt, u16 old_tss_sel,
> ulong old_tss_base, struct desc_struct *new_desc)
> {
> struct tss_segment_32 tss_seg;
> @@ -3268,10 +3266,9 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
> old_tss_sel = 0xffff;
>
> if (next_tss_desc.type & 8)
> - ret = task_switch_32(ctxt, tss_selector, old_tss_sel,
> - old_tss_base, &next_tss_desc);
> + ret = task_switch_32(ctxt, old_tss_sel, old_tss_base, &next_tss_desc);
> else
> - ret = task_switch_16(ctxt, tss_selector, old_tss_sel,
> + ret = task_switch_16(ctxt, old_tss_sel,
> old_tss_base, &next_tss_desc);
> if (ret != X86EMUL_CONTINUE)
> return ret;

2022-01-25 23:12:41

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 16/19] KVM: x86: Remove unused "vcpu" of kvm_arch_tsc_has_attr()

On 1/25/22 10:59, Jinrong Liang wrote:
> From: Jinrong Liang <[email protected]>
>
> The "struct kvm_vcpu *vcpu" parameter of kvm_arch_tsc_has_attr()
> is not used, so remove it. No functional change intended.
>
> Signed-off-by: Jinrong Liang <[email protected]>
> ---
> arch/x86/kvm/x86.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index df46d0737b85..22b73b918884 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5003,8 +5003,7 @@ static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
> return 0;
> }
>
> -static int kvm_arch_tsc_has_attr(struct kvm_vcpu *vcpu,
> - struct kvm_device_attr *attr)
> +static int kvm_arch_tsc_has_attr(struct kvm_device_attr *attr)
> {
> int r;
>
> @@ -5099,7 +5098,7 @@ static int kvm_vcpu_ioctl_device_attr(struct kvm_vcpu *vcpu,
>
> switch (ioctl) {
> case KVM_HAS_DEVICE_ATTR:
> - r = kvm_arch_tsc_has_attr(vcpu, &attr);
> + r = kvm_arch_tsc_has_attr(&attr);
> break;
> case KVM_GET_DEVICE_ATTR:
> r = kvm_arch_tsc_get_attr(vcpu, &attr);

I can't make my mind on this. I think it's better to have the argument
in case some attributes depend on VM capabilities in the future.

Paolo

2022-01-26 01:18:00

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 00/19] KVM: x86: Bulk removal of unused function parameters

On 1/25/22 10:58, Jinrong Liang wrote:
> From: Like Xu <[email protected]>
>
> Hi,
>
> This patch set is a follow up to a similar patch [1], and may
> hopefully help to improve the code quality of KVM.
>
> Basically, the cleanup is triggered by a compiler feature[2], but obviously
> there are a lot of false positives here, and so far we may apply at least
> this changset, which also helps the related developers to think more
> carefully about why these functions were declared that way in the first
> place or what is left after a series of loosely-coupled clean-ups.
>
> [1] https://lore.kernel.org/kvm/[email protected]/
> [2] ccflags-y += -Wunused-parameter
>
> Thanks,
> Like Xu
>
> Jinrong Liang (19):
> KVM: x86/mmu: Remove unused "kvm" of kvm_mmu_unlink_parents()
> KVM: x86/mmu: Remove unused "kvm" of __rmap_write_protect()
> KVM: x86/mmu: Remove unused "vcpu" of
> reset_{tdp,ept}_shadow_zero_bits_mask()
> KVM: x86/tdp_mmu: Remove unused "kvm" of kvm_tdp_mmu_get_root()
> KVM: x86/mmu_audit: Remove unused "level" of audit_spte_after_sync()
> KVM: x86/svm: Remove unused "vcpu" of svm_check_exit_valid()
> KVM: x86/svm: Remove unused "vcpu" of nested_svm_check_tlb_ctl()
> KVM: x86/svm: Remove unused "vcpu" of kvm_after_interrupt()
> KVM: x86/sev: Remove unused "svm" of sev_es_prepare_guest_switch()
> KVM: x86/sev: Remove unused "kvm" of sev_unbind_asid()
> KVM: x86/sev: Remove unused "vector" of sev_vcpu_deliver_sipi_vector()
> KVM: x86/i8259: Remove unused "addr" of elcr_ioport_{read,write}()
> KVM: x86/ioapic: Remove unused "addr" and "length" of
> ioapic_read_indirect()
> KVM: x86/emulate: Remove unused "ctxt" of setup_syscalls_segments()
> KVM: x86/emulate: Remove unused "ctxt" of task_switch_{16, 32}()
> KVM: x86: Remove unused "vcpu" of kvm_arch_tsc_has_attr()
> KVM: x86: Remove unused "vcpu" of kvm_scale_tsc()
> KVM: Remove unused "kvm" of kvm_make_vcpu_request()
> KVM: Remove unused "flags" of kvm_pv_kick_cpu_op()
>
> arch/x86/include/asm/kvm_host.h | 2 +-
> arch/x86/kvm/emulate.c | 20 ++++++++------------
> arch/x86/kvm/i8259.c | 8 ++++----
> arch/x86/kvm/ioapic.c | 6 ++----
> arch/x86/kvm/mmu/mmu.c | 23 ++++++++++-------------
> arch/x86/kvm/mmu/mmu_audit.c | 4 ++--
> arch/x86/kvm/mmu/tdp_mmu.c | 4 ++--
> arch/x86/kvm/mmu/tdp_mmu.h | 3 +--
> arch/x86/kvm/svm/nested.c | 4 ++--
> arch/x86/kvm/svm/sev.c | 12 ++++++------
> arch/x86/kvm/svm/svm.c | 10 +++++-----
> arch/x86/kvm/svm/svm.h | 4 ++--
> arch/x86/kvm/vmx/vmx.c | 2 +-
> arch/x86/kvm/x86.c | 25 ++++++++++++-------------
> arch/x86/kvm/x86.h | 2 +-
> virt/kvm/kvm_main.c | 9 ++++-----
> 16 files changed, 63 insertions(+), 75 deletions(-)
>

Queued the patches I didn't comment on, thanks.

Paolo