From nobody Wed Apr 8 04:27:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1773163134; cv=none; d=zohomail.com; s=zohoarc; b=l/1QxRGMran5WcuUkAu8aXb6yWsYw/75PO4AUi39JCOIJH4pmSY6BrEsaU80lQ25m0u+LU+diZ7KA1+bWv5qHgvFTAAcuCsFbwLDB3Jv8UHlnHdCnpfk4+CzTUUBV+OHGtRaXBRtQTBXzMd7XFdiStXpvhgIohUbnuCHFkFGI4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773163134; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hH9znhbJsO7IzrzhoOYnrjac5Z3LLI2ieI1hChueBHI=; b=a59qE4HUZ03Qi/knZZeiviU1MIxKzF6oBkhpDzDz/t8kXINGA8G+Cq5vpvZhsW5KrG/lIaXMBLmiGVqhFtgtJpDZOlFO3oM36FqSJdkT1srg636vb/ohP5I+nPvcXi1P1IDvYnXLsp+I9W3H38RX8QgqIukOQgda8WcGU95uXAU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773163134559348.5721484311895; Tue, 10 Mar 2026 10:18:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1250569.1548071 (Exim 4.92) (envelope-from ) id 1w00j8-0005ql-9E; Tue, 10 Mar 2026 17:18:38 +0000 Received: by outflank-mailman (output) from mailman id 1250569.1548071; Tue, 10 Mar 2026 17:18:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w00j8-0005pe-63; Tue, 10 Mar 2026 17:18:38 +0000 Received: by outflank-mailman (input) for mailman id 1250569; Tue, 10 Mar 2026 17:18:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w00aL-0001Q4-H7 for xen-devel@lists.xenproject.org; Tue, 10 Mar 2026 17:09:33 +0000 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [2a00:1450:4864:20::32e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e7a07e20-1ca3-11f1-b164-2bf370ae4941; Tue, 10 Mar 2026 18:09:31 +0100 (CET) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4852c9b4158so28934155e9.0 for ; Tue, 10 Mar 2026 10:09:31 -0700 (PDT) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485359bf807sm119619845e9.2.2026.03.10.10.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 10:09:30 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: e7a07e20-1ca3-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773162571; x=1773767371; darn=lists.xenproject.org; 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=hH9znhbJsO7IzrzhoOYnrjac5Z3LLI2ieI1hChueBHI=; b=Y4DkD/FJ6idyy/ETSIEB3Lce9eUGQw5qOmA5brIy9bFsihE5ZkKdJivL5KOxB3BaeX SQ0fBpcbDGKb+qltfLu6uqgQMOlYBJr7VfCJ9SCwBET2c7s6k4L9/e2MEtAtvjoKrR4s xXj6GLQGX2pd9W4cPwHj+NNBZUIzP//YY0s6ugNpHuIOVtoQmTAcBdG40mNU8QbAsBr9 tJUV2gKNyw07ofkZy9hc2sNUjKjMJLU7nC7eFh3ZZz+Zu0Jqn3xmd2PgJn3MH8MOxxr+ AFnXIfHCRd0eAm97JNB/vYubKihg7X7tqcXBKxeoDAoRNDa+FKwSQU9s9OIt+b3CobW0 47LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773162571; x=1773767371; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hH9znhbJsO7IzrzhoOYnrjac5Z3LLI2ieI1hChueBHI=; b=s5bIpSPsmRDMnARCaWBRrBfgJ7kiKLqVfkgygy+f4vsIql46lN0tUGh85UbxzBkHcM H4GC/RLg4Fiuwb1ctU6iSd245i/sOowycwTjlRQAnIh8WGQ8hvC2hB4EGfZT3W55Yeoq NYsXcqGaMVeyUUyYMSOGgVsCq+98Cs9J6LNWL7oF6vp4DQMKMB1fQGMql95P7QDr7mUt A83abdLLH4xjM9df3QiOTunTrXRqQ2HeH92tlUCgrtBIMcT24ygzSICFV9VksGZ6mSNt c6G0B6Juc+wGFoJ6hzOjFuQ6ri8JW+jBZrLwFPANEPq1+N4GSTVsYrJwLk5Vea5jBV6Z n5hQ== X-Gm-Message-State: AOJu0YzXHUVXdt6ffDH5Zma2zKtV5EEJ+6aCOZ0y4WGDOMN8keEm+6ms 4oExoqL05jtpzH84MVngwK9diCZ8eJIp5RHB0lgHLl/mrMj+XfcFSXX6D06hMZR8 X-Gm-Gg: ATEYQzzzPkY4PTwqAcym4km0sRIM7X4QhNVdyN7qvxKjyVRS0gB9mtyU0PI7SB+DdWa I+/7qmRwQUOye3njOV/DRQRFirWK1QLeGlU62Ywj6Xo8TNm8lT53S77z6zXfP22Wz30I3zfXQdk X3thEGSgoXAsb1PgEcyMYCUYtMqjvpglSTWaebSNuaMwG71uqbu6UoRXmhwzFnGWrawrBeSXqYp OCihTGWPjNjW83gEe4UZNAxkUCh4xhmQePyOINiXwFKuRYgO3xAnbWvBUnXEYwmR7tejQhoEugB q1KghQHiiN/c53sqjEmJvo/NaEluMNn4zf7WsqwwYLe6JfZVLS6UHqJykaeTc8PC4oHbNr2peMw A8TFuqljC57yyZk8AXtgl1W3tXUb2N5uxtspaDDpqLg/z7PYvVGPtDi8aA2+xqrCKsAqAIrWhLz LB+aJTin3SZPZ+XvPbsGBYG4XzGiEVyLOQBmlbv0FXXu4iDrPWR+lzFU1yb0dpK2165zjNlQ== X-Received: by 2002:a05:600c:8707:b0:485:3ff1:d5c3 with SMTP id 5b1f17b1804b1-4853ff1d6a6mr122929915e9.5.1773162570910; Tue, 10 Mar 2026 10:09:30 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v1 18/27] xen/riscv: add vaplic access check Date: Tue, 10 Mar 2026 18:08:51 +0100 Message-ID: <0fc9adf790d4f981e8117bd9759c7e64bb11e439.1773157782.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1773163135980154100 Content-Type: text/plain; charset="utf-8" Provide a mechanism for the virtual APLIC to determine whether a guest access targets the physical APLIC MMIO region. This is required to correctly identify and route guest APLIC accesses. Co-developed-by: Romain Caritey Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/aplic.c | 1 + xen/arch/riscv/include/asm/intc.h | 3 +++ xen/arch/riscv/vaplic.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index e139946a05a0..754b444a2a13 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -38,6 +38,7 @@ static struct aplic_priv aplic =3D { =20 static struct intc_info __ro_after_init aplic_info =3D { .hw_version =3D INTC_APLIC, + .private =3D &aplic, }; =20 static void __init aplic_init_hw_interrupts(void) diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index 76d2fd09cb8b..e6b6c179415a 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -25,6 +25,9 @@ struct intc_info { =20 /* number of irqs */ unsigned int num_irqs; + + /* private data pointer of the interrupt controller */ + void *private; }; =20 struct intc_hw_operations { diff --git a/xen/arch/riscv/vaplic.c b/xen/arch/riscv/vaplic.c index 0c69f087cf4d..82e74a609ee6 100644 --- a/xen/arch/riscv/vaplic.c +++ b/xen/arch/riscv/vaplic.c @@ -127,6 +127,20 @@ int vaplic_map_device_irqs_to_domain(struct domain *d, return 0; } =20 +static int cf_check vaplic_is_access(const struct vcpu *vcpu, + const unsigned long addr) +{ + const struct vaplic *vaplic =3D to_vaplic(vcpu->domain->arch.vintc); + const struct aplic_priv *priv =3D vaplic->base.info->private; + const paddr_t paddr_end =3D priv->paddr_start + priv->size; + + /* check if it is an APLIC access */ + if ( priv->paddr_start <=3D addr && addr < paddr_end ) + return 1; + + return 0; +} + static int __init cf_check vcpu_vaplic_init(struct vcpu *v) { int rc =3D 0; @@ -143,6 +157,7 @@ static int __init cf_check vcpu_vaplic_init(struct vcpu= *v) static const struct vintc_ops vaplic_ops =3D { .vcpu_init =3D vcpu_vaplic_init, .map_device_irqs_to_domain =3D vaplic_map_device_irqs_to_domain, + .is_access =3D vaplic_is_access, }; =20 static struct vintc * __init vaplic_alloc(void) --=20 2.53.0