From patchwork Tue Sep 6 08:35:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1674581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=3DNPgapH; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=PrdqU1cZ; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MMJdk3sDXz1yh5 for ; Tue, 6 Sep 2022 18:36:42 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wdvOB7w6OmTgpvZZjMC4JJfMZFlk4q8mseIlk2GTPbU=; b=3DNPgapH7yhObl efTIXtUscMyh0uS22hyq9GDjJS0UEczuoeslE/NHvOUljB5FVapus6hGfepDzvGIHvlmo0zZzRdtv 2JG74M18VSADlKmI/RNmqi1TujVq3hWEkgVo0mqsaelJOhFma9dE5WycOzWiDqoNws7DYdB2wAvRa 3MS2fcmSzYkp4Wm+p9hNA5hm6w+7abiATGHScywy5PiOk+pmHzZUyH4a1yqpCi7sfqYioSCESXtuN lTypCjwKSxqjnhd66H0oo3E3Vyp+QnnMfGDTu6+v0SVyQ43yxtKb6I4NXRpjX9AlXzKGtJSat6C7F Wh/qPgDqtABh5yBOEzyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVU4T-00BJhz-L4; Tue, 06 Sep 2022 08:36:37 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVU3x-00BJJE-0Z for kvm-riscv@lists.infradead.org; Tue, 06 Sep 2022 08:36:13 +0000 Received: by mail-ej1-x633.google.com with SMTP id og21so21545067ejc.2 for ; Tue, 06 Sep 2022 01:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=K0PbgrG3aEce+RNqVBrfv7es9LlST45m+grejWUOs6U=; b=PrdqU1cZ1HghRZTDIYbB2OHdFouvReQtmKEIIazTE3+bG71IPDaNeFTWG7kJDT8okv UHpsi21w+Wc0w45fd/rn6BWvs0zt06svSFmaY0xBuT1+HcGZAHz6gwh/e8DC9+xeA2xr kjZaJ/fjQloNMOp+7drn9N2WDKyP57UM3ifzUlf7LjWYBezkSn8pekDYLP6erGXX7eFp 6wzoQXaYts0o76dLNMh+gJCz4ve1gT4cjZU3Duk+LBSAZZZNrzeAk9lVeOohytH5AFoK eXC4uJ9rklwhBKJVVDYq8CEEXIGIhRUVuaJSQMImd92uh+JwNf27xnk7XGznYYvJd2fE xMNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=K0PbgrG3aEce+RNqVBrfv7es9LlST45m+grejWUOs6U=; b=RHWvQMu1zEgAZo9JVVuyT+B1UxcPx8RNS+K76TQADb90cDLs1op4DzpiXrK8syEEOC sDPks8tIJyv2FO6qUKO3gYtBT1H6aMEo8Q1/IqitLJMLUe4MQ8eekV2xCmKQxILEH9Sr wCdcOqG6HNDJikc0StYg8OZ/y+QwFOSXnnQT6XYPPrsaHATZPYPsg5dRxUd8ki/Z6t/5 IenNcLaJ2v84ccQd+1eK64rJD8zI4CjJh8Rt4kdz4cPwiPfZfv/+5t/rOOxT4He+ka9K gpUaUU8cMmnelLCB9F+6UR/8M7/YAWnwvrSGEiKPXv0+30n9KoTlSESLWmu4FYFHKKU1 FxtA== X-Gm-Message-State: ACgBeo1Ms4mtlL4lAWfhBGesKvLjpBTaF77oQGDgjBdXyc/vBFVBnXH4 qCJIFaAu/9IyIwt1WX44q91llEqI/PrDdw== X-Google-Smtp-Source: AA6agR7nYfbY1GSdXqsuaL4WdMWDHUT+LNz7bU3OEKAjDKWlYckD1nCZThji/A1t+vSGTW4t23asjA== X-Received: by 2002:a17:906:da85:b0:741:40a7:d08d with SMTP id xh5-20020a170906da8500b0074140a7d08dmr35183008ejb.263.1662453361294; Tue, 06 Sep 2022 01:36:01 -0700 (PDT) Received: from localhost (cst2-173-61.cust.vodafone.cz. [31.30.173.61]) by smtp.gmail.com with ESMTPSA id d14-20020a05640208ce00b004482dd03fe8sm1734062edz.91.2022.09.06.01.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 01:36:00 -0700 (PDT) From: Andrew Jones To: kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org Cc: Anup Patel , Atish Patra Subject: [PATCH 3/3] RISC-V: KVM: Expose Zicbom to the guest Date: Tue, 6 Sep 2022 10:35:55 +0200 Message-Id: <20220906083555.931806-4-ajones@ventanamicro.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220906083555.931806-1-ajones@ventanamicro.com> References: <20220906083555.931806-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_013609_846127_06DD15F8 X-CRM114-Status: GOOD ( 10.40 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Guests may use the cbo.inval,clean,flush instructions when the CPU has the Zicbom extension and the hypervisor sets henvcfg.CBIE (for cbo.inval) and henvcfg.CBCFE (for cbo.clean,flush). Add Zicbom support for KVM guests which may be enabled and disabled from KVM userspace using the ISA extension ONE_REG API. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:633 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Guests may use the cbo.inval,clean,flush instructions when the CPU has the Zicbom extension and the hypervisor sets henvcfg.CBIE (for cbo.inval) and henvcfg.CBCFE (for cbo.clean,flush). Add Zicbom support for KVM guests which may be enabled and disabled from KVM userspace using the ISA extension ONE_REG API. Signed-off-by: Andrew Jones --- arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/vcpu.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index b9a4cf36be4b..ed37a4a6e5cf 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -99,6 +99,7 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_M, KVM_RISCV_ISA_EXT_SVPBMT, KVM_RISCV_ISA_EXT_SSTC, + KVM_RISCV_ISA_EXT_ZICBOM, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 3f36e79876e7..3ce4f1c11b4c 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -54,6 +54,7 @@ static const unsigned long kvm_isa_ext_arr[] = { RISCV_ISA_EXT_m, RISCV_ISA_EXT_SVPBMT, RISCV_ISA_EXT_SSTC, + RISCV_ISA_EXT_ZICBOM, }; static unsigned long kvm_riscv_vcpu_base2isa_ext(unsigned long base_ext) @@ -795,6 +796,10 @@ static void kvm_riscv_vcpu_update_config(const unsigned long *isa) if (__riscv_isa_extension_available(isa, RISCV_ISA_EXT_SSTC)) henvcfg |= ENVCFG_STCE; + + if (__riscv_isa_extension_available(isa, RISCV_ISA_EXT_ZICBOM)) + henvcfg |= (ENVCFG_CBIE | ENVCFG_CBCFE); + csr_write(CSR_HENVCFG, henvcfg); #ifdef CONFIG_32BIT csr_write(CSR_HENVCFGH, henvcfg >> 32);