From patchwork Wed Jul 12 16:34:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13310746 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F26EBEB64DD for ; Wed, 12 Jul 2023 16:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232432AbjGLQfq (ORCPT ); Wed, 12 Jul 2023 12:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232401AbjGLQfp (ORCPT ); Wed, 12 Jul 2023 12:35:45 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B942E69 for ; Wed, 12 Jul 2023 09:35:32 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1b89b75dc1cso6757115ad.1 for ; Wed, 12 Jul 2023 09:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1689179732; x=1691771732; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4HjOxqUEAXA51EuHpHwbjwPyrknL5nW6rIhKCbZ+yO0=; b=YXSMrW0M1RBWBmGJlT2Wy60B/ZLTRiOX5hor5Fzk3iJyOJO4pDTuWUIGzIKVmENaQb jViZLsXmcNm02RTHa1xmasblY3NF5k1OUG+r86S6X0GPCiqUahmzXO8nwZV3XsgVVnPT si1GOS3Kf/vthK9/2rbI7JrPRhT7PP3Qf5Di/VeR5X/4r1dnT1qS8TL/CwTwienYKk2t oaPZzZvRKwSES4OrYwm4y0E5VXNjiLwtpWHyskhfICGA1TAAUy95IRCS61ABrY6Nd+9E hXJaCMF6/Rf2xyuXUfpBAEPJB9rOwkK3XfL8ylpxPdwCavmV2QeIfiZc7tlhtg7SVBR8 pmjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689179732; x=1691771732; 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:message-id:reply-to; bh=4HjOxqUEAXA51EuHpHwbjwPyrknL5nW6rIhKCbZ+yO0=; b=bC8y53CYa9EFzeRyeAs2SBT2C4F+AqCyWiaG9Ce1MRVXOekHrtQ6ibE0z5OJ+gAtdT 5pohreUqvaKTAlxaIREiQJDGHdDuGo+oOn0mTwCzQAOoUxcK60n1nkYrpOIOEWJEpTDd bh+UdGrxnYZKrFogxeLKW+C6Hk8lNxAU+W+hxYJjFv0yB4BKQpaFx6MFaPbK3XQAb25w B/zfwc8kBxkOsBz5ifnN3laaOWlxKHl3imJGckiVIPkBo8ROksc0jKygBRtHnaBp7liv jOUexBjPuRFLAlTVFwDKfqHw+WXa3OQll0S2ftIVi4EGeU57cDhfASH19KEdv5XA1X3q 09vg== X-Gm-Message-State: ABy/qLbK1Fx3oytHVgw6CPc5ENSRm8jSc0hyd+Tn5W3RcX8lxwp++7sY vpUlHpDu1ryfHkFjlRjbK20kAw== X-Google-Smtp-Source: APBJJlFlf3Me+kL74vCtKpeeKN1GsOD8x1VGV5fMdP0mcjhOPAl+8OXHH+geptIIp3pojesT9hq5iQ== X-Received: by 2002:a17:902:db10:b0:1b8:a936:1915 with SMTP id m16-20020a170902db1000b001b8a9361915mr2988708plx.22.1689179731780; Wed, 12 Jul 2023 09:35:31 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([171.76.82.173]) by smtp.gmail.com with ESMTPSA id w15-20020a1709027b8f00b001b9df74ba5asm4172164pll.210.2023.07.12.09.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 09:35:31 -0700 (PDT) From: Anup Patel To: Will Deacon , julien.thierry.kdev@gmail.com, maz@kernel.org Cc: Paolo Bonzini , Atish Patra , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Anup Patel Subject: [kvmtool PATCH v4 7/9] riscv: Add Zicboz extension support Date: Wed, 12 Jul 2023 22:04:59 +0530 Message-Id: <20230712163501.1769737-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712163501.1769737-1-apatel@ventanamicro.com> References: <20230712163501.1769737-1-apatel@ventanamicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Andrew Jones When the Zicboz extension is available expose it to the guest. Also provide the guest the size of the cache block through DT. Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- riscv/fdt.c | 12 +++++++++++- riscv/include/kvm/kvm-config-arch.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/riscv/fdt.c b/riscv/fdt.c index 17d6757..a76dc37 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -21,6 +21,7 @@ struct isa_ext_info isa_info_arr[] = { {"svpbmt", KVM_RISCV_ISA_EXT_SVPBMT}, {"zbb", KVM_RISCV_ISA_EXT_ZBB}, {"zicbom", KVM_RISCV_ISA_EXT_ZICBOM}, + {"zicboz", KVM_RISCV_ISA_EXT_ZICBOZ}, {"zihintpause", KVM_RISCV_ISA_EXT_ZIHINTPAUSE}, }; @@ -47,7 +48,7 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm) int cpu, pos, i, index, valid_isa_len; const char *valid_isa_order = "IEMAFDQCLBJTPVNSUHKORWXYZG"; int arr_sz = ARRAY_SIZE(isa_info_arr); - unsigned long cbom_blksz = 0; + unsigned long cbom_blksz = 0, cboz_blksz = 0; _FDT(fdt_begin_node(fdt, "cpus")); _FDT(fdt_property_cell(fdt, "#address-cells", 0x1)); @@ -97,6 +98,13 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm) die("KVM_GET_ONE_REG failed (config.zicbom_block_size)"); } + if (isa_info_arr[i].ext_id == KVM_RISCV_ISA_EXT_ZICBOZ && !cboz_blksz) { + reg.id = RISCV_CONFIG_REG(zicboz_block_size); + reg.addr = (unsigned long)&cboz_blksz; + if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) + die("KVM_GET_ONE_REG failed (config.zicboz_block_size)"); + } + if ((strlen(isa_info_arr[i].name) + pos + 1) >= CPU_ISA_MAX_LEN) { pr_warning("Insufficient space to append ISA exension\n"); break; @@ -118,6 +126,8 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm) _FDT(fdt_property_string(fdt, "riscv,isa", cpu_isa)); if (cbom_blksz) _FDT(fdt_property_cell(fdt, "riscv,cbom-block-size", cbom_blksz)); + if (cboz_blksz) + _FDT(fdt_property_cell(fdt, "riscv,cboz-block-size", cboz_blksz)); _FDT(fdt_property_cell(fdt, "reg", cpu)); _FDT(fdt_property_string(fdt, "status", "okay")); diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h index 8448b1a..b12605d 100644 --- a/riscv/include/kvm/kvm-config-arch.h +++ b/riscv/include/kvm/kvm-config-arch.h @@ -40,6 +40,9 @@ struct kvm_config_arch { OPT_BOOLEAN('\0', "disable-zicbom", \ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOM], \ "Disable Zicbom Extension"), \ + OPT_BOOLEAN('\0', "disable-zicboz", \ + &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOZ], \ + "Disable Zicboz Extension"), \ OPT_BOOLEAN('\0', "disable-zihintpause", \ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\ "Disable Zihintpause Extension"), \