From patchwork Fri Sep 9 14:43:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1676097 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=L3U6bJlh; 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=bUEc1xgI; 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 4MPJfV1QTSz1yp6 for ; Sat, 10 Sep 2022 00:44:18 +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=KcNtreheENAZapQYWMQ1EwDVQxCFDei03u6TU0bgwzk=; b=L3U6bJlhjuFHhs 2rnCC5s9Qug3Yg+o95yDsoW1YbwU2YI1Hbg2I75N61HTqBNCkQ/SdgqfyII8dL76aKlf+dum0iXxI uyxX5lpppqDLL0Xo+8lOoWD+0FCabWenPmRHSEyAJ4zbbAjBuXQ0LyRsG1bkFdvdUkIPoO8ji73L7 dr9tkHiBEIOlzY3H1bqZ7zt0h5RkhM7LP7Xykg9vhfrjLrVomJUWELdpSXu/bf/s9l0odY/wkxsvx k3cPQzxx4jJzqDgy0j8wtIc5aYsd1Hql2wHcF6FbbdLazZ7TioT3UsYjoLRsooDNkxmohpUFiFk8h PeyE2YPMcSwsWfNHKZSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWfEr-00GpCv-6r; Fri, 09 Sep 2022 14:44:13 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWfEl-00Gp8y-IZ for kvm-riscv@lists.infradead.org; Fri, 09 Sep 2022 14:44:10 +0000 Received: by mail-ed1-x52f.google.com with SMTP id z21so2881893edi.1 for ; Fri, 09 Sep 2022 07:44:05 -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=ZscIA4unI47g9cHmq9kCd1DJd3OFd3rFM2bFM5Fr5h0=; b=bUEc1xgI6l8DN1CzlFpXa8YLF1M0B48kmco3oQRvUFO1kYa89zPbb13XITjostxEE1 Ca8EcywBzITy2unkM8bNGgCAIvvick+Wko60JarBNJhzToYu8WBoc9gIovmEWtnhUMHx ZUk4gMKRmvwTqIWzp710nuuDMe0wqIk4M0YLOTHmprws1qmYYliiRmp4HzMJwyDLLYes qOPqJ7pIGlk4J/PJvEUUGbWExRDDh1xuHLqULSkiTAVTmXPbCEE7MjlFPennFTgpaEa+ 3yI/mesmZO46swsS7M8aDmccI7maHouDSVgY361RrcPwwZfN56URAZ3jILkd5Qd0sj0b sp/Q== 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=ZscIA4unI47g9cHmq9kCd1DJd3OFd3rFM2bFM5Fr5h0=; b=c48VV9LmzmS3n4vFOaesfFWlIX1k5lapviz6H3jjmkUuVyHEVv30dZ3TiCYj1/TUI7 KvyfX4FqiizOUI5DTvMl4JWwZ73SS2UiWzDJuVX3r0F35/k6tN4PNs8Z0pJkIJlUvmpk 7GRyeGyYOADJ4nHevPpE9Qu16p96y+riB6V7TDAqd0c19aBs21/8TPxGJLkF3yKvfNPJ 284r3YwSaZr1qbGYRL9MHIC+5djsooA/VifYogDVAZ/f6oXayeIWovp/xoSs9Q9PU77K xRAWQfsi9mD+lH0M4e9sOPeAC2TQrGambrxBbF/QCBTKbZ6g1ExilhBLxbezntMk1G8c u2Ng== X-Gm-Message-State: ACgBeo0sq1kzsYOtrbtTz6+2DnXS9TQIiIZLVgcbfqBGqF9Wla86nm9K EQbYaDtRYxAkQuaVRfOprQVYwoIQwBVNdA== X-Google-Smtp-Source: AA6agR5e4/MGy+nOuVfr62aNL1Y0RJydMmpicm5Hig7pe02PAhMnTEg7SyDZ9RKwE8Cl5oZ6Bn4a2g== X-Received: by 2002:a05:6402:2753:b0:43a:d6f2:9839 with SMTP id z19-20020a056402275300b0043ad6f29839mr11415019edd.73.1662734643701; Fri, 09 Sep 2022 07:44:03 -0700 (PDT) Received: from localhost (cst2-173-61.cust.vodafone.cz. [31.30.173.61]) by smtp.gmail.com with ESMTPSA id l3-20020a056402344300b0044604ad8b41sm494613edc.23.2022.09.09.07.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 07:44:03 -0700 (PDT) From: Andrew Jones To: kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org Cc: Anup Patel , Atish Patra , Conor Dooley Subject: [PATCH v3 1/2] RISC-V: KVM: Provide UAPI for Zicbom block size Date: Fri, 9 Sep 2022 16:43:59 +0200 Message-Id: <20220909144400.1114485-2-ajones@ventanamicro.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220909144400.1114485-1-ajones@ventanamicro.com> References: <20220909144400.1114485-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220909_074407_687132_C847452B X-CRM114-Status: GOOD ( 14.17 ) 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: We're about to allow guests to use the Zicbom extension. KVM userspace needs to know the cache block size in order to properly advertise it to the guest. Provide a virtual config register for userspac [...] 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:52f 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 We're about to allow guests to use the Zicbom extension. KVM userspace needs to know the cache block size in order to properly advertise it to the guest. Provide a virtual config register for userspace to get it with the GET_ONE_REG API, but setting it cannot be supported, so disallow SET_ONE_REG. Signed-off-by: Andrew Jones Reviewed-by: Conor Dooley Reviewed-by: Atish Patra --- arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/vcpu.c | 8 ++++++++ arch/riscv/mm/cacheflush.c | 1 + 3 files changed, 10 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index 7351417afd62..b9a4cf36be4b 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -48,6 +48,7 @@ struct kvm_sregs { /* CONFIG registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ struct kvm_riscv_config { unsigned long isa; + unsigned long zicbom_block_size; }; /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index d0f08d5b4282..2ef33d5d94d1 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { @@ -254,6 +255,11 @@ static int kvm_riscv_vcpu_get_reg_config(struct kvm_vcpu *vcpu, case KVM_REG_RISCV_CONFIG_REG(isa): reg_val = vcpu->arch.isa[0] & KVM_RISCV_BASE_ISA_MASK; break; + case KVM_REG_RISCV_CONFIG_REG(zicbom_block_size): + if (!riscv_isa_extension_available(vcpu->arch.isa, ZICBOM)) + return -EINVAL; + reg_val = riscv_cbom_block_size; + break; default: return -EINVAL; } @@ -311,6 +317,8 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu, return -EOPNOTSUPP; } break; + case KVM_REG_RISCV_CONFIG_REG(zicbom_block_size): + return -EOPNOTSUPP; default: return -EINVAL; } diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index e5b087be1577..f318b2553612 100644 --- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -90,6 +90,7 @@ void flush_icache_pte(pte_t pte) #endif /* CONFIG_MMU */ unsigned int riscv_cbom_block_size; +EXPORT_SYMBOL_GPL(riscv_cbom_block_size); #ifdef CONFIG_RISCV_ISA_ZICBOM void riscv_init_cbom_blocksize(void)