From nobody Sun Dec 22 03:14:56 2024 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=1727195100; cv=none; d=zohomail.com; s=zohoarc; b=m1NkOKX3gnfepxkqmBXaTC3BPbL9mJJ+YBqw0pKA//ZA+kjk59m18NsN0+7WWpaYsLCFAf06vG7iuMUjduiWG5TQmYJZaj4xpliFFX0U6LIFPZmEpnc0pBWq7+covI2dvIPxNqq+8qXFpEc/V3/uwVKPpG72dWe6LiR87jofW4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727195100; 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=jmcayURbwLA4fglObLyXfZR4RfFVjxNCGtPf3/Kime4=; b=YhhhjKprpUjMYH5E//VF7Wjn5iBNT/7q5YRfcAeBJ4SmAPQTR8s0vhJeB/s10jqS+vIhftTgllmwwt/ZORfuLmfZ5zhpP6TIrew4iYiDIQnZiq5DhqWt+nX8T3yzNtXmfJb5YNckMK3tnZXRE+SGmYvbqY7Py9NluX1gsYurQX4= 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 17271951005253.868756011507685; Tue, 24 Sep 2024 09:25:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.803109.1213569 (Exim 4.92) (envelope-from ) id 1st8LF-0007nS-Cf; Tue, 24 Sep 2024 16:24:45 +0000 Received: by outflank-mailman (output) from mailman id 803109.1213569; Tue, 24 Sep 2024 16:24:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1st8LF-0007nI-96; Tue, 24 Sep 2024 16:24:45 +0000 Received: by outflank-mailman (input) for mailman id 803109; Tue, 24 Sep 2024 16:24:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1st8LE-0005nz-10 for xen-devel@lists.xenproject.org; Tue, 24 Sep 2024 16:24:44 +0000 Received: from mail-vs1-xe31.google.com (mail-vs1-xe31.google.com [2607:f8b0:4864:20::e31]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 80977fbc-7a91-11ef-99a2-01e77a169b0f; Tue, 24 Sep 2024 18:24:42 +0200 (CEST) Received: by mail-vs1-xe31.google.com with SMTP id ada2fe7eead31-49bc44e51bcso1878536137.2 for ; Tue, 24 Sep 2024 09:24:42 -0700 (PDT) Received: from gmail.com ([168.243.189.171]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4a1517c0e1asm1003400137.17.2024.09.24.09.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 09:24:40 -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: 80977fbc-7a91-11ef-99a2-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727195081; x=1727799881; 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=jmcayURbwLA4fglObLyXfZR4RfFVjxNCGtPf3/Kime4=; b=ljIA0e47/O/1iIMLfUCWSKFByZuePAOKqAocQC7xBR0dgXcuGByX0LPbztD21ze0Y/ VvLnk0GYXCjC80VY68MjJ16iK9cDxRavQOapHMTD/qiqjYOSBMgUF6+sm9lRRx7n7roV TpwTdbK7opKTh+GpZczBfC6Dvycck2HP9Ljetqkb5bDNfJNEmt5e8V+7SPQrfmkGiZO8 v8BtKkO7qhzmKm6mhraggxfnTTnrlh5JBM9l5UqrZXkfFevDkGBxEwWVzPioKDiad/PK I3dKgjbp0S0piMKvg7XRcndBbmdBXs2rkhz1KrHVHlfqThPn5opcQ37xaV6i7CFni2EO AkDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727195081; x=1727799881; 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=jmcayURbwLA4fglObLyXfZR4RfFVjxNCGtPf3/Kime4=; b=CuSQKb1/bhlcg0bjXZF9uRT/z/b19O4G//7jN9l8bHG8wICb6t4hxkbKESZhIOlTpu w3yH9XRhMfBOIbeNVvGeOIgZh8brD3QdWFHgo7xFGI9DKIixJwT08azINxt7g3FfHUw8 bx12ulqBMULeO/M3oODlnAyMrsgYgxrj7spMbwfPPbTP/DgruRqGxFxvhWU1hxjd3sK/ wWWr3cEb5sfkoroiAvwt+hgTiTlhqHYinNpxCd/YMNVeS/5Q6uz8l4ZAZB/VOcZIwDVL LH7XoIkcd/FeAh7RT+mHAjOLz7OQUfPuGDiXej3Hz6nWzVciLbqR5MiMBce8bwlxmrTW 5L1A== X-Gm-Message-State: AOJu0Yzd/JUpG4/kbi4+xBVJB2In4mjaW//ZYepqBBX9pXQQuwhI9qZ3 z05Qc61u4tqDG4Mx2AD2NKWKOUuWUPQyyXbOvhW7tM3E0eZQzVH74rF3HE2d X-Google-Smtp-Source: AGHT+IHLZSH080iTk+As1JXYiDfxpcGs1Rd+oD5mrht+Y1a4L+lu+7BUt7tkPVi8MQkr+poDU4lhew== X-Received: by 2002:a05:6102:c92:b0:49a:211a:f08d with SMTP id ada2fe7eead31-4a15dd7897amr47661137.24.1727195080731; Tue, 24 Sep 2024 09:24:40 -0700 (PDT) From: "Edgar E. Iglesias" To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, julien@xen.org, bertrand.marquis@arm.com, michal.orzel@amd.com, Volodymyr_Babchuk@epam.com, dpsmith@apertussolutions.com, edgar.iglesias@amd.com Subject: [PATCH v1 5/6] xen/arm: io: Add a read-const writes-ignored mmio handler Date: Tue, 24 Sep 2024 18:23:58 +0200 Message-ID: <20240924162359.1390487-6-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240924162359.1390487-1-edgar.iglesias@gmail.com> References: <20240924162359.1390487-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1727195102310116600 Content-Type: text/plain; charset="utf-8" From: "Edgar E. Iglesias" Add a read-const writes-ignored mmio handler. This is useful to for example register background regions that return a fixed value instead of raising data aborts. Signed-off-by: Edgar E. Iglesias Reviewed-by: Stefano Stabellini --- xen/arch/arm/include/asm/mmio.h | 2 ++ xen/arch/arm/io.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/xen/arch/arm/include/asm/mmio.h b/xen/arch/arm/include/asm/mmi= o.h index 7da542cd79..605620a2f4 100644 --- a/xen/arch/arm/include/asm/mmio.h +++ b/xen/arch/arm/include/asm/mmio.h @@ -82,6 +82,8 @@ struct vmmio { struct mmio_handler *handlers; }; =20 +extern const struct mmio_handler_ops mmio_read_const_writes_ignored; + enum io_state try_handle_mmio(struct cpu_user_regs *regs, mmio_info_t *info); void register_mmio_bg_handler(struct domain *d, diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c index 934a2ad2b9..8ab0435afc 100644 --- a/xen/arch/arm/io.c +++ b/xen/arch/arm/io.c @@ -20,6 +20,27 @@ =20 #include "decode.h" =20 +/* + * Reusable mmio handler useful as background while waiting for IOREQ. + * Register with priv as default read value. Writes ignored. + */ +static int bg_read(struct vcpu *v, mmio_info_t *info, register_t *r, void = *priv) +{ + *r =3D (uintptr_t) priv; + return 1; +} + +static int bg_write(struct vcpu *v, mmio_info_t *info, register_t r, void = *priv) +{ + return 1; +} + +/* Read const value (from priv), writes ignored. */ +const struct mmio_handler_ops mmio_read_const_writes_ignored =3D { + .read =3D bg_read, + .write =3D bg_write, +}; + static enum io_state handle_read(const struct mmio_handler *handler, struct vcpu *v, mmio_info_t *info) --=20 2.43.0