Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp890537rdb; Fri, 1 Dec 2023 00:59:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHW6hnAIBA5aWYN/AZEihi8Q9CBm7AEYEU0DuNDjWpRyA/tSySUhC6c4316GYq98s6agLSl X-Received: by 2002:a05:6a20:729c:b0:18c:7b7:8630 with SMTP id o28-20020a056a20729c00b0018c07b78630mr24184470pzk.13.1701421177090; Fri, 01 Dec 2023 00:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701421177; cv=none; d=google.com; s=arc-20160816; b=Lq996spYZmLSyh4F7rdsoMp9r5f+LxdI+SNCS/EFXtCu+ot9pmaQKhlQhPmjf6CvkL NxlGfVfFCE65U9CxP1Yd/7LKlE3+bDLm8v9kh//g5rtknkXlpeg8X601pHXSTW7ox2zP VabB2tb/u9IWL0AH8vfOhZjkLUNHJnjeFcITuL9X3hdVlbTaFnDylGcuQw+WdWIKC5rx ZoMVEWlNB57tJwbhSaaHMyGPHIO46tLSxsSwIaCpyWQYXbqdKL7oP2Ors1moSrMD/9ts uTZV14C/qAuxOT8cTk4xS9AeOaj9nUl67mkzEWp5Ot9gvt3XYW/Lm7sIdPSooqGEH8Sa zbhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=54c8ZOotVLawfDmYYgkhRlm9K2+xSwNFfnXr9o5RFGo=; fh=P5g7S4mE2XjWgKgrqkiXRFHBND3MsoJuQrg1sbxMU0U=; b=we8hpsIi7/iFlE3MSNq0GjVfs3m54Afr+ksePpwgLHF2CK0bCgYmsHoS8qJVz7uzXO 6rOcOyGsC4TvPL8KRJRUB+1SzV/E/MFyN9CSMKjWQlXNjO02MZBpds3e2xOzXBfPLvVV b845Cmy18JcVsz0YyrsgS8q/sLpCtKLIaXlLjqWiSpZAAmdbBZ9T5S2tPlxXtGEMsBdo 6sqchf8LVktv8e7SxA0OfFn+CYAGqhihgNPc962CJaLbYxfSZUI2Sx7/1h31D+Wn105q oxH1BzU4mdBOAWObVZUpKkEIWxXnsBcLTBOKk7GIB3e1je+MRfjIlKfy7nfN48yfutns RT6Q== 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 ik26-20020a170902ab1a00b001c9b15bf936si531692plb.220.2023.12.01.00.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 00:59:37 -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 B462B801B49A; Fri, 1 Dec 2023 00:59:31 -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 S1377855AbjLAI7P (ORCPT + 99 others); Fri, 1 Dec 2023 03:59:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjLAI7O (ORCPT ); Fri, 1 Dec 2023 03:59:14 -0500 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C275A8; Fri, 1 Dec 2023 00:59:19 -0800 (PST) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8BxuOhloGllYSg+AA--.22465S3; Fri, 01 Dec 2023 16:59:17 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxG9xkoGll4ndRAA--.49050S2; Fri, 01 Dec 2023 16:59:16 +0800 (CST) From: Tianrui Zhao To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Huacai Chen , WANG Xuerui , Greg Kroah-Hartman , loongarch@lists.linux.dev, Jens Axboe , Mark Brown , Alex Deucher , Oliver Upton , maobibo@loongson.cn, zhaotianrui@loongson.cn Subject: [PATCH v2 0/2] LoongArch: KVM: Add LSX,LASX support Date: Fri, 1 Dec 2023 16:46:17 +0800 Message-Id: <20231201084619.2255983-1-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8AxG9xkoGll4ndRAA--.49050S2 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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]); Fri, 01 Dec 2023 00:59:31 -0800 (PST) From: zhaotianrui This patch series add LSX,LASX support for LoongArch KVM. There will be LSX,LASX exception in KVM when guest use the LSX,LASX instructions. KVM will enable LSX,LASX and restore the vector registers for guest then return to guest to continue running. Changes for v2: 1. Add interface to return CPUCFG2 features which have been supported by current KVM to user space. So that user space can get CPU features such as FPU,LSX,LASX whether support by KVM. 2. Add CPUCFG2 checking interface to check that if the value which is passed from user space has any errors. 3. Export both _restore_lsx_upper and _restore_lasx_upper to keep consistency. 4. Use "jr ra" instruction to repalce "jirl zero, ra, 0". Changes for v1: 1. Add LSX support for LoongArch KVM. 2. Add LASX support for LoongArch KVM. Tianrui Zhao (2): LoongArch: KVM: Add LSX support LoongArch: KVM: Add LASX support arch/loongarch/include/asm/kvm_host.h | 18 ++- arch/loongarch/include/asm/kvm_vcpu.h | 22 ++++ arch/loongarch/include/uapi/asm/kvm.h | 19 ++-- arch/loongarch/kernel/fpu.S | 2 + arch/loongarch/kvm/exit.c | 36 ++++++ arch/loongarch/kvm/switch.S | 36 ++++++ arch/loongarch/kvm/trace.h | 6 +- arch/loongarch/kvm/vcpu.c | 153 +++++++++++++++++++++++++- 8 files changed, 276 insertions(+), 16 deletions(-) -- 2.39.3