Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp267178rdf; Tue, 21 Nov 2023 02:01:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdzYM6W7arqKvwvoFHMPKU7OgNnOxXEb6vB7x0TKWsuIEEW80ymtljijIXcdUGiNhDdFCb X-Received: by 2002:a05:6a21:6d8a:b0:187:d380:fd98 with SMTP id wl10-20020a056a216d8a00b00187d380fd98mr8796889pzb.44.1700560893691; Tue, 21 Nov 2023 02:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700560893; cv=none; d=google.com; s=arc-20160816; b=WM6rX7CLF1EwKgXtfapFVaEcB73gNz0A4pQHRX8pf3lb00CUynLsl/4oPCKhk6oBNB cJRcHeVnT+V7sXlyPemIACKDbaZ4Q2af/w3gddCGx8J2UqbTAnIxQkoigqCL1A/u/0Ub tD9A027hsnehjNqj9H5rcw8YwQZoRp2xU5W+Vy0V7BpTlcXQopZBfX0OYDCX/SBEpHIq P8OzYUiWT7cUoIkMBZl/9Hn4/u3il4CLff2foeEbdaA6jOo3aQVB5kx7RUKKv2TMPWT2 tg0Zjo7sp4uBOO9Dd+xkwxM/godOIUhD5fL3DhDU6cXCpn/4+7HNN3EArwMpx/kHjg/c 7qhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=0nqulESqJdI/xAclGwv9sgOHugpsdOURdMFTE8FO8Vg=; fh=NfxQezD5HM8dDGd2brv3UUjjHpqyRN1t8bruD5N33og=; b=mwHUd2orR1LhF2xZNyOhva8WzlJQXU4H9zaVCSiv24OHeFouQZlhzV9b5+d1JwrBQ8 5S8FjtLGCCtPwQEAMQVxZIHuzoLpdYqb/qEOBNswCcopWovR1qXE8Rqrh+KKFA3sRZJT rv8ZEnwIwtZKuAJKbXvCU60V5zkTR7K5+JR1R5WOafXHCSLl9CNzty9fnmIcsH0tCeHt Xb16rii6Gq4Ic38u4LeyAHoxTAvOuhMdVUSMsw/tTC/iigXj1LNRKBglrQRpxv552rnO +9g1tjVO42ndHjqve4QGpbA445yUVOBFIDL45y4bWXBfIn9oMz3Dzzw7pRg5DndUrdOa CUuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id lb8-20020a17090b4a4800b002791baa4729si10504539pjb.57.2023.11.21.02.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:01:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 27A92807F4B6; Tue, 21 Nov 2023 02:00:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234179AbjKUJ74 (ORCPT + 99 others); Tue, 21 Nov 2023 04:59:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234117AbjKUJ7x (ORCPT ); Tue, 21 Nov 2023 04:59:53 -0500 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D9ED011A; Tue, 21 Nov 2023 01:59:48 -0800 (PST) Received: from loongson.cn (unknown [10.20.42.183]) by gateway (Coremail) with SMTP id _____8BxpPCTf1xlfoQ7AA--.52256S3; Tue, 21 Nov 2023 17:59:47 +0800 (CST) Received: from [10.20.42.183] (unknown [10.20.42.183]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axzy+Pf1xlGU1IAA--.28376S3; Tue, 21 Nov 2023 17:59:45 +0800 (CST) Subject: Re: [PATCH v1 2/2] LoongArch: KVM: Add lasx support To: WANG Xuerui , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Huacai Chen , Greg Kroah-Hartman , loongarch@lists.linux.dev, Jens Axboe , Mark Brown , Alex Deucher , Oliver Upton , maobibo@loongson.cn, Xi Ruoyao References: <20231115091921.85516-1-zhaotianrui@loongson.cn> <20231115091921.85516-3-zhaotianrui@loongson.cn> From: zhaotianrui Message-ID: <6d9395b5-e8f1-3990-adb0-a52d03411fc6@loongson.cn> Date: Tue, 21 Nov 2023 18:02:06 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID: AQAAf8Axzy+Pf1xlGU1IAA--.28376S3 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxWr47Cry7WFWUuF1DGF4DAwc_yoWrXr4UpF 97Crs5JayrCFn3Gr9rtw1DZ345Xrs7Gw1aqa43ta43AF1Yqryjqr1kWrWqgFyUJw48KF1S vF15tr13uF15AwbCm3ZEXasCq-sJn29KB7ZKAUJUUUUf529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUPab4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI4 8JMxk0xIA0c2IEe2xFo4CEbIxvr21lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67 AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIY rxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14 v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWx JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU4Xo7DU UUU X-Spam-Status: No, score=-2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 02:00:18 -0800 (PST) 在 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 >> --- >>   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