From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF4C3C369DC for ; Mon, 28 Apr 2025 13:46:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9OnM-0000fM-HF; Mon, 28 Apr 2025 09:45:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9Ofu-0004GF-03 for qemu-riscv@nongnu.org; Mon, 28 Apr 2025 09:37:52 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u9Ofp-0001DT-R7 for qemu-riscv@nongnu.org; Mon, 28 Apr 2025 09:37:32 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-39d94327297so604641f8f.0 for ; Mon, 28 Apr 2025 06:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1745847447; x=1746452247; darn=nongnu.org; h=in-reply-to:references:cc:subject:from:to:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=G/3gG/ZaE7DaiwKoxmsM3/UdNWWdxYHJtBxnwxmPe3k=; b=NqMw0zh562GAjJWO0FZZPoDDZfpfnDynNDNMi0UU2AJkTtl6zMAa9VLjboVTTerd3w 5MI8zdIZyH3N8xLnxjMhf9ew+e863GDN54Zezt+PDzpIdfWqM9wueGuJclpUgnUVYl7q TKOaiHJtCTek5GguJXaoKSNtBpZzEuHIeWon6P9Z6zdAjkhEfirYaDLA2iVBJXszj8XZ mLvHwklUyTfsND8QeawjRxviepB30OzP8OpKx09mJvrCSmSdiNXWkIuTtxtIhNDn78NP gPSYsoj4xaiwEV5vjlmIIgXgkl904RFcKxZ66gGExAoKzaWm1OX7xcIZpbz6c2/8/Lym wG9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745847447; x=1746452247; h=in-reply-to:references:cc:subject:from:to:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=G/3gG/ZaE7DaiwKoxmsM3/UdNWWdxYHJtBxnwxmPe3k=; b=Bwh6AdIxVEU4debdrh2Ir7wmPVDLxbDnesjR2oMIA4P7cGqz2TYGfe52/gW4dEMjQ4 uTNyPyYLNWvAJge23ed6vMoPkM+vGEbmcQt8CYGVchweVVsNToLhpicELDWd+l0m/qrR HA4aLpCEtMEiB3i/9B1mTcJ9INELh5EyZH97VWIuoaTLuxR3lns0jkrWbwuHLXFnAVHx t/ScuQaaa8J7WSNoZ+KLXMkPkyyWlyjej3JNTEFrkaO4KCxfYbe7sdlDQnEyMFJM5tI1 DAfA6XTs/++01o7pULX7wCIZh8C3JgMArcnmEKJsAjedR7QK4rc9jurKEYHa5A+N8kgt rIcA== X-Forwarded-Encrypted: i=1; AJvYcCVysprkFmVwZvry4FZ7WzNYiWHTAJwpKIDbDPh/elEWCwFq3XyksPyGpAmMUV4pvThBM2lJ3bYe3K47@nongnu.org X-Gm-Message-State: AOJu0YzqQe6lKKMcVAs+esOOrPoZxO12jIiRPdF6JZ4DlEXyJvq8GNNC Si4S4rgic/fBM4JYNZKu9ADefUCHTa73i99ucv6pl7/oLCPefZI9eSDtt/O0kSZQZoqUDOrLf+p Vyec= X-Gm-Gg: ASbGnctiGSV+TQKWihkNq1sXLBV6JJWnKKeb8WaOv8zOB79gb4ymtnTuzkY3d+DavRG WY4GGLSCJDuEPaRpjf5LHzmI9AxTI4NBz9EsarQhabz6ZN15Su6ibTzqWH1zWVTCZPaUwy/am6w CIwpclm7fc4ffwAo3sLFjAkaxEJTpQEujtCO+QYg321mFBfQfhcpNUQuPsPkmXbrnjs4WFDGHXl LxKfFJI9cIt2glNVxBtwr65kdNiIAFLWxuzjFbhb6wMqG7bDKE58qtf6Sr7nCpslTuDvwBPsRYh OVINCAz6UQANdTj2ADNcS6JhIQmi/KypSmKs0DzjGqUdn2Q= X-Google-Smtp-Source: AGHT+IEnTFNJ18fmzAaiDVTJ4NKdELQHx/MVKWGT4I2VMPcsz5zkPws0tQ5PTK712u+S0Bq393mnSg== X-Received: by 2002:a05:6000:4210:b0:3a0:87f1:1900 with SMTP id ffacd0b85a97d-3a087f125b0mr442850f8f.2.1745847447041; Mon, 28 Apr 2025 06:37:27 -0700 (PDT) Received: from localhost ([2a02:8308:a00c:e200:785:f3a7:1fbb:6b76]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a073ccb8e1sm11345667f8f.59.2025.04.28.06.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Apr 2025 06:37:26 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 28 Apr 2025 15:37:26 +0200 Message-Id: To: "Andrew Jones" From: =?utf-8?q?Radim_Kr=C4=8Dm=C3=A1=C5=99?= Subject: Re: [PATCH] target/riscv: add satp mode for kvm host cpu Cc: "Meng Zhuo" , , , "Alistair Francis" , "Liu Zhiwei" , "Weiwei Li" , "Palmer Dabbelt" , "Daniel Henrique Barboza" , References: <20250427132557.1589276-1-mengzhuo@iscas.ac.cn> <20250428-00fc862d2d2d628ffa4c8547@orel> <20250428-4cb96c7f0226e15a40006dee@orel> In-Reply-To: <20250428-4cb96c7f0226e15a40006dee@orel> Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=rkrcmar@ventanamicro.com; helo=mail-wr1-x429.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 28 Apr 2025 09:44:58 -0400 X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org 2025-04-28T14:08:59+02:00, Andrew Jones : > On Mon, Apr 28, 2025 at 11:30:36AM +0200, Radim Kr=C4=8Dm=C3=A1=C5=99 wro= te: >> 2025-04-28T09:00:55+02:00, Andrew Jones : >> > On Sun, Apr 27, 2025 at 09:25:57PM +0800, Meng Zhuo wrote: >> >> This patch adds host satp mode while kvm/host cpu satp mode is not >> >> set. >> > >> > Huh, the KVM side[1] was written for this purpose, but it appears we n= ever >> > got a QEMU side merged. >> > >> > [1] commit 2776421e6839 ("RISC-V: KVM: provide UAPI for host SATP mode= ") >>=20 >> KVM satp_mode is the current SATP.mode and I don't think the other >> SATP.modes can generally be guessed from the host SATP mode. >>=20 >> Can't QEMU use the host capabilities from cpuinfo or something? >>=20 >> Do we need to return a bitmask from KVM? >> (e.g. WARL all modes in vsatp and return what sticks.) >> > > The widest supported is sufficient because all narrower must also be > supported. Linux should be figuring out the widest and capturing that > at boot time and we should be returing that info for the KVM satp_mode > get-one-reg call. Linux has command line overrides for the mode (no4lvl and no5vlv), so the active mode in Linux might not be the widest supported by the cpu. Let's say Linux decides to use 9 on a host cpu that has 0,8,9,10. set_satp_mode_max_supported() will set supported vcpu modes to 0,8,9. Should "-cpu host" contain the 10? > If the satp_mode we're currently returning isn't the widest possible, > then we should fix that in KVM. The numbers are even more complicated... Pasting the values from manual: 0 Bare 1-7 Reserved for standard use 8 Sv39 9 Sv48 10 Sv57 11 Reserved for Sv64 12-13 Reserved for standard use 14-15 Designated for custom use The reserved values make this extra juicy, let's say Linux uses 14 on machine that has 0,8,9,14. QEMU sees 14 and sets the vcpu modes to 0,8,9,10 -- it's not even a subset of the host CPU. (There might be similar problems even with future standard extensions.)