Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3477310ybz; Mon, 20 Apr 2020 03:36:23 -0700 (PDT) X-Google-Smtp-Source: APiQypJ3j9pGQR6YTEV4im+FFKaLO47pSFWUDJD9PFPHUpu6Uk3EBNKD0bAZxWygWLqSnvBRCGuD X-Received: by 2002:a17:906:855a:: with SMTP id h26mr15864731ejy.56.1587378983236; Mon, 20 Apr 2020 03:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587378983; cv=none; d=google.com; s=arc-20160816; b=TAqGCLFYuEx2TTiTQ43VD7m+vTO0I70rzlFHkQo5BGl/7zUXARYOUW+VTu6p2o6nhd Lb4EeB+LrC+ZwsgiFdgRCcFpxuNqu+Nd3rbCJCI8CvNg5UzUPmWa0G37sFuNeDqgTIrO MMPfHKrFfTRIp1pt2s7LG/FkRxKMa0aIM1aCP8Rf7yiUTlYS+fLC7QVsRX4vWFzmZX3x l3nZEiy/0SFCYMZKyvUQ5WJC8IgncuBvoQfN/OICKu6krCq0dWY3MlM1whTD+rs/oj9T bLJN1DdBtAA8aN9vfaJ7EgV+srIoYfd0YWKG6PJK1Xdamm/+yRij6tGluyaZGSJtn58k HyOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=RbHCi7DRJeoJJqRss0OZKMWbE/SXUV0V2yWsDMkazL4=; b=iiB8DSJsI8Qjf8ucBLsOzlQiEDbaiK7Qvm5EdPqfrhKK1xrb28qGY52kLwMlgHoMMz nFK9QYzklbZ2tcUZup9UOcsuKO8COpTyQRLslQIc6vRqqndURIUkw/FNc7xQKzs8x1Bv KNhD6z23lMQsLB+nJwxv2XHEroIXLPKPK4GQdBWW+3Ukmp6GEZvIJT4oK6quzLnqaUdS Ap41BJiNkc7Wp7vQDOxuukFeiARTqrn8Rlk0m3uSruV2N3RT4jPgyojnJh4aqIw1/EK2 VnqGYNojXdbLCTmHNcmpfBtRiapk0pbd790Km4td2faJMTpzIfstHbd27kHgo0/ssAwj mlnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf11si286258edb.297.2020.04.20.03.35.58; Mon, 20 Apr 2020 03:36:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726089AbgDTKfA (ORCPT + 99 others); Mon, 20 Apr 2020 06:35:00 -0400 Received: from mail.loongson.cn ([114.242.206.163]:35492 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725773AbgDTKfA (ORCPT ); Mon, 20 Apr 2020 06:35:00 -0400 Received: from [10.20.42.25] (unknown [10.20.42.25]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxj9xHep1eHB0qAA--.15S3; Mon, 20 Apr 2020 18:32:40 +0800 (CST) Subject: Re: [PATCH 7/7] KVM: MIPS: clean up redundant kvm_run parameters in assembly To: Tianjia Zhang , pbonzini@redhat.com, tsbogend@alpha.franken.de, paulus@ozlabs.org, mpe@ellerman.id.au, benh@kernel.crashing.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, heiko.carstens@de.ibm.com, gor@linux.ibm.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, christoffer.dall@arm.com, peterx@redhat.com, thuth@redhat.com References: <20200419075106.16248-1-tianjia.zhang@linux.alibaba.com> <20200419075106.16248-8-tianjia.zhang@linux.alibaba.com> Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org From: maobibo Message-ID: <0b110e7f-9d08-496e-158e-8c3ff7307423@loongson.cn> Date: Mon, 20 Apr 2020 18:32:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20200419075106.16248-8-tianjia.zhang@linux.alibaba.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf9Dxj9xHep1eHB0qAA--.15S3 X-Coremail-Antispam: 1UD129KBjvJXoW3WrWrJr1kWw4ruF1kArW7twb_yoW7CFWUpF n7C3WDua1IqrWUK34xArsY9F4aqrs8Kr17ua4UJFWYqw1YqF1rtFs2krZ8Ar98Cr1F93Wf ZF9YqFn8Crs2ywUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9jb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xv F2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r 4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwACI402YVCY1x02628vn2kIc2xK xwCYjI0SjxkI62AI1cAE67vIY487MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r 1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CE b7AF67AKxVWrXVW8Jr1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1l IxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvf C2KfnxnUUI43ZEXa7IU56KZtUUUUU== X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/19/2020 03:51 PM, Tianjia Zhang wrote: > In the current kvm version, 'kvm_run' has been included in the 'kvm_vcpu' > structure. Earlier than historical reasons, many kvm-related function > parameters retain the 'kvm_run' and 'kvm_vcpu' parameters at the same time. > This patch does a unified cleanup of these remaining redundant parameters. > > Signed-off-by: Tianjia Zhang > --- > arch/mips/include/asm/kvm_host.h | 4 ++-- > arch/mips/kvm/entry.c | 15 +++++---------- > arch/mips/kvm/mips.c | 3 ++- > arch/mips/kvm/trap_emul.c | 2 +- > arch/mips/kvm/vz.c | 2 +- > 5 files changed, 11 insertions(+), 15 deletions(-) > > diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h > index 971439297cea..db915c55166d 100644 > --- a/arch/mips/include/asm/kvm_host.h > +++ b/arch/mips/include/asm/kvm_host.h > @@ -310,7 +310,7 @@ struct kvm_mmu_memory_cache { > #define KVM_MIPS_GUEST_TLB_SIZE 64 > struct kvm_vcpu_arch { > void *guest_ebase; > - int (*vcpu_run)(struct kvm_run *run, struct kvm_vcpu *vcpu); > + int (*vcpu_run)(struct kvm_vcpu *vcpu); > > /* Host registers preserved across guest mode execution */ > unsigned long host_stack; > @@ -821,7 +821,7 @@ int kvm_mips_emulation_init(struct kvm_mips_callbacks **install_callbacks); > /* Debug: dump vcpu state */ > int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu); > > -extern int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu); > +extern int kvm_mips_handle_exit(struct kvm_vcpu *vcpu); > > /* Building of entry/exception code */ > int kvm_mips_entry_setup(void); > diff --git a/arch/mips/kvm/entry.c b/arch/mips/kvm/entry.c > index 16e1c93b484f..e3f29af3b6cd 100644 > --- a/arch/mips/kvm/entry.c > +++ b/arch/mips/kvm/entry.c > @@ -204,7 +204,7 @@ static inline void build_set_exc_base(u32 **p, unsigned int reg) > * Assemble the start of the vcpu_run function to run a guest VCPU. The function > * conforms to the following prototype: > * > - * int vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu); > + * int vcpu_run(struct kvm_vcpu *vcpu); > * > * The exit from the guest and return to the caller is handled by the code > * generated by kvm_mips_build_ret_to_host(). > @@ -217,8 +217,7 @@ void *kvm_mips_build_vcpu_run(void *addr) > unsigned int i; > > /* > - * A0: run > - * A1: vcpu > + * A0: vcpu > */ > > /* k0/k1 not being used in host kernel context */ > @@ -237,10 +236,10 @@ void *kvm_mips_build_vcpu_run(void *addr) > kvm_mips_build_save_scratch(&p, V1, K1); > > /* VCPU scratch register has pointer to vcpu */ > - UASM_i_MTC0(&p, A1, scratch_vcpu[0], scratch_vcpu[1]); > + UASM_i_MTC0(&p, A0, scratch_vcpu[0], scratch_vcpu[1]); > > /* Offset into vcpu->arch */ > - UASM_i_ADDIU(&p, K1, A1, offsetof(struct kvm_vcpu, arch)); > + UASM_i_ADDIU(&p, K1, A0, offsetof(struct kvm_vcpu, arch)); > > /* > * Save the host stack to VCPU, used for exception processing > @@ -628,10 +627,7 @@ void *kvm_mips_build_exit(void *addr) > /* Now that context has been saved, we can use other registers */ > > /* Restore vcpu */ > - UASM_i_MFC0(&p, S1, scratch_vcpu[0], scratch_vcpu[1]); > - > - /* Restore run (vcpu->run) */ > - UASM_i_LW(&p, S0, offsetof(struct kvm_vcpu, run), S1); > + UASM_i_MFC0(&p, S0, scratch_vcpu[0], scratch_vcpu[1]); > > /* > * Save Host level EPC, BadVaddr and Cause to VCPU, useful to process > @@ -793,7 +789,6 @@ void *kvm_mips_build_exit(void *addr) > * with this in the kernel > */ > uasm_i_move(&p, A0, S0); > - uasm_i_move(&p, A1, S1); > UASM_i_LA(&p, T9, (unsigned long)kvm_mips_handle_exit); > uasm_i_jalr(&p, RA, T9); > UASM_i_ADDIU(&p, SP, SP, -CALLFRAME_SIZ); I suggest keeping asm code untouched, the change for c code is much easier to understand, however I do not see obvious advantage to remove one redundant function parameter :) regards bibo,mao > diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c > index 9710477a9827..32850470c037 100644 > --- a/arch/mips/kvm/mips.c > +++ b/arch/mips/kvm/mips.c > @@ -1186,8 +1186,9 @@ static void kvm_mips_set_c0_status(void) > /* > * Return value is in the form (errcode<<2 | RESUME_FLAG_HOST | RESUME_FLAG_NV) > */ > -int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu) > +int kvm_mips_handle_exit(struct kvm_vcpu *vcpu) > { > + struct kvm_run *run = vcpu->run; > u32 cause = vcpu->arch.host_cp0_cause; > u32 exccode = (cause >> CAUSEB_EXCCODE) & 0x1f; > u32 __user *opc = (u32 __user *) vcpu->arch.pc; > diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c > index d822f3aee3dc..04c864cc356a 100644 > --- a/arch/mips/kvm/trap_emul.c > +++ b/arch/mips/kvm/trap_emul.c > @@ -1238,7 +1238,7 @@ static int kvm_trap_emul_vcpu_run(struct kvm_vcpu *vcpu) > */ > kvm_mips_suspend_mm(cpu); > > - r = vcpu->arch.vcpu_run(vcpu->run, vcpu); > + r = vcpu->arch.vcpu_run(vcpu); > > /* We may have migrated while handling guest exits */ > cpu = smp_processor_id(); > diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c > index 94f1d23828e3..c5878fa0636d 100644 > --- a/arch/mips/kvm/vz.c > +++ b/arch/mips/kvm/vz.c > @@ -3152,7 +3152,7 @@ static int kvm_vz_vcpu_run(struct kvm_vcpu *vcpu) > kvm_vz_vcpu_load_tlb(vcpu, cpu); > kvm_vz_vcpu_load_wired(vcpu); > > - r = vcpu->arch.vcpu_run(vcpu->run, vcpu); > + r = vcpu->arch.vcpu_run(vcpu); > > kvm_vz_vcpu_save_wired(vcpu); > >