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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 93A281073C9B for ; Wed, 8 Apr 2026 11:27:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1275749.1561490 (Exim 4.92) (envelope-from ) id 1wAR4G-0006WE-Fi; Wed, 08 Apr 2026 11:27:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1275749.1561490; Wed, 08 Apr 2026 11:27:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAR4G-0006W7-BV; Wed, 08 Apr 2026 11:27:32 +0000 Received: by outflank-mailman (input) for mailman id 1275749; Wed, 08 Apr 2026 11:27:31 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAR4F-0006Vz-6b for xen-devel@lists.xenproject.org; Wed, 08 Apr 2026 11:27:31 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wAR4E-005guk-Io for xen-devel@lists.xenproject.org; Wed, 08 Apr 2026 13:27:30 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69d63b91-bab6-0a2a0a5309dd-0a2a450ca434-46 for ; Wed, 08 Apr 2026 13:27:30 +0200 Received: from [209.85.221.54] (helo=mail-wr1-f54.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69d63b2a-f40c-0a2a450c0019-d155dd36d1e1-3 for ; Wed, 08 Apr 2026 13:25:30 +0200 Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-43cfde3c3f3so5923938f8f.3 for ; Wed, 08 Apr 2026 04:25:30 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e2a6f08sm60438329f8f.6.2026.04.08.04.25.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Apr 2026 04:25:29 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1775647530; x=1776252330; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=SBdtrVKnRDnuCZ5SKaN1WgYqxSH99iwR1eEH7wK1pxI=; b=Z1OI6+u6uuUIecuDuxiuNmmcNxUw3H6AAh3IBNFjrbItn4nSScgG0ZhYPr9xkrp6EL 2jIH9DW6RUonMGAlCvkHHnuiSiMqOYvyYdiK5+/KmaA/WrYVKUFVuJRAa5FeXvavfKFk FUQzd2SYTvpo3qhJxWPqQTwC2eJj1MoXdx4zhln0LBdxVR4VYcGWd+MzSsoEhO32SqzJ Pz+ovfnK9ChYXXi+wFldEFxwl4PVeOdala0RNLdhYMREr33dpCfzPNK8x734gvaKOOSF GIpwHvGfsi5olblYDBkzYQR+fRPhjJ8Dlv93XMW+uMsZ4tIFf7v3IzfSA09uAm6Sr/G8 CDMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775647530; x=1776252330; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SBdtrVKnRDnuCZ5SKaN1WgYqxSH99iwR1eEH7wK1pxI=; b=rxOORMA2ndl9VhxKy43jVQpsrbPIfzRdfsTMB3iCOAnjS4xnIvYQB6DlmA4BRLlsAv 5jnvfq6kKk/S4YFzHRBC9IKxr654Vdpwl8aKUyRZmC1n3ZxPJSKHQOhQL12FbpkQUW56 6qc0EcdHquXpJizqPSR5DsQ488BhW70OsVb/+qxP1dmHm4OntgztwsMevohKgs5pESK+ hRkGvzioYnjdggWV8Tvi807mYiCcOcVYBh854zY28XqZQqsCp4kVy8+A0/rCS4jd3pjd FJziqvGj9YbklGXJgshfNcRX4j99xU1kdgCNIrdxEKB8SjHRes2/PBrGIQWK0vDeNsGf PKmQ== X-Forwarded-Encrypted: i=1; AJvYcCXHXgwBWYfAqCoSURY7kCJ8OI6L9Zip2xWIsZEGNXNDBJtxqdX4cL/pc24dpiP4m4YDzO4QE0tJ+/g=@lists.xenproject.org X-Gm-Message-State: AOJu0YxOD97a9gRFb5E4xcDtTUZHh8RPPoTRVBXT98GDo1JGLQ32n3ih KyIcjwmWM/+dHH2+dsa0T9/WUjz2BUHSWYeic6Vai2auBqXzcRWNcoLcE7swQbgSFg== X-Gm-Gg: AeBDievdQEU6RMGxw3+7sQE1SGsi2th3tavwphQJTnuOS5VG2+rwk4uxskc9svG9IVm WwgLZ8FrEcgqOhiJGuQfQy+JbqVLzqNIe6QoUEf3cMd0GNgYWu1cNk8o0wAEDqE7zNaFUTo+Mn2 UYqq8gA8/aW4p4WlHWfUIeTwoTALefiWEavQxUdEZrGWmUtcMl1+V1qxs1HpRqgTgNhqUFFq6mL Y8Vv5LUjtWqDoZw+U+3MuEpEB9fekT0taGlOaEknV7UebzNytpU9edoZxGghSUZEVEq4c6jIK93 1+Z6JHS8cHyWoCf/0Qk6GTCu3e1daXfEIU1HbcoGPwQH1VFPCS9MneDk8ez2vQKo0A/1K1JDLvr PER2JhbQb+UalfW9aY7u6op4+RClNS6VM2Un8RqMbWK/qQnE5RMPTe2NftrzE/qfRiK9iba9c7b 7IdxP+zq3YqWxdoD68JPexNHcHwo8eE6iSDz7laACANyBn5zT9KvlsxbHx6B+ZEnoKMcJSf0jVV QdPXpnoHXZU/7U= X-Received: by 2002:a5d:5f85:0:b0:43c:f7f6:6016 with SMTP id ffacd0b85a97d-43d292daa51mr30310863f8f.32.1775647529378; Wed, 08 Apr 2026 04:25:29 -0700 (PDT) Message-ID: <2830de65-c037-439b-a9ff-bfe6d9cce212@suse.com> Date: Wed, 8 Apr 2026 13:25:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/4] xen/riscv: allow Xen to use SSTC while hiding it from guests To: Oleksii Kurochko Cc: Romain Caritey , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org References: Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJ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085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-d25034/1775647530-FDD53A3D-800E6822/0/0 X-purgate-type: clean X-purgate-size: 2574 On 08.04.2026 12:58, Oleksii Kurochko wrote: > On 4/2/26 8:41 AM, Jan Beulich wrote: >> On 31.03.2026 21:04, Oleksii Kurochko wrote: >>> @@ -61,20 +73,7 @@ int reprogram_timer(s_time_t timeout) >>> if ( deadline <= now ) >>> return 0; >>> >>> - /* >>> - * TODO: When the SSTC extension is supported, it would be preferable to >>> - * use the supervisor timer registers directly here for better >>> - * performance, since an SBI call and mode switch would no longer >>> - * be required. >>> - * >>> - * This would also reduce reliance on a specific SBI implementation. >>> - * For example, it is not ideal to panic() if sbi_set_timer() returns >>> - * a non-zero value. Currently it can return 0 or -ENOSUPP, and >>> - * without SSTC we still need an implementation because only the >>> - * M-mode timer is available, and it can only be programmed in >>> - * M-mode. >>> - */ >>> - if ( (rc = sbi_set_timer(deadline)) ) >>> + if ( (rc = set_xen_timer(deadline)) ) >>> panic("%s: timer wasn't set because: %d\n", __func__, rc); >>> >>> /* Enable timer interrupt */ >>> @@ -85,10 +84,17 @@ int reprogram_timer(s_time_t timeout) >>> >>> void __init preinit_xen_time(void) >>> { >>> + unsigned long tmp; >>> + >>> if ( acpi_disabled ) >>> preinit_dt_xen_time(); >>> else >>> panic("%s: ACPI isn't supported\n", __func__); >>> >>> boot_clock_cycles = get_cycles(); >>> + >>> + if ( csr_read_safe(CSR_STIMECMP, &tmp) ) >>> + set_xen_timer = sstc_set_xen_timer; >>> + else >>> + set_xen_timer = sbi_set_timer; >>> } >> >> Doesn't all of this together eliminate the need for sbi_set_timer as a >> separate global variable? > There's still a need for that SBI-level dispatch. However, sbi_set_timer > doesn't need to be a global variable (exported from sbi.h). Since the > only external user after this patch is the time.c, sbi_set_timer could > be refactored into a plain static internal pointer with a non-static > wrapper function: > > // sbi.c — keep dispatch internal > static int (* __ro_after_init sbi_set_timer_fn)(uint64_t) = > sbi_set_timer_v01; > > int cf_check sbi_set_timer(uint64_t stime_value) > { > return sbi_set_timer_fn(stime_value); > } > > Do you mean this? No. Why is it that we'd still need both set_xen_timer and sbi_set_timer as distinct variables? Jan