From: zhaotianrui <zhaotianrui@loongson.cn>
To: WANG Xuerui <kernel@xen0n.name>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Huacai Chen <chenhuacai@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
loongarch@lists.linux.dev, Jens Axboe <axboe@kernel.dk>,
Mark Brown <broonie@kernel.org>,
Alex Deucher <alexander.deucher@amd.com>,
Oliver Upton <oliver.upton@linux.dev>,
maobibo@loongson.cn, Xi Ruoyao <xry111@xry111.site>
Subject: Re: [PATCH v1 2/2] LoongArch: KVM: Add lasx support
Date: Tue, 21 Nov 2023 18:02:06 +0800 [thread overview]
Message-ID: <6d9395b5-e8f1-3990-adb0-a52d03411fc6@loongson.cn> (raw)
In-Reply-To: <f003f38d-37fd-43ed-ada6-fb2d5b282e91@xen0n.name>
在 2023/11/16 下午3:19, WANG Xuerui 写道:
> On 11/15/23 17:19, Tianrui Zhao wrote:
>> This patch adds LASX support for LoongArch KVM. The LASX means
>> LoongArch 256-bits vector instruction.
>> There will be LASX exception in KVM when guest use the LASX
>> instruction. KVM will enable LASX and restore the vector
>> registers for guest then return to guest to continue running.
>>
>> Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
>> ---
>> arch/loongarch/include/asm/kvm_host.h | 6 ++++
>> arch/loongarch/include/asm/kvm_vcpu.h | 10 +++++++
>> arch/loongarch/kernel/fpu.S | 1 +
>> arch/loongarch/kvm/exit.c | 18 +++++++++++
>> arch/loongarch/kvm/switch.S | 16 ++++++++++
>> arch/loongarch/kvm/trace.h | 4 ++-
>> arch/loongarch/kvm/vcpu.c | 43 ++++++++++++++++++++++++++-
>> 7 files changed, 96 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/loongarch/include/asm/kvm_host.h
>> b/arch/loongarch/include/asm/kvm_host.h
>> index 6c65c25169..4c05b5eca0 100644
>> --- a/arch/loongarch/include/asm/kvm_host.h
>> +++ b/arch/loongarch/include/asm/kvm_host.h
>> @@ -95,6 +95,7 @@ enum emulation_result {
>> #define KVM_LARCH_SWCSR_LATEST (0x1 << 1)
>> #define KVM_LARCH_HWCSR_USABLE (0x1 << 2)
>> #define KVM_LARCH_LSX (0x1 << 3)
>> +#define KVM_LARCH_LASX (0x1 << 4)
>> struct kvm_vcpu_arch {
>> /*
>> @@ -181,6 +182,11 @@ static inline bool kvm_guest_has_lsx(struct
>> kvm_vcpu_arch *arch)
>> return arch->cpucfg[2] & CPUCFG2_LSX;
>> }
>> +static inline bool kvm_guest_has_lasx(struct kvm_vcpu_arch *arch)
>> +{
>> + return arch->cpucfg[2] & CPUCFG2_LASX;
>> +}
>> +
>> /* Debug: dump vcpu state */
>> int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu);
>> diff --git a/arch/loongarch/include/asm/kvm_vcpu.h
>> b/arch/loongarch/include/asm/kvm_vcpu.h
>> index c629771e12..4f87f16018 100644
>> --- a/arch/loongarch/include/asm/kvm_vcpu.h
>> +++ b/arch/loongarch/include/asm/kvm_vcpu.h
>> @@ -67,6 +67,16 @@ static inline void kvm_restore_lsx(struct
>> loongarch_fpu *fpu) { }
>> static inline void kvm_restore_lsx_upper(struct loongarch_fpu *fpu)
>> { }
>> #endif
>> +#ifdef CONFIG_CPU_HAS_LASX
>> +void kvm_own_lasx(struct kvm_vcpu *vcpu);
>> +void kvm_save_lasx(struct loongarch_fpu *fpu);
>> +void kvm_restore_lasx(struct loongarch_fpu *fpu);
>> +#else
>> +static inline void kvm_own_lasx(struct kvm_vcpu *vcpu) { }
>> +static inline void kvm_save_lasx(struct loongarch_fpu *fpu) { }
>> +static inline void kvm_restore_lasx(struct loongarch_fpu *fpu) { }
>> +#endif
>> +
>> void kvm_acquire_timer(struct kvm_vcpu *vcpu);
>> void kvm_init_timer(struct kvm_vcpu *vcpu, unsigned long hz);
>> void kvm_reset_timer(struct kvm_vcpu *vcpu);
>> diff --git a/arch/loongarch/kernel/fpu.S b/arch/loongarch/kernel/fpu.S
>> index d53ab10f46..f4524fe866 100644
>> --- a/arch/loongarch/kernel/fpu.S
>> +++ b/arch/loongarch/kernel/fpu.S
>> @@ -384,6 +384,7 @@ SYM_FUNC_START(_restore_lasx_upper)
>> lasx_restore_all_upper a0 t0 t1
>> jr ra
>> SYM_FUNC_END(_restore_lasx_upper)
>> +EXPORT_SYMBOL(_restore_lasx_upper)
>
> Why the added export? It doesn't seem necessary, given the previous
> patch doesn't have a similar export added for _restore_lsx_upper. (Or
> if it's truly needed it should probably become EXPORT_SYMBOL_GPL.)
It is needed to be exported, as it is called by kvm_own_lasx. However
the "_restore_lsx_upper" is not used in kvm.
Thanks
Tianrui Zhao
next prev parent reply other threads:[~2023-11-21 9:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 9:19 [PATCH v1 0/2] LoongArch: KVM: Add LSX,LASX support Tianrui Zhao
2023-11-15 9:19 ` [PATCH v1 1/2] LoongArch: KVM: Add lsx support Tianrui Zhao
2023-11-15 19:35 ` kernel test robot
2023-11-16 7:15 ` WANG Xuerui
2023-11-21 9:56 ` zhaotianrui
2023-11-17 8:24 ` maobibo
2023-11-20 1:31 ` zhaotianrui
2023-11-15 9:19 ` [PATCH v1 2/2] LoongArch: KVM: Add lasx support Tianrui Zhao
2023-11-16 7:19 ` WANG Xuerui
2023-11-21 10:02 ` zhaotianrui [this message]
2023-11-21 11:55 ` Huacai Chen
2023-11-21 12:17 ` zhaotianrui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6d9395b5-e8f1-3990-adb0-a52d03411fc6@loongson.cn \
--to=zhaotianrui@loongson.cn \
--cc=alexander.deucher@amd.com \
--cc=axboe@kernel.dk \
--cc=broonie@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@xen0n.name \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=xry111@xry111.site \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®