Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2058192rdb; Thu, 7 Dec 2023 17:45:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGy+w0C2RWkxLStPk9k+hJ7/G2OvQVsbGs1uSrPJ5YlpjlSXBeEwA6+UOySakktMUikf/bF X-Received: by 2002:a05:6870:e40e:b0:1fa:c88e:19fc with SMTP id n14-20020a056870e40e00b001fac88e19fcmr3725879oag.20.1701999904629; Thu, 07 Dec 2023 17:45:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701999904; cv=none; d=google.com; s=arc-20160816; b=g3irtujWaa19dIxSmbjLv5cXhDtcwXW5NsT/ksJJJRd+97RhIXq0p90dFlkxmzpJPU HI3twXj2lCem8kbIcyzTqpqDLYjdAgvl/dUJf6fzlM+JO4AOX8VjYugm3sNREDIDAQBo EDrAyaYZNrUPzUXM8Xxj+Jclrq76kOoVIRWPM4WkVWchHmkiBsW0PeK0BSFARd/j3yVc vClEq6xSDSW83fgq7Z2yH4REBxUJV7EUItiu4LGlgnDoAdZNGacjnpGkzXCZigBWtfDc rnYqYRwIVYVlmtRCI/AUYvRjo6eDVLydFkzGzgxu0yn2cU5e/7n+2QveLoqGGZDzaHwu QBVg== 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=EYexCTLGKKhKDqUOukXdKXY4tAKqGqHZuSUqEgtS6AI=; fh=P5g7S4mE2XjWgKgrqkiXRFHBND3MsoJuQrg1sbxMU0U=; b=TX3si+tm3o07gn0qcT9QqhusuFld2uWLLGIEaRYJ14V3s0GoEHvAq7c4GysoDolnxC yjErSkWoGljrwcJjQZs9JqWyJbr0ITmCvx0SV716iYLK+NZalD5NMYGRLLw49EUNQegd CB95gvmBTiqgUzgXlbd/pNDu8swZrsBbU+OanoblxyizjFyc3N3TxGRNDCmMYWcPIeS7 UW8E3Qe2GGMqRb+WpervnsJgrwfvtzYbjZJihPtzC7jZjfq4Wp8pY9RQ7oOjhzeVXHS5 2D+oLLoLkLuPnFSI70726dBFS6gI3y72nA9ge2zijUtjYlPSHUpw9Bq86RZn5cQ3l3fX 1Ftw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id by32-20020a056a0205a000b005be1ee5bea2si667099pgb.374.2023.12.07.17.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 17:45:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id A57E5819D9E6; Thu, 7 Dec 2023 17:45:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235374AbjLHBos (ORCPT + 99 others); Thu, 7 Dec 2023 20:44:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232852AbjLHBoq (ORCPT ); Thu, 7 Dec 2023 20:44:46 -0500 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD9C11728; Thu, 7 Dec 2023 17:44:50 -0800 (PST) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Dx_+sOdXJlP9g_AA--.60895S3; Fri, 08 Dec 2023 09:44:46 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Ax3twNdXJlUvVXAA--.62660S2; Fri, 08 Dec 2023 09:44:45 +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 v3 0/2] LoongArch: KVM: Add LSX,LASX support Date: Fri, 8 Dec 2023 09:31:49 +0800 Message-Id: <20231208013151.2668156-1-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Ax3twNdXJlUvVXAA--.62660S2 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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 07 Dec 2023 17:45:01 -0800 (PST) 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 v3: 1. Use KVM_GET_DEVICE_ATTR interface to return CPUCFG2 features which are supported by KVM to user space. 2. Remove version checking in kvm_check_cpucfg. 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 (1): LoongArch: KVM: Add LSX support zhaotianrui (1): LoongArch: KVM: Add LASX support arch/loongarch/include/asm/kvm_host.h | 17 ++ arch/loongarch/include/asm/kvm_vcpu.h | 22 +++ arch/loongarch/include/uapi/asm/kvm.h | 1 + arch/loongarch/kernel/fpu.S | 2 + arch/loongarch/kvm/exit.c | 41 +++++ arch/loongarch/kvm/switch.S | 36 ++++ arch/loongarch/kvm/trace.h | 6 +- arch/loongarch/kvm/vcpu.c | 245 +++++++++++++++++++++++++- 8 files changed, 364 insertions(+), 6 deletions(-) -- 2.39.1